2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 #include <appcore-watch/watch_app.h>
19 #include <appcore-watch/watch_app_extension.h>
20 #include <dali-test-suite-utils.h>
21 #include <dali/dali.h>
23 #include "public-api/dali-wearable.h"
24 #define TIMEZONE_BUFFER_MAX 102
28 void utc_dali_watchtime_startup(void)
30 test_return_value = TET_UNDEF;
33 void utc_dali_watchtime_cleanup(void)
35 test_return_value = TET_PASS;
40 struct MyTestApp : public ConnectionTracker
42 MyTestApp(WatchApplication& app)
46 mApplication.InitSignal().Connect(this, &MyTestApp::Create);
49 void Create(Application& app)
61 WatchApplication& mApplication;
64 } // unnamed namespace
66 int UtcDaliWatchTimeNew(void)
69 WatchTime* watchTimeRef = &watchTime;
71 DALI_TEST_CHECK(watchTimeRef);
76 int UtcDaliWatchTimeGetHour(void)
80 watch_time_h watch_time = {
84 ret = watch_time_get_current_time(&watch_time);
86 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
88 ret = watch_time_get_hour(watch_time, &hour);
90 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
92 DALI_TEST_CHECK(watchTime.GetHour() == hour);
97 int UtcDaliWatchTimeGetHour24(void)
101 watch_time_h watch_time = {
105 ret = watch_time_get_current_time(&watch_time);
106 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
108 ret = watch_time_get_hour24(watch_time, &hour24);
109 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
111 DALI_TEST_CHECK(watchTime.GetHour24() == hour24);
116 int UtcDaliWatchTimeGetMinute(void)
120 watch_time_h watch_time = {
124 ret = watch_time_get_current_time(&watch_time);
125 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
127 ret = watch_time_get_minute(watch_time, &minute);
128 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
130 DALI_TEST_CHECK(watchTime.GetMinute() == minute);
135 int UtcDaliWatchTimeGetSecond(void)
139 watch_time_h watch_time = {
143 ret = watch_time_get_current_time(&watch_time);
144 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
146 ret = watch_time_get_second(watch_time, &second);
147 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
149 DALI_TEST_CHECK(watchTime.GetSecond() == second);
154 int UtcDaliWatchTimeGetMillisecond(void)
156 int ret, millisecond;
158 watch_time_h watch_time = {
162 ret = watch_time_get_current_time(&watch_time);
163 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
165 ret = watch_time_get_millisecond(watch_time, &millisecond);
166 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
168 DALI_TEST_CHECK(watchTime.GetMillisecond() == millisecond);
173 int UtcDaliWatchTimeGetYear(void)
177 watch_time_h watch_time = {
181 ret = watch_time_get_current_time(&watch_time);
182 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
184 ret = watch_time_get_year(watch_time, &year);
185 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
187 DALI_TEST_CHECK(watchTime.GetYear() == year);
192 int UtcDaliWatchTimeGetMonth(void)
196 watch_time_h watch_time = {
200 ret = watch_time_get_current_time(&watch_time);
201 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
203 ret = watch_time_get_month(watch_time, &month);
204 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
206 DALI_TEST_CHECK(watchTime.GetMonth() == month);
211 int UtcDaliWatchTimeGetDay(void)
215 watch_time_h watch_time = {
219 ret = watch_time_get_current_time(&watch_time);
220 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
222 ret = watch_time_get_day(watch_time, &day);
223 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
225 DALI_TEST_CHECK(watchTime.GetDay() == day);
230 int UtcDaliWatchTimeGetDayOfWeek(void)
234 watch_time_h watch_time = {
238 ret = watch_time_get_current_time(&watch_time);
239 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
241 ret = watch_time_get_day_of_week(watch_time, &dayOfWeek);
242 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
244 DALI_TEST_CHECK(watchTime.GetDayOfWeek() == dayOfWeek);
249 int UtcDaliWatchTimeGetUtcTime(void)
252 struct tm* utcTime = (struct tm*)calloc(1, sizeof(struct tm));
254 watch_time_h watch_time = {
258 ret = watch_time_get_current_time(&watch_time);
259 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
261 ret = watch_time_get_day(watch_time, utcTime);
262 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
264 DALI_TEST_CHECK(watchTime.GetUtcTime().tm_sec == (*utcTime).tm_sec);
269 int UtcDaliWatchTimeGetUtcTimeStamp(void)
272 time_t* timeStamp = (time_t*)calloc(1, sizeof(time_t));
274 watch_time_h watch_time = {
278 ret = watch_time_get_current_time(&watch_time);
279 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
281 ret = watch_time_get_day(watch_time, timeStamp);
282 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
284 DALI_TEST_CHECK(watchTime.GetUtcTimeStamp() == *timeStamp);
289 int UtcDaliWatchTimeGetTimeZone(void)
292 char* timeZone[TIMEZONE_BUFFER_MAX] = {
296 watch_time_h watch_time = {
300 ret = watch_time_get_current_time(&watch_time);
301 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
303 ret = watch_time_get_day(watch_time, timeZone);
304 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
306 DALI_TEST_CHECK(watchTime.GetTimeZone() == timeZone);
311 int UtcDaliWatchTimeGetDaylightSavingTimeStatus(void)
316 watch_time_h watch_time = {
320 ret = watch_time_get_current_time(&watch_time);
321 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
323 ret = watch_time_get_day(watch_time, &daylight);
324 DALI_TEST_CHECK(ret == APP_ERROR_NONE);
326 DALI_TEST_CHECK(watchTime.GetDaylightSavingTimeStatus() == daylight);