summaryrefslogtreecommitdiff
path: root/legacy/elementary/src/tests/elm_test_fileselector.c
diff options
context:
space:
mode:
authorRyuan Choi <ryuan.choi@gmail.com>2014-07-02 07:55:53 +0900
committerRyuan Choi <ryuan.choi@gmail.com>2014-07-02 07:58:45 +0900
commit9f61c65296f0a5f8817d71202075c5b8d62592e7 (patch)
treed9572f6f899a66e153a1fb8a11dcdb7bced17027 /legacy/elementary/src/tests/elm_test_fileselector.c
parentf56f430abd888c7f6e68fd83a487b219b0120243 (diff)
fileselector: Make selected_set actually select the file
This patch comes from Kai Huuhko. Added test case for selected_set/get. @fix
Diffstat (limited to '')
-rw-r--r--legacy/elementary/src/tests/elm_test_fileselector.c61
1 files changed, 60 insertions, 1 deletions
diff --git a/legacy/elementary/src/tests/elm_test_fileselector.c b/legacy/elementary/src/tests/elm_test_fileselector.c
index 5d09430837..e5dd0677be 100644
--- a/legacy/elementary/src/tests/elm_test_fileselector.c
+++ b/legacy/elementary/src/tests/elm_test_fileselector.c
@@ -27,8 +27,67 @@ START_TEST (elm_atspi_role_get)
27} 27}
28END_TEST 28END_TEST
29 29
30static void
31_directory_open_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
32{
33 Eina_Bool *ret = data;
34 *ret = EINA_TRUE;
35}
36
37START_TEST (elm_fileselector_selected)
38{
39 Evas_Object *win, *fileselector;
40 Eina_Tmpstr *tmp_path;
41 Eina_Stringshare *exist, *no_exist;
42 FILE *fp;
43 char *path;
44 Eina_Bool selected;
45
46 elm_init(1, NULL);
47
48 if (!eina_file_mkdtemp("elm_test-XXXXXX", &tmp_path))
49 {
50 /* can not test */
51 ck_assert(EINA_FALSE);
52 return;
53 }
54
55 path = strdup(tmp_path);
56 eina_tmpstr_del(tmp_path);
57
58 exist = eina_stringshare_printf("%s/exist", path);
59 no_exist = eina_stringshare_printf("%s/no_exist", path);
60 fp = fopen(exist, "w");
61 fclose(fp);
62
63 win = elm_win_add(NULL, "fileselector", ELM_WIN_BASIC);
64
65 fileselector = elm_fileselector_add(win);
66 evas_object_smart_callback_add(fileselector, "directory,open", _directory_open_cb, &selected);
67
68 ck_assert(!elm_fileselector_selected_set(fileselector, no_exist));
69
70 selected = EINA_FALSE;
71 ck_assert(elm_fileselector_selected_set(fileselector, path));
72 while (!selected) ecore_main_loop_iterate();
73 ck_assert_str_eq(elm_fileselector_selected_get(fileselector), path);
74
75 selected = EINA_FALSE;
76 ck_assert(elm_fileselector_selected_set(fileselector, exist));
77 while (!selected) ecore_main_loop_iterate();
78 ck_assert_str_eq(elm_fileselector_selected_get(fileselector), exist);
79
80 eina_stringshare_del(exist);
81 eina_stringshare_del(no_exist);
82 free(path);
83
84 elm_shutdown();
85}
86END_TEST
87
30void elm_test_fileselector(TCase *tc) 88void elm_test_fileselector(TCase *tc)
31{ 89{
32 tcase_add_test(tc, elm_atspi_role_get); 90 tcase_add_test(tc, elm_atspi_role_get);
91 tcase_add_test(tc, elm_fileselector_selected);
33} 92}
34 93