• 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, Hardware
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 "utils/vertices.h"
19 
20 using namespace testing;
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace Rosen {
25 namespace Drawing {
26 class VerticesTest : public testing::Test {
27 public:
28     static void SetUpTestCase();
29     static void TearDownTestCase();
30     void SetUp() override;
31     void TearDown() override;
32 };
33 
34 constexpr int VERTICES_COUNT = 3;
35 
SetUpTestCase()36 void VerticesTest::SetUpTestCase() {}
TearDownTestCase()37 void VerticesTest::TearDownTestCase() {}
SetUp()38 void VerticesTest::SetUp() {}
TearDown()39 void VerticesTest::TearDown() {}
40 
41 /**
42  * @tc.name: MakeCopy001
43  * @tc.desc:
44  * @tc.type: FUNC
45  * @tc.require:AR000GGNV3
46  * @tc.author:
47  */
48 HWTEST_F(VerticesTest, MakeCopy001, TestSize.Level1)
49 {
50     std::unique_ptr<Vertices> vertices = std::make_unique<Vertices>();
51     ASSERT_TRUE(vertices != nullptr);
52     Point positions[VERTICES_COUNT] = { {0, 0}, {1, 1}, {2, 2} };
53     Point texs[VERTICES_COUNT] = { {0, 1}, {1, 2}, {2, 3} };
54     ColorQuad colors[VERTICES_COUNT] = { 0xFFFFFFFF, 0xFFFF00FF, 0xFFFF0000 };
55     uint16_t indices[VERTICES_COUNT] = { 0, 1, 2 };
56     bool flag1 = vertices->MakeCopy(VertexMode::LAST_VERTEXMODE,
57         VERTICES_COUNT, positions, texs, colors, VERTICES_COUNT, indices);
58     EXPECT_EQ(flag1, true);
59 
60     std::unique_ptr<Vertices> vertices2 = std::make_unique<Vertices>(nullptr);
61     bool flag2 = vertices2->MakeCopy(VertexMode::LAST_VERTEXMODE,
62         VERTICES_COUNT, positions, texs, colors, VERTICES_COUNT, indices);
63     EXPECT_EQ(flag2, false);
64 }
65 
66 /**
67  * @tc.name: MakeCopy002
68  * @tc.desc:
69  * @tc.type: FUNC
70  * @tc.require:AR000GGNV3
71  * @tc.author:
72  */
73 HWTEST_F(VerticesTest, MakeCopy002, TestSize.Level1)
74 {
75     std::unique_ptr<Vertices> vertices = std::make_unique<Vertices>();
76     ASSERT_TRUE(vertices != nullptr);
77     Point positions[] = { {0, 0}, {1, 1}, {2, 2} };
78     Point texs[] = { {0, 1}, {1, 2}, {2, 3} };
79     ColorQuad colors[] = { 0xFFFFFFFF, 0xFFFF00FF, 0xFFFF0000 };
80     bool flag1 = vertices->MakeCopy(VertexMode::LAST_VERTEXMODE, VERTICES_COUNT, positions, texs, colors);
81     EXPECT_EQ(flag1, true);
82 
83     std::unique_ptr<Vertices> vertices2 = std::make_unique<Vertices>(nullptr);
84     bool flag2 = vertices2->MakeCopy(VertexMode::LAST_VERTEXMODE, VERTICES_COUNT, positions, texs, colors);
85     EXPECT_EQ(flag2, false);
86 }
87 } // namespace Drawing
88 } // namespace Rosen
89 } // namespace OHOS