diff --git a/dm/test/systemtest/display_change_test.cpp b/dm/test/systemtest/display_change_test.cpp index 857cb4a0..f6396268 100644 --- a/dm/test/systemtest/display_change_test.cpp +++ b/dm/test/systemtest/display_change_test.cpp @@ -220,6 +220,7 @@ HWTEST_F(DisplayChangeTest, CheckDisplayStateChange01, Function | SmallTest | Le { WLOGFI("CheckDisplayStateChange01"); sptr defaultDisplay = DisplayManager::GetInstance().GetDisplayById(defaultDisplayId_); + ASSERT_NE(nullptr, defaultDisplay); ScreenId screenId = defaultDisplay->GetScreenId(); sptr screen = ScreenManager::GetInstance().GetScreenById(screenId); ASSERT_NE(nullptr, screen); @@ -238,6 +239,7 @@ HWTEST_F(DisplayChangeTest, CheckDisplayStateChange02, Function | SmallTest | Le { WLOGFI("CheckDisplayStateChange02"); sptr defaultDisplay = DisplayManager::GetInstance().GetDisplayById(defaultDisplayId_); + ASSERT_NE(nullptr, defaultDisplay); ScreenId screenId = defaultDisplay->GetScreenId(); sptr screen = ScreenManager::GetInstance().GetScreenById(screenId); ASSERT_NE(nullptr, screen); @@ -270,6 +272,7 @@ HWTEST_F(DisplayChangeTest, CheckDisplaySizeChange01, Function | MediumTest | Le { WLOGFI("CheckDisplaySizeChange01"); sptr defaultDisplay = DisplayManager::GetInstance().GetDisplayById(defaultDisplayId_); + ASSERT_NE(nullptr, defaultDisplay); ScreenId screenId = defaultDisplay->GetScreenId(); sptr screen = ScreenManager::GetInstance().GetScreenById(screenId); ASSERT_NE(nullptr, screen); @@ -302,6 +305,7 @@ HWTEST_F(DisplayChangeTest, CheckDisplaySizeChange02, Function | MediumTest | Le { WLOGFI("CheckDisplaySizeChange02"); sptr defaultDisplay = DisplayManager::GetInstance().GetDisplayById(defaultDisplayId_); + ASSERT_NE(nullptr, defaultDisplay); ScreenId screenId = defaultDisplay->GetScreenId(); sptr screen = ScreenManager::GetInstance().GetScreenById(screenId); ASSERT_NE(nullptr, screen); @@ -315,6 +319,7 @@ HWTEST_F(DisplayChangeTest, CheckDisplaySizeChange02, Function | MediumTest | Le WLOGFI("SetScreenActiveMode: %{public}u -> %{public}u", usedModeIdx, modeIdx); ASSERT_EQ(true, CheckDisplayChangeEventCallback(true)); defaultDisplay = DisplayManager::GetInstance().GetDisplayById(defaultDisplayId_); + ASSERT_NE(nullptr, defaultDisplay); ASSERT_EQ(true, DisplaySizeEqual(defaultDisplay, modes[modeIdx])); break; } diff --git a/dm/test/unittest/display_change_unit_test.cpp b/dm/test/unittest/display_change_unit_test.cpp index e4a21e0b..ccc7bbec 100644 --- a/dm/test/unittest/display_change_unit_test.cpp +++ b/dm/test/unittest/display_change_unit_test.cpp @@ -59,7 +59,9 @@ void DisplayChangeUnitTest::SetUpTestCase() { defaultDisplayId_ = DisplayManager::GetInstance().GetDefaultDisplayId(); sptr defaultDisplay = DisplayManager::GetInstance().GetDisplayById(defaultDisplayId_); - defaultScreenId_ = defaultDisplay->GetScreenId(); + if (defaultDisplay != nullptr) { + defaultScreenId_ = defaultDisplay->GetScreenId(); + } } void DisplayChangeUnitTest::TearDownTestCase() diff --git a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp index 218b6b2b..2233b260 100644 --- a/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp +++ b/interfaces/kits/napi/window_runtime/window_manager_napi/js_window_manager.cpp @@ -330,7 +330,6 @@ NativeValue* JsWindowManager::OnMinimizeAll(NativeEngine& engine, NativeCallback WLOGFE("param is too small!"); errCode = WMError::WM_ERROR_INVALID_PARAM; } - // TODO: use DisplayId instead of int64_t when engine supported int64_t displayId = static_cast(DISPLAY_ID_INVALD); if (errCode == WMError::WM_OK && !ConvertFromJsValue(engine, info.argv[0], displayId)) { WLOGFE("Failed to convert parameter to displayId"); diff --git a/wm/test/systemtest/BUILD.gn b/wm/test/systemtest/BUILD.gn index 4aa3d3a2..60863b09 100644 --- a/wm/test/systemtest/BUILD.gn +++ b/wm/test/systemtest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -214,7 +214,7 @@ ohos_static_library("wm_systemtest_common") { public_deps = [ "//foundation/ace/ace_engine/interfaces/innerkits/ace:ace_uicontent", - # todo need delete it for abilitycontext + # need delete it for abilitycontext "//foundation/ace/napi:ace_napi", "//foundation/graphic/standard/rosen/modules/render_service_client:librender_service_client", "//foundation/multimodalinput/input/frameworks/proxy:libmmi-client", diff --git a/wm/test/systemtest/window_focus_test.cpp b/wm/test/systemtest/window_focus_test.cpp index e96f3c40..ed45139a 100644 --- a/wm/test/systemtest/window_focus_test.cpp +++ b/wm/test/systemtest/window_focus_test.cpp @@ -76,10 +76,9 @@ void WindowFocusTest::SetUpTestCase() if (display == nullptr) { WLOGFE("GetDefaultDisplay: failed!"); return; - } else { - WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u", - display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate()); } + WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u", + display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate()); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; utils::InitByDisplayRect(displayRect); } diff --git a/wm/test/systemtest/window_immersive_test.cpp b/wm/test/systemtest/window_immersive_test.cpp index 8ae3a159..aface79c 100644 --- a/wm/test/systemtest/window_immersive_test.cpp +++ b/wm/test/systemtest/window_immersive_test.cpp @@ -163,10 +163,10 @@ void WindowImmersiveTest::SetUpTestCase() auto display = DisplayManager::GetInstance().GetDisplayById(0); if (display == nullptr) { WLOGFE("GetDefaultDisplay: failed!"); - } else { - WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u", - display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate()); + return; } + WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u", + display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate()); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; utils::InitByDisplayRect(displayRect); } diff --git a/wm/test/systemtest/window_input_method_test.cpp b/wm/test/systemtest/window_input_method_test.cpp index a445d05c..c0405c37 100644 --- a/wm/test/systemtest/window_input_method_test.cpp +++ b/wm/test/systemtest/window_input_method_test.cpp @@ -38,10 +38,9 @@ void WindowInputMethodTest::SetUpTestCase() if (display == nullptr) { printf("GetDefaultDisplay: failed!\n"); return; - } else { - printf("GetDefaultDisplay: id %llu, w %d, h %d, fps %u\n", display->GetId(), display->GetWidth(), - display->GetHeight(), display->GetFreshRate()); } + printf("GetDefaultDisplay: id %llu, w %d, h %d, fps %u\n", display->GetId(), display->GetWidth(), + display->GetHeight(), display->GetFreshRate()); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; utils::InitByDisplayRect(displayRect); } diff --git a/wm/test/systemtest/window_layout_test.cpp b/wm/test/systemtest/window_layout_test.cpp index 136425cf..9412d440 100644 --- a/wm/test/systemtest/window_layout_test.cpp +++ b/wm/test/systemtest/window_layout_test.cpp @@ -42,10 +42,10 @@ void WindowLayoutTest::SetUpTestCase() auto display = DisplayManager::GetInstance().GetDisplayById(0); if (display == nullptr) { printf("GetDefaultDisplay: failed!\n"); - } else { - printf("GetDefaultDisplay: id %llu, w %d, h %d, fps %u\n", display->GetId(), display->GetWidth(), - display->GetHeight(), display->GetFreshRate()); + return; } + printf("GetDefaultDisplay: id %llu, w %d, h %d, fps %u\n", display->GetId(), display->GetWidth(), + display->GetHeight(), display->GetFreshRate()); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; utils::InitByDisplayRect(displayRect); diff --git a/wm/test/systemtest/window_move_drag_test.cpp b/wm/test/systemtest/window_move_drag_test.cpp index fabc81c5..43d7e2d7 100644 --- a/wm/test/systemtest/window_move_drag_test.cpp +++ b/wm/test/systemtest/window_move_drag_test.cpp @@ -78,10 +78,10 @@ void WindowMoveDragTest::SetUp() auto display = DisplayManager::GetInstance().GetDisplayById(0); if (display == nullptr) { WLOGFE("GetDefaultDisplay: failed!\n"); - } else { - WLOGFI("GetDefaultDisplay: id %{public}llu, w %{public}d, h %{public}d, fps %{public}u\n", - display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate()); + return; } + WLOGFI("GetDefaultDisplay: id %{public}llu, w %{public}d, h %{public}d, fps %{public}u\n", + display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate()); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; utils::InitByDisplayRect(displayRect); diff --git a/wm/test/systemtest/window_test_utils.cpp b/wm/test/systemtest/window_test_utils.cpp index a2c75e80..e096ca81 100644 --- a/wm/test/systemtest/window_test_utils.cpp +++ b/wm/test/systemtest/window_test_utils.cpp @@ -275,10 +275,10 @@ void WindowTestUtils::InitSplitRects() auto display = DisplayManager::GetInstance().GetDisplayById(0); if (display == nullptr) { WLOGFE("GetDefaultDisplay: failed!"); - } else { - WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u", - display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate()); + return; } + WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u", + display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate()); Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; displayRect_ = displayRect; diff --git a/wm/test/systemtest/window_visibility_info_test.cpp b/wm/test/systemtest/window_visibility_info_test.cpp index 360cc587..ec98a552 100644 --- a/wm/test/systemtest/window_visibility_info_test.cpp +++ b/wm/test/systemtest/window_visibility_info_test.cpp @@ -69,10 +69,10 @@ void WindowVisibilityInfoTest::SetUpTestCase() auto display = DisplayManager::GetInstance().GetDisplayById(0); if (display == nullptr) { WLOGFE("GetDefaultDisplay: failed!"); - } else { - WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u", - display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate()); + return; } + WLOGFI("GetDefaultDisplay: id %{public}" PRIu64", w %{public}d, h %{public}d, fps %{public}u", + display->GetId(), display->GetWidth(), display->GetHeight(), display->GetFreshRate()); Rect displayRect = {0, 0, static_cast(display->GetWidth()), static_cast(display->GetHeight())}; utils::InitByDisplayRect(displayRect); diff --git a/wm/test/unittest/BUILD.gn b/wm/test/unittest/BUILD.gn index 8223f95a..f7cd3817 100644 --- a/wm/test/unittest/BUILD.gn +++ b/wm/test/unittest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/wm/test/unittest/window_impl_test.cpp b/wm/test/unittest/window_impl_test.cpp index badd6769..9db53054 100644 --- a/wm/test/unittest/window_impl_test.cpp +++ b/wm/test/unittest/window_impl_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/wmserver/src/drag_controller.cpp b/wmserver/src/drag_controller.cpp index 481f91ca..dd5a0390 100644 --- a/wmserver/src/drag_controller.cpp +++ b/wmserver/src/drag_controller.cpp @@ -138,4 +138,4 @@ bool DragController::GetHitPoint(uint32_t windowId, PointInfo& point) return true; } } -} \ No newline at end of file +} diff --git a/wmserver/src/window_node_container.cpp b/wmserver/src/window_node_container.cpp index 6be9ea74..95862bdb 100644 --- a/wmserver/src/window_node_container.cpp +++ b/wmserver/src/window_node_container.cpp @@ -242,7 +242,7 @@ WMError WindowNodeContainer::DestroyWindowNode(sptr& node, std::vect WMError WindowNodeContainer::RemoveWindowNode(sptr& node) { - if (node == nullptr || !node->surfaceNode_) { + if (node == nullptr) { WLOGFE("window node or surface node is nullptr, invalid"); return WMError::WM_ERROR_DESTROYED_OBJECT; }