Implement Test: Dialer Page Refresh
Test: https://paste.googleplex.com/6160438966878208
Bug: 273366005
Change-Id: Ie918b8c2dd7b941edc65c1e5882fb83e965b9b3e
diff --git a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoDialHelper.java b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoDialHelper.java
index 1937bad..8400eea 100644
--- a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoDialHelper.java
+++ b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoDialHelper.java
@@ -109,7 +109,7 @@
*
* <p>This method is used to get the number entered on dialpad
*/
- String getDialInNumber();
+ String getNumberInDialPad();
/**
* Setup expectations: The app is open and there is an ongoing call.
@@ -259,6 +259,10 @@
* @param contact Contact's details page to be opened.
*/
void openDetailsPage(String contact);
+
+ /** Setup expectations: The dialer main page is open. Opens the dial pad screen. */
+ void openDialPad();
+
/**
* Setup expectations: The app is open.
*
diff --git a/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json b/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json
index 38a536d..8addee3 100644
--- a/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json
+++ b/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json
@@ -384,6 +384,23 @@
"TYPE": "TEXT",
"VALUE": "Dial.?pad"
},
+ "DIAL_PAD_BUTTON": {
+ "TYPE": "MULTIPLE",
+ "SPECIFIERS": [
+ {
+ "TYPE": "CLASS",
+ "VALUE": "android.widget.LinearLayout"
+ },
+ {
+ "TYPE": "HAS_DESCENDANT",
+ "MAX_DEPTH": 2,
+ "DESCENDANT": {
+ "TYPE": "TEXT",
+ "VALUE": "Dialpad"
+ }
+ }
+ ]
+ },
"FAVORITES_MENU": {
"TYPE": "TEXT",
"VALUE": "Favo.?rite.?"
diff --git a/libraries/automotive-helpers/auto-default-config/src/android/platform/helpers/AutomotiveConfigConstants.java b/libraries/automotive-helpers/auto-default-config/src/android/platform/helpers/AutomotiveConfigConstants.java
index 7e7e78d..d44cbcf 100644
--- a/libraries/automotive-helpers/auto-default-config/src/android/platform/helpers/AutomotiveConfigConstants.java
+++ b/libraries/automotive-helpers/auto-default-config/src/android/platform/helpers/AutomotiveConfigConstants.java
@@ -34,6 +34,7 @@
public static final String DIAL_IN_NUMBER = "DIAL_IN_NUMBER";
public static final String DIALED_CONTACT_TITLE = "DIALED_CONTACT_TITLE";
public static final String SWITCH_TO_DIAL_PAD = "SWITCH_TO_DIAL_PAD";
+ public static final String DIAL_PAD_BUTTON = "DIAL_PAD_BUTTON";
public static final String MUTE_CALL = "MUTE_CALL";
public static final String CONTACT_LIST_SCROLL_ACTION = "CONTACT_LIST_SCROLL_ACTION";
public static final String CONTACT_LIST_SCROLL_FORWARD = "CONTACT_LIST_SCROLL_FORWARD";
diff --git a/libraries/automotive-helpers/dial-app-helper/src/android/platform/helpers/DialHelperImpl.java b/libraries/automotive-helpers/dial-app-helper/src/android/platform/helpers/DialHelperImpl.java
index 21c2779..1d1e266 100644
--- a/libraries/automotive-helpers/dial-app-helper/src/android/platform/helpers/DialHelperImpl.java
+++ b/libraries/automotive-helpers/dial-app-helper/src/android/platform/helpers/DialHelperImpl.java
@@ -190,7 +190,7 @@
/** {@inheritDoc} */
public void deleteDialedNumber() {
- String phoneNumber = getDialInNumber();
+ String phoneNumber = getNumberInDialPad();
BySelector deleteButtonSelector =
getUiElementFromConfig(AutomotiveConfigConstants.DELETE_NUMBER);
UiObject2 deleteButton = getSpectatioUiUtil().findUiObject(deleteButtonSelector);
@@ -202,7 +202,8 @@
}
/** {@inheritDoc} */
- public String getDialInNumber() {
+ @Override
+ public String getNumberInDialPad() {
BySelector dialedInNumberSelector =
getUiElementFromConfig(AutomotiveConfigConstants.DIAL_IN_NUMBER);
UiObject2 dialInNumber = getSpectatioUiUtil().findUiObject(dialedInNumberSelector);
@@ -548,6 +549,17 @@
}
/** {@inheritDoc} */
+ @Override
+ public void openDialPad() {
+ BySelector contactMenuSelector =
+ getUiElementFromConfig(AutomotiveConfigConstants.DIALER_DIALPAD);
+ UiObject2 contactMenuButton = getSpectatioUiUtil().findUiObject(contactMenuSelector);
+ getSpectatioUiUtil()
+ .validateUiObject(contactMenuButton, AutomotiveConfigConstants.DIALER_DIALPAD);
+ getSpectatioUiUtil().clickAndWait(contactMenuButton);
+ }
+
+ /** {@inheritDoc} */
public void openDetailsPage(String contactName) {
openContacts();
UiObject2 contact = getContactFromContactList(contactName);
diff --git a/tests/automotive/functional/dialer/src/android/platform/tests/DialTest.java b/tests/automotive/functional/dialer/src/android/platform/tests/DialTest.java
index 0941e6a..8af2cd8 100644
--- a/tests/automotive/functional/dialer/src/android/platform/tests/DialTest.java
+++ b/tests/automotive/functional/dialer/src/android/platform/tests/DialTest.java
@@ -124,7 +124,7 @@
public void testDeleteDialedNumber() {
mDialerHelper.get().dialANumber(mSmallPhoneNumber.get());
mDialerHelper.get().deleteDialedNumber();
- String numberAfterDelete = mDialerHelper.get().getDialInNumber();
+ String numberAfterDelete = mDialerHelper.get().getNumberInDialPad();
assertTrue(DIAL_A_NUMBER.equals(numberAfterDelete));
}
diff --git a/tests/automotive/mobly_tests/dialer/Android.bp b/tests/automotive/mobly_tests/dialer/Android.bp
index 9af1d6d..0f558b8 100644
--- a/tests/automotive/mobly_tests/dialer/Android.bp
+++ b/tests/automotive/mobly_tests/dialer/Android.bp
@@ -481,6 +481,34 @@
main: "dialer_test_search_contacts_and_call.py",
srcs: ["dialer_test_search_contacts_and_call.py"],
libs: [
+ "mobly",
+ "utilities",
+ "bluetooth_test"
+ ],
+ test_suites: [
+ "catbox",
+ ],
+ test_options: {
+ unit_test: false,
+ },
+ data: [
+ // Package the snippet with the mobly test
+ ":AutomotiveSnippet",
+ ":PhoneSnippet",
+ ],
+ version: {
+ py3: {
+ embedded_launcher: true,
+ },
+ },
+}
+
+python_test_host {
+ name: "BTDialerPageRefresh",
+ main: "dialer_test_page_refresh.py",
+ srcs: ["dialer_test_page_refresh.py"],
+
+ libs: [
"mobly",
"utilities",
"bluetooth_test"
diff --git a/tests/automotive/mobly_tests/dialer/dialer_test_page_refresh.py b/tests/automotive/mobly_tests/dialer/dialer_test_page_refresh.py
new file mode 100644
index 0000000..9427c61
--- /dev/null
+++ b/tests/automotive/mobly_tests/dialer/dialer_test_page_refresh.py
@@ -0,0 +1,69 @@
+# Copyright (C) 2023 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+"""
+
+Test steps:
+1 Tap on Phone icon from facet rail or App launcher to launch Dialer app
+2. Go to Dialpad and enter some number or go to Search and type any contact name
+3. Go to Settings > More > Bluetooth and disconnect the paired mobile device
+4. Tap on listed paired device and reconnect the BT connection
+5. Go to dialer app again and verify that its refreshed and earlier typed phone number or contact name is not showing
+"""
+
+from bluetooth_test import bluetooth_base_test
+import logging
+from mobly import asserts
+from utilities import constants
+from utilities.main_utils import common_main
+
+
+class DialerPageRefresh(bluetooth_base_test.BluetoothBaseTest):
+
+
+
+ def setup_test(self):
+ # Pair the devices
+ self.bt_utils.pair_primary_to_secondary()
+
+ def test_dialer_page_refresh(self):
+
+ test_number = constants.DIALER_THREE_DIGIT_NUMBER
+
+ # Launcher the dialer app and input a number into the dial pad
+ self.call_utils.open_phone_app()
+ self.call_utils.dial_a_number(test_number)
+
+ # Navigate to the bluetooth settings
+ self.discoverer.mbs.pressHome()
+ self.call_utils.open_bluetooth_settings()
+
+ # Disconnect and reconnect the device's bluetooth
+ self.call_utils.press_bluetooth_toggle_on_device(self.target.mbs.btGetName())
+ self.call_utils.wait_with_log(constants.BT_DEFAULT_TIMEOUT)
+ self.call_utils.press_bluetooth_toggle_on_device(self.target.mbs.btGetName())
+
+ # Navigate back to the dial pad and confirm that there is no entered number
+ self.discoverer.mbs.pressHome()
+ self.call_utils.open_phone_app()
+ self.discoverer.mbs.openDialPad()
+ stored_number = self.discoverer.mbs.getNumberInDialPad()
+
+ asserts.assert_true(stored_number == constants.DEFAULT_DIAL_PAD_ENTRY,
+ "Expected \'%s\' in dial pad after reconnection, but found %s"
+ % (constants.DEFAULT_DIAL_PAD_ENTRY,
+ str(stored_number)))
+
+
+if __name__ == '__main__':
+ common_main()
\ No newline at end of file
diff --git a/tests/automotive/mobly_tests/utilities/constants.py b/tests/automotive/mobly_tests/utilities/constants.py
index f999218..a29bbc2 100644
--- a/tests/automotive/mobly_tests/utilities/constants.py
+++ b/tests/automotive/mobly_tests/utilities/constants.py
@@ -35,7 +35,7 @@
EXPECTED_PHONE_NUMBER = "611"
ROOT = "root"
DATE_CMD = "date"
-
+DEFAULT_DIAL_PAD_ENTRY = "Dial a number"
# The word or phrase present in a device summary that is connected.
CONNECTED_SUMMARY_STATUS = "Connected"
DISCONNECTED_SUMMARY_STATUS = "Disconnected"
diff --git a/tests/automotive/mobly_tests/utilities/spectatio_utils.py b/tests/automotive/mobly_tests/utilities/spectatio_utils.py
index cadb268..6a8a721 100644
--- a/tests/automotive/mobly_tests/utilities/spectatio_utils.py
+++ b/tests/automotive/mobly_tests/utilities/spectatio_utils.py
@@ -101,6 +101,11 @@
logging.info("Opening contacts")
self.device.mbs.openContacts()
+ def open_dialpad(self):
+ """Open the dial pad from the dialer main screen"""
+ logging.info("Opening the dialpad")
+ self.device.mbs.openDialPad()
+
def open_phone_app(self):
logging.info("Opening phone app")
self.device.mbs.openPhoneApp()
@@ -549,7 +554,7 @@
return self.device.mbs.isBluetoothMediaButtonEnabled()
def get_dial_in_number(self):
- return self.device.mbs.getDialInNumber()
+ return self.device.mbs.getNumberInDialPad()
# Verify dialed number on Dial Pad the same as expected
def verify_dialed_number_on_dial_pad(self, expected_dialed_number):
diff --git a/tests/automotive/snippets/phone/src/com/google/android/mobly/snippet/bundled/DialerSnippet.java b/tests/automotive/snippets/phone/src/com/google/android/mobly/snippet/bundled/DialerSnippet.java
index 3b1e211..18a5865 100644
--- a/tests/automotive/snippets/phone/src/com/google/android/mobly/snippet/bundled/DialerSnippet.java
+++ b/tests/automotive/snippets/phone/src/com/google/android/mobly/snippet/bundled/DialerSnippet.java
@@ -40,6 +40,12 @@
mDialerHelper.get().open();
}
+ /** Opens the dial pad from the dialer main screen. */
+ @Rpc(description = "Open Dial Pad.")
+ public void openDialPad() {
+ mDialerHelper.get().openDialPad();
+ }
+
@Rpc(description = "Open Dial Pad and dial in a number using keypad.")
public void dialANumber(String phoneNumber) {
mDialerHelper.get().dialANumber(phoneNumber);
@@ -81,8 +87,8 @@
}
@Rpc(description = "Get the entered on dial pad.")
- public String getDialInNumber() {
- return mDialerHelper.get().getDialInNumber();
+ public String getNumberInDialPad() {
+ return mDialerHelper.get().getNumberInDialPad();
}
@Rpc(description = "Get the home address from an open contacts page.")