• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "window_manager_lite.h"
18 #include "mock_window_adapter_lite.h"
19 #include "singleton_mocker.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 namespace OHOS::Rosen {
24 using Mocker = SingletonMocker<WindowAdapterLite, MockWindowAdapterLite>;
25 class WindowManagerLiteTest : public testing::Test {
26 public:
27     static void SetUpTestCase();
28     static void TearDownTestCase();
29     void SetUp() override;
30     void TearDown() override;
31 };
32 
SetUpTestCase()33 void WindowManagerLiteTest::SetUpTestCase()
34 {
35 }
36 
TearDownTestCase()37 void WindowManagerLiteTest::TearDownTestCase()
38 {
39 }
40 
SetUp()41 void WindowManagerLiteTest::SetUp()
42 {
43 }
44 
TearDown()45 void WindowManagerLiteTest::TearDown()
46 {
47 }
48 
49 namespace {
50 /**
51  * @tc.name: GetFocusWindowInfo
52  * @tc.desc: using windowManagerLite to get focus info
53  * @tc.type: FUNC
54  */
55 HWTEST_F(WindowManagerLiteTest, GetFocusWindowInfo, Function | SmallTest | Level2)
56 {
57     std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
58     FocusChangeInfo infosInput;
59     FocusChangeInfo infosResult;
60     infosResult.pid_ = 10;
61     infosResult.uid_ = 11;
62     infosResult.displayId_ = 12;
63     infosResult.windowId_ = 13;
64     EXPECT_CALL(m->Mock(), GetFocusWindowInfo(_)).Times(1).WillOnce(DoAll(SetArgReferee<0>(infosResult), Return()));
65     WindowManagerLite::GetInstance().GetFocusWindowInfo(infosInput);
66     ASSERT_EQ(infosInput.windowId_, infosResult.windowId_);
67     ASSERT_EQ(infosInput.uid_, infosResult.uid_);
68     ASSERT_EQ(infosInput.pid_, infosResult.pid_);
69     ASSERT_EQ(infosInput.displayId_, infosResult.displayId_);
70 }
71 }
72 }