• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2022 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 "display_manager_adapter.h"
18 
19 using namespace testing;
20 using namespace testing::ext;
21 
22 namespace OHOS {
23 namespace Rosen {
24 class DisplayManagerAdapterTest : public testing::Test {
25 public:
26     static void SetUpTestCase();
27     static void TearDownTestCase();
28     void SetUp() override;
29     void TearDown() override;
30 };
31 
SetUpTestCase()32 void DisplayManagerAdapterTest::SetUpTestCase()
33 {
34 }
35 
TearDownTestCase()36 void DisplayManagerAdapterTest::TearDownTestCase()
37 {
38 }
39 
SetUp()40 void DisplayManagerAdapterTest::SetUp()
41 {
42 }
43 
TearDown()44 void DisplayManagerAdapterTest::TearDown()
45 {
46 }
47 
48 namespace {
49 /**
50  * @tc.name: GetDisplayInfo
51  * @tc.desc: test nullptr
52  * @tc.type: FUNC
53  */
54 HWTEST_F(DisplayManagerAdapterTest, GetDisplayInfo, Function | SmallTest | Level2)
55 {
56     sptr<DisplayInfo> info = SingletonContainer::Get<DisplayManagerAdapter>().GetDisplayInfo(DISPLAY_ID_INVALID);
57     ASSERT_EQ(info, nullptr);
58 }
59 
60 /**
61  * @tc.name: GetCutoutInfo
62  * @tc.desc: test nullptr
63  * @tc.type: FUNC
64  */
65 HWTEST_F(DisplayManagerAdapterTest, GetCutoutInfo, Function | SmallTest | Level2)
66 {
67     sptr<CutoutInfo> info = SingletonContainer::Get<DisplayManagerAdapter>().GetCutoutInfo(DISPLAY_ID_INVALID);
68     ASSERT_EQ(info, nullptr);
69 }
70 
71 /**
72  * @tc.name: GetScreenSupportedColorGamuts
73  * @tc.desc: test success
74  * @tc.type: FUNC
75  */
76 HWTEST_F(DisplayManagerAdapterTest, GetScreenSupportedColorGamuts, Function | SmallTest | Level2)
77 {
78     std::vector<ScreenColorGamut> colorGamuts;
79     SingletonContainer::Get<ScreenManagerAdapter>().GetScreenSupportedColorGamuts(0, colorGamuts);
80 }
81 
82 /**
83  * @tc.name: SetScreenColorGamut
84  * @tc.desc: test success
85  * @tc.type: FUNC
86  */
87 HWTEST_F(DisplayManagerAdapterTest, SetScreenColorGamut, Function | SmallTest | Level2)
88 {
89     std::vector<ScreenColorGamut> colorGamuts;
90     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetScreenColorGamut(0, -1);
91     ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
92 }
93 
94 /**
95  * @tc.name: GetScreenColorGamut
96  * @tc.desc: test success
97  * @tc.type: FUNC
98  */
99 HWTEST_F(DisplayManagerAdapterTest, GetScreenColorGamut, Function | SmallTest | Level2)
100 {
101     ScreenColorGamut colorGamut;
102     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().GetScreenColorGamut(0, colorGamut);
103     ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
104 }
105 
106 /**
107  * @tc.name: GetScreenGamutMap
108  * @tc.desc: test success
109  * @tc.type: FUNC
110  */
111 HWTEST_F(DisplayManagerAdapterTest, GetScreenGamutMap, Function | SmallTest | Level2)
112 {
113     ScreenGamutMap gamutMap;
114     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().GetScreenGamutMap(0, gamutMap);
115     ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
116 }
117 
118 /**
119  * @tc.name: SetScreenGamutMap
120  * @tc.desc: test success
121  * @tc.type: FUNC
122  */
123 HWTEST_F(DisplayManagerAdapterTest, SetScreenGamutMap, Function | SmallTest | Level2)
124 {
125     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetScreenGamutMap(0, GAMUT_MAP_CONSTANT);
126     ASSERT_EQ(err, DMError::DM_ERROR_RENDER_SERVICE_FAILED);
127 }
128 
129 /**
130  * @tc.name: SetScreenColorTransform
131  * @tc.desc: test success
132  * @tc.type: FUNC
133  */
134 HWTEST_F(DisplayManagerAdapterTest, SetScreenColorTransform, Function | SmallTest | Level2)
135 {
136     DMError err = SingletonContainer::Get<ScreenManagerAdapter>().SetScreenColorTransform(0);
137     ASSERT_EQ(err, DMError::DM_OK);
138 }
139 
140 /**
141  * @tc.name: SetFreeze
142  * @tc.desc: test success
143  * @tc.type: FUNC
144  */
145 HWTEST_F(DisplayManagerAdapterTest, SetFreeze, Function | SmallTest | Level2)
146 {
147     std::vector<DisplayId> displayIds;
148     bool ret = SingletonContainer::Get<DisplayManagerAdapter>().SetFreeze(displayIds, false);
149     ASSERT_TRUE(ret);
150 }
151 
152 /**
153  * @tc.name: GetScreenGroupInfoById
154  * @tc.desc: test nullptr
155  * @tc.type: FUNC
156  */
157 HWTEST_F(DisplayManagerAdapterTest, GetScreenGroupInfoById, Function | SmallTest | Level2)
158 {
159     auto info = SingletonContainer::Get<ScreenManagerAdapter>().GetScreenGroupInfoById(SCREEN_ID_INVALID);
160     ASSERT_EQ(info, nullptr);
161 }
162 
163 /**
164  * @tc.name: GetScreenInfo
165  * @tc.desc: test nullptr
166  * @tc.type: FUNC
167  */
168 HWTEST_F(DisplayManagerAdapterTest, GetScreenInfo, Function | SmallTest | Level2)
169 {
170     sptr<ScreenInfo> info = SingletonContainer::Get<ScreenManagerAdapter>().GetScreenInfo(SCREEN_ID_INVALID);
171     ASSERT_EQ(info, nullptr);
172 }
173 
174 /**
175  * @tc.name: OnRemoteDied
176  * @tc.desc: test nullptr
177  * @tc.type: FUNC
178  */
179 HWTEST_F(DisplayManagerAdapterTest, OnRemoteDied, Function | SmallTest | Level2)
180 {
181     sptr<IRemoteObject::DeathRecipient> dmsDeath_ = nullptr;
182     dmsDeath_ = new(std::nothrow) DMSDeathRecipient(SingletonContainer::Get<ScreenManagerAdapter>());
183     dmsDeath_->OnRemoteDied(nullptr);
184 }
185 
186 /**
187  * @tc.name: OnRemoteDied01
188  * @tc.desc: test nullptr
189  * @tc.type: FUNC
190  */
191 HWTEST_F(DisplayManagerAdapterTest, OnRemoteDied01, Function | SmallTest | Level2)
192 {
193     sptr<IRemoteObject::DeathRecipient> dmsDeath_ = nullptr;
194     dmsDeath_ = new(std::nothrow) DMSDeathRecipient(SingletonContainer::Get<ScreenManagerAdapter>());
195     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
196     sptr<IRemoteObject> obj = SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_->AsObject();
197     wptr<IRemoteObject> wptrDeath = obj;
198     dmsDeath_->OnRemoteDied(wptrDeath);
199 }
200 
201 /**
202  * @tc.name: Clear
203  * @tc.desc: test success
204  * @tc.type: FUNC
205  */
206 HWTEST_F(DisplayManagerAdapterTest, Clear, Function | SmallTest | Level2)
207 {
208     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
209     SingletonContainer::Get<ScreenManagerAdapter>().Clear();
210     ASSERT_FALSE(SingletonContainer::Get<ScreenManagerAdapter>().isProxyValid_);
211 }
212 
213 /**
214  * @tc.name: Clear01
215  * @tc.desc: test success
216  * @tc.type: FUNC
217  */
218 HWTEST_F(DisplayManagerAdapterTest, Clear01, Function | SmallTest | Level2)
219 {
220     SingletonContainer::Get<ScreenManagerAdapter>().InitDMSProxy();
221     SingletonContainer::Get<ScreenManagerAdapter>().displayManagerServiceProxy_ = nullptr;
222     SingletonContainer::Get<ScreenManagerAdapter>().Clear();
223     ASSERT_FALSE(SingletonContainer::Get<ScreenManagerAdapter>().isProxyValid_);
224 }
225 }
226 }
227 }