From b8f451bfc594a6451d808ccd8740cb94bd259fb3 Mon Sep 17 00:00:00 2001 From: wangxinpeng Date: Wed, 19 Jan 2022 19:25:44 +0800 Subject: [PATCH] input method window ST Signed-off-by: wangxinpeng Change-Id: I6c5bc1ffa1fafea084afae5ea13f2a91fae4802b --- wm/test/systemtest/BUILD.gn | 12 ++ .../systemtest/window_input_method_test.cpp | 128 ++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 wm/test/systemtest/window_input_method_test.cpp diff --git a/wm/test/systemtest/BUILD.gn b/wm/test/systemtest/BUILD.gn index e60a6e5c53..9b6a9563e7 100644 --- a/wm/test/systemtest/BUILD.gn +++ b/wm/test/systemtest/BUILD.gn @@ -20,6 +20,7 @@ group("systemtest") { deps = [ ":wm_window_immersive_test", + ":wm_window_input_method_test", ":wm_window_layout_test", ":wm_window_multi_ability_test", ":wm_window_split_test", @@ -82,6 +83,17 @@ ohos_systemtest("wm_window_split_test") { ## SystemTest wm_window_split_test }}} +## SystemTest window_input_method_test {{{ +ohos_systemtest("wm_window_input_method_test") { + module_out_path = module_out_path + + sources = [ "window_input_method_test.cpp" ] + + deps = [ ":wm_systemtest_common" ] +} + +## SystemTest window_input_method_test }}} + ## Build wm_systemtest_common.a {{{ config("wm_systemtest_common_public_config") { include_dirs = [ diff --git a/wm/test/systemtest/window_input_method_test.cpp b/wm/test/systemtest/window_input_method_test.cpp new file mode 100644 index 0000000000..63b164ce28 --- /dev/null +++ b/wm/test/systemtest/window_input_method_test.cpp @@ -0,0 +1,128 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// gtest +#include +#include "window_test_utils.h" +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace Rosen { +using utils = WindowTestUtils; +class WindowInputMethodTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + virtual void SetUp() override; + virtual void TearDown() override; + utils::TestWindowInfo inputMethodWindowInfo_; + utils::TestWindowInfo keyGuardWindowInfo_; +}; + +void WindowInputMethodTest::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()); + } + Rect displayRect = {0, 0, display->GetWidth(), display->GetHeight()}; + utils::InitByDisplayRect(displayRect); +} + +void WindowInputMethodTest::TearDownTestCase() +{ +} + +void WindowInputMethodTest::SetUp() +{ + inputMethodWindowInfo_ = { + .name = "", + .rect = utils::defaultAppRect_, + .type = WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, + .mode = WindowMode::WINDOW_MODE_FLOATING, + .needAvoid = false, + .parentLimit = false, + .parentName = "", + }; + keyGuardWindowInfo_ = { + .name = "", + .rect = utils::defaultAppRect_, + .type = WindowType::WINDOW_TYPE_KEYGUARD, + .mode = WindowMode::WINDOW_MODE_FULLSCREEN, + .needAvoid = false, + .parentLimit = false, + .parentName = "", + }; +} + +void WindowInputMethodTest::TearDown() +{ +} + +namespace { +/** + * @tc.name: InputMethodWindow01 + * @tc.desc: One InputMethod Floating Window + * @tc.type: FUNC + * @tc.require: AR000GGTUT + */ +HWTEST_F(WindowInputMethodTest, InputMethodWindow01, Function | MediumTest | Level3) +{ + inputMethodWindowInfo_.name = "input_method.1"; + const sptr& window = utils::CreateTestWindow(inputMethodWindowInfo_); + ASSERT_EQ(WindowType::WINDOW_TYPE_INPUT_METHOD_FLOAT, window->GetType()); + ASSERT_EQ(WMError::WM_OK, window->Show()); + ASSERT_EQ(WMError::WM_OK, window->Hide()); +} + +/** + * @tc.name: InputMethodWindow02 + * @tc.desc: One KeyGuard Window + * @tc.type: FUNC + * @tc.require: AR000GGTUT + */ +HWTEST_F(WindowInputMethodTest, InputMethodWindow02, Function | MediumTest | Level3) +{ + keyGuardWindowInfo_.name = "keyGuard.1"; + const sptr& window = utils::CreateTestWindow(keyGuardWindowInfo_); + ASSERT_EQ(WindowType::WINDOW_TYPE_KEYGUARD, window->GetType()); + ASSERT_EQ(WMError::WM_OK, window->Show()); + ASSERT_EQ(WMError::WM_OK, window->Hide()); +} + +/** + * @tc.name: InputMethodWindow03 + * @tc.desc: One InputMethod Floating Window & One KeyGuard Window + * @tc.type: FUNC + * @tc.require: AR000GGTUU + */ +HWTEST_F(WindowInputMethodTest, InputMethodWindow03, Function | MediumTest | Level3) +{ + inputMethodWindowInfo_.name = "input_method.2"; + keyGuardWindowInfo_.name = "keyGuard.2"; + const sptr& inputMethodWindow = utils::CreateTestWindow(inputMethodWindowInfo_); + const sptr& keyGuardWindow = utils::CreateTestWindow(keyGuardWindowInfo_); + keyGuardWindow->Show(); + inputMethodWindow->Show(); + ASSERT_TRUE(utils::RectEqualTo(keyGuardWindow, utils::displayRect_)); + ASSERT_TRUE(utils::RectEqualTo(inputMethodWindow, utils::defaultAppRect_)); +} +} // namespace +} // namespace Rosen +} // namespace OHOS -- Gitee