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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TYPOGRAPHY_PROPERTIES_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TYPOGRAPHY_PROPERTIES_H 18 19 #include <cstddef> 20 21 #include "testing_rect.h" 22 23 namespace OHOS::Ace::Testing { 24 enum class TextDirection { 25 RTL, 26 LTR, 27 }; 28 29 class TestingTypographyProperties { 30 public: 31 enum class RectWidthStyle { 32 TIGHT, 33 MAX, 34 }; 35 36 enum class Affinity { 37 UPSTREAM, 38 DOWNSTREAM, 39 }; 40 41 enum class RectHeightStyle { 42 TIGHT, 43 MAX, 44 INCLUDELINESPACEMIDDLE, 45 INCLUDELINESPACETOP, 46 INCLUDELINESPACEBOTTOM, 47 STRUCT, 48 }; 49 50 struct TextBox { 51 TextDirection direction_; 52 TestingRect rect_; 53 TextBox() = default; TextBoxTextBox54 TextBox(TestingRect rect, TextDirection direction) : direction_(direction), rect_(rect) {} 55 }; 56 57 struct PositionAndAffinity { 58 const size_t pos_; 59 const Affinity affinity_; PositionAndAffinityPositionAndAffinity60 PositionAndAffinity(size_t pos, Affinity affinity) : pos_(pos), affinity_(affinity) {} 61 }; 62 63 template<typename T> 64 struct Range { 65 T start_, end_; RangeRange66 Range() : start_(), end_() {} RangeRange67 Range(T a, T b) : start_(a), end_(b) {} 68 bool operator==(const Range<T>& rhs) const 69 { 70 return start_ == rhs.start_ && end_ == rhs.end_; 71 } 72 WidthRange73 T Width() const 74 { 75 return end_ - start_; 76 } 77 ShiftRange78 void Shift(T offset) 79 { 80 start_ += offset; 81 end_ += offset; 82 } 83 }; 84 }; 85 } // namespace OHOS::Ace::Testing 86 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_MOCK_ROSEN_TEST_TESTING_TYPOGRAPHY_PROPERTIES_H 87