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 #include "draw_rect_test.h"
16 
17 namespace OHOS {
18 namespace Rosen {
OnTestFunction(Drawing::Canvas * canvas)19 void DrawRectTest::OnTestFunction(Drawing::Canvas* canvas)
20 {
21     Drawing::Brush brush;
22     brush.SetColor(0xFFFF0000); // color:red
23     canvas->AttachBrush(brush);
24     auto rect = Drawing::Rect(0, 0, 100, 100); // xy (0, 0), size 100*100
25     canvas->DrawRect(rect);
26     canvas->DetachBrush();
27 }
OnTestPerformance(Drawing::Canvas * canvas)28 void DrawRectTest::OnTestPerformance(Drawing::Canvas* canvas)
29 {
30     Drawing::Brush brush;
31     brush.SetColor(0xFFFF0000); // color:red
32     canvas->AttachBrush(brush);
33     auto rect = Drawing::Rect(0, 0, 100, 100); // xy (0, 0), size 100*100
34     for (int i = 0; i < testCount_; i++) {
35         canvas->DrawRect(rect);
36     }
37     canvas->DetachBrush();
38 }
39 } // namespace Rosen
40 } // namespace OHOS