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 "drawing_brush.h"
19 #include "drawing_color.h"
20
21 #ifdef RS_ENABLE_VK
22 #include "platform/ohos/backend/rs_vulkan_context.h"
23 #endif
24
25 using namespace testing;
26 using namespace testing::ext;
27
28 namespace OHOS {
29 namespace Rosen {
30 namespace Drawing {
31 class NativeDrawingColorTest : public testing::Test {
32 public:
33 static void SetUpTestCase();
34 static void TearDownTestCase();
35 void SetUp() override;
36 void TearDown() override;
37 };
38
SetUpTestCase()39 void NativeDrawingColorTest::SetUpTestCase()
40 {
41 #ifdef RS_ENABLE_VK
42 RsVulkanContext::SetRecyclable(false);
43 #endif
44 }
TearDownTestCase()45 void NativeDrawingColorTest::TearDownTestCase() {}
SetUp()46 void NativeDrawingColorTest::SetUp() {}
TearDown()47 void NativeDrawingColorTest::TearDown() {}
48
49 /*
50 * @tc.name: NativeDrawingColorTest_color001
51 * @tc.desc: test for ColorSetArgb.
52 * @tc.type: FUNC
53 * @tc.require: AR000GTO5R
54 */
55 HWTEST_F(NativeDrawingColorTest, NativeDrawingColorTest_color001, TestSize.Level1)
56 {
57 OH_Drawing_Brush* brush1 = OH_Drawing_BrushCreate();
58 OH_Drawing_BrushSetAntiAlias(brush1, false);
59 EXPECT_EQ(OH_Drawing_BrushIsAntiAlias(brush1), false);
60 OH_Drawing_BrushSetColor(brush1, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0x00, 0x00));
61 EXPECT_EQ(OH_Drawing_BrushGetColor(brush1), 0xFFFF0000);
62 }
63 } // namespace Drawing
64 } // namespace Rosen
65 } // namespace OHOS