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, 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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TYPOGRAPHY_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TYPOGRAPHY_H 18 19 #include <vector> 20 21 #include "testing_canvas.h" 22 #include "testing_typography_properties.h" 23 24 namespace OHOS::Ace::Testing { 25 enum class WordBreakType { WordBreakTypeNormal = 0, WordBreakTypeBreakAll, WordBreakTypeBreakWord }; 26 27 enum class TextAlign { 28 LEFT = 0, 29 RIGHT, 30 CENTER, 31 JUSTIFY, 32 START, 33 END, 34 }; 35 36 class TestingTypography { 37 public: 38 TestingTypography() = default; 39 virtual ~TestingTypography() = default; 40 GetHeight()41 virtual double GetHeight() 42 { 43 return 1.0; 44 } 45 Layout(double width)46 virtual void Layout(double width) {} 47 GetMaxIntrinsicWidth()48 virtual double GetMaxIntrinsicWidth() 49 { 50 return 1.0; 51 } 52 GetMaxWidth()53 virtual double GetMaxWidth() 54 { 55 return 1.0; 56 } 57 GetLongestLine()58 virtual double GetLongestLine() 59 { 60 return 1.0; 61 } 62 GetMinIntrinsicWidth()63 virtual double GetMinIntrinsicWidth() 64 { 65 return 1.0; 66 } 67 Paint(TestingCanvas * canvas,double x,double y)68 virtual void Paint(TestingCanvas* canvas, double x, double y) {} 69 GetRectsForRange(size_t,size_t,TestingTypographyProperties::RectHeightStyle,TestingTypographyProperties::RectWidthStyle)70 virtual std::vector<TestingTypographyProperties::TextBox> GetRectsForRange(size_t /* start */, size_t /* end */, 71 TestingTypographyProperties::RectHeightStyle /* height */, 72 TestingTypographyProperties::RectWidthStyle /* width */) 73 { 74 return {}; 75 } 76 GetGlyphPositionAtCoordinateWithCluster(double x,double y)77 virtual TestingTypographyProperties::PositionAndAffinity GetGlyphPositionAtCoordinateWithCluster(double x, double y) 78 { 79 TestingTypographyProperties::PositionAndAffinity res(1, TestingTypographyProperties::Affinity::UPSTREAM); 80 return res; 81 } 82 GetGlyphPositionAtCoordinate(double x,double y)83 virtual TestingTypographyProperties::PositionAndAffinity GetGlyphPositionAtCoordinate(double x, double y) 84 { 85 TestingTypographyProperties::PositionAndAffinity res(1, TestingTypographyProperties::Affinity::UPSTREAM); 86 return res; 87 } 88 GetWordBoundary(size_t offset)89 virtual TestingTypographyProperties::Range<size_t> GetWordBoundary(size_t offset) 90 { 91 TestingTypographyProperties::Range<size_t> range = 92 TestingTypographyProperties::Range<size_t>(offset, offset + 1); 93 return range; 94 } 95 }; 96 } // namespace OHOS::Ace::Testing 97 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TYPOGRAPHY_H 98