1 /* 2 * Copyright (c) 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 "base/subwindow/subwindow_manager.h" 19 20 using namespace testing; 21 using namespace testing::ext; 22 23 namespace OHOS::Ace { 24 namespace { 25 const int32_t CONATINERID = 100000; 26 } // namespace 27 28 class SubwindowManagerTest : public testing::Test { 29 public: SetUp()30 void SetUp() override {}; TearDown()31 void TearDown() override {}; 32 }; 33 34 /** 35 * @tc.name: SubwindowManagerTest_ShowPreviewNG001 36 * @tc.desc: Test frame node method ShowPreviewNG 37 * @tc.type: FUNC 38 */ 39 HWTEST_F(SubwindowManagerTest, ShowPreviewNG001, TestSize.Level1) 40 { 41 /** 42 * @tc.steps: step1. get subwindowManager. 43 */ 44 auto manager = SubwindowManager::GetInstance(); 45 ASSERT_NE(manager, nullptr); 46 47 /** 48 * @tc.steps: step2. 49 * @tc.expected: expect ShowPreviewNG return nullptr. 50 */ 51 EXPECT_EQ(manager->ShowPreviewNG(false), nullptr); 52 } 53 54 /** 55 * @tc.name: SubwindowManagerTest_HidePreviewNG001 56 * @tc.desc: Test frame node method HidePreviewNG 57 * @tc.type: FUNC 58 */ 59 HWTEST_F(SubwindowManagerTest, HidePreviewNG001, TestSize.Level1) 60 { 61 /** 62 * @tc.steps: step1. get subwindowManager, and initialize parameters. 63 */ 64 auto manager = SubwindowManager::GetInstance(); 65 ASSERT_NE(manager, nullptr); 66 auto subwindow = manager->ShowPreviewNG(false); 67 ASSERT_EQ(subwindow, nullptr); 68 69 /** 70 * @tc.steps: step2. call HidePreviewNG. 71 * @tc.expected: HidePreviewNG return void. 72 */ 73 manager->HidePreviewNG(); 74 } 75 76 /** 77 * @tc.name: SubwindowManagerTest_CloseDialog001 78 * @tc.desc: Test frame node method CloseDialog 79 * @tc.type: FUNC 80 */ 81 HWTEST_F(SubwindowManagerTest, CloseDialog001, TestSize.Level1) 82 { 83 /** 84 * @tc.steps: step1. get subwindowManager, and CloseDialog. 85 */ 86 auto manager = SubwindowManager::GetInstance(); 87 ASSERT_NE(manager, nullptr); 88 manager->CloseDialog(CONATINERID); 89 } 90 91 /** 92 * @tc.name: SubwindowManagerTest_ShowDialogNG001 93 * @tc.desc: Test frame node method ShowDialogNG 94 * @tc.type: FUNC 95 */ 96 HWTEST_F(SubwindowManagerTest, ShowDialogNG001, TestSize.Level1) 97 { 98 /** 99 * @tc.steps: step1. get subwindowManager, and ShowDialogNG. 100 */ 101 auto manager = SubwindowManager::GetInstance(); 102 ASSERT_NE(manager, nullptr); 103 DialogProperties dialogProps; 104 std::function<void()> buildFunc = nullptr; 105 auto dialogNode = manager->ShowDialogNG(dialogProps, std::move(buildFunc)); 106 ASSERT_EQ(dialogNode, nullptr); 107 } 108 }