1 /*
2 * Copyright (c) 2023 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 <gtest/gtest.h>
17 #include <gmock/gmock.h>
18
19 #include "texgine_path_1d_path_effect.h"
20
21 using namespace testing;
22 using namespace testing::ext;
23
24 struct MockVars {
25 #ifndef USE_ROSEN_DRAWING
26 sk_sp<SkPathEffect> skPathEffect_ = nullptr;
27 #else
28 std::shared_ptr<RSPathEffect> skPathEffect_ = nullptr;
29 #endif
30 };
31
32 namespace {
33 struct MockVars g_tp1peMockvars;
34
InitTp1peMockVars(struct MockVars && vars)35 void InitTp1peMockVars(struct MockVars &&vars)
36 {
37 g_tp1peMockvars = std::move(vars);
38 }
39 } // namespace
40
41 #ifndef USE_ROSEN_DRAWING
Make(const SkPath & path,SkScalar advance,SkScalar phase,Style style)42 sk_sp<SkPathEffect> SkPath1DPathEffect::Make(const SkPath& path, SkScalar advance, SkScalar phase, Style style)
43 {
44 return g_tp1peMockvars.skPathEffect_;
45 }
46 #endif
47
48 namespace OHOS {
49 namespace Rosen {
50 namespace TextEngine {
51 class TexginePath1DPathEffectTest : public testing::Test {
52 };
53
54 /**
55 * @tc.name:Make
56 * @tc.desc: Verify the Make
57 * @tc.type:FUNC
58 */
59 HWTEST_F(TexginePath1DPathEffectTest, Make, TestSize.Level1)
60 {
61 std::shared_ptr<TexginePath> tp = std::make_shared<TexginePath>();
62 EXPECT_NO_THROW({
63 InitTp1peMockVars({});
64 std::shared_ptr<TexginePathEffect> tpe =
65 TexginePath1DPathEffect::Make(*tp, 0.0, 0.0, TexginePath1DPathEffect::Style::K_TRANSLATE_STYLE);
66 EXPECT_NE(tpe->GetPathEffect(), g_tp1peMockvars.skPathEffect_);
67 });
68 }
69 } // namespace TextEngine
70 } // namespace Rosen
71 } // namespace OHOS
72