• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_data.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 
24 struct MockVars {
25 #ifndef USE_ROSEN_DRAWING
26     sk_sp<SkData> skData_ = SkData::MakeEmpty();
27 #else
28     std::shared_ptr<RSData> skData_ = std::make_shared<RSData>();
29 #endif
30 } g_tdMockvars;
31 
InitTdMockVars(struct MockVars && vars)32 void InitTdMockVars(struct MockVars &&vars)
33 {
34     g_tdMockvars = std::move(vars);
35 }
36 
37 #ifndef USE_ROSEN_DRAWING
MakeFromFileName(const char path[])38 sk_sp<SkData> SkData::MakeFromFileName(const char path[])
39 {
40     return g_tdMockvars.skData_;
41 }
42 #endif
43 
44 namespace OHOS {
45 namespace Rosen {
46 namespace TextEngine {
47 class TexgineDataTest : public testing::Test {
48 };
49 
50 /**
51  * @tc.name:MakeFromFileName
52  * @tc.desc: Verify the MakeFromFileName
53  * @tc.type:FUNC
54  */
55 HWTEST_F(TexgineDataTest, MakeFromFileName, TestSize.Level1)
56 {
57     EXPECT_NO_THROW({
58         InitTdMockVars({});
59         std::string str = "";
60         auto td = TexgineData::MakeFromFileName(str);
61         EXPECT_NE(td->GetData(), g_tdMockvars.skData_);
62     });
63 }
64 } // namespace TextEngine
65 } // namespace Rosen
66 } // namespace OHOS
67