Tizen 2.1 base
[platform/core/system/sync-agent.git] / TC / testcase / utc_sync_agent_framework_initialization.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_P   "../../../testcase/fw-test-cfg/test_fw_config.xml"
34 #define TEST_FW_CONFIG_FILE_N   "../../../testcase/fw-test-cfg/test_fw_config_not_existing.xml"
35
36 #define API_NAME_SYNC_AGENT_INIT        "sync_agent_init"
37 #define API_NAME_SYNC_AGENT_DEINIT      "sync_agent_deinit"
38
39 static void utc_sync_agent_framework_sync_agent_init_p(void);
40 static void utc_sync_agent_framework_sync_agent_init_n(void);
41 static void utc_sync_agent_framework_sync_agent_deinit_p(void);
42 static void utc_sync_agent_framework_sync_agent_deinit_n(void);
43
44 struct tet_testlist tet_testlist[] = {
45         {utc_sync_agent_framework_sync_agent_init_p, POSITIVE_TC_IDX},
46         {utc_sync_agent_framework_sync_agent_init_n, NEGATIVE_TC_IDX},
47         {utc_sync_agent_framework_sync_agent_deinit_p, POSITIVE_TC_IDX},
48         {utc_sync_agent_framework_sync_agent_deinit_n, NEGATIVE_TC_IDX},
49         {NULL, 0}
50 };
51
52 static void startup(void)
53 {
54         /* start of TC */
55 }
56
57 static void cleanup(void)
58 {
59         /* start of TC */
60 }
61
62 static void utc_sync_agent_framework_sync_agent_init_p(void)
63 {
64         char *api_name = API_NAME_SYNC_AGENT_INIT;
65
66         sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_FILE_P);
67         if (init_error != SYNC_AGENT_INIT_SUCCESS) {
68                 dts_message(api_name, "sync_agent_init : %d", init_error);
69                 dts_fail(api_name);
70         } else {
71                 dts_pass(api_name);
72         }
73 }
74
75 static void utc_sync_agent_framework_sync_agent_init_n(void)
76 {
77         char *api_name = API_NAME_SYNC_AGENT_INIT;
78
79         sync_agent_init_error_e init_error = sync_agent_init(TEST_FW_CONFIG_FILE_N);
80         if (init_error != SYNC_AGENT_INIT_SUCCESS) {
81                 dts_pass(api_name);
82         } else {
83                 dts_message(api_name, "sync_agent_init : %d", init_error);
84                 dts_fail(api_name);
85         }
86 }
87
88 static void utc_sync_agent_framework_sync_agent_deinit_p(void)
89 {
90         char *api_name = API_NAME_SYNC_AGENT_DEINIT;
91
92         sync_agent_init_error_e init_error = sync_agent_deinit();
93         if (init_error != SYNC_AGENT_INIT_SUCCESS) {
94                 dts_message(api_name, "sync_agent_deinit : %d", init_error);
95                 dts_fail(api_name);
96         } else {
97                 dts_pass(api_name);
98         }
99 }
100
101 static void utc_sync_agent_framework_sync_agent_deinit_n(void)
102 {
103         char *api_name = API_NAME_SYNC_AGENT_DEINIT;
104
105 //      Trying to deinitialize without initializing..
106         sync_agent_init_error_e init_error = sync_agent_deinit();
107         if (init_error != SYNC_AGENT_INIT_SUCCESS) {
108                 dts_pass(api_name);
109         } else {
110                 dts_message(api_name, "sync_agent_deinit : %d", init_error);
111                 dts_fail(api_name);
112         }
113 }