/* * Copyright (c) 2021 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. */ #include #include "input_manager.h" #include "input_transfer_station.h" #include "window_impl.h" #include "mock_window_adapter.h" #include "singleton_mocker.h" using namespace testing; using namespace testing::ext; namespace OHOS { namespace Rosen { using WindowMocker = SingletonMocker; class InputTransferStationTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); virtual void SetUp() override; virtual void TearDown() override; sptr window_; }; void InputTransferStationTest::SetUpTestCase() { } void InputTransferStationTest::TearDownTestCase() { } void InputTransferStationTest::SetUp() { sptr option = new WindowOption(); option->SetWindowName("inputwindow"); window_ = new WindowImpl(option); window_->Create(INVALID_WINDOW_ID); } void InputTransferStationTest::TearDown() { window_->Destroy(); window_ = nullptr; } namespace { /** * @tc.name: AddInputWindow * @tc.desc: add input window in station. * @tc.type: FUNC * @tc.require: issueI5I5L4 */ HWTEST_F(InputTransferStationTest, AddInputWindow, Function | SmallTest | Level2) { std::shared_ptr listener = std::make_shared(InputEventListener()); MMI::InputManager::GetInstance()->SetWindowInputEventConsumer(listener); InputTransferStation::GetInstance().AddInputWindow(window_); } /** * @tc.name: RemoveInputWindow * @tc.desc: remove input window in station. * @tc.type: FUNC * @tc.require: issueI5I5L4 */ HWTEST_F(InputTransferStationTest, RemoveInputWindow, Function | SmallTest | Level2) { InputTransferStation::GetInstance().RemoveInputWindow(window_->GetWindowId()); } } } // namespace Rosen } // namespace OHOS