1 /*
2  * Copyright (c) 2024 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 INTERFACE_TEXT_BLOB_TEST_H
17 #define INTERFACE_TEXT_BLOB_TEST_H
18 #include <bits/alltypes.h>
19 #include <native_drawing/drawing_canvas.h>
20 #include <native_drawing/drawing_rect.h>
21 
22 #include "test_base.h"
23 
24 class TextBlobBuilderCreate : public TestBase {
25 public:
TextBlobBuilderCreate(int type)26     explicit TextBlobBuilderCreate(int type) : TestBase(type)
27     {
28         fileName_ = "TextBlobBuilderCreate";
29     };
~TextBlobBuilderCreate()30     ~TextBlobBuilderCreate() override {};
31 
32 protected:
33     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 614 ms 1000次
34 };
35 
36 class TextBlobCreateFromText : public TestBase {
37 public:
TextBlobCreateFromText(int type)38     explicit TextBlobCreateFromText(int type) : TestBase(type)
39     {
40         fileName_ = "TextBlobCreateFromText";
41     };
~TextBlobCreateFromText()42     ~TextBlobCreateFromText() override {};
43 
44 protected:
45     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 440 ms 100次
46 };
47 
48 class TextBlobCreateFromPosText : public TestBase {
49 public:
TextBlobCreateFromPosText(int type)50     explicit TextBlobCreateFromPosText(int type) : TestBase(type)
51     {
52         fileName_ = "TextBlobCreateFromPosText";
53     };
~TextBlobCreateFromPosText()54     ~TextBlobCreateFromPosText() override {};
55 
56 protected:
57     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 230 ms 100次
58 };
59 
60 class TextBlobCreateFromString : public TestBase {
61 public:
TextBlobCreateFromString(int type)62     explicit TextBlobCreateFromString(int type) : TestBase(type)
63     {
64         fileName_ = "TextBlobCreateFromString";
65     };
~TextBlobCreateFromString()66     ~TextBlobCreateFromString() override {};
67 
68 protected:
69     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 486 ms 100次
70 };
71 
72 class TextBlobGetBounds : public TestBase {
73 public:
TextBlobGetBounds(int type)74     explicit TextBlobGetBounds(int type) : TestBase(type)
75     {
76         fileName_ = "TextBlobGetBounds";
77     };
~TextBlobGetBounds()78     ~TextBlobGetBounds() override {};
79 
80 protected:
81     void OnTestPerformance(OH_Drawing_Canvas* canvas) override; // 365 ms 100次
82 };
83 
84 class TextBlobBuilderAllocRunPos : public TestBase {
85 public:
TextBlobBuilderAllocRunPos(int type)86     explicit TextBlobBuilderAllocRunPos(int type) : TestBase(type) {}
~TextBlobBuilderAllocRunPos()87     ~TextBlobBuilderAllocRunPos() override {};
88 
89 protected:
90     int rectWidth_ = 0;
91     int rectHeight_ = 0;
92     void OnTestPerformance(OH_Drawing_Canvas* canvas) override;
93 };
94 
95 #endif // INTERFACE_TEXT_BLOB_TEST_H