• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 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 "UTTest_dm_screen_common_event.h"
17 
18 #include "bluetooth_def.h"
19 #include "common_event_support.h"
20 #include "dm_constants.h"
21 #include "dm_screen_common_event.h"
22 #include "matching_skills.h"
23 #include "system_ability_definition.h"
24 
25 namespace OHOS {
26 namespace DistributedHardware {
SetUp()27 void DmScreenCommonEventManagerTest::SetUp()
28 {
29 }
30 
TearDown()31 void DmScreenCommonEventManagerTest::TearDown()
32 {
33 }
34 
SetUpTestCase()35 void DmScreenCommonEventManagerTest::SetUpTestCase()
36 {
37 }
38 
TearDownTestCase()39 void DmScreenCommonEventManagerTest::TearDownTestCase()
40 {
41 }
42 
43 namespace {
44 
45 HWTEST_F(DmScreenCommonEventManagerTest, SubscribeScreenCommonEvent_001, testing::ext::TestSize.Level1)
46 {
47     std::shared_ptr<DmScreenCommonEventManager> screenCommonEventManager
48         = std::make_shared<DmScreenCommonEventManager>();
49     std::vector<std::string> commonEventVec;
50     bool ret = screenCommonEventManager->SubscribeScreenCommonEvent(commonEventVec, nullptr);
51     ASSERT_EQ(ret, false);
52     commonEventVec.emplace_back(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_ON);
53     ret = screenCommonEventManager->SubscribeScreenCommonEvent(commonEventVec, nullptr);
54     ASSERT_EQ(ret, false);
55 }
56 
57 HWTEST_F(DmScreenCommonEventManagerTest, UnSubscribeScreenCommonEvent_001, testing::ext::TestSize.Level1)
58 {
59     std::shared_ptr<DmScreenCommonEventManager> screenCommonEventManager
60         = std::make_shared<DmScreenCommonEventManager>();
61     bool ret = screenCommonEventManager->UnsubscribeScreenCommonEvent();
62     ASSERT_EQ(ret, false);
63     screenCommonEventManager->eventValidFlag_ = true;
64     ret = screenCommonEventManager->UnsubscribeScreenCommonEvent();
65     ASSERT_EQ(ret, true);
66 }
67 }
68 } // namespace DistributedHardware
69 } // namespace OHOS
70