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 "draw/brush.h"
19 #include "effect/color_space.h"
20 #include "drawing/engine_adapter/impl_factory.h"
21 #include "image/bitmap.h"
22 #include "image/image.h"
23 #include "image/picture.h"
24 #include "utils/matrix.h"
25 #include "utils/size.h"
26
27 using namespace testing;
28 using namespace testing::ext;
29
30 namespace OHOS {
31 namespace Rosen {
32 namespace Drawing {
33 class ImageTest : public testing::Test {
34 public:
35 static void SetUpTestCase();
36 static void TearDownTestCase();
37 void SetUp() override;
38 void TearDown() override;
39 };
40
SetUpTestCase()41 void ImageTest::SetUpTestCase() {}
TearDownTestCase()42 void ImageTest::TearDownTestCase() {}
SetUp()43 void ImageTest::SetUp() {}
TearDown()44 void ImageTest::TearDown() {}
45
46 /**
47 * @tc.name: CreateAndDestroy001
48 * @tc.desc:
49 * @tc.type: FUNC
50 * @tc.require:AR000GGNV3
51 * @tc.author:
52 */
53 HWTEST_F(ImageTest, CreateAndDestroy001, TestSize.Level1)
54 {
55 // The best way to create Image.
56 std::unique_ptr<Image> image = std::make_unique<Image>();
57 ASSERT_TRUE(image != nullptr);
58 }
59
60 /**
61 * @tc.name: BuildFromBitmap001
62 * @tc.desc:
63 * @tc.type: FUNC
64 * @tc.require:AR000GGNV3
65 * @tc.author:
66 */
67 HWTEST_F(ImageTest, BuildFromBitmap001, TestSize.Level1)
68 {
69 std::unique_ptr<Image> image = std::make_unique<Image>();
70 ASSERT_TRUE(image != nullptr);
71 Bitmap bitmap;
72 image->BuildFromBitmap(bitmap);
73 }
74
75 /**
76 * @tc.name: ImageGetWidthTest001
77 * @tc.desc:
78 * @tc.type: FUNC
79 * @tc.require:AR000GGNV3
80 * @tc.author:
81 */
82 HWTEST_F(ImageTest, ImageGetWidthTest001, TestSize.Level1)
83 {
84 Bitmap bitmap;
85 BitmapFormat bitmapFormat { COLORTYPE_RGBA_8888, ALPHATYPE_OPAQUE };
86 bitmap.Build(10, 10, bitmapFormat);
87 Image image;
88 image.BuildFromBitmap(bitmap);
89 ASSERT_EQ(10, image.GetWidth());
90 }
91
92 /**
93 * @tc.name: ImageGetWidthTest002
94 * @tc.desc:
95 * @tc.type: FUNC
96 * @tc.require:AR000GGNV3
97 * @tc.author:
98 */
99 HWTEST_F(ImageTest, ImageGetWidthTest002, TestSize.Level1)
100 {
101 Bitmap bitmap;
102 BitmapFormat bitmapFormat { COLORTYPE_RGBA_8888, ALPHATYPE_OPAQUE };
103 bitmap.Build(15, 15, bitmapFormat);
104 Image image;
105 image.BuildFromBitmap(bitmap);
106 ASSERT_EQ(15, image.GetWidth());
107 }
108
109 /**
110 * @tc.name: ImageGetHeightTest001
111 * @tc.desc:
112 * @tc.type: FUNC
113 * @tc.require:AR000GGNV3
114 * @tc.author:
115 */
116 HWTEST_F(ImageTest, ImageGetHeightTest001, TestSize.Level1)
117 {
118 Bitmap bitmap;
119 BitmapFormat bitmapFormat { COLORTYPE_RGBA_8888, ALPHATYPE_OPAQUE };
120 bitmap.Build(10, 10, bitmapFormat);
121 Image image;
122 image.BuildFromBitmap(bitmap);
123 ASSERT_EQ(10, image.GetHeight());
124 }
125
126 /**
127 * @tc.name: ImageGetHeightTest002
128 * @tc.desc:
129 * @tc.type: FUNC
130 * @tc.require:AR000GGNV3
131 * @tc.author:
132 */
133 HWTEST_F(ImageTest, ImageGetHeightTest002, TestSize.Level1)
134 {
135 Bitmap bitmap;
136 BitmapFormat bitmapFormat { COLORTYPE_RGBA_8888, ALPHATYPE_OPAQUE };
137 bitmap.Build(15, 15, bitmapFormat);
138 Image image;
139 image.BuildFromBitmap(bitmap);
140 ASSERT_EQ(15, image.GetHeight());
141 }
142 } // namespace Drawing
143 } // namespace Rosen
144 } // namespace OHOS