/* * Copyright (c) 2023 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 "window_manager_lite.h" #include "mock_window_adapter_lite.h" #include "singleton_mocker.h" using namespace testing; using namespace testing::ext; namespace OHOS::Rosen { using Mocker = SingletonMocker; class WindowManagerLiteTest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); void SetUp() override; void TearDown() override; }; void WindowManagerLiteTest::SetUpTestCase() { } void WindowManagerLiteTest::TearDownTestCase() { } void WindowManagerLiteTest::SetUp() { } void WindowManagerLiteTest::TearDown() { } namespace { /** * @tc.name: GetFocusWindowInfo * @tc.desc: using windowManagerLite to get focus info * @tc.type: FUNC */ HWTEST_F(WindowManagerLiteTest, GetFocusWindowInfo, Function | SmallTest | Level2) { std::unique_ptr m = std::make_unique(); FocusChangeInfo infosInput; FocusChangeInfo infosResult; infosResult.pid_ = 10; infosResult.uid_ = 11; infosResult.displayId_ = 12; infosResult.windowId_ = 13; EXPECT_CALL(m->Mock(), GetFocusWindowInfo(_)).Times(1).WillOnce(DoAll(SetArgReferee<0>(infosResult), Return())); WindowManagerLite::GetInstance().GetFocusWindowInfo(infosInput); ASSERT_EQ(infosInput.windowId_, infosResult.windowId_); ASSERT_EQ(infosInput.uid_, infosResult.uid_); ASSERT_EQ(infosInput.pid_, infosResult.pid_); ASSERT_EQ(infosInput.displayId_, infosResult.displayId_); } } }