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 java.util.List;
20 
21 public interface IAutoDialHelper extends IAppHelper, Scrollable {
22 
23     /** enum class for contact list order type. */
24     enum OrderType {
25         FIRST_NAME,
26         LAST_NAME
27     }
28     /** enum class for phone call audio channel. */
29     enum AudioSource {
30         PHONE,
31         CAR_SPEAKERS,
32     }
33 
34     /**
35      * Setup expectations: The app is open and the dialpad is open
36      *
37      * <p>This method is used to dial the phonenumber on dialpad
38      *
39      * @param phoneNumber phone number to dial.
40      */
dialANumber(String phoneNumber)41     void dialANumber(String phoneNumber);
42 
43     /**
44      * Setup expectations: A prompt allowing the user to select "Device" is open.
45      *
46      * <p>This method is meant to be used when contacts are being uploaded onto a device (the
47      * confirmation dialogue allows either the device to be selected for upload, or for
48      * cancellation.
49      */
pressDeviceOnPrompt()50     void pressDeviceOnPrompt();
51 
52     /**
53      * Press the contact info element on screen containing the given name.
54      *
55      * @param expectedName - The contact name on the contact info element
56      */
pressContactResult(String expectedName)57     void pressContactResult(String expectedName);
58 
59     /** Assumes contact page is open. Press the mobile call button on a contact page. */
pressMobileCallOnContact()60     void pressMobileCallOnContact();
61 
62     /** Assumes Dialer settings page is open. Press the active call toggle. */
pressActiveCallToggle()63     void pressActiveCallToggle();
64 
65     /**
66      * Assumes home screen is currently open, and the phone card is the bottommost card on the left
67      * side of the screen.
68      *
69      * <p>Press the dialer button on the phone card.
70      */
pressDialerButtonOnPhoneCard()71     void pressDialerButtonOnPhoneCard();
72 
73     /**
74      * Setup expectations: The app is open and there is an ongoing call.
75      *
76      * <p>This method is used to end call using softkey.
77      */
endCall()78     void endCall();
79 
80     /**
81      * Setup expectations: The app is open.
82      *
83      * <p>This method is used to open call history details.
84      */
openCallHistory()85     void openCallHistory();
86 
87     /**
88      * Setup expectations: The app is open.
89      *
90      * <p>This method dials a contact from the contact list.
91      *
92      * @param contactName to dial.
93      */
callContact(String contactName)94     void callContact(String contactName);
95 
96     /**
97      * Setup expectations: The app is open and in Dialpad.
98      *
99      * <p>This method is used to delete the number entered on dialpad using backspace
100      */
deleteDialedNumber()101     void deleteDialedNumber();
102 
103     /**
104      * Setup expectations: The app is open and in Dialpad
105      *
106      * <p>This method is used to get the number entered on dialing screen.
107      */
getDialedNumber()108     String getDialedNumber();
109 
110     /**
111      * Setup expectations: A call is underway, and the call screen is in focus on the device.
112      *
113      * <p>This method is used to get the number that is currently being dialed, or has been dialed
114      * on a currently-displayed ongoing call
115      */
getDialingNumber()116     String getDialingNumber();
117 
118     /**
119      * Setup expectations: A call is underway, and the call screen is in focus on the device.
120      *
121      * <p>This method is used to get the number that is has been dialed /called on a
122      * currently-displayed ongoing call
123      */
getUserProfilePhoneNumber()124     String getUserProfilePhoneNumber();
125 
126     /**
127      * Setup expectations: The app is open and in Dialpad
128      *
129      * <p>This method is used to get the number entered on dialpad
130      */
getNumberInDialPad()131     String getNumberInDialPad();
132 
133     /**
134      * Setup expectations: The app is open and there is an ongoing call.
135      *
136      * <p>This method is used to get the name of the contact for the ongoing call
137      */
getDialedContactName()138     String getDialedContactName();
139 
140     /**
141      * Setup expectations: The app is open and Call History is open.
142      *
143      * <p>This method is used to get the most recent call history.
144      */
getRecentCallHistory()145     String getRecentCallHistory();
146 
147     /**
148      * Setup expectations: The app is open and phonenumber is entered on the dialpad.
149      *
150      * <p>This method is used to make/receive a call using softkey.
151      */
makeCall()152     void makeCall();
153 
154     /**
155      * Setup expectations: The app is open.
156      *
157      * <p>This method is used to dial a number from a list (Favorites, Call History, Contact).
158      *
159      * @param contact (number or name) dial.
160      */
dialFromList(String contact)161     void dialFromList(String contact);
162 
163     /**
164      * Setup expectations: The app is open and there is an ongoing call.
165      *
166      * <p>This method is used to enter number on the in-call dialpad.
167      *
168      * @param phoneNumber to dial.
169      */
inCallDialPad(String phoneNumber)170     void inCallDialPad(String phoneNumber);
171 
172     /**
173      * Setup expectations: The app is open and there is an ongoing call.
174      *
175      * <p>This method is used to mute the ongoing call.
176      */
muteCall()177     void muteCall();
178 
179     /**
180      * Setup expectations: The app is open and there is an ongoing call.
181      *
182      * <p>This method is used to unmute the ongoing call.
183      */
unmuteCall()184     void unmuteCall();
185 
186     /**
187      * Setup expectations: The app is open and there is an ongoing call.
188      *
189      * <p>This method is used to change voice channel to handset/bluetooth.
190      *
191      * @param source to switch to.
192      */
changeAudioSource(AudioSource source)193     void changeAudioSource(AudioSource source);
194 
195     /**
196      * Setup expectations: The app is open.
197      *
198      * <p>This method is used to make a call to the first history from Call History.
199      */
callMostRecentHistory()200     void callMostRecentHistory();
201 
202     /**
203      * Setup expectations: The Phone Dialer Settings page is open.
204      *
205      * <p>This method returns the phone name recorded under the "Connected Phone" settings field.
206      */
getConnectedPhoneName()207     String getConnectedPhoneName();
208 
209     /**
210      * Setup expectations: The app is open and there is an ongoing call.
211      *
212      * <p>This method is used to get the contact name being called.
213      */
getContactName()214     String getContactName();
215 
216     /**
217      * Setup expectations: The app is open and there is an ongoing call
218      *
219      * <p>This method is used to get the contact type (Mobile, Work, Home and etc.) being called.
220      */
getContactType()221     String getContactType();
222 
223     /**
224      * Setup expectations: The app is open.
225      *
226      * <p>This method is used to search a contact in the contact list.
227      *
228      * @param contact to search.
229      */
searchContactsByName(String contact)230     void searchContactsByName(String contact);
231 
232     /**
233      * Setup expectations: The app is open.
234      *
235      * <p>This method is used to search a number in the contact list.
236      *
237      * @param number to search.
238      */
searchContactsByNumber(String number)239     void searchContactsByNumber(String number);
240 
241     /**
242      * Setup expectations: The app is open.
243      *
244      * <p>This method is used to get the first search result for contact.
245      */
getFirstSearchResult()246     String getFirstSearchResult();
247 
248     /**
249      * Setup expectations: The app is open.
250      *
251      * <p>This method is used to order the contact list based on first/last name.
252      *
253      * @param orderType to use.
254      */
sortContactListBy(OrderType orderType)255     void sortContactListBy(OrderType orderType);
256 
257     /**
258      * Setup expectations: The app is open.
259      *
260      * <p>This method is used to get the first contact name from contact list.
261      */
getFirstContactFromContactList()262     String getFirstContactFromContactList();
263 
264     /**
265      * Setup expectations: A Contact details page is open.
266      *
267      * <p>This method is used to get the home address from the currently-open contact.
268      */
getHomeAddress()269     String getHomeAddress();
270 
271     /**
272      * Setup expectations: The app is open.
273      *
274      * <p>This method is used to verify if a contact is added to Favorites.
275      *
276      * @param contact to check.
277      */
isContactInFavorites(String contact)278     boolean isContactInFavorites(String contact);
279 
280     /**
281      * Setup expectations: The contact's details page is open.
282      *
283      * <p>This method is used to close the details page.
284      *
285      * @param contact Contact's details page to be opened.
286      */
openDetailsPage(String contact)287     void openDetailsPage(String contact);
288 
289     /** Setup expectations: The dialer main page is open. Opens the dial pad screen. */
openDialPad()290     void openDialPad();
291 
292     /**
293      * Setup expectations: The dialer app page is open.
294      *
295      * <p>This method opens the dialer settings page (via the Settings icon button on the dialer
296      * page.
297      */
openDialerSettings()298     void openDialerSettings();
299 
isPhonePaired()300     boolean isPhonePaired();
301     /**
302      * Setup expectations: The app is open.
303      *
304      * <p>This method is used to open contact list
305      */
openContacts()306     void openContacts();
307 
308     /**
309      * Setup expectations: The contacts page is open.
310      *
311      * <p>This method is used to open the contact details page of the first visible contact. Throws
312      * an error if no contacts are visible.
313      */
openFirstContactDetails()314     void openFirstContactDetails();
315 
316     /**
317      * Setup expectations: The app is open and there is an ongoing call.
318      *
319      * <p>This method is used check if ongoing call is displayed on home.
320      */
isOngoingCallDisplayedOnHome()321     boolean isOngoingCallDisplayedOnHome();
322 
323     /**
324      * Setup expectations: None
325      *
326      * @return Whether the screen currently shows an ongoing call (in full-screen mode).
327      */
isOngoingCallInFullScreen()328     boolean isOngoingCallInFullScreen();
329 
330     /**
331      * Setup expectations: The home screen is open
332      *
333      * <p>This method is used for opening phone app from homescreen
334      */
openPhoneAppFromHome()335     void openPhoneAppFromHome();
336 
337     /**
338      * Setup expectations: The app is open.
339      *
340      * <p>This method is used to get visible contacts list
341      */
getListOfAllVisibleContacts()342     List<String> getListOfAllVisibleContacts();
343 
344     /**
345      * Setup expectations: The call history view is open.
346      *
347      * @return - The number of call histrory entries currently on screen.
348      */
getNumberOfCallHistoryEntries()349     int getNumberOfCallHistoryEntries();
350 
351     /**
352      * Setup expectations: the Dialer Settings page is open.
353      *
354      * <p>Returns true if the Active Call feature is enabled, false otherwise.
355      */
isActiveCallEnabled()356     boolean isActiveCallEnabled();
357 
358     /**
359      * Setup expectations: bluetooth is off
360      *
361      * <p>This method is used for checking if error message is displaye when bluetooth is off
362      */
isBluetoothHfpErrorDisplayed()363     boolean isBluetoothHfpErrorDisplayed();
364 
365     /**
366      * Setup expectations: The app is open
367      *
368      * <p>This method is adding favorites from the Favorites Tab
369      */
addFavoritesFromFavoritesTab(String contact)370     void addFavoritesFromFavoritesTab(String contact);
371     /**
372      * Setup expectations: The bluetooth palette is open
373      *
374      * <p>This method is used for clicking phone button from bluetooth palette
375      */
clickPhoneButton()376     void clickPhoneButton();
377     /**
378      * Setup expectations: The dialer page is open
379      *
380      * <p>This method is used to check if Recents tab is present in dialer page
381      */
verifyDialerRecentsTab()382     boolean verifyDialerRecentsTab();
383     /**
384      * Setup expectations: The dialer page is open
385      *
386      * <p>This method is used to check if Contacts tab is present in dialer page
387      */
verifyDialerContactsTab()388     boolean verifyDialerContactsTab();
389     /**
390      * Setup expectations: The dialer page is open
391      *
392      * <p>This method is used to check if Favorites tab is present in dialer page
393      */
verifyDialerFavoritesTab()394     boolean verifyDialerFavoritesTab();
395     /**
396      * Setup expectations: The dialer page is open
397      *
398      * <p>This method is used to check if Dialpad tab is present in dialer page
399      */
verifyDialerDialpadTab()400     boolean verifyDialerDialpadTab();
401 }
402