1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#ifndef TEST_TIMER_H
17#define TEST_TIMER_H
18
19#include "commonlibrary/ets_utils/js_concurrent_module/common/helper/napi_helper.h"
20#include "../timer.h"
21
22namespace OHOS::JsSysModule {
23class TimerTest {
24public:
25    TimerTest() = default;
26    ~TimerTest() = default;
27    static napi_value SetTimeout(napi_env env, napi_callback_info cbinfo);
28    static napi_value SetInterval(napi_env env, napi_callback_info cbinfo);
29    static napi_value ClearTimer(napi_env env, napi_callback_info cbinfo);
30    static void DeleteTimer(uint32_t tId, TimerCallbackInfo* callbackInfo);
31    static std::map<uint32_t, TimerCallbackInfo*>& create_timerTable();
32    static void TimerCallback(uv_timer_t* handle);
33    static void ClearEnvironmentTimer(napi_env env);
34};
35
36napi_value TimerTest::SetTimeout(napi_env env, napi_callback_info cbinfo)
37{
38    return Timer::SetTimeout(env, cbinfo);
39};
40
41napi_value TimerTest::SetInterval(napi_env env, napi_callback_info cbinfo)
42{
43    return Timer::SetInterval(env, cbinfo);
44};
45
46napi_value TimerTest::ClearTimer(napi_env env, napi_callback_info cbinfo)
47{
48    return Timer::ClearTimer(env, cbinfo);
49};
50
51void TimerTest::DeleteTimer(uint32_t tId, TimerCallbackInfo* callbackInfo)
52{
53    return Timer::DeleteTimer(tId, callbackInfo);
54};
55
56std::map<uint32_t, TimerCallbackInfo*>& TimerTest::create_timerTable()
57{
58    return Timer::timerTable;
59};
60
61void TimerTest::ClearEnvironmentTimer(napi_env env)
62{
63    return Timer::ClearEnvironmentTimer(env);
64}
65
66void TimerTest::TimerCallback(uv_timer_t* handle)
67{
68    return Timer::TimerCallback(handle);
69}
70}
71#endif // TEST_TIMER_H
72