• 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 
16 #include <gtest/gtest.h>
17 
18 #include "device/distributed_module_config.h"
19 #include "pasteboard_error.h"
20 
21 namespace OHOS::MiscServices {
22 using namespace testing::ext;
23 class DistributedModuleConfigTest : public testing::Test {
24 public:
25     static void SetUpTestCase(void);
26     static void TearDownTestCase(void);
27     void SetUp();
28     void TearDown();
29 };
30 
SetUpTestCase(void)31 void DistributedModuleConfigTest::SetUpTestCase(void) { }
32 
TearDownTestCase(void)33 void DistributedModuleConfigTest::TearDownTestCase(void) { }
34 
SetUp(void)35 void DistributedModuleConfigTest::SetUp(void) { }
36 
TearDown(void)37 void DistributedModuleConfigTest::TearDown(void) { }
38 
39 /**
40  * @tc.name: IsOnTest001
41  * @tc.desc: Is On.
42  * @tc.type: FUNC
43  * @tc.require:
44  * @tc.author:
45  */
46 HWTEST_F(DistributedModuleConfigTest, IsOnTest001, TestSize.Level0)
47 {
48     DistributedModuleConfig config;
49     config.Init();
50     bool result = config.IsOn();
51     config.DeInit();
52     EXPECT_FALSE(result);
53 }
54 
55 /**
56  * @tc.name: IsOnTest
57  * @tc.desc: Is On.
58  * @tc.type: FUNC
59  * @tc.require:
60  * @tc.author:
61  */
62 HWTEST_F(DistributedModuleConfigTest, IsOnTest002, TestSize.Level0)
63 {
64     DistributedModuleConfig config;
65     std::string device = "validDevice";
66     bool result = config.IsOn();
67     config.OnReady(device);
68     config.Online(device);
69     config.Offline(device);
70     EXPECT_FALSE(result);
71 }
72 
73 /**
74  * @tc.name: WatchTest
75  * @tc.desc: Watch.
76  * @tc.type: FUNC
77  * @tc.require:
78  * @tc.author:
79  */
80 HWTEST_F(DistributedModuleConfigTest, WatchTest, TestSize.Level0)
81 {
82     DistributedModuleConfig::Observer observer;
83     DistributedModuleConfig config;
84     config.Notify();
85     config.Watch(observer);
86     EXPECT_FALSE(observer);
87 }
88 } // namespace OHOS::MiscServices
89