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
16 #include <cstddef>
17 #include "gtest/gtest.h"
18 #include "skia_adapter/skia_runtime_effect.h"
19 #include "skia_adapter/skia_runtime_shader_builder.h"
20 #include "effect/runtime_effect.h"
21
22 using namespace testing;
23 using namespace testing::ext;
24
25 namespace OHOS {
26 namespace Rosen {
27 namespace Drawing {
28 class SkiaRuntimeEffectTest : public testing::Test {
29 public:
30 static void SetUpTestCase();
31 static void TearDownTestCase();
32 void SetUp() override;
33 void TearDown() override;
34 };
35
SetUpTestCase()36 void SkiaRuntimeEffectTest::SetUpTestCase() {}
TearDownTestCase()37 void SkiaRuntimeEffectTest::TearDownTestCase() {}
SetUp()38 void SkiaRuntimeEffectTest::SetUp() {}
TearDown()39 void SkiaRuntimeEffectTest::TearDown() {}
40
41 /**
42 * @tc.name: InitForShader001
43 * @tc.desc: Test InitForShader
44 * @tc.type: FUNC
45 * @tc.require: I91EQ7
46 */
47 HWTEST_F(SkiaRuntimeEffectTest, InitForShader001, TestSize.Level1)
48 {
49 RuntimeEffectOptions op;
50 std::string s = "safd";
51 SkiaRuntimeEffect skiaRuntimeEffect;
52 skiaRuntimeEffect.InitForShader(s, op);
53 }
54
55 /**
56 * @tc.name: InitForShader002
57 * @tc.desc: Test InitForShader
58 * @tc.type: FUNC
59 * @tc.require: I91EQ7
60 */
61 HWTEST_F(SkiaRuntimeEffectTest, InitForShader002, TestSize.Level1)
62 {
63 std::string s = "safd";
64 SkiaRuntimeEffect skiaRuntimeEffect;
65 skiaRuntimeEffect.InitForShader(s);
66 }
67
68 /**
69 * @tc.name: InitForBlender001
70 * @tc.desc: Test InitForBlender
71 * @tc.type: FUNC
72 * @tc.require: I91EQ7
73 */
74 HWTEST_F(SkiaRuntimeEffectTest, InitForBlender001, TestSize.Level1)
75 {
76 std::string s = "safd";
77 SkiaRuntimeEffect skiaRuntimeEffect;
78 skiaRuntimeEffect.InitForBlender(s);
79 }
80
81 /**
82 * @tc.name: GetRuntimeEffect001
83 * @tc.desc: Test GetRuntimeEffect
84 * @tc.type: FUNC
85 * @tc.require: I91EQ7
86 */
87 HWTEST_F(SkiaRuntimeEffectTest, GetRuntimeEffect001, TestSize.Level1)
88 {
89 SkiaRuntimeEffect skiaRuntimeEffect;
90 EXPECT_TRUE(skiaRuntimeEffect.GetRuntimeEffect() == nullptr);
91 }
92
93 /**
94 * @tc.name: MakeShader001
95 * @tc.desc: Test MakeShader
96 * @tc.type: FUNC
97 * @tc.require: I91EQ7
98 */
99 HWTEST_F(SkiaRuntimeEffectTest, MakeShader001, TestSize.Level1)
100 {
101 SkiaRuntimeShaderBuilder skiaRuntimeShaderBuilder;
102 skiaRuntimeShaderBuilder.MakeShader(nullptr, false);
103 Matrix matrix;
104 skiaRuntimeShaderBuilder.MakeShader(&matrix, false);
105 }
106
107 /**
108 * @tc.name: SetRuntimeEffect001
109 * @tc.desc: Test SetRuntimeEffect
110 * @tc.type: FUNC
111 * @tc.require: I91EQ7
112 */
113 HWTEST_F(SkiaRuntimeEffectTest, SetRuntimeEffect001, TestSize.Level1)
114 {
115 SkiaRuntimeEffect skiaRuntimeEffect;
116 sk_sp<SkRuntimeEffect> effect;
117 skiaRuntimeEffect.SetRuntimeEffect(effect);
118 auto effect2 = skiaRuntimeEffect.GetRuntimeEffect();
119 ASSERT_TRUE(effect == effect2);
120 }
121
122 /**
123 * @tc.name: InitForES3Shader001
124 * @tc.desc: Test InitForES3Shader
125 * @tc.type: FUNC
126 * @tc.require: I91EQ7
127 */
128 HWTEST_F(SkiaRuntimeEffectTest, InitForES3Shader001, TestSize.Level1)
129 {
130 std::string s1 = "safd";
131 SkiaRuntimeEffect skiaRuntimeEffect;
132 skiaRuntimeEffect.InitForES3Shader(s1);
133 }
134 } // namespace Drawing
135 } // namespace Rosen
136 } // namespace OHOS