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 <cstdint>
17 #include <gtest/gtest.h>
18 #include "mock_session_manager_service.h"
19 #include "display_manager.h"
20 #include "window_agent.h"
21 #include "window_impl.h"
22 #include "window_property.h"
23 #include "window_root.h"
24 #include "wm_common.h"
25
26 using namespace testing;
27 using namespace testing::ext;
28
29 namespace OHOS {
30 namespace Rosen {
31 namespace {
32 constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, HILOG_DOMAIN_WINDOW, "MockSessionManagerServiceTest"};
33 }
34
35 class MockSessionManagerServiceTest : public testing::Test {
36 public:
37 static void SetUpTestCase();
38 static void TearDownTestCase();
39 void SetUp() override;
40 void TearDown() override;
41 };
42
SetUpTestCase()43 void MockSessionManagerServiceTest::SetUpTestCase()
44 {
45 }
46
TearDownTestCase()47 void MockSessionManagerServiceTest::TearDownTestCase()
48 {
49 }
50
SetUp()51 void MockSessionManagerServiceTest::SetUp()
52 {
53 }
54
TearDown()55 void MockSessionManagerServiceTest::TearDown()
56 {
57 }
58
59 namespace {
60 /**
61 * @tc.name: OnRemoteDied
62 * @tc.desc: OnRemoteDied
63 * @tc.type: FUNC
64 */
65 HWTEST_F(MockSessionManagerServiceTest, OnRemoteDied, Function | SmallTest | Level2)
66 {
67 WLOGI("OnRemoteDied");
68 MockSessionManagerService::SMSDeathRecipient smsDeathRecipient;
69 auto res = WMError::WM_OK;
70 wptr<IRemoteObject> object = nullptr;
71 smsDeathRecipient.OnRemoteDied(object);
72 ASSERT_EQ(WMError::WM_OK, res);
73 }
74
75 /**
76 * @tc.name: SetSessionManagerService
77 * @tc.desc: set session manager service
78 * @tc.type: FUNC
79 */
80 HWTEST_F(MockSessionManagerServiceTest, SetSessionManagerService, Function | SmallTest | Level2)
81 {
82 WLOGI("SetSessionManagerService");
83 auto res = WMError::WM_OK;
84 sptr<IRemoteObject> sessionManagerService = nullptr;
85 MockSessionManagerService::GetInstance().SetSessionManagerService(sessionManagerService);
86 ASSERT_EQ(WMError::WM_OK, res);
87 }
88
89 /**
90 * @tc.name: GetSessionManagerService
91 * @tc.desc: get session manager service
92 * @tc.type: FUNC
93 */
94 HWTEST_F(MockSessionManagerServiceTest, GetSessionManagerService, Function | SmallTest | Level2)
95 {
96 WLOGI("GetSessionManagerService");
97 sptr<IRemoteObject> sessionManagerService =
98 MockSessionManagerService::GetInstance().GetSessionManagerService();
99 ASSERT_EQ(nullptr, sessionManagerService);
100 }
101
102 /**
103 * @tc.name: onStart
104 * @tc.desc: on start
105 * @tc.type: FUNC
106 */
107 HWTEST_F(MockSessionManagerServiceTest, OnStart, Function | SmallTest | Level2)
108 {
109 WLOGI("onStart");
110 auto ret = WMError::WM_OK;
111 MockSessionManagerService::GetInstance().OnStart();
112 ASSERT_EQ(ret, WMError::WM_OK);
113 }
114 }
115 }
116 }