• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 #include <securec.h>
16 #include "gtest/gtest.h"
17 
18 #include "softbus_adapter_timer.h"
19 #include "softbus_def.h"
20 #include "softbus_errcode.h"
21 
22 using namespace std;
23 using namespace testing::ext;
24 
25 namespace OHOS {
26 const int32_t TIMER_TIMEOUT = 1000;
27 
28 class SoftbusTimeTest : public testing::Test {
29 protected:
30     static void SetUpTestCase(void);
31     static void TearDownTestCase(void);
32     void SetUp();
33     void TearDown();
34 };
SetUpTestCase(void)35 void SoftbusTimeTest::SetUpTestCase(void)
36 {
37 }
TearDownTestCase(void)38 void SoftbusTimeTest::TearDownTestCase(void)
39 {
40 }
SetUp()41 void SoftbusTimeTest::SetUp()
42 {
43 }
TearDown()44 void SoftbusTimeTest::TearDown()
45 {
46 }
47 /*
48 * @tc.name: SoftBusTimerTest001
49 * @tc.desc: soft bus timer test
50 * @tc.type: FUNC
51 * @tc.require:
52 */
53 HWTEST_F(SoftbusTimeTest, SoftBusTimerTest001, TestSize.Level1)
54 {
55     void *timerId = NULL;
56     SoftBusSysTime times = {0};
57     int32_t ret;
58 
59     ret = SoftBusStartTimer(NULL, TIMER_TIMEOUT);
60     EXPECT_EQ(SOFTBUS_ERR, ret);
61     SoftBusCreateTimer(NULL, TIMER_TYPE_ONCE);
62     SoftBusCreateTimer(&timerId, TIMER_TYPE_ONCE);
63     ret = SoftBusStartTimer(timerId, TIMER_TIMEOUT);
64     EXPECT_NE(SOFTBUS_ERR, ret);
65     ret = SoftBusDeleteTimer(NULL);
66     EXPECT_EQ(SOFTBUS_ERR, ret);
67     ret = SoftBusDeleteTimer(timerId);
68     EXPECT_EQ(SOFTBUS_OK, ret);
69     ret = SoftBusGetTime(NULL);
70     EXPECT_EQ(SOFTBUS_INVALID_PARAM, ret);
71     ret = SoftBusGetTime(&times);
72     EXPECT_EQ(SOFTBUS_OK, ret);
73 }
74 }