• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 
18 #include "abstract_display.h"
19 #include "abstract_screen_controller.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 
24 namespace OHOS {
25 namespace Rosen {
26 class AbstractDisplayTest : public testing::Test {
27 public:
28     static void SetUpTestCase();
29     static void TearDownTestCase();
30     void SetUp() override;
31     void TearDown() override;
32 
33     DisplayId id = 1;
34     std::string name = "abstract_display_test";
35     SupportedScreenModes modesInfo;
36     std::recursive_mutex mutex;
37     sptr<AbstractScreenController> absController;
38     sptr<AbstractScreen> absScreen;
39     sptr<AbstractDisplay> absDisplay;
40     sptr<AbstractDisplay> absDisplay2;
41     sptr<AbstractDisplay> absDisplay3;
42 };
43 
SetUpTestCase()44 void AbstractDisplayTest::SetUpTestCase()
45 {
46 }
47 
TearDownTestCase()48 void AbstractDisplayTest::TearDownTestCase()
49 {
50 }
51 
SetUp()52 void AbstractDisplayTest::SetUp()
53 {
54     modesInfo.width_ = 2160;
55     modesInfo.height_ = 1600;
56     modesInfo.refreshRate_ = 60;
57     sptr<SupportedScreenModes> info = new SupportedScreenModes(modesInfo);
58     absController = nullptr;
59     absScreen = new AbstractScreen(absController, name, 1, 1);
60     absDisplay = new AbstractDisplay(id, name, info, absScreen);
61     modesInfo.width_ = 800;
62     modesInfo.height_ = 2560;
63     absDisplay2 = new AbstractDisplay(id, name, info, absScreen);
64     modesInfo.width_ = 2560;
65     modesInfo.height_ = 2560;
66     absDisplay3 = new AbstractDisplay(id, name, info, absScreen);
67 }
68 
TearDown()69 void AbstractDisplayTest::TearDown()
70 {
71 }
72 
73 namespace {
74 /**
75  * @tc.name: BindAbstractScreen
76  * @tc.desc: BindAbstractScreen test
77  * @tc.type: FUNC
78  */
79 HWTEST_F(AbstractDisplayTest, BindAbstractScreen01, Function | SmallTest | Level3)
80 {
81     sptr<AbstractScreen> abstractScreen = nullptr;
82     ASSERT_EQ(false, absDisplay->BindAbstractScreen(abstractScreen));
83 }
84 /**
85  * @tc.name: BindAbstractScreen
86  * @tc.desc: BindAbstractScreen test
87  * @tc.type: FUNC
88  */
89 HWTEST_F(AbstractDisplayTest, BindAbstractScreen02, Function | SmallTest | Level3)
90 {
91     sptr<AbstractScreen> abstractScreen = absScreen;
92     abstractScreen->activeIdx_ = -1;
93     ASSERT_EQ(false, absDisplay->BindAbstractScreen(abstractScreen));
94 }
95 }
96 } // namespace Rosen
97 } // namespace OHOS
98