9267bad1d0a9232dcdd43b9366b33742aab28683
[platform/core/appfw/shortcut.git] / test / icon.c
1 /*
2  * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17
18 #include <Elementary.h>
19 #include <shortcut.h>
20
21 static int result_cb(struct shortcut_icon *handle, int ret, void *data)
22 {
23         printf("Client: Return %d (%p)\n", ret, handle);
24         return 0;
25 }
26
27 static Eina_Bool test_main(void *data)
28 {
29         struct shortcut_icon *handle;
30         static int idx = 0;
31         int ret;
32         char filename[256];
33         int type;
34
35         idx++;
36
37         handle = shortcut_icon_request_create();
38         if (!handle) {
39                 printf("Failed to create a request\n");
40                 return ECORE_CALLBACK_RENEW;
41         }
42
43         printf("Test: %d\n", idx);
44         ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_IMAGE, DEFAULT_ICON_PART, "/usr/share/icons/default/small/org.tizen.music-player.png", NULL, NULL);
45         printf("NAME set_info: %d\n", ret);
46
47         snprintf(filename, sizeof(filename), "App Name %d", idx);
48         ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_TEXT, DEFAULT_NAME_PART, filename, NULL, NULL);
49         printf("TEXT set_info: %d\n", ret);
50
51         snprintf(filename, sizeof(filename), "/opt/usr/share/live_magazine/always/out%d.png", idx);
52
53         switch (idx % 7) {
54         case 0: type = LIVEBOX_TYPE_1x1; break;
55         case 1: type = LIVEBOX_TYPE_2x1; break;
56         case 2: type = LIVEBOX_TYPE_2x2; break;
57         case 3: type = LIVEBOX_TYPE_4x1; break;
58         case 4: type = LIVEBOX_TYPE_4x2; break;
59         case 5: type = LIVEBOX_TYPE_4x3; break;
60         case 6: type = LIVEBOX_TYPE_4x4; break;
61         default: type = LIVEBOX_TYPE_1x1; break;
62         }
63
64         ret = shortcut_icon_request_send(handle, type, NULL, NULL, filename, result_cb, NULL);
65         printf("request: %d\n", ret);
66
67         ret = shortcut_icon_request_destroy(handle);
68         printf("destroy: %d\n", ret);
69         return ECORE_CALLBACK_RENEW;
70 }
71
72 static int initialized_cb(int status, void *data)
73 {
74         printf("Hello initializer\n");
75         return 0;
76 }
77
78 int elm_main(int argc, char *argv[])
79 {
80         shortcut_icon_service_init(NULL, NULL);
81
82         ecore_timer_add(5.0f, test_main, NULL);
83
84         elm_run();
85         shortcut_icon_service_fini();
86         elm_shutdown();
87         return 0;
88 }
89
90 ELM_MAIN()
91 /* End of a file */