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 "test/mock/core/render/mock_paragraph.h"
17
18 #include "core/components_ng/render/paragraph.h"
19
20 namespace OHOS::Ace::NG {
21 RefPtr<MockParagraph> MockParagraph::paragraph_;
22 bool MockParagraph::enabled_ = true;
23
Create(const ParagraphStyle & paraStyle,const RefPtr<FontCollection> & fontCollection)24 RefPtr<Paragraph> Paragraph::Create(const ParagraphStyle& paraStyle, const RefPtr<FontCollection>& fontCollection)
25 {
26 return MockParagraph::enabled_ ? MockParagraph::paragraph_ : nullptr;
27 }
28
Create(void * paragraph)29 RefPtr<Paragraph> Paragraph::Create(void* paragraph)
30 {
31 return MockParagraph::enabled_ ? MockParagraph::paragraph_ : nullptr;
32 }
33
GetOrCreateMockParagraph()34 RefPtr<MockParagraph> MockParagraph::GetOrCreateMockParagraph()
35 {
36 if (!paragraph_) {
37 paragraph_ = AceType::MakeRefPtr<MockParagraph>();
38 }
39 return paragraph_;
40 }
41
TearDown()42 void MockParagraph::TearDown()
43 {
44 if (paragraph_) {
45 paragraph_ = nullptr;
46 }
47 }
48
UpdateColor(size_t from,size_t to,const Color & color)49 void MockParagraph::UpdateColor(size_t from, size_t to, const Color& color) {}
50 } // namespace OHOS::Ace::NG
51