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