• 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 #include "cutout_info.h"
18 
19 using namespace testing;
20 using namespace testing::ext;
21 
22 namespace OHOS {
23 namespace Rosen {
24 class CutoutInfoTest : 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 CutoutInfoTest::SetUpTestCase() {}
33 
TearDownTestCase()34 void CutoutInfoTest::TearDownTestCase() {}
35 
SetUp()36 void CutoutInfoTest::SetUp() {}
37 
TearDown()38 void CutoutInfoTest::TearDown() {}
39 
40 namespace {
41 /**
42  * @tc.name: WriteBoundingRectsVector01
43  * @tc.desc: WriteBoundingRectsVector test
44  * @tc.type: FUNC
45  */
46 HWTEST_F(CutoutInfoTest, WriteBoundingRectsVector01, TestSize.Level1)
47 {
48     sptr<CutoutInfo> info = new CutoutInfo();
49     DMRect rect = { 0, 0, 0, 0 };
50     std::vector<DMRect> boundingRects;
51     boundingRects.emplace_back(rect);
52     Parcel parcel;
53     bool ret = info->WriteBoundingRectsVector(boundingRects, parcel);
54     ASSERT_TRUE(ret);
55 }
56 
57 /**
58  * @tc.name: WriteBoundingRectsVector02
59  * @tc.desc: WriteBoundingRectsVector test
60  * @tc.type: FUNC
61  */
62 HWTEST_F(CutoutInfoTest, WriteBoundingRectsVector02, TestSize.Level1)
63 {
64     sptr<CutoutInfo> info = new CutoutInfo();
65     std::vector<DMRect> boundingRects;
66     for (int i = 0; i < 21; i++) { // MAX_CUTOUT_INFO_SIZE + 1
67         DMRect rect = { 0, 0, 0, 0 };
68         boundingRects.emplace_back(rect);
69     }
70     Parcel parcel;
71     bool ret = info->WriteBoundingRectsVector(boundingRects, parcel);
72     ASSERT_FALSE(ret);
73 }
74 
75 /**
76  * @tc.name: ReadBoundingRectsVector01
77  * @tc.desc: ReadBoundingRectsVector test
78  * @tc.type: FUNC
79  */
80 HWTEST_F(CutoutInfoTest, ReadBoundingRectsVector01, TestSize.Level1)
81 {
82     sptr<CutoutInfo> info = new CutoutInfo();
83     DMRect rect = { 0, 0, 0, 0 };
84     std::vector<DMRect> boundingRects;
85     boundingRects.emplace_back(rect);
86     Parcel parcel;
87     bool ret = info->ReadBoundingRectsVector(boundingRects, parcel);
88     ASSERT_FALSE(ret);
89 }
90 
91 /**
92  * @tc.name: ReadBoundingRectsVector02
93  * @tc.desc: ReadBoundingRectsVector test
94  * @tc.type: FUNC
95  */
96 HWTEST_F(CutoutInfoTest, ReadBoundingRectsVector02, TestSize.Level1)
97 {
98     sptr<CutoutInfo> info = new CutoutInfo();
99     std::vector<DMRect> boundingRects;
100     for (int i = 0; i < 21; i++) { // MAX_CUTOUT_INFO_SIZE + 1
101         DMRect rect = { 0, 0, 0, 0 };
102         boundingRects.emplace_back(rect);
103     }
104     Parcel parcel;
105     bool ret = info->ReadBoundingRectsVector(boundingRects, parcel);
106     ASSERT_FALSE(ret);
107 }
108 } // namespace
109 } // namespace Rosen
110 } // namespace OHOS