Tizen 2.1 base
[platform/core/system/sync-agent.git] / TC / testcase / utc_sync_agent_framework_device.c
1 /*
2  * sync-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #include <tet_api.h>
19
20 #include <sync_agent.h>
21
22 enum {
23         POSITIVE_TC_IDX = 0x01,
24         NEGATIVE_TC_IDX,
25 };
26
27 static void startup(void);
28 static void cleanup(void);
29
30 void (*tet_startup) (void) = startup;
31 void (*tet_cleanup) (void) = cleanup;
32
33 #define TEST_FW_CONFIG_FILE     "../../../testcase/fw-test-cfg/test_fw_config.xml"
34
35 #define API_NAME_SYNC_START_UP  "startup"
36
37 #define API_NAME_SYNC_AGENT_EXECUTE_DEV_FUNCTION                "sync_agent_execute_dev_function"
38 #define API_NAME_SYNC_AGENT_GET_DEVINFO                         "sync_agent_get_devinfo"
39
40 ////////////////////////////////////////executor.h//////////////////////////////////////////////
41
42 static void utc_sync_agent_framework_sync_agent_execute_dev_function_p(void);
43 static void utc_sync_agent_framework_sync_agent_execute_dev_function_n(void);
44
45 ////////////////////////////////////////information.h//////////////////////////////////////////////
46
47 static void utc_sync_agent_framework_sync_agent_get_devinfo_p(void);
48 static void utc_sync_agent_framework_sync_agent_get_devinfo_n(void);
49
50 struct tet_testlist tet_testlist[] = {
51         {utc_sync_agent_framework_sync_agent_execute_dev_function_p, POSITIVE_TC_IDX},
52         {utc_sync_agent_framework_sync_agent_execute_dev_function_n, NEGATIVE_TC_IDX},
53         {utc_sync_agent_framework_sync_agent_get_devinfo_p, POSITIVE_TC_IDX},
54         {utc_sync_agent_framework_sync_agent_get_devinfo_n, NEGATIVE_TC_IDX},
55         {NULL, 0}
56 };
57
58 static void startup(void)
59 {
60         /* start of TC */
61         sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_FILE);
62         if (init_error != SYNC_AGENT_INIT_SUCCESS) {
63                 dts_message(API_NAME_SYNC_START_UP, "sync_agent_init : %d", init_error);
64                 dts_fail(API_NAME_SYNC_START_UP);
65         } else {
66                 dts_pass(API_NAME_SYNC_START_UP);
67         }
68 }
69
70 static void cleanup(void)
71 {
72         /* start of TC */
73 }
74
75 static void utc_sync_agent_framework_sync_agent_execute_dev_function_p(void)
76 {
77         sync_agent_dev_return_e err = SYNC_AGENT_DEV_RETURN_SUCCESS;
78         char *api_name = API_NAME_SYNC_AGENT_EXECUTE_DEV_FUNCTION;
79         int memory_type = 0;
80         char *function_name = NULL;
81
82         function_name = "fota_flag";
83
84         err = sync_agent_execute_dev_function(2, function_name, 1, memory_type);
85         if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
86                 dts_message(api_name, "sync_agent_execute_dev_function : %d", err);
87                 dts_fail(api_name);
88         } else {
89                 dts_pass(api_name);
90         }
91 }
92
93 static void utc_sync_agent_framework_sync_agent_execute_dev_function_n(void)
94 {
95         sync_agent_dev_return_e err = SYNC_AGENT_DEV_RETURN_SUCCESS;
96         char *api_name = API_NAME_SYNC_AGENT_EXECUTE_DEV_FUNCTION;
97         int memory_type = 0;
98         char *function_name = NULL;
99
100         err = sync_agent_execute_dev_function(2, function_name, 1, memory_type);
101         if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
102                 dts_pass(api_name);
103         } else {
104                 dts_message(api_name, "sync_agent_execute_dev_function : %d", err);
105                 dts_fail(api_name);
106         }
107 }
108
109 static void utc_sync_agent_framework_sync_agent_get_devinfo_p(void)
110 {
111         sync_agent_dev_return_e err = SYNC_AGENT_DEV_RETURN_SUCCESS;
112         char *api_name = API_NAME_SYNC_AGENT_GET_DEVINFO;
113
114         int device_plugin_id = 0;
115         char *info_name = NULL;
116         char *value = NULL;
117
118         device_plugin_id = 2;
119         info_name = "FOTADownDir";
120
121         err = sync_agent_get_devinfo(device_plugin_id, info_name, &value);
122         if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
123                 dts_message(api_name, "sync_agent_get_devinfo : %d", err);
124                 dts_fail(api_name);
125         } else {
126                 dts_pass(api_name);
127         }
128 }
129
130 static void utc_sync_agent_framework_sync_agent_get_devinfo_n(void)
131 {
132         sync_agent_dev_return_e err = SYNC_AGENT_ACC_SUCCESS;
133         char *api_name = API_NAME_SYNC_AGENT_GET_DEVINFO;
134
135         int device_plugin_id = 0;
136         char *info_name = NULL;
137         char *value = NULL;
138
139         device_plugin_id = 2;
140
141         err = sync_agent_get_devinfo(device_plugin_id, info_name, &value);
142         if (err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
143                 dts_pass(api_name);
144         } else {
145                 dts_message(api_name, "sync_agent_get_devinfo : %d", err);
146                 dts_fail(api_name);
147         }
148 }