1 /*
2 * Copyright (c) 2022 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 <gtest/gtest.h>
16 #include "window_scene.h"
17 #include "ability_context_impl.h"
18 #include "mock_static_call.h"
19 #include "singleton_mocker.h"
20 #include "window_impl.h"
21 #include <configuration.h>
22
23 #include "window_scene_session_impl.h"
24
25 using namespace testing;
26 using namespace testing::ext;
27
28 namespace OHOS {
29 namespace Rosen {
30 using Mocker = SingletonMocker<StaticCall, MockStaticCall>;
31 class WindowSceneTest : public testing::Test {
32 public:
33 static void SetUpTestCase();
34 static void TearDownTestCase();
35 virtual void SetUp() override;
36 virtual void TearDown() override;
37
38 sptr<WindowScene> scene_ = nullptr;
39 std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext_;
40 };
SetUpTestCase()41 void WindowSceneTest::SetUpTestCase()
42 {
43 }
44
TearDownTestCase()45 void WindowSceneTest::TearDownTestCase()
46 {
47 }
48
SetUp()49 void WindowSceneTest::SetUp()
50 {
51 DisplayId displayId = 0;
52 sptr<IWindowLifeCycle> listener = nullptr;
53 scene_ = new WindowScene();
54 abilityContext_ = std::make_shared<AbilityRuntime::AbilityContextImpl>();
55 std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
56 sptr<WindowOption> option = new WindowOption();
57 EXPECT_CALL(m->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(new WindowImpl(option)));
58 ASSERT_EQ(WMError::WM_OK, scene_->Init(displayId, abilityContext_, listener));
59 }
60
TearDown()61 void WindowSceneTest::TearDown()
62 {
63 scene_->GoDestroy();
64 scene_ = nullptr;
65 abilityContext_ = nullptr;
66 }
67
68 namespace {
69 /**
70 * @tc.name: Init01
71 * @tc.desc: Init Scene with null abilityContext, null listener
72 * @tc.type: FUNC
73 */
74 HWTEST_F(WindowSceneTest, Init01, Function | SmallTest | Level2)
75 {
76 std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
77 sptr<WindowOption> optionTest = new WindowOption();
78 EXPECT_CALL(m->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(new WindowImpl(optionTest)));
79 DisplayId displayId = 0;
80 sptr<IWindowLifeCycle> listener = nullptr;
81 sptr<WindowScene> scene = new WindowScene();
82 std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext = nullptr;
83 ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext, listener, optionTest));
84 }
85
86 /**
87 * @tc.name: Init02
88 * @tc.desc: Mock window Create Static Method return nullptr, init Scene with null abilityContext, null listener
89 * @tc.type: FUNC
90 */
91 HWTEST_F(WindowSceneTest, Init02, Function | SmallTest | Level2)
92 {
93 std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
94 sptr<WindowOption> optionTest = new WindowOption();
95 EXPECT_CALL(m->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(nullptr));
96 DisplayId displayId = 0;
97 sptr<IWindowLifeCycle> listener = nullptr;
98 sptr<WindowScene> scene = new WindowScene();
99 std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext = nullptr;
100 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->Init(displayId, abilityContext, listener, optionTest));
101 }
102
103 /**
104 * @tc.name: Init03
105 * @tc.desc: Init Scene with abilityContext, null listener
106 * @tc.type: FUNC
107 */
108 HWTEST_F(WindowSceneTest, Init03, Function | SmallTest | Level2)
109 {
110 std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
111 sptr<WindowOption> optionTest = new WindowOption();
112 EXPECT_CALL(m->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(new WindowImpl(optionTest)));
113 DisplayId displayId = 0;
114 sptr<IWindowLifeCycle> listener = nullptr;
115 sptr<WindowScene> scene = new WindowScene();
116 ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext_, listener, optionTest));
117 }
118
119 /**
120 * @tc.name: Init04
121 * @tc.desc: Init Scene with abilityContext, null listener
122 * @tc.type: FUNC
123 */
124 HWTEST_F(WindowSceneTest, Init04, Function | SmallTest | Level2)
125 {
126 sptr<IRemoteObject> iSession = nullptr;
127 sptr<WindowOption> optionTest = nullptr;
128 DisplayId displayId = 1;
129 sptr<IWindowLifeCycle> listener = nullptr;
130 sptr<WindowScene> scene = new WindowScene();
131 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->Init(displayId, abilityContext_, listener, optionTest, iSession));
132 }
133
134 /**
135 * @tc.name: Init05
136 * @tc.desc: Init Scene with abilityContext, null listener
137 * @tc.type: FUNC
138 */
139 HWTEST_F(WindowSceneTest, Init05, Function | SmallTest | Level2)
140 {
141 sptr<WindowScene> scene = new WindowScene();
142 sptr<WindowOption> optionTest = new WindowOption();
143 sptr<IRemoteObject> iSession = new IPCObjectStub();
144 DisplayId displayId = 1;
145 sptr<IWindowLifeCycle> listener = nullptr;
146 std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext = nullptr;
147 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->Init(displayId, abilityContext, listener, optionTest, iSession));
148 }
149
150 /**
151 * @tc.name: Init06
152 * @tc.desc: Init Scene with abilityContext, null listener
153 * @tc.type: FUNC
154 */
155 HWTEST_F(WindowSceneTest, Init06, Function | SmallTest | Level2)
156 {
157 std::string identityToken = "testToken";
158 sptr<WindowScene> scene = new WindowScene();
159 sptr<WindowOption> optionTest = new WindowOption();
160 sptr<IRemoteObject> iSession = new IPCObjectStub();
161 DisplayId displayId = 1;
162 sptr<IWindowLifeCycle> listener = nullptr;
163 std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext = nullptr;
164 ASSERT_EQ(WMError::WM_ERROR_NULLPTR,
165 scene->Init(displayId, abilityContext, listener, optionTest, iSession, identityToken));
166 }
167
168
169 /**
170 * @tc.name: Create01
171 * @tc.desc: CreateWindow without windowName
172 * @tc.type: FUNC
173 */
174 HWTEST_F(WindowSceneTest, Create01, Function | SmallTest | Level2)
175 {
176 sptr<WindowOption> optionTest = new WindowOption();
177 sptr<WindowScene> scene = new WindowScene();
178 ASSERT_EQ(nullptr, scene->CreateWindow("", optionTest));
179 }
180
181 /**
182 * @tc.name: Create02
183 * @tc.desc: CreateWindow with windowName and without mainWindow
184 * @tc.type: FUNC
185 */
186 HWTEST_F(WindowSceneTest, Create02, Function | SmallTest | Level2)
187 {
188 sptr<WindowOption> optionTest = new WindowOption();
189 sptr<WindowScene> scene = new WindowScene();
190 ASSERT_EQ(nullptr, scene->CreateWindow("WindowSceneTest02", optionTest));
191 }
192
193 /**
194 * @tc.name: Create03
195 * @tc.desc: CreateWindow with windowName and mainWindow
196 * @tc.type: FUNC
197 */
198 HWTEST_F(WindowSceneTest, Create03, Function | SmallTest | Level2)
199 {
200 std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
201 sptr<WindowOption> optionTest = new WindowOption();
202 EXPECT_CALL(m->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(new WindowImpl(optionTest)));
203 ASSERT_NE(nullptr, scene_->CreateWindow("WindowSceneTest03", optionTest));
204 }
205
206 /**
207 * @tc.name: Create04
208 * @tc.desc: Mock window Create Static Method return nullptr, createWindow with windowName and mainWindow
209 * @tc.type: FUNC
210 */
211 HWTEST_F(WindowSceneTest, Create04, Function | SmallTest | Level2)
212 {
213 sptr<WindowOption> optionTest = new WindowOption();
214 std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
215 EXPECT_CALL(m->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(nullptr));
216 ASSERT_EQ(nullptr, scene_->CreateWindow("WindowSceneTest04", optionTest));
217 }
218
219 /**
220 * @tc.name: Create05
221 * @tc.desc: createWindow with windowName and null option
222 * @tc.type: FUNC
223 */
224 HWTEST_F(WindowSceneTest, Create05, Function | SmallTest | Level2)
225 {
226 sptr<WindowOption> optionTest = nullptr;
227 ASSERT_EQ(nullptr, scene_->CreateWindow("WindowSceneTest05", optionTest));
228 }
229
230 /**
231 * @tc.name: GetMainWindow01
232 * @tc.desc: GetMainWindow without scene init
233 * @tc.type: FUNC
234 */
235 HWTEST_F(WindowSceneTest, GetMainWindow01, Function | SmallTest | Level2)
236 {
237 sptr<WindowScene> scene = new WindowScene();
238 ASSERT_EQ(nullptr, scene->GetMainWindow());
239 }
240
241 /**
242 * @tc.name: GetMainWindow02
243 * @tc.desc: GetMainWindow01 with nullptr
244 * @tc.type: FUNC
245 */
246 HWTEST_F(WindowSceneTest, GetMainWindow02, Function | SmallTest | Level2)
247 {
248 ASSERT_NE(nullptr, scene_->GetMainWindow());
249 }
250
251 /**
252 * @tc.name: GetSubWindow01
253 * @tc.desc: GetSubWindow without scene init
254 * @tc.type: FUNC
255 */
256 HWTEST_F(WindowSceneTest, GetSubWindow01, Function | SmallTest | Level2)
257 {
258 sptr<WindowScene> scene = new WindowScene();
259 std::vector<sptr<Window>> subWindows = scene->GetSubWindow();
260 ASSERT_TRUE(subWindows.empty());
261 }
262
263 /**
264 * @tc.name: GetSubWindow02
265 * @tc.desc: GetSubWindow without scene init
266 * @tc.type: FUNC
267 */
268 HWTEST_F(WindowSceneTest, GetSubWindow02, Function | SmallTest | Level2)
269 {
270 std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
271 sptr<WindowOption> optionTest = new WindowOption();
272 EXPECT_CALL(m->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(new WindowImpl(optionTest)));
273 DisplayId displayId = 0;
274 sptr<IWindowLifeCycle> listener = nullptr;
275 sptr<WindowScene> scene = new WindowScene();
276 std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext = nullptr;
277 ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext, listener));
278 std::vector<sptr<Window>> subWindows = scene->GetSubWindow();
279 ASSERT_TRUE(subWindows.empty());
280 }
281
282 /**
283 * @tc.name: OnNewWant01
284 * @tc.desc: OnNewWant nullptr
285 * @tc.type: FUNC
286 */
287 HWTEST_F(WindowSceneTest, OnNewWant01, Function | SmallTest | Level2)
288 {
289 sptr<WindowScene> scene = new WindowScene();
290 AAFwk::Want want;
291 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->OnNewWant(want));
292 }
293
294 /**
295 * @tc.name: OnNewWant02
296 * @tc.desc: OnNewWant without scene init
297 * @tc.type: FUNC
298 */
299 HWTEST_F(WindowSceneTest, OnNewWant02, Function | SmallTest | Level2)
300 {
301 std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
302 sptr<WindowOption> optionTest = new WindowOption();
303 EXPECT_CALL(m->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(new WindowImpl(optionTest)));
304 DisplayId displayId = 0;
305 sptr<IWindowLifeCycle> listener = nullptr;
306 sptr<WindowScene> scene = new WindowScene();
307 std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext = nullptr;
308 ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext, listener));
309 AAFwk::Want want;
310 ASSERT_EQ(WMError::WM_OK, scene->OnNewWant(want));
311 }
312
313 /**
314 * @tc.name: UpdateConfiguration01
315 * @tc.desc: UpdateConfiguration01 without mainWindow
316 * @tc.type: FUNC
317 * @tc.require: issueI5JQ04
318 */
319 HWTEST_F(WindowSceneTest, UpdateConfiguration01, Function | SmallTest | Level2)
320 {
321 sptr<WindowScene> scene = new WindowScene();
322 std::shared_ptr<AppExecFwk::Configuration> configuration = nullptr;
323 scene->UpdateConfiguration(configuration);
324 int32_t level = 0;
325 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->NotifyMemoryLevel(level));
326 }
327
328 /**
329 * @tc.name: UpdateConfiguration02
330 * @tc.desc: UpdateConfiguration without scene init
331 * @tc.type: FUNC
332 */
333 HWTEST_F(WindowSceneTest, UpdateConfiguration02, Function | SmallTest | Level2)
334 {
335 std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
336 sptr<WindowOption> optionTest = new WindowOption();
337 EXPECT_CALL(m->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(new WindowImpl(optionTest)));
338 DisplayId displayId = 0;
339 sptr<IWindowLifeCycle> listener = nullptr;
340 sptr<WindowScene> scene = new WindowScene();
341 std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext = nullptr;
342 ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext, listener));
343 std::shared_ptr<AppExecFwk::Configuration> configuration = std::make_shared<AppExecFwk::Configuration>();
344 scene->UpdateConfiguration(configuration);
345 }
346
347 /**
348 * @tc.name: GetContentInfo01
349 * @tc.desc: GetContentInfo nullptr
350 * @tc.type: FUNC
351 */
352 HWTEST_F(WindowSceneTest, GetContentInfo01, Function | SmallTest | Level2)
353 {
354 sptr<WindowScene> scene = new WindowScene();
355 ASSERT_EQ("", scene->GetContentInfo());
356 }
357
358 /**
359 * @tc.name: GetContentInfo02
360 * @tc.desc: GetContentInfo without scene init
361 * @tc.type: FUNC
362 */
363 HWTEST_F(WindowSceneTest, GetContentInfo02, Function | SmallTest | Level2)
364 {
365 std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
366 sptr<WindowOption> optionTest = new WindowOption();
367 EXPECT_CALL(m->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(new WindowImpl(optionTest)));
368 DisplayId displayId = 0;
369 sptr<IWindowLifeCycle> listener = nullptr;
370 sptr<WindowScene> scene = new WindowScene();
371 std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext = nullptr;
372 ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext, listener));
373 ASSERT_EQ("", scene->GetContentInfo());
374 }
375
376 /**
377 * @tc.name: SetSystemBarProperty01
378 * @tc.desc: SetSystemBarProperty nullptr
379 * @tc.type: FUNC
380 */
381 HWTEST_F(WindowSceneTest, SetSystemBarProperty01, Function | SmallTest | Level2)
382 {
383 sptr<WindowScene> scene = new WindowScene();
384 WindowType type = WindowType::WINDOW_TYPE_DIALOG;
385 SystemBarProperty property;
386 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->SetSystemBarProperty(type, property));
387 }
388
389 /**
390 * @tc.name: SetSystemBarProperty02
391 * @tc.desc: SetSystemBarProperty without scene init
392 * @tc.type: FUNC
393 */
394 HWTEST_F(WindowSceneTest, SetSystemBarProperty02, Function | SmallTest | Level2)
395 {
396 std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
397 sptr<WindowOption> optionTest = new WindowOption();
398 EXPECT_CALL(m->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(new WindowImpl(optionTest)));
399 DisplayId displayId = 0;
400 sptr<IWindowLifeCycle> listener = nullptr;
401 sptr<WindowScene> scene = new WindowScene();
402 std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext = nullptr;
403 ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext, listener));
404 WindowType type = WindowType::WINDOW_TYPE_DIALOG;
405 SystemBarProperty property;
406 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, scene->SetSystemBarProperty(type, property));
407 }
408
409 /**
410 * @tc.name: GoForeground01
411 * @tc.desc: GoForeground01 without mainWindow
412 * @tc.type: FUNC
413 */
414 HWTEST_F(WindowSceneTest, GoForeground01, Function | SmallTest | Level2)
415 {
416 sptr<WindowScene> scene = new WindowScene();
417 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->GoForeground());
418 }
419
420 /**
421 * @tc.name: GoForeground02
422 * @tc.desc: GoForeground02 without mainWindow
423 * @tc.type: FUNC
424 */
425 HWTEST_F(WindowSceneTest, GoForeground02, Function | SmallTest | Level2)
426 {
427 std::unique_ptr<Mocker> m1 = std::make_unique<Mocker>();
428 sptr<WindowOption> optionTest = new WindowOption();
429 EXPECT_CALL(m1->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(new WindowImpl(optionTest)));
430 DisplayId displayId = 0;
431 sptr<IWindowLifeCycle> listener = nullptr;
432 sptr<WindowScene> scene = new WindowScene();
433 ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext_, listener));
434 uint32_t reason = 0;
435 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, scene->GoForeground(reason));
436 }
437
438 /**
439 * @tc.name: GoBackground01
440 * @tc.desc: GoBackground01 without mainWindow
441 * @tc.type: FUNC
442 */
443 HWTEST_F(WindowSceneTest, GoBackground01, Function | SmallTest | Level2)
444 {
445 sptr<WindowScene> scene = new WindowScene();
446 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->GoBackground());
447 }
448
449 /**
450 * @tc.name: GoBackground02
451 * @tc.desc: GoBackground02 without mainWindow
452 * @tc.type: FUNC
453 */
454 HWTEST_F(WindowSceneTest, GoBackground02, Function | SmallTest | Level2)
455 {
456 std::unique_ptr<Mocker> m2 = std::make_unique<Mocker>();
457 sptr<WindowOption> optionTest = new WindowOption();
458 EXPECT_CALL(m2->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(new WindowImpl(optionTest)));
459 DisplayId displayId = 0;
460 sptr<IWindowLifeCycle> listener = nullptr;
461 sptr<WindowScene> scene = new WindowScene();
462 ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext_, listener));
463 uint32_t reason = 0;
464 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, scene->GoBackground(reason));
465 }
466
467 /**
468 * @tc.name: RequestFocus01
469 * @tc.desc: RequestFocus01 without mainWindow
470 * @tc.type: FUNC
471 */
472 HWTEST_F(WindowSceneTest, RequestFocus01, Function | SmallTest | Level2)
473 {
474 sptr<WindowScene> scene = new WindowScene();
475 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->RequestFocus());
476 }
477
478 /**
479 * @tc.name: RequestFocus02
480 * @tc.desc: RequestFocus02 without mainWindow
481 * @tc.type: FUNC
482 */
483 HWTEST_F(WindowSceneTest, RequestFocus02, Function | SmallTest | Level2)
484 {
485 std::unique_ptr<Mocker> m3 = std::make_unique<Mocker>();
486 sptr<WindowOption> optionTest = new WindowOption();
487 EXPECT_CALL(m3->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(new WindowImpl(optionTest)));
488 DisplayId displayId = 0;
489 sptr<IWindowLifeCycle> listener = nullptr;
490 sptr<WindowScene> scene = new WindowScene();
491 ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext_, listener));
492 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, scene->RequestFocus());
493 }
494
495 /**
496 * @tc.name: NotifyMemoryLevel01
497 * @tc.desc: NotifyMemoryLevel without mainWindow
498 * @tc.type: FUNC
499 * @tc.require: issueI5JQ04
500 */
501 HWTEST_F(WindowSceneTest, NotifyMemoryLevel01, Function | SmallTest | Level2)
502 {
503 sptr<WindowScene> scene = new WindowScene();
504 int32_t level = 0;
505 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->NotifyMemoryLevel(level));
506 }
507
508 /**
509 * @tc.name: NotifyMemoryLevel02
510 * @tc.desc: NotifyMemoryLevel with level
511 * @tc.type: FUNC
512 * @tc.require: issueI5JQ04
513 */
514 HWTEST_F(WindowSceneTest, NotifyMemoryLevel02, Function | SmallTest | Level2)
515 {
516 DisplayId displayId = 0;
517 std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
518 sptr<IWindowLifeCycle> listener = nullptr;
519 sptr<WindowScene> scene = new WindowScene();
520 sptr<WindowOption> option = new WindowOption();
521 EXPECT_CALL(m->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(new WindowImpl(option)));
522 ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext_, listener));
523 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->NotifyMemoryLevel(0)); // ui content is null
524 }
525
526 /**
527 * @tc.name: NotifyMemoryLevel03
528 * @tc.desc: NotifyMemoryLevel with windowsession
529 * @tc.type: FUNC
530 * @tc.require: issueI5JQ04
531 */
532 HWTEST_F(WindowSceneTest, NotifyMemoryLevel03, Function | SmallTest | Level2)
533 {
534 DisplayId displayId = 0;
535 std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
536 sptr<IWindowLifeCycle> listener = nullptr;
537 sptr<WindowScene> scene = new WindowScene();
538 sptr<WindowOption> option = new WindowOption();
539 EXPECT_CALL(m->Mock(), CreateWindow(_, _, _)).Times(1).WillOnce(Return(new WindowSceneSessionImpl(option)));
540 ASSERT_EQ(WMError::WM_OK, scene->Init(displayId, abilityContext_, listener));
541 ASSERT_EQ(WMError::WM_ERROR_NULLPTR, scene->NotifyMemoryLevel(0)); // ui content is null
542 }
543
544 }
545 } // namespace Rosen
546 } // namespace OHOS