1 /*
2 * Copyright (c) 2024 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 "session_manager/include/screen_session_manager_lite.h"
19 #include "window_manager_hilog.h"
20 #include "display_manager_agent_default.h"
21
22 using namespace testing;
23 using namespace testing::ext;
24
25 namespace OHOS {
26 namespace Rosen {
27 namespace {
28 constexpr uint32_t SLEEP_TIME_US = 100000;
29 }
30
31 class ScreenSessionManagerLiteTest : public testing::Test {
32 public:
33 static void SetUpTestCase();
34 static void TearDownTestCase();
35 void SetUp() override;
36 void TearDown() override;
37 };
38
SetUpTestCase()39 void ScreenSessionManagerLiteTest::SetUpTestCase()
40 {
41 }
42
TearDownTestCase()43 void ScreenSessionManagerLiteTest::TearDownTestCase()
44 {
45 }
46
SetUp()47 void ScreenSessionManagerLiteTest::SetUp()
48 {
49 }
50
TearDown()51 void ScreenSessionManagerLiteTest::TearDown()
52 {
53 usleep(SLEEP_TIME_US);
54 }
55
56 namespace {
57
58 /**
59 * @tc.name: ConnectToServer
60 * @tc.desc: ConnectToServer
61 * @tc.type: FUNC
62 */
63 HWTEST_F(ScreenSessionManagerLiteTest, ConnectToServer, Function | SmallTest | Level3)
64 {
65 ScreenSessionManagerLite screenSessionManagerLite = ScreenSessionManagerLite();
66 screenSessionManagerLite.ConnectToServer();
67 ASSERT_EQ(screenSessionManagerLite.screenSessionManager_, nullptr);
68 }
69
70 /**
71 * @tc.name: RegisterDisplayManagerAgent
72 * @tc.desc: RegisterDisplayManagerAgent
73 * @tc.type: FUNC
74 */
75 HWTEST_F(ScreenSessionManagerLiteTest, RegisterDisplayManagerAgent, Function | SmallTest | Level3)
76 {
77 ScreenSessionManagerLite screenSessionManagerLite = ScreenSessionManagerLite();
78 sptr<IDisplayManagerAgent> displayManagerAgent= new DisplayManagerAgentDefault();
79 DisplayManagerAgentType type = DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER;
80 DMError ret = screenSessionManagerLite.RegisterDisplayManagerAgent(displayManagerAgent, type);
81 ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR);
82 }
83
84 /**
85 * @tc.name: UnregisterDisplayManagerAgent
86 * @tc.desc: UnregisterDisplayManagerAgent
87 * @tc.type: FUNC
88 */
89 HWTEST_F(ScreenSessionManagerLiteTest, UnregisterDisplayManagerAgent, Function | SmallTest | Level3)
90 {
91 ScreenSessionManagerLite screenSessionManagerLite = ScreenSessionManagerLite();
92 sptr<IDisplayManagerAgent> displayManagerAgent= new DisplayManagerAgentDefault();
93 DisplayManagerAgentType type = DisplayManagerAgentType::DISPLAY_POWER_EVENT_LISTENER;
94 DMError ret = screenSessionManagerLite.UnregisterDisplayManagerAgent(displayManagerAgent, type);
95 ASSERT_EQ(ret, DMError::DM_ERROR_NULLPTR);
96 }
97
98 /**
99 * @tc.name: GetFoldDisplayMode
100 * @tc.desc: GetFoldDisplayMode
101 * @tc.type: FUNC
102 */
103 HWTEST_F(ScreenSessionManagerLiteTest, GetFoldDisplayMode, Function | SmallTest | Level3)
104 {
105 ScreenSessionManagerLite screenSessionManagerLite = ScreenSessionManagerLite();
106 FoldDisplayMode ret = screenSessionManagerLite.GetFoldDisplayMode();
107 ASSERT_EQ(ret, FoldDisplayMode::UNKNOWN);
108 }
109
110 /**
111 * @tc.name: IsFoldable
112 * @tc.desc: IsFoldable
113 * @tc.type: FUNC
114 */
115 HWTEST_F(ScreenSessionManagerLiteTest, IsFoldable, Function | SmallTest | Level3)
116 {
117 ScreenSessionManagerLite screenSessionManagerLite = ScreenSessionManagerLite();
118 bool ret = screenSessionManagerLite.IsFoldable();
119 ASSERT_FALSE(ret);
120 }
121
122 /**
123 * @tc.name: GetFoldStatus
124 * @tc.desc: GetFoldStatus
125 * @tc.type: FUNC
126 */
127 HWTEST_F(ScreenSessionManagerLiteTest, GetFoldStatus, Function | SmallTest | Level3)
128 {
129 ScreenSessionManagerLite screenSessionManagerLite = ScreenSessionManagerLite();
130 FoldStatus ret = screenSessionManagerLite.GetFoldStatus();
131 ASSERT_EQ(ret, FoldStatus::UNKNOWN);
132 }
133
134 /**
135 * @tc.name: GetDefaultDisplayInfo
136 * @tc.desc: GetDefaultDisplayInfo
137 * @tc.type: FUNC
138 */
139 HWTEST_F(ScreenSessionManagerLiteTest, GetDefaultDisplayInfo, Function | SmallTest | Level3)
140 {
141 ScreenSessionManagerLite screenSessionManagerLite = ScreenSessionManagerLite();
142 sptr<DisplayInfo> ret = screenSessionManagerLite.GetDefaultDisplayInfo();
143 ASSERT_EQ(ret, nullptr);
144 }
145
146 /**
147 * @tc.name: GetDisplayInfoById
148 * @tc.desc: GetDisplayInfoById
149 * @tc.type: FUNC
150 */
151 HWTEST_F(ScreenSessionManagerLiteTest, GetDisplayInfoById, Function | SmallTest | Level3)
152 {
153 ScreenSessionManagerLite screenSessionManagerLite = ScreenSessionManagerLite();
154 DisplayId displayId = 0;
155 sptr<DisplayInfo> ret = screenSessionManagerLite.GetDisplayInfoById(displayId);
156 ASSERT_EQ(ret, nullptr);
157 }
158
159 /**
160 * @tc.name: GetCutoutInfo
161 * @tc.desc: GetCutoutInfo
162 * @tc.type: FUNC
163 */
164 HWTEST_F(ScreenSessionManagerLiteTest, GetCutoutInfo, Function | SmallTest | Level3)
165 {
166 ScreenSessionManagerLite screenSessionManagerLite = ScreenSessionManagerLite();
167 DisplayId displayId = 0;
168 sptr<CutoutInfo> ret = screenSessionManagerLite.GetCutoutInfo(displayId);
169 ASSERT_EQ(ret, nullptr);
170 }
171
172 /**
173 * @tc.name: Clear
174 * @tc.desc: Clear
175 * @tc.type: FUNC
176 */
177 HWTEST_F(ScreenSessionManagerLiteTest, Clear, Function | SmallTest | Level3)
178 {
179 ScreenSessionManagerLite screenSessionManagerLite = ScreenSessionManagerLite();
180 screenSessionManagerLite.Clear();
181 ASSERT_EQ(screenSessionManagerLite.screenSessionManager_, nullptr);
182 }
183 }
184 } // namespace Rosen
185 } // namespace OHOS