1/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.graphics.perftests;
18
19import android.graphics.Path;
20import android.graphics.RectF;
21import android.perftests.utils.BenchmarkState;
22import android.perftests.utils.PerfStatusReporter;
23import android.support.test.filters.LargeTest;
24
25import org.junit.Rule;
26import org.junit.Test;
27
28@LargeTest
29public class PathPerfTest {
30    @Rule
31    public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
32
33    @Test
34    public void testReset() {
35        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
36        Path path = new Path();
37        while (state.keepRunning()) {
38            path.reset();
39        }
40    }
41
42    @Test
43    public void testAddReset() {
44        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
45        Path path = new Path();
46        while (state.keepRunning()) {
47            path.addRect(0, 0, 100, 100, Path.Direction.CW);
48            path.reset();
49        }
50    }
51
52    @Test
53    public void testRewind() {
54        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
55        Path path = new Path();
56        while (state.keepRunning()) {
57            path.rewind();
58        }
59    }
60
61    @Test
62    public void testAddRewind() {
63        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
64        Path path = new Path();
65        while (state.keepRunning()) {
66            path.addRect(0, 0, 100, 100, Path.Direction.CW);
67            path.rewind();
68        }
69    }
70
71    @Test
72    public void testIsEmpty() {
73        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
74        Path path = new Path();
75        path.addRect(0, 0, 100, 100, Path.Direction.CW);
76        while (state.keepRunning()) {
77            path.isEmpty();
78        }
79    }
80
81    @Test
82    public void testIsConvex() {
83        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
84        Path path = new Path();
85        path.addRect(0, 0, 100, 100, Path.Direction.CW);
86        while (state.keepRunning()) {
87            path.isConvex();
88        }
89    }
90
91    @Test
92    public void testGetSetFillType() {
93        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
94        Path path = new Path();
95        path.addRect(0, 0, 100, 100, Path.Direction.CW);
96        while (state.keepRunning()) {
97            path.setFillType(Path.FillType.EVEN_ODD);
98            path.getFillType();
99        }
100    }
101
102    @Test
103    public void testIsRect() {
104        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
105        Path path = new Path();
106        path.addRect(0, 0, 100, 100, Path.Direction.CW);
107        final RectF outRect = new RectF();
108        while (state.keepRunning()) {
109            path.isRect(outRect);
110        }
111    }
112}
113