summaryrefslogtreecommitdiff
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
commit5622df6914329bca7e816aac334c2dda25d296a8 (patch)
treee9322bf9eec535a5b293b843561c7a7d6fc5e1ec
parent389f300d88c292dc8c5e0c5863a32f92c3aa8e9e (diff)
fileselector: Make selected_set actually select the file
This patch comes from Kai Huuhko. Added test case for selected_set/get. @fix
-rw-r--r--src/lib/elc_fileselector.c2
-rw-r--r--src/tests/elm_test_fileselector.c61
2 files changed, 61 insertions, 2 deletions
diff --git a/src/lib/elc_fileselector.c b/src/lib/elc_fileselector.c
index 0f6903c95..106b91039 100644
--- a/src/lib/elc_fileselector.c
+++ b/src/lib/elc_fileselector.c
@@ -1902,7 +1902,7 @@ _elm_fileselector_elm_interface_fileselector_selected_set(Eo *obj, Elm_Fileselec
1902 } 1902 }
1903 1903
1904 selected = ecore_file_dir_get(path); 1904 selected = ecore_file_dir_get(path);
1905 _populate(obj, selected, NULL, NULL); 1905 _populate(obj, selected, NULL, path);
1906 eina_stringshare_replace(&sd->selection, path); 1906 eina_stringshare_replace(&sd->selection, path);
1907 free(selected); 1907 free(selected);
1908 } 1908 }
diff --git a/src/tests/elm_test_fileselector.c b/src/tests/elm_test_fileselector.c
index 5d0943083..e5dd0677b 100644
--- a/src/tests/elm_test_fileselector.c
+++ b/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