Fix db recovery
[platform/core/appfw/shortcut.git] / test / icon.c
1 /*
2  * Copyright (c) 2011 - 2016 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 #include <tzplatform_config.h>
21
22 #define PATH_FMT_RO_ICONS_ROOT tzplatform_getenv(TZ_SYS_RO_ICONS)
23 #define PATH_FMT_USER_SHARE_ROOT tzplatform_getenv(TZ_USER_SHARE)
24 #define TIZEN_PATH_MAX 1024
25
26 static int result_cb(struct shortcut_icon *handle, int ret, void *data)
27 {
28         printf("Client: Return %d (%p)\n", ret, handle);
29         return 0;
30 }
31
32 static Eina_Bool test_main(void *data)
33 {
34         struct shortcut_icon *handle;
35         static int idx = 0;
36         int ret;
37         char filename[256];
38         int type;
39         char path[TIZEN_PATH_MAX] = {0, };
40
41         idx++;
42
43         handle = shortcut_icon_request_create();
44         if (!handle) {
45                 printf("Failed to create a request\n");
46                 return ECORE_CALLBACK_RENEW;
47         }
48
49         printf("Test: %d\n", idx);
50         snprintf(path, TIZEN_PATH_MAX, "%s/default/small/org.tizen.music-player.png", PATH_FMT_RO_ICONS_ROOT);
51         ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_IMAGE, DEFAULT_ICON_PART, path, NULL, NULL);
52         printf("NAME set_info: %d\n", ret);
53
54         snprintf(filename, sizeof(filename), "App Name %d", idx);
55         ret = shortcut_icon_request_set_info(handle, NULL, SHORTCUT_ICON_TYPE_TEXT, DEFAULT_NAME_PART, filename, NULL, NULL);
56         printf("TEXT set_info: %d\n", ret);
57
58         snprintf(filename, sizeof(filename), "%s/live_magazine/always/out%d.png", PATH_FMT_USER_SHARE_ROOT, idx);
59
60         switch (idx % 7) {
61         case 0: type = DYNAMICBOX_TYPE_1x1; break;
62         case 1: type = DYNAMICBOX_TYPE_2x1; break;
63         case 2: type = DYNAMICBOX_TYPE_2x2; break;
64         case 3: type = DYNAMICBOX_TYPE_4x1; break;
65         case 4: type = DYNAMICBOX_TYPE_4x2; break;
66         case 5: type = DYNAMICBOX_TYPE_4x3; break;
67         case 6: type = DYNAMICBOX_TYPE_4x4; break;
68         default: type = DYNAMICBOX_TYPE_1x1; break;
69         }
70
71         ret = shortcut_icon_request_send(handle, type, NULL, NULL, filename, result_cb, NULL);
72         printf("request: %d\n", ret);
73
74         ret = shortcut_icon_request_destroy(handle);
75         printf("destroy: %d\n", ret);
76         return ECORE_CALLBACK_RENEW;
77 }
78
79 static int initialized_cb(int status, void *data)
80 {
81         printf("Hello initializer\n");
82         return 0;
83 }
84
85 int elm_main(int argc, char *argv[])
86 {
87         shortcut_icon_service_init(NULL, NULL);
88
89         ecore_timer_add(5.0f, test_main, NULL);
90
91         elm_run();
92         shortcut_icon_service_fini();
93         elm_shutdown();
94         return 0;
95 }
96
97 ELM_MAIN()
98 /* End of a file */