• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 
17 package com.android.launcher3.shapes
18 
19 import android.platform.test.annotations.EnableFlags
20 import android.platform.test.flag.junit.SetFlagsRule
21 import androidx.core.graphics.PathParser
22 import androidx.test.ext.junit.runners.AndroidJUnit4
23 import androidx.test.filters.SmallTest
24 import com.android.launcher3.Flags.FLAG_ENABLE_LAUNCHER_ICON_SHAPES
25 import com.android.launcher3.graphics.ShapeDelegate.GenericPathShape
26 import com.android.launcher3.shapes.ShapesProvider.ARCH_KEY
27 import com.android.launcher3.shapes.ShapesProvider.CIRCLE_KEY
28 import com.android.launcher3.shapes.ShapesProvider.FOUR_SIDED_COOKIE_KEY
29 import com.android.launcher3.shapes.ShapesProvider.SEVEN_SIDED_COOKIE_KEY
30 import com.android.launcher3.shapes.ShapesProvider.SQUARE_KEY
31 import com.android.systemui.shared.Flags.FLAG_NEW_CUSTOMIZATION_PICKER_UI
32 import org.junit.Rule
33 import org.junit.Test
34 import org.junit.runner.RunWith
35 
36 @SmallTest
37 @RunWith(AndroidJUnit4::class)
38 class ShapesProviderTest {
39 
40     @get:Rule val setFlagsRule: SetFlagsRule = SetFlagsRule()
41 
42     @Test
43     @EnableFlags(FLAG_ENABLE_LAUNCHER_ICON_SHAPES, FLAG_NEW_CUSTOMIZATION_PICKER_UI)
verify valid path archnull44     fun `verify valid path arch`() {
45         ShapesProvider.iconShapes
46             .find { it.key == ARCH_KEY }!!
47             .run {
48                 GenericPathShape(pathString)
49                 PathParser.createPathFromPathData(pathString)
50             }
51     }
52 
53     @Test
54     @EnableFlags(FLAG_ENABLE_LAUNCHER_ICON_SHAPES, FLAG_NEW_CUSTOMIZATION_PICKER_UI)
verify valid path 4_sided_cookienull55     fun `verify valid path 4_sided_cookie`() {
56         ShapesProvider.iconShapes
57             .find { it.key == FOUR_SIDED_COOKIE_KEY }!!
58             .run {
59                 GenericPathShape(pathString)
60                 PathParser.createPathFromPathData(pathString)
61             }
62     }
63 
64     @Test
65     @EnableFlags(FLAG_ENABLE_LAUNCHER_ICON_SHAPES, FLAG_NEW_CUSTOMIZATION_PICKER_UI)
verify valid path seven_sided_cookienull66     fun `verify valid path seven_sided_cookie`() {
67         ShapesProvider.iconShapes
68             .find { it.key == SEVEN_SIDED_COOKIE_KEY }!!
69             .run {
70                 GenericPathShape(pathString)
71                 PathParser.createPathFromPathData(pathString)
72             }
73     }
74 
75     @Test
76     @EnableFlags(FLAG_ENABLE_LAUNCHER_ICON_SHAPES, FLAG_NEW_CUSTOMIZATION_PICKER_UI)
verify valid path circlenull77     fun `verify valid path circle`() {
78         ShapesProvider.iconShapes
79             .find { it.key == CIRCLE_KEY }!!
80             .run {
81                 GenericPathShape(pathString)
82                 PathParser.createPathFromPathData(pathString)
83             }
84     }
85 
86     @Test
87     @EnableFlags(FLAG_ENABLE_LAUNCHER_ICON_SHAPES, FLAG_NEW_CUSTOMIZATION_PICKER_UI)
verify valid path squarenull88     fun `verify valid path square`() {
89         ShapesProvider.iconShapes
90             .find { it.key == ARCH_KEY }!!
91             .run {
92                 GenericPathShape(pathString)
93                 PathParser.createPathFromPathData(pathString)
94             }
95     }
96 
97     @Test
98     @EnableFlags(FLAG_ENABLE_LAUNCHER_ICON_SHAPES, FLAG_NEW_CUSTOMIZATION_PICKER_UI)
verify valid folder path clovernull99     fun `verify valid folder path clover`() {
100         ShapesProvider.iconShapes
101             .find { it.key == CIRCLE_KEY }!!
102             .run {
103                 GenericPathShape(folderPathString)
104                 PathParser.createPathFromPathData(folderPathString)
105             }
106     }
107 
108     @Test
109     @EnableFlags(FLAG_ENABLE_LAUNCHER_ICON_SHAPES, FLAG_NEW_CUSTOMIZATION_PICKER_UI)
verify valid folder path complexClovernull110     fun `verify valid folder path complexClover`() {
111         ShapesProvider.iconShapes
112             .find { it.key == FOUR_SIDED_COOKIE_KEY }!!
113             .run {
114                 GenericPathShape(folderPathString)
115                 PathParser.createPathFromPathData(folderPathString)
116             }
117     }
118 
119     @Test
120     @EnableFlags(FLAG_ENABLE_LAUNCHER_ICON_SHAPES, FLAG_NEW_CUSTOMIZATION_PICKER_UI)
verify valid folder path archnull121     fun `verify valid folder path arch`() {
122         ShapesProvider.iconShapes
123             .find { it.key == ARCH_KEY }!!
124             .run {
125                 GenericPathShape(folderPathString)
126                 PathParser.createPathFromPathData(folderPathString)
127             }
128     }
129 
130     @Test
131     @EnableFlags(FLAG_ENABLE_LAUNCHER_ICON_SHAPES, FLAG_NEW_CUSTOMIZATION_PICKER_UI)
verify valid folder path squarenull132     fun `verify valid folder path square`() {
133         ShapesProvider.iconShapes
134             .find { it.key == SQUARE_KEY }!!
135             .run {
136                 GenericPathShape(folderPathString)
137                 PathParser.createPathFromPathData(folderPathString)
138             }
139     }
140 }
141