3 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * PROPRIETARY/CONFIDENTIAL
6 * This software is the confidential and proprietary information of SAMSUNG
7 * ELECTRONICS ("Confidential Information"). You agree and acknowledge that
8 * this software is owned by Samsung and you shall not disclose such
9 * Confidential Information and shall use it only in accordance with the terms
10 * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG
11 * make no representations or warranties about the suitability of the software,
12 * either express or implied, including but not limited to the implied
13 * warranties of merchantability, fitness for a particular purpose, or
14 * non-infringement. SAMSUNG shall not be liable for any damages suffered by
15 * licensee arising out of or related to this software.
21 #define API_NAME_DEVICE_BATTERY_GET_PERCENT "device_battery_get_percent"
22 #define API_NAME_DEVICE_BATTERY_IS_FULL "device_battery_is_full"
23 #define API_NAME_DEVICE_BATTERY_IS_CHARGING "device_battery_is_charging"
24 #define API_NAME_DEVICE_BATTERY_SET_CB "device_battery_set_cb"
25 #define API_NAME_DEVICE_BATTERY_UNSET_CB "device_battery_unset_cb"
27 static void startup(void);
28 static void cleanup(void);
30 void (*tet_startup)(void) = startup;
31 void (*tet_cleanup)(void) = cleanup;
33 static void utc_system_device_battery_get_percent_p(void);
34 static void utc_system_device_battery_get_percent_n(void);
35 static void utc_system_device_battery_is_full_p(void);
36 static void utc_system_device_battery_is_full_n(void);
37 static void utc_system_device_battery_is_charging_p(void);
38 static void utc_system_device_battery_is_charging_n(void);
39 static void utc_system_device_battery_set_cb_p(void);
40 static void utc_system_device_battery_set_cb_n(void);
41 static void utc_system_device_battery_unset_cb_p(void);
45 POSITIVE_TC_IDX = 0x01,
49 struct tet_testlist tet_testlist[] = {
50 { utc_system_device_battery_get_percent_p, POSITIVE_TC_IDX },
51 { utc_system_device_battery_get_percent_n, NEGATIVE_TC_IDX },
52 { utc_system_device_battery_is_full_p, POSITIVE_TC_IDX },
53 { utc_system_device_battery_is_full_n, NEGATIVE_TC_IDX },
54 { utc_system_device_battery_is_charging_p, POSITIVE_TC_IDX },
55 { utc_system_device_battery_is_charging_n, NEGATIVE_TC_IDX },
56 { utc_system_device_battery_set_cb_p, POSITIVE_TC_IDX },
57 { utc_system_device_battery_set_cb_n, NEGATIVE_TC_IDX },
58 { utc_system_device_battery_unset_cb_p, POSITIVE_TC_IDX },
62 static void startup(void)
67 static void cleanup(void)
73 * @brief Positive test case of device_battery_get_percent()
75 static void utc_system_device_battery_get_percent_p(void)
78 int error = DEVICE_ERROR_NONE;
79 error = device_battery_get_percent(&percent);
81 dts_check_eq(API_NAME_DEVICE_BATTERY_GET_PERCENT, error, DEVICE_ERROR_NONE);
85 * @brief Negative test case of device_battery_get_percent()
87 static void utc_system_device_battery_get_percent_n(void)
89 int error = DEVICE_ERROR_NONE;
90 error = device_battery_get_percent(NULL);
92 dts_check_ne(API_NAME_DEVICE_BATTERY_GET_PERCENT, error, DEVICE_ERROR_NONE);
96 * @brief Positive test case of device_battery_is_full()
98 static void utc_system_device_battery_is_full_p(void)
101 int error = DEVICE_ERROR_NONE;
102 error = device_battery_is_full(&full);
103 dts_check_eq(API_NAME_DEVICE_BATTERY_IS_FULL, error, DEVICE_ERROR_NONE);
107 * @brief Negative test case of device_battery_is_full()
109 static void utc_system_device_battery_is_full_n(void)
111 int error = DEVICE_ERROR_NONE;
112 error = device_battery_is_full(NULL);
113 dts_check_ne(API_NAME_DEVICE_BATTERY_IS_FULL, error, DEVICE_ERROR_NONE);
117 static void utc_system_device_battery_is_charging_p(void)
120 int error = DEVICE_ERROR_NONE;
121 error = device_battery_is_charging(&charging);
122 dts_check_eq(API_NAME_DEVICE_BATTERY_IS_CHARGING, error, DEVICE_ERROR_NONE);
125 static void utc_system_device_battery_is_charging_n(void)
128 int error = DEVICE_ERROR_NONE;
129 error = device_battery_is_charging(NULL);
130 dts_check_ne(API_NAME_DEVICE_BATTERY_IS_CHARGING, error, DEVICE_ERROR_NONE);
133 static void battery_cb(int percent, void *user_data)
137 static void utc_system_device_battery_set_cb_p(void)
139 int error = device_battery_set_cb(battery_cb, NULL);
140 device_battery_unset_cb();
141 dts_check_eq(API_NAME_DEVICE_BATTERY_SET_CB, error, DEVICE_ERROR_NONE);
144 static void utc_system_device_battery_set_cb_n(void)
146 int error = device_battery_set_cb(NULL, NULL);
147 device_battery_unset_cb();
148 dts_check_ne(API_NAME_DEVICE_BATTERY_SET_CB, error, DEVICE_ERROR_NONE);
151 static void utc_system_device_battery_unset_cb_p(void)
153 device_battery_set_cb(battery_cb, NULL);
154 int error = device_battery_unset_cb();
155 dts_check_eq(API_NAME_DEVICE_BATTERY_SET_CB, error, DEVICE_ERROR_NONE);