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 "c/drawing_brush.h"
19 #include "c/drawing_color.h"
20 #include "c/drawing_filter.h"
21 #include "c/drawing_mask_filter.h"
22 #include "c/drawing_rect.h"
23
24 using namespace testing;
25 using namespace testing::ext;
26
27 namespace OHOS {
28 namespace Rosen {
29 namespace Drawing {
30 class NativeDrawingBrushTest : 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 NativeDrawingBrushTest::SetUpTestCase() {}
TearDownTestCase()39 void NativeDrawingBrushTest::TearDownTestCase() {}
SetUp()40 void NativeDrawingBrushTest::SetUp() {}
TearDown()41 void NativeDrawingBrushTest::TearDown() {}
42
43 /*
44 * @tc.name: NativeDrawingBrushTest_brush001
45 * @tc.desc: test for create brush and destroy brush.
46 * @tc.type: FUNC
47 * @tc.require: AR000GTO5R
48 */
49 HWTEST_F(NativeDrawingBrushTest, NativeDrawingBrushTest_brush001, TestSize.Level1)
50 {
51 OH_Drawing_Brush* brush = OH_Drawing_BrushCreate();
52 EXPECT_EQ(brush == nullptr, false);
53 OH_Drawing_BrushDestroy(brush);
54 }
55
56 /*
57 * @tc.name: NativeDrawingBrushTest_brush002
58 * @tc.desc: test for the set methods of brush.
59 * @tc.type: FUNC
60 * @tc.require: AR000GTO5R
61 */
62 HWTEST_F(NativeDrawingBrushTest, NativeDrawingBrushTest_brush002, TestSize.Level1)
63 {
64 OH_Drawing_Brush* brush1 = OH_Drawing_BrushCreate();
65 OH_Drawing_BrushSetAntiAlias(brush1, false);
66 EXPECT_EQ(OH_Drawing_BrushIsAntiAlias(brush1), false);
67 OH_Drawing_BrushSetColor(brush1, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0x00, 0x00));
68 EXPECT_EQ(OH_Drawing_BrushGetColor(brush1), 0xFFFF0000);
69 constexpr uint8_t alpha = 128;
70 OH_Drawing_BrushSetAlpha(brush1, alpha);
71 EXPECT_EQ(OH_Drawing_BrushGetAlpha(brush1), alpha);
72 }
73 } // namespace Drawing
74 } // namespace Rosen
75 } // namespace OHOS