1 /*
2 * Copyright (c) 2024 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 #define LOG_TAG "SystemDefinedPixelMapTest"
16
17 #include <unistd.h>
18 #include <gtest/gtest.h>
19 #include <string>
20
21 #include "logger.h"
22 #include "system_defined_pixelmap.h"
23
24 using namespace testing::ext;
25 using namespace OHOS::UDMF;
26 using namespace OHOS;
27 namespace OHOS::Test {
28 using namespace std;
29
30 class SystemDefinedPixelMapTest : public testing::Test {
31 public:
32 static void SetUpTestCase();
33 static void TearDownTestCase();
34 void SetUp() override;
35 void TearDown() override;
36 };
37
SetUpTestCase()38 void SystemDefinedPixelMapTest::SetUpTestCase()
39 {
40 }
41
TearDownTestCase()42 void SystemDefinedPixelMapTest::TearDownTestCase()
43 {
44 }
45
SetUp()46 void SystemDefinedPixelMapTest::SetUp()
47 {
48 }
49
TearDown()50 void SystemDefinedPixelMapTest::TearDown()
51 {
52 }
53
54 /**
55 * @tc.name: SystemDefinedPixelMap001
56 * @tc.desc: Normal testcase of SystemDefinedPixelMap
57 * @tc.type: FUNC
58 */
59 HWTEST_F(SystemDefinedPixelMapTest, SystemDefinedPixelMap001, TestSize.Level1)
60 {
61 LOG_INFO(UDMF_TEST, "SystemDefinedPixelMap001 begin.");
62 std::vector<uint8_t> data = std::vector<uint8_t>();
63 SystemDefinedPixelMap systemDefinedPixelMap(data);
64 EXPECT_EQ(systemDefinedPixelMap.dataType_, SYSTEM_DEFINED_PIXEL_MAP);
65 EXPECT_EQ(systemDefinedPixelMap.rawData_, data);
66 LOG_INFO(UDMF_TEST, "SystemDefinedPixelMap001 end.");
67 }
68
69 /**
70 * @tc.name: SystemDefinedPixelMap002
71 * @tc.desc: Normal testcase of SystemDefinedPixelMap
72 * @tc.type: FUNC
73 */
74 HWTEST_F(SystemDefinedPixelMapTest, SystemDefinedPixelMap002, TestSize.Level1)
75 {
76 LOG_INFO(UDMF_TEST, "SystemDefinedPixelMap002 begin.");
77 UDType type = UDType::ENTITY;
78 ValueType value = std::vector<uint8_t>();
79 SystemDefinedPixelMap systemDefinedPixelMap(type, value);
80 EXPECT_EQ(systemDefinedPixelMap.dataType_, SYSTEM_DEFINED_PIXEL_MAP);
81 EXPECT_EQ(systemDefinedPixelMap.rawData_, std::get<std::vector<uint8_t>>(value));
82 LOG_INFO(UDMF_TEST, "SystemDefinedPixelMap002 end.");
83 }
84
85 /**
86 * @tc.name: SystemDefinedPixelMap003
87 * @tc.desc: Abnormal testcase of SystemDefinedPixelMap, because value is not of type std::vector<uint8_t>
88 * @tc.type: FUNC
89 */
90 HWTEST_F(SystemDefinedPixelMapTest, SystemDefinedPixelMap003, TestSize.Level1)
91 {
92 LOG_INFO(UDMF_TEST, "SystemDefinedPixelMap003 begin.");
93 UDType type = UDType::ENTITY;
94 ValueType value = 0;
95 SystemDefinedPixelMap systemDefinedPixelMap(type, value);
96 EXPECT_EQ(systemDefinedPixelMap.dataType_, SYSTEM_DEFINED_PIXEL_MAP);
97 EXPECT_EQ(systemDefinedPixelMap.rawData_.size(), 0);
98 LOG_INFO(UDMF_TEST, "SystemDefinedPixelMap003 end.");
99 }
100 } // OHOS::Test