• 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 "iremote_object_mocker.h"
18 #include "mock/mock_session.h"
19 #include "mock/mock_session_stage.h"
20 #include "mock/mock_window_event_channel.h"
21 #include "session_manager/include/scene_session_manager.h"
22 #include "session_manager/include/zidl/scene_session_manager_interface.h"
23 #include "session_manager/include/zidl/scene_session_manager_proxy.h"
24 #include "window_manager_agent.h"
25 #include "zidl/window_manager_agent_interface.h"
26 
27 using namespace testing;
28 using namespace testing::ext;
29 namespace OHOS {
30 namespace Rosen {
31 class sceneSessionManagerProxyLifecycleTest : public testing::Test {
32 public:
33     static void SetUpTestCase();
34     static void TearDownTestCase();
35     void SetUp() override;
36     void TearDown() override;
37     sptr<IRemoteObject> iRemoteObjectMocker;
38 };
39 
SetUpTestCase()40 void sceneSessionManagerProxyLifecycleTest::SetUpTestCase()
41 {
42 }
43 
TearDownTestCase()44 void sceneSessionManagerProxyLifecycleTest::TearDownTestCase()
45 {
46 }
47 
SetUp()48 void sceneSessionManagerProxyLifecycleTest::SetUp()
49 {
50 }
51 
TearDown()52 void sceneSessionManagerProxyLifecycleTest::TearDown()
53 {
54 }
55 
56 namespace {
57 /**
58  * @tc.name: UpdateSessionWindowVisibilityListener001
59  * @tc.desc: normal function
60  * @tc.type: FUNC
61  */
62 HWTEST_F(sceneSessionManagerProxyLifecycleTest, UpdateSessionWindowVisibilityListener001, Function | SmallTest | Level2)
63 {
64     int32_t persistentId = 0;
65     bool haveListener = true;
66     sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr();
67     sptr<SceneSessionManagerProxy> sceneSessionManagerProxy =
68         sptr<SceneSessionManagerProxy>::MakeSptr(iRemoteObjectMocker);
69     EXPECT_NE(sceneSessionManagerProxy, nullptr);
70 
71     ASSERT_EQ(WSError::WS_OK, sceneSessionManagerProxy->UpdateSessionWindowVisibilityListener(persistentId,
72         haveListener));
73 }
74 
75 /**
76  * @tc.name: PendingSessionToForeground
77  * @tc.desc: normal function
78  * @tc.type: FUNC
79  */
80 HWTEST_F(sceneSessionManagerProxyLifecycleTest, PendingSessionToForeground, Function | SmallTest | Level2)
81 {
82     sptr<IRemoteObject> token = nullptr;
83     sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr();
84     sptr<SceneSessionManagerProxy> sceneSessionManagerProxy =
85         sptr<SceneSessionManagerProxy>::MakeSptr(iRemoteObjectMocker);
86     EXPECT_NE(sceneSessionManagerProxy, nullptr);
87 
88     ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, sceneSessionManagerProxy->PendingSessionToForeground(token));
89 }
90 
91 /**
92  * @tc.name: PendingSessionToBackgroundForDelegator
93  * @tc.desc: normal function
94  * @tc.type: FUNC
95  */
96 HWTEST_F(sceneSessionManagerProxyLifecycleTest, PendingSessionToBackgroundForDelegator, Function | SmallTest | Level2)
97 {
98     sptr<IRemoteObject> token = nullptr;
99     sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr();
100     sptr<SceneSessionManagerProxy> sceneSessionManagerProxy =
101         sptr<SceneSessionManagerProxy>::MakeSptr(iRemoteObjectMocker);
102     EXPECT_NE(sceneSessionManagerProxy, nullptr);
103 
104     ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED,
105         sceneSessionManagerProxy->PendingSessionToBackgroundForDelegator(token, true));
106 }
107 
108 /**
109  * @tc.name: GetVisibilityWindowInfo
110  * @tc.desc: normal function
111  * @tc.type: FUNC
112  */
113 HWTEST_F(sceneSessionManagerProxyLifecycleTest, GetVisibilityWindowInfo, Function | SmallTest | Level2)
114 {
115     sptr<IRemoteObject> iRemoteObjectMocker = sptr<IRemoteObjectMocker>::MakeSptr();
116     sptr<SceneSessionManagerProxy> sceneSessionManagerProxy =
117         sptr<SceneSessionManagerProxy>::MakeSptr(iRemoteObjectMocker);
118     EXPECT_NE(sceneSessionManagerProxy, nullptr);
119 
120     std::vector<sptr<WindowVisibilityInfo>> infos;
121     ASSERT_EQ(WMError::WM_OK, sceneSessionManagerProxy->GetVisibilityWindowInfo(infos));
122 }
123 }  // namespace
124 }
125 }
126