BT tests fix for CF auto
Keep only one default command to launch BluetoothMediaBrowserService.
Different command for CF auto will be a runtime config override.
Add bugreport for BT tests.
Check availability of cancel button before attempt to click it.
Input phone number with '+' on auto
Enable video recording for phone_notpaired
Add 2 CF timezones to dict
Launch dialer app on phone using adb command instead of UI click since dialer app doesn't have "Phone" label on CF
Fix a few typo and missing refactor
Bug: 418063595
Test: https://paste.googleplex.com/6385208062115840
Test: https://paste.googleplex.com/6230131674447872
Test: https://paste.googleplex.com/5717278924210176
Test: https://paste.googleplex.com/6423764402962432
Change-Id: I5f9dac651859da7fd66c1169c2d92e380e917c06
diff --git a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaHelper.java b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaHelper.java
index 2fab6d2..e505010 100644
--- a/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaHelper.java
+++ b/libraries/app-helpers/interfaces/auto/src/android/platform/helpers/IAutoMediaHelper.java
@@ -231,6 +231,13 @@
boolean isConnectToBluetoothLabelVisible();
/**
+ * Setup expectations: Bluetooth Audio page opened.
+ *
+ * <p>This method returns whether cancel button visible or not.
+ */
+ boolean isCancelButtonVisible();
+
+ /**
* Setup expectations: on home screen.
*
* <p>This method is used to open Bluetooth Audio screen.
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 5325d6f..ea3ab03 100644
--- a/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json
+++ b/libraries/automotive-helpers/auto-default-config/resources/assets/defaultSpectatioConfig.json
@@ -72,7 +72,6 @@
"OPEN_NOTIFICATIONS_COMMAND": "service call statusbar 1",
"STOP_SETTING_APP_COMMAND": "am force-stop com.android.car.settings",
"OPEN_SETTINGS_COMMAND": "am start --user $user_id -a android.settings.SETTINGS",
- "MEDIA_LAUNCH_COMMAND": "am start --user $user_id -a android.car.intent.action.MEDIA_TEMPLATE -e android.car.intent.extra.MEDIA_COMPONENT com.android.bluetooth/com.android.bluetooth.avrcpcontroller.BluetoothMediaBrowserService",
"MEDIA_LAUNCH_BLUETOOTH_AUDIO_COMMAND": "am start -a android.car.intent.action.MEDIA_TEMPLATE -e android.car.intent.extra.MEDIA_COMPONENT com.google.android.bluetooth/com.android.bluetooth.avrcpcontroller.BluetoothMediaBrowserService",
"NIGHT_MODE_COMMAND": "dumpsys activity service com.android.car/.CarService day-night-mode night",
"DAY_MODE_COMMAND": "dumpsys activity service com.android.car/.CarService day-night-mode day",
@@ -117,6 +116,11 @@
"TYPE": "CLASS",
"VALUE": "android.widget.EditText"
},
+ "MOBILE_DIALPAD_TITLE_INPUT": {
+ "TYPE": "RESOURCE_ID",
+ "VALUE": "title",
+ "PACKAGE": "com.android.car.dialer"
+ },
"END_CALL": {
"TYPE": "RESOURCE_ID",
"VALUE": "end_call_button",
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 3bed7dc..055ccb0 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
@@ -310,7 +310,6 @@
// Media Center
public static final String MEDIA_CENTER_PACKAGE = "MEDIA_CENTER_PACKAGE";
- public static final String MEDIA_LAUNCH_COMMAND = "MEDIA_LAUNCH_COMMAND";
// Media Center Screen
public static final String PLAY_PAUSE_BUTTON = "PLAY_PAUSE_BUTTON";
public static final String MEDIA_SONGS_LIST = "MEDIA_SONGS_LIST";
@@ -724,6 +723,7 @@
public static final String MOBILE_PHONE_ICON = "MOBILE_PHONE_ICON";
public static final String PHONE_DEVICE_PACKAGE = "PHONE_DEVICE_PACAKAGE";
public static final String MOBILE_DIALPAD_INPUT = "MOBILE_DIALPAD_INPUT";
+ public static final String MOBILE_DIALPAD_TITLE_INPUT = "MOBILE_DIALPAD_TITLE_INPUT";
// Phone Card Identifiers
public static final String PHONE_CARD_DIALER_BUTTON = "PHONE_CARD_DIALER_BUTTON";
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 0dc37b6..3d64127 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
@@ -175,7 +175,7 @@
/** {@inheritDoc} */
public void dialANumber(String phoneNumber) {
- enterNumber(phoneNumber);
+ enterNumberOnDialpad(phoneNumber);
getSpectatioUiUtil().wait1Second();
}
@@ -787,6 +787,10 @@
getSpectatioUiUtil().validateUiObject(dialPad, AutomotiveConfigConstants.DIAL_PAD_FRAGMENT);
char[] array = phoneNumber.toCharArray();
for (char ch : array) {
+ boolean shouldLongPressZero = ch == '+';
+ if (shouldLongPressZero) {
+ ch = '0';
+ }
UiObject2 numberButton =
getSpectatioUiUtil()
.findUiObject(getUiElementFromConfig(Character.toString(ch)));
@@ -796,10 +800,44 @@
getSpectatioUiUtil()
.validateUiObject(
numberButton, String.format("Number %s", Character.toString(ch)));
- getSpectatioUiUtil().clickAndWait(numberButton);
+ if (shouldLongPressZero) {
+ getSpectatioUiUtil().longPress(numberButton);
+ } else {
+ getSpectatioUiUtil().clickAndWait(numberButton);
+ }
}
}
+ /**
+ * This method is used to enter phonenumber from the on-screen number input text field
+ *
+ * @param phoneNumber number to be dialed
+ */
+ private void enterNumberOnDialpad(String phoneNumber) {
+ if (phoneNumber == null || phoneNumber.trim().isEmpty()) {
+ throw new IllegalArgumentException("No phone number provided");
+ }
+ getSpectatioUiUtil().pressHome();
+ getSpectatioUiUtil().wait1Second();
+ getSpectatioUiUtil()
+ .executeShellCommand(
+ getCommandFromConfig(AutomotiveConfigConstants.OPEN_DIAL_PAD_COMMAND));
+ BySelector dialPadMenuSelector =
+ getUiElementFromConfig(AutomotiveConfigConstants.DIAL_PAD_MENU);
+ UiObject2 dialMenuButton = getSpectatioUiUtil().findUiObject(dialPadMenuSelector);
+ getSpectatioUiUtil()
+ .validateUiObject(dialMenuButton, AutomotiveConfigConstants.DIAL_PAD_MENU);
+ getSpectatioUiUtil().clickAndWait(dialMenuButton);
+ getSpectatioUiUtil().wait1Second();
+ BySelector dialPadInputSelector =
+ getUiElementFromConfig(AutomotiveConfigConstants.MOBILE_DIALPAD_TITLE_INPUT);
+ UiObject2 dialPadInput = getSpectatioUiUtil().findUiObject(dialPadInputSelector);
+ getSpectatioUiUtil()
+ .validateUiObject(
+ dialPadInput, AutomotiveConfigConstants.MOBILE_DIALPAD_TITLE_INPUT);
+ dialPadInput.setText(phoneNumber);
+ }
+
/** This method is used check if ongoing call is displayed on home. */
public boolean isOngoingCallDisplayedOnHome() {
getSpectatioUiUtil().wait5Seconds();
diff --git a/libraries/automotive-helpers/media-center-app-helper/src/android/platform/helpers/MediaCenterHelperImpl.java b/libraries/automotive-helpers/media-center-app-helper/src/android/platform/helpers/MediaCenterHelperImpl.java
index 7323061..abbef36 100644
--- a/libraries/automotive-helpers/media-center-app-helper/src/android/platform/helpers/MediaCenterHelperImpl.java
+++ b/libraries/automotive-helpers/media-center-app-helper/src/android/platform/helpers/MediaCenterHelperImpl.java
@@ -137,7 +137,8 @@
getSpectatioUiUtil().waitForIdle();
getSpectatioUiUtil()
.executeShellCommand(
- getCommandFromConfig(AutomotiveConfigConstants.MEDIA_LAUNCH_COMMAND));
+ getCommandFromConfig(
+ AutomotiveConfigConstants.MEDIA_LAUNCH_BLUETOOTH_AUDIO_COMMAND));
}
/**
@@ -584,6 +585,14 @@
return getSpectatioUiUtil().hasUiElement(connectToBluetoothLabel);
}
+ /** {@inheritDoc} */
+ @Override
+ public boolean isCancelButtonVisible() {
+ BySelector cancelBluetoothAudioConncetionButton =
+ getUiElementFromConfig(AutomotiveConfigConstants.CANCEL_BT_AUDIO_CONNECTION_BUTTON);
+ return getSpectatioUiUtil().hasUiElement(cancelBluetoothAudioConncetionButton);
+ }
+
private UiObject2 scrollAndFindApp(BySelector selector) {
UiObject2 object =
diff --git a/tests/automotive/mobly_tests/bluetooth_base_test.py b/tests/automotive/mobly_tests/bluetooth_base_test.py
index 4bcf4ce..3438339 100644
--- a/tests/automotive/mobly_tests/bluetooth_base_test.py
+++ b/tests/automotive/mobly_tests/bluetooth_base_test.py
@@ -60,6 +60,7 @@
self.discoverer.mbs.btEnable()
def teardown_test(self):
+ android_device.take_bug_reports(self.ads, destination=self.log_path)
# Turn Bluetooth off on both devices.
logging.info("Running basic test teardown.")
self.call_utils.press_home()
diff --git a/tests/automotive/mobly_tests/bluetooth_sms_base_test.py b/tests/automotive/mobly_tests/bluetooth_sms_base_test.py
index 906828b..b4854ad 100644
--- a/tests/automotive/mobly_tests/bluetooth_sms_base_test.py
+++ b/tests/automotive/mobly_tests/bluetooth_sms_base_test.py
@@ -49,17 +49,28 @@
self.target,
self.__class__.__name__,
)
-
- logging.info('Enabling video recording for Discoverer device')
- self.video_utils_service.enable_screen_recording()
-
- logging.info('Enabling video recording for Target device')
- self.video_utils_service_target.enable_screen_recording()
-
+ self.video_utils_service_phone_notpaired = VideoRecording(
+ self.phone_notpaired,
+ self.__class__.__name__,
+ )
self.call_utils.press_phone_home_icon_using_adb_command(
self.phone_notpaired
)
+ def hu_recording_handler(self):
+ super().hu_recording_handler()
+ logging.info("Stopping the screen recording on phone_notpaired")
+ self.video_utils_service_phone_notpaired.stop_screen_recording()
+ logging.info("Pull the screen recording from phone_notpaired")
+ self.video_utils_service_phone_notpaired.pull_recording_file(self.log_path)
+ logging.info("delete the screen recording from phone_notpaired")
+ self.video_utils_service_phone_notpaired.delete_screen_recording_from_device()
+
+ def enable_recording(self):
+ super().enable_recording()
+ logging.info("Enabling video recording for phone_notpaired")
+ self.video_utils_service_phone_notpaired.enable_screen_recording()
+ logging.info("Video recording started on phone_notpaired")
if __name__ == '__main__':
common_main()
diff --git a/tests/automotive/mobly_tests/dialer/dialer_test_basic_calling_test_with_reject_call.py b/tests/automotive/mobly_tests/dialer/dialer_test_basic_calling_test_with_reject_call.py
index 477a367..4128740 100644
--- a/tests/automotive/mobly_tests/dialer/dialer_test_basic_calling_test_with_reject_call.py
+++ b/tests/automotive/mobly_tests/dialer/dialer_test_basic_calling_test_with_reject_call.py
@@ -38,14 +38,14 @@
super().enable_recording()
def test_basic_call(self):
- # call the callee phone with automotive device
- target_phone_number = self.phone_notpaired.mbs.getPhoneNumber()
+ # call the callee phone with automotive device
+ phone_notpaired_number = self.phone_notpaired.mbs.getPhoneNumber()
logging.info(
'Calling from %s calling to %s',
- self.phone_notpaired.serial,
self.target.serial,
+ self.phone_notpaired.serial,
)
- self.call_utils.dial_a_number(target_phone_number);
+ self.call_utils.dial_a_number(phone_notpaired_number)
self.call_utils.make_call()
self.call_utils.wait_with_log(5)
self.call_utils.end_call()
diff --git a/tests/automotive/mobly_tests/media/media_test_stream_when_radio_lunched.py b/tests/automotive/mobly_tests/media/media_test_stream_when_radio_lunched.py
index 3423cf4..286aad1 100644
--- a/tests/automotive/mobly_tests/media/media_test_stream_when_radio_lunched.py
+++ b/tests/automotive/mobly_tests/media/media_test_stream_when_radio_lunched.py
@@ -45,7 +45,7 @@
'<' + constants.RADIO_APP + '> has to be present on HU screen')
self.media_utils.open_radio_app()
self.media_utils.tune_fm_radio_on_hu(constants.DEFAULT_FM_FREQUENCY)
-# self.bt_utils.pair_primary_to_secondary()
+ self.bt_utils.pair_primary_to_secondary()
self.media_utils.open_media_app_on_hu()
current_phone_song_title = self.media_utils.get_song_title_from_phone()
current_hu_song_title = self.media_utils.get_song_title_from_hu()
diff --git a/tests/automotive/mobly_tests/media/media_test_synchronized_device_disconnected_connected.py b/tests/automotive/mobly_tests/media/media_test_synchronized_device_disconnected_connected.py
index 7981f62..1350ce3 100644
--- a/tests/automotive/mobly_tests/media/media_test_synchronized_device_disconnected_connected.py
+++ b/tests/automotive/mobly_tests/media/media_test_synchronized_device_disconnected_connected.py
@@ -60,7 +60,7 @@
self.call_utils.wait_with_log(5)
# Assert <Bluetooth Audio disconnected> label is NOT present
asserts.assert_false(self.call_utils.is_bluetooth_audio_disconnected_label_visible(),
- '<Bluetooth Audio disconnected> label should be present')
+ '<Bluetooth Audio disconnected> label should not be present')
# Assert song title same on both devices after reconnect
current_next_phone_song_title = self.media_utils.get_song_title_from_phone()
current_next_hu_song_title = self.media_utils.get_song_title_from_hu()
diff --git a/tests/automotive/mobly_tests/utilities/constants.py b/tests/automotive/mobly_tests/utilities/constants.py
index 3c5ee97..507af95 100644
--- a/tests/automotive/mobly_tests/utilities/constants.py
+++ b/tests/automotive/mobly_tests/utilities/constants.py
@@ -153,7 +153,9 @@
"PST": "Pacific Standard Time",
"PDT": "Pacific Daylight Time",
"EST": "Eastern Standard Time",
- "EDT": "Eastern Daylight Time"
+ "EDT": "Eastern Daylight Time",
+ "GMT": "Greenwich Mean Time",
+ "UTC": "Coordinated Universal Time"
}
CLEAR_MESSAGING_APP = 'pm clear com.google.android.apps.messaging'
DELETE_MESSAGING_DB = 'rm /data/data/com.android.providers.telephony/databases/mmssms.db'
@@ -165,6 +167,7 @@
DIALER_CONTACTS_LABEL = "Contacts"
DIALER_FAVORITES_LABEL = "Favorites"
DIALER_DIALPAD_LABEL = "Dialpad"
+START_DIALER_SHELL = 'am start -a android.intent.action.DIAL'
# Bluetooth Logs
BLUETOOTH_TAG="setprop persist.log.tag.bluetooth verbose"
diff --git a/tests/automotive/mobly_tests/utilities/phone_device_utils.py b/tests/automotive/mobly_tests/utilities/phone_device_utils.py
index 3909b1c..9d94ad7 100644
--- a/tests/automotive/mobly_tests/utilities/phone_device_utils.py
+++ b/tests/automotive/mobly_tests/utilities/phone_device_utils.py
@@ -29,9 +29,8 @@
self.phone_device = phone_device
def call_number_from_home_screen(self, number):
- """Assumes the phone is on its home screen.
- Opens the phone app, then dial pad, enters the given number, and starts a call"""
- self.phone_device.mbs.pressPhoneIcon()
+ """Opens the phone app, then dial pad, enters the given number, and starts a call"""
+ self.phone_device.adb.shell(constants.START_DIALER_SHELL)
logging.info("Close the video call popup on Phone")
self.phone_device.mbs.clickUIElementWithText(constants.NOT_NOW_TEXT)
isDialPadOpen = self.phone_device.mbs.isDialPadOpen()
diff --git a/tests/automotive/mobly_tests/utilities/spectatio_utils.py b/tests/automotive/mobly_tests/utilities/spectatio_utils.py
index 8b997c1..7fa79f4 100644
--- a/tests/automotive/mobly_tests/utilities/spectatio_utils.py
+++ b/tests/automotive/mobly_tests/utilities/spectatio_utils.py
@@ -369,10 +369,17 @@
def is_connect_to_bluetooth_label_visible_on_bluetooth_audio_page(self):
"""Return is <Connect to Bluetooth> label present """
logging.info('Checking is <Connect to Bluetooth> label present')
- actual_status = self.device.mbs.isBluetoothAudioDisconnectedLabelVisible()
+ actual_status = self.device.mbs.isConnectToBluetoothLabelVisible()
logging.info('<Connect to Bluetooth> label is present: %s',actual_status)
return actual_status
+ def is_cancel_button_visible_on_bluetooth_audio_page(self):
+ """Return is <Cancel> button present """
+ logging.info('Checking is <Cancel> button present')
+ actual_status = self.device.mbs.isCancelButtonVisible()
+ logging.info('<Cancel> button is present: %s',actual_status)
+ return actual_status
+
def click_cancel_label_visible_on_bluetooth_audio_page(self):
"""Clicks on <Cancel> label present on bluetooth Audio page"""
self.device.mbs.cancelBluetoothAudioConncetion()
@@ -383,7 +390,8 @@
logging.info('Adding wait to check the Bluetooth Audio popup')
time.sleep(constants.DEFAULT_WAIT_TIME_FIVE_SECS)
is_bluetooth_media_popup_present = self.is_connect_to_bluetooth_label_visible_on_bluetooth_audio_page()
- if is_bluetooth_media_popup_present:
+ is_cancel_button_visible = self.is_cancel_button_visible_on_bluetooth_audio_page()
+ if is_bluetooth_media_popup_present and is_cancel_button_visible:
logging.info('BT Audio popup present, cancelling that.')
self.click_cancel_label_visible_on_bluetooth_audio_page()
diff --git a/tests/automotive/mobly_tests/uxrestriction/uxrestriction_test_play_message_while_driving.py b/tests/automotive/mobly_tests/uxrestriction/uxrestriction_test_play_message_while_driving.py
index a25e499..710edd0 100644
--- a/tests/automotive/mobly_tests/uxrestriction/uxrestriction_test_play_message_while_driving.py
+++ b/tests/automotive/mobly_tests/uxrestriction/uxrestriction_test_play_message_while_driving.py
@@ -55,7 +55,7 @@
self.call_utils.open_sms_app()
# Verify that there is no new sms currently
- self.call_utils.verify_sms_app_unread_message(False)
+ self.call_utils.verify_sms_app_unread_message()
# Send a new sms
target_phone_number = self.target.mbs.getPhoneNumber()
@@ -63,8 +63,8 @@
self.call_utils.wait_with_log(constants.BT_DEFAULT_TIMEOUT)
# Perform the verifications
- self.call_utils.verify_sms_app_unread_message(True)
- self.call_utils.verify_sms_preview_timestamp(True)
+ self.call_utils.verify_sms_app_unread_message()
+ self.call_utils.verify_sms_preview_timestamp()
# Tap on Received Text message to read it aloud
self.call_utils.tap_to_read_aloud()
diff --git a/tests/automotive/mobly_tests/uxrestriction/uxrestriction_test_sms_db_sync.py b/tests/automotive/mobly_tests/uxrestriction/uxrestriction_test_sms_db_sync.py
index 289041d..b793a3e 100644
--- a/tests/automotive/mobly_tests/uxrestriction/uxrestriction_test_sms_db_sync.py
+++ b/tests/automotive/mobly_tests/uxrestriction/uxrestriction_test_sms_db_sync.py
@@ -65,8 +65,8 @@
self.call_utils.open_sms_app()
# Perform the verifications
- self.call_utils.verify_sms_app_unread_message(True)
- self.call_utils.verify_sms_preview_timestamp(True)
+ self.call_utils.verify_sms_app_unread_message()
+ self.call_utils.verify_sms_preview_timestamp()
self.call_utils.verify_sms_preview_text(True, constants.SMS_TEXT_DRIVE_MODE)
# Disable driving mode
diff --git a/tests/automotive/snippets/phone/src/com/google/android/mobly/snippet/bundled/MediaPlayerSnippet.java b/tests/automotive/snippets/phone/src/com/google/android/mobly/snippet/bundled/MediaPlayerSnippet.java
index 7b3d63d..75eb32a 100644
--- a/tests/automotive/snippets/phone/src/com/google/android/mobly/snippet/bundled/MediaPlayerSnippet.java
+++ b/tests/automotive/snippets/phone/src/com/google/android/mobly/snippet/bundled/MediaPlayerSnippet.java
@@ -93,6 +93,11 @@
return mAutoMediaHelper.get().isConnectToBluetoothLabelVisible();
}
+ @Rpc(description = "Is Cancel button present")
+ public boolean isCancelButtonVisible() {
+ return mAutoMediaHelper.get().isCancelButtonVisible();
+ }
+
@Rpc(description = "Open Bluetooth Audio app")
public void openBluetoothMediaApp() {
mAutoMediaHelper.get().openBluetoothMediaApp();