14d6c458bSopenharmony_ci/* 24d6c458bSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 34d6c458bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 44d6c458bSopenharmony_ci * you may not use this file except in compliance with the License. 54d6c458bSopenharmony_ci * You may obtain a copy of the License at 64d6c458bSopenharmony_ci * 74d6c458bSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 84d6c458bSopenharmony_ci * 94d6c458bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 104d6c458bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 114d6c458bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 124d6c458bSopenharmony_ci * See the License for the specific language governing permissions and 134d6c458bSopenharmony_ci * limitations under the License. 144d6c458bSopenharmony_ci */ 154d6c458bSopenharmony_ci 164d6c458bSopenharmony_ci#ifndef TEST_TIMER_H 174d6c458bSopenharmony_ci#define TEST_TIMER_H 184d6c458bSopenharmony_ci 194d6c458bSopenharmony_ci#include "commonlibrary/ets_utils/js_concurrent_module/common/helper/napi_helper.h" 204d6c458bSopenharmony_ci#include "../timer.h" 214d6c458bSopenharmony_ci 224d6c458bSopenharmony_cinamespace OHOS::JsSysModule { 234d6c458bSopenharmony_ciclass TimerTest { 244d6c458bSopenharmony_cipublic: 254d6c458bSopenharmony_ci TimerTest() = default; 264d6c458bSopenharmony_ci ~TimerTest() = default; 274d6c458bSopenharmony_ci static napi_value SetTimeout(napi_env env, napi_callback_info cbinfo); 284d6c458bSopenharmony_ci static napi_value SetInterval(napi_env env, napi_callback_info cbinfo); 294d6c458bSopenharmony_ci static napi_value ClearTimer(napi_env env, napi_callback_info cbinfo); 304d6c458bSopenharmony_ci static void DeleteTimer(uint32_t tId, TimerCallbackInfo* callbackInfo); 314d6c458bSopenharmony_ci static std::map<uint32_t, TimerCallbackInfo*>& create_timerTable(); 324d6c458bSopenharmony_ci static void TimerCallback(uv_timer_t* handle); 334d6c458bSopenharmony_ci static void ClearEnvironmentTimer(napi_env env); 344d6c458bSopenharmony_ci}; 354d6c458bSopenharmony_ci 364d6c458bSopenharmony_cinapi_value TimerTest::SetTimeout(napi_env env, napi_callback_info cbinfo) 374d6c458bSopenharmony_ci{ 384d6c458bSopenharmony_ci return Timer::SetTimeout(env, cbinfo); 394d6c458bSopenharmony_ci}; 404d6c458bSopenharmony_ci 414d6c458bSopenharmony_cinapi_value TimerTest::SetInterval(napi_env env, napi_callback_info cbinfo) 424d6c458bSopenharmony_ci{ 434d6c458bSopenharmony_ci return Timer::SetInterval(env, cbinfo); 444d6c458bSopenharmony_ci}; 454d6c458bSopenharmony_ci 464d6c458bSopenharmony_cinapi_value TimerTest::ClearTimer(napi_env env, napi_callback_info cbinfo) 474d6c458bSopenharmony_ci{ 484d6c458bSopenharmony_ci return Timer::ClearTimer(env, cbinfo); 494d6c458bSopenharmony_ci}; 504d6c458bSopenharmony_ci 514d6c458bSopenharmony_civoid TimerTest::DeleteTimer(uint32_t tId, TimerCallbackInfo* callbackInfo) 524d6c458bSopenharmony_ci{ 534d6c458bSopenharmony_ci return Timer::DeleteTimer(tId, callbackInfo); 544d6c458bSopenharmony_ci}; 554d6c458bSopenharmony_ci 564d6c458bSopenharmony_cistd::map<uint32_t, TimerCallbackInfo*>& TimerTest::create_timerTable() 574d6c458bSopenharmony_ci{ 584d6c458bSopenharmony_ci return Timer::timerTable; 594d6c458bSopenharmony_ci}; 604d6c458bSopenharmony_ci 614d6c458bSopenharmony_civoid TimerTest::ClearEnvironmentTimer(napi_env env) 624d6c458bSopenharmony_ci{ 634d6c458bSopenharmony_ci return Timer::ClearEnvironmentTimer(env); 644d6c458bSopenharmony_ci} 654d6c458bSopenharmony_ci 664d6c458bSopenharmony_civoid TimerTest::TimerCallback(uv_timer_t* handle) 674d6c458bSopenharmony_ci{ 684d6c458bSopenharmony_ci return Timer::TimerCallback(handle); 694d6c458bSopenharmony_ci} 704d6c458bSopenharmony_ci} 714d6c458bSopenharmony_ci#endif // TEST_TIMER_H 72