1 #ifdef HAVE_CONFIG_H
2 # include <config.h>
3 #endif
4
5 #include <Ecore_Evas.h>
6 #include <Efl_Core.h>
7
8 #include "ecore_suite.h"
9
10 #define WINDOW_HEIGHT 200
11 #define WINDOW_WIDTH 200
12
13 static int log_abort;
14 static int log_abort_level;
15
16 void
fail_on_errors_teardown(void)17 fail_on_errors_teardown(void)
18 {
19 eina_log_abort_on_critical_set(log_abort);
20 eina_log_abort_on_critical_level_set(log_abort_level);
21 }
22
23 void
fail_on_errors_setup(void)24 fail_on_errors_setup(void)
25 {
26 log_abort = eina_log_abort_on_critical_get();
27 log_abort_level = eina_log_abort_on_critical_level_get();
28 eina_log_abort_on_critical_level_set(2);
29 eina_log_abort_on_critical_set(1);
30 }
31
32 static Ecore_Evas *ee;
33
34 void
_setup(void)35 _setup(void)
36 {
37 ecore_evas_init();
38 ee = ecore_evas_buffer_new(50, 50);
39 }
40
41 void
_teardown(void)42 _teardown(void)
43 {
44 ecore_evas_free(ee);
45 ecore_evas_shutdown();
46 }
47
EFL_START_TEST(ecore_test_selection_get_twice)48 EFL_START_TEST(ecore_test_selection_get_twice)
49 {
50 //this is just running this and checking that we do not error
51 for (int i = 0; i < ECORE_EVAS_SELECTION_BUFFER_LAST; ++i)
52 {
53 if (i == ECORE_EVAS_SELECTION_BUFFER_DRAG_AND_DROP_BUFFER) continue;
54 const char *types[] = {eina_stringshare_add("text/plain")};
55 ck_assert_ptr_ne(ecore_evas_selection_get(ee, 0, i, EINA_C_ARRAY_ITERATOR_NEW(types)), NULL);
56 }
57 for (int i = 0; i < ECORE_EVAS_SELECTION_BUFFER_LAST; ++i)
58 {
59 if (i == ECORE_EVAS_SELECTION_BUFFER_DRAG_AND_DROP_BUFFER) continue;
60 const char *types[] = {eina_stringshare_add("text/plain")};
61 ck_assert_ptr_ne(ecore_evas_selection_get(ee, 0, i, EINA_C_ARRAY_ITERATOR_NEW(types)), NULL);
62 }
63 }
64 EFL_END_TEST
65
EFL_START_TEST(ecore_test_selection_claim_twice)66 EFL_START_TEST(ecore_test_selection_claim_twice)
67 {
68 //this is just running this and checking that we do not error
69 for (int i = 0; i < ECORE_EVAS_SELECTION_BUFFER_LAST; ++i)
70 {
71 if (i == ECORE_EVAS_SELECTION_BUFFER_DRAG_AND_DROP_BUFFER) continue;
72 Eina_Content *content = eina_content_new((Eina_Slice)EINA_SLICE_STR_FULL("asdf"), "text/plain");
73 ck_assert_int_eq(ecore_evas_selection_set(ee, 0, i, content), EINA_TRUE);
74 }
75 for (int i = 0; i < ECORE_EVAS_SELECTION_BUFFER_LAST; ++i)
76 {
77 if (i == ECORE_EVAS_SELECTION_BUFFER_DRAG_AND_DROP_BUFFER) continue;
78 Eina_Content *content = eina_content_new((Eina_Slice)EINA_SLICE_STR_FULL("asdf"), "text/plain");
79 ck_assert_int_eq(ecore_evas_selection_set(ee, 0, i, content), EINA_TRUE);
80 }
81 }
82 EFL_END_TEST
ecore_test_ecore_evas_selection(TCase * tc)83 void ecore_test_ecore_evas_selection(TCase *tc)
84 {
85 tcase_add_checked_fixture(tc, fail_on_errors_setup, fail_on_errors_teardown);
86 tcase_add_checked_fixture(tc, _setup, _teardown);
87 tcase_add_test(tc, ecore_test_selection_get_twice);
88 tcase_add_test(tc, ecore_test_selection_claim_twice);
89 }
90