2 * Copyright (c) 2017 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 <dali/dali.h>
19 #include <dali-test-suite-utils.h>
20 #include "public-api/dali-wearable.h"
21 #include <appcore-watch/watch_app.h>
22 #include <appcore-watch/watch_app_extension.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;
41 struct MyTestApp : public ConnectionTracker
43 MyTestApp( WatchApplication& app)
44 : initCalled( false ),
47 mApplication.InitSignal().Connect( this, &MyTestApp::Create );
50 void Create(Application& app)
62 WatchApplication& mApplication;
65 } // unnamed namespace
67 int UtcDaliWatchTimeNew(void)
70 WatchTime *watchTimeRef = &watchTime;
72 DALI_TEST_CHECK( watchTimeRef );
77 int UtcDaliWatchTimeGetHour(void)
81 watch_time_h watch_time = {0,};
83 ret = watch_time_get_current_time(&watch_time);
85 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
87 ret = watch_time_get_hour(watch_time, &hour);
89 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
91 DALI_TEST_CHECK( watchTime.GetHour() == hour );
96 int UtcDaliWatchTimeGetHour24(void)
100 watch_time_h watch_time = {0,};
102 ret = watch_time_get_current_time(&watch_time);
103 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
105 ret = watch_time_get_hour24(watch_time, &hour24);
106 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
108 DALI_TEST_CHECK( watchTime.GetHour24() == hour24 );
113 int UtcDaliWatchTimeGetMinute(void)
117 watch_time_h watch_time = {0,};
119 ret = watch_time_get_current_time(&watch_time);
120 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
122 ret = watch_time_get_minute(watch_time, &minute);
123 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
125 DALI_TEST_CHECK( watchTime.GetMinute() == minute );
130 int UtcDaliWatchTimeGetSecond(void)
134 watch_time_h watch_time = {0,};
136 ret = watch_time_get_current_time(&watch_time);
137 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
139 ret = watch_time_get_second(watch_time, &second);
140 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
142 DALI_TEST_CHECK( watchTime.GetSecond() == second );
147 int UtcDaliWatchTimeGetMillisecond(void)
149 int ret, millisecond;
151 watch_time_h watch_time = {0,};
153 ret = watch_time_get_current_time(&watch_time);
154 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
156 ret = watch_time_get_millisecond(watch_time, &millisecond);
157 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
159 DALI_TEST_CHECK( watchTime.GetMillisecond() == millisecond );
164 int UtcDaliWatchTimeGetYear(void)
168 watch_time_h watch_time = {0,};
170 ret = watch_time_get_current_time(&watch_time);
171 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
173 ret = watch_time_get_year(watch_time, &year);
174 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
176 DALI_TEST_CHECK( watchTime.GetYear() == year );
181 int UtcDaliWatchTimeGetMonth(void)
185 watch_time_h watch_time = {0,};
187 ret = watch_time_get_current_time(&watch_time);
188 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
190 ret = watch_time_get_month(watch_time, &month);
191 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
193 DALI_TEST_CHECK( watchTime.GetMonth() == month );
198 int UtcDaliWatchTimeGetDay(void)
202 watch_time_h watch_time = {0,};
204 ret = watch_time_get_current_time(&watch_time);
205 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
207 ret = watch_time_get_day(watch_time, &day);
208 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
210 DALI_TEST_CHECK( watchTime.GetDay() == day );
215 int UtcDaliWatchTimeGetDayOfWeek(void)
219 watch_time_h watch_time = {0,};
221 ret = watch_time_get_current_time(&watch_time);
222 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
224 ret = watch_time_get_day_of_week(watch_time, &dayOfWeek);
225 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
227 DALI_TEST_CHECK( watchTime.GetDayOfWeek() == dayOfWeek );
232 int UtcDaliWatchTimeGetUtcTime(void)
235 struct tm *utcTime = (struct tm *)calloc( 1, sizeof( struct tm ) );
237 watch_time_h watch_time = {0,};
239 ret = watch_time_get_current_time(&watch_time);
240 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
242 ret = watch_time_get_day(watch_time, utcTime);
243 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
245 DALI_TEST_CHECK( watchTime.GetUtcTime().tm_sec == (*utcTime).tm_sec );
250 int UtcDaliWatchTimeGetUtcTimeStamp(void)
253 time_t *timeStamp = (time_t *)calloc( 1, sizeof( time_t ) );
255 watch_time_h watch_time = {0,};
257 ret = watch_time_get_current_time(&watch_time);
258 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
260 ret = watch_time_get_day(watch_time, timeStamp);
261 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
263 DALI_TEST_CHECK( watchTime.GetUtcTimeStamp() == *timeStamp );
268 int UtcDaliWatchTimeGetTimeZone(void)
271 char *timeZone[TIMEZONE_BUFFER_MAX] = {0,};
273 watch_time_h watch_time = {0,};
275 ret = watch_time_get_current_time(&watch_time);
276 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
278 ret = watch_time_get_day(watch_time, timeZone);
279 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
281 DALI_TEST_CHECK( watchTime.GetTimeZone() == timeZone );
286 int UtcDaliWatchTimeGetDaylightSavingTimeStatus(void)
291 watch_time_h watch_time = {0,};
293 ret = watch_time_get_current_time(&watch_time);
294 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
296 ret = watch_time_get_day(watch_time, &daylight);
297 DALI_TEST_CHECK( ret == APP_ERROR_NONE );
299 DALI_TEST_CHECK( watchTime.GetDaylightSavingTimeStatus() == daylight );