1 /*
2  * Copyright (C) 2019 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 android.platform.helpers;
18 
19 import androidx.test.uiautomator.UiObject2;
20 
21 /** Helper class for functional tests of Settings facet */
22 public interface IAutoSettingHelper extends IAppHelper {
23 
24     /**
25      * enum for Day/Night mode.
26      *
27      * <p>The values of DAY_MODE(0) and NIGHT_MODE(2) are determined by the returned value of
28      * UiModeManager.getNightMode()
29      */
30     public enum DayNightMode {
31         DAY_MODE(0),
32         NIGHT_MODE(2);
33 
34         private final int value;
35 
DayNightMode(int value)36         DayNightMode(int value) {
37             this.value = value;
38         }
39 
getValue()40         public int getValue() {
41             return value;
42         }
43     }
44 
45     /** enum for changing(increasing, decreasing) value. */
46     enum ChangeType {
47         INCREASE,
48         DECREASE
49     }
50 
51     /**
52      * Setup expectations: The settings app is open
53      *
54      * @param setting option to find.
55      */
findSettingMenu(String setting)56     UiObject2 findSettingMenu(String setting);
57 
58     /**
59      * Setup expectations: The app is open and the settings facet is open
60      *
61      * <p>Scroll backward(down) in the settings menu page.
62      */
scrollBackward()63     boolean scrollBackward();
64 
65     /**
66      * Setup expectations: The app is open and the settings facet is open.
67      *
68      * <p>Scroll forward(up) in the settings menu page.
69      */
scrollForward()70     boolean scrollForward();
71 
72     /**
73      * Setup expectations: The app is open and the settings facet is open
74      *
75      * @param setting option to open.
76      */
openSetting(String setting)77     void openSetting(String setting);
78 
79     /**
80      * Setup expectations: The app is open
81      *
82      * <p>Open full settings page
83      */
openFullSettings()84     void openFullSettings();
85 
86     /**
87      * Setup expectations: The app is open and wifi setting options is selected
88      *
89      * @param option to turn on/off wifi
90      */
turnOnOffWifi(boolean turnOn)91     void turnOnOffWifi(boolean turnOn);
92 
93     /**
94      * Setup expectations: The app is open and bluetooth setting options is selected
95      *
96      * @param option to turn on/off bluetooth
97      */
turnOnOffBluetooth(boolean turnOn)98     void turnOnOffBluetooth(boolean turnOn);
99 
100     /**
101      * Setup expectations: The app is open and Hotspot & tethering setting options is selected
102      *
103      * @param turnOn to turn on/off Hotspot
104      */
turnOnOffHotspot(boolean turnOn)105     void turnOnOffHotspot(boolean turnOn);
106 
107     /**
108      * Setup expectations: The app is open.
109      *
110      * <p>Toggle on/off hotspot.
111      */
toggleHotspot()112     void toggleHotspot();
113 
114     /**
115      * Setup expectations: The app is open.
116      *
117      * Checks if the wifi is enabled.
118      */
isWifiOn()119     boolean isWifiOn();
120 
121     /**
122      * Setup expectations: The app is open.
123      *
124      * Checks if the bluetooth is enabled.
125      */
isBluetoothOn()126     boolean isBluetoothOn();
127 
128     /**
129      * Setup expectations: The app is open.
130      *
131      * Checks if hotspot is enabled.
132      */
isHotspotOn()133     boolean isHotspotOn();
134 
135     /**
136      * Setup expectations: The app is open and the settings facet is open
137      */
goBackToSettingsScreen()138     void goBackToSettingsScreen();
139 
140     /**
141      * Force stops the settings application
142      */
stopSettingsApplication()143     void stopSettingsApplication();
144 
145     /**
146      * Setup expectations: settings app is open.
147      *
148      * <p>This method is used to open Settings Menu with menuOptions. Example - Settings->App
149      * info->Calandar->Permissions openMenuWith("App info", "Calandar", "Permissions");
150      *
151      * @param - menuOptions used to pass multiple level of menu options in one go.
152      */
openMenuWith(String... menuOptions)153     void openMenuWith(String... menuOptions);
154 
155     /**
156      * Setup expectations: settings app is open.
157      *
158      * <p>gets the value of the setting.
159      *
160      * @param setting should be passed. example for setting is screen_brightness.
161      */
getValue(String setting)162     int getValue(String setting);
163 
164     /**
165      * Setup expectations: settings app is open
166      *
167      * <p>sets the value of the setting.
168      *
169      * @param setting should be passed. example for setting is screen_brightness.
170      */
setValue(String setting, int value)171     void setValue(String setting, int value);
172 
173     /**
174      * Setup expectations: full settings facet is open.
175      *
176      * <p>search in settings app and select the first search result.
177      *
178      * @param item to be searched.
179      */
searchAndSelect(String item)180     void searchAndSelect(String item);
181 
182     /**
183      * Setup expectations: full settings facet is open.
184      *
185      * <p>search in settings app.
186      *
187      * @param item to be searched.
188      * @param selectedIndex determines which search result to select.
189      */
searchAndSelect(String item, int selectedIndex)190     void searchAndSelect(String item, int selectedIndex);
191 
192     /**
193      * Setup expectations: search result is open.
194      *
195      * <p>verify page title contains the searched item.
196      *
197      * @param item to be verified.
198      */
isValidPageTitle(String item)199     boolean isValidPageTitle(String item);
200 
201     /**
202      * Setup expectations: Setting is open.
203      *
204      * <p>check whether a setting menu in Settings is enabled or not.
205      *
206      * @param name of the setting menu.
207      */
isSettingMenuEnabled(String menu)208     boolean isSettingMenuEnabled(String menu);
209 
210     /**
211      * Setup expectations: Setting is open.
212      *
213      * <p>Get the current page title text.
214      */
getPageTitleText()215     String getPageTitleText();
216 
217     /**
218      * Setup expectations: Setting is open.
219      *
220      * <p>check whether a setting menu in Settings is displayed or not.
221      */
checkMenuExists(String setting)222     boolean checkMenuExists(String setting);
223 
224     /**
225      * Setup expectations: Setting is open.
226      *
227      * <p>Find the setting menu and perform a click action.
228      *
229      * @param name of the setting menu.
230      */
findSettingMenuAndClick(String setting)231     void findSettingMenuAndClick(String setting);
232 
233     /**
234      * Set the brightness and report the resulting brightness value
235      *
236      * @param targetPercentage Where on the brightness seekbar to tap
237      * @return The brightness value as reported by the service
238      */
setBrightness(float targetPercentage)239     int setBrightness(float targetPercentage);
240 
241     /**
242      * Setup expectation: None
243      *
244      * <p>This method checks if Recently accessed apps is displayed in settings Location
245      */
isRecentAppDisplayedInLocationSettings(String app)246     boolean isRecentAppDisplayedInLocationSettings(String app);
247 }
248