1.0.5-rc.0
PiperOrigin-RevId: 755145813
diff --git a/README.md b/README.md
index ca887fc..bcba18f 100644
--- a/README.md
+++ b/README.md
@@ -8,8 +8,8 @@
#### Python 3
-You need a python 3 environment to run the script.
-Google Home UI Automator requires python 3.11 or newer.
+You need a python 3 environment to run the script. Google Home UI Automator
+requires python 3.11 or newer.
#### Android phone
@@ -20,7 +20,8 @@
1. You need to install Google Home App on your Android phone.
1. Login to your Google Home App.
-1. Make sure the Google Home App's version is between `3.1.1.14` and `3.25.1.4`.
+1. Make sure the Google Home App's version is between `3.1.1.14` and
+ `3.25.1.4`.
NOTE: Please select the correct Google account on Google Home App.
@@ -29,17 +30,21 @@
### Installation
#### PyPI (recommended)
+
```shell
$ pip install google-home-ui-automator
```
#### Build from source code
+
1. clone this repo.
```shell
$ git clone https://testsuite-smarthome-matter.googlesource.com/ui-automator
```
+
2. `cd` to the folder.
+
3. Run `pip install .`
## Usage
@@ -49,44 +54,55 @@
Follow the steps below to automatically commission a matter device.
```shell
-$ ui-automator --commission DEVICE_NAME,PAIRING_CODE,ROOM_NAME
+$ ui-automator --commission DEVICE_NAME,PAIRING_CODE,ROOM_NAME [--google_account <GOOGLE_ACCOUNT>]
```
+
* `DEVICE_NAME`: desired Matter device, e.g. `m5stack`
* `PAIRING_CODE`: pairing code of your Matter device, e.g. `34970112332`
* `ROOM_NAME`: room that is going to be assigned, e.g. `Office`
+* `GOOGLE_ACCOUNT`: Optional. Account to use in Google Home App, e.g.
+ `test@gmail.com`
### Decommissioning Matter device
Follow the steps below to decommission a matter device.
```shell
-$ ui-automator --decommission DEVICE_NAME
+$ ui-automator --decommission DEVICE_NAME [--google_account <GOOGLE_ACCOUNT>]
```
-* `DEVICE_NAME`: display name of commissioned Matter device on GHA, e.g. `m5stack`
+
+* `DEVICE_NAME`: display name of commissioned Matter device on GHA, e.g.
+ `m5stack`
+* `GOOGLE_ACCOUNT`: Optional. Account to use in Google Home App, e.g.
+ `test@gmail.com`
### Regression Test
Follow the steps below to run a regression test.
```shell
-$ ui-automator --commission DEVICE_NAME,PAIRING_CODE,ROOM_NAME --regtest [--repeat <REPEAT_TIMES>] [--hub <HUB_VERSION>] [--dut <MODEL>,<TYPE>,<PROTOCOL>] [--fw <DEVICE_FIRMWARE>]
+$ ui-automator --commission DEVICE_NAME,PAIRING_CODE,ROOM_NAME --regtest [--repeat <REPEAT_TIMES>] [--hub <HUB_VERSION>] [--dut <MODEL>,<TYPE>,<PROTOCOL>] [--fw <DEVICE_FIRMWARE>] [--google_account <GOOGLE_ACCOUNT>]
```
-* flag `--regtest` is required
-* regression test need to be used with flag `--commission`
-* regression test now only supports commissioning/decommissioning cycle
-* defaultly, regression test will run until users use keyboard interrupt to
- stop the process
-* optionally add `--repeat` to run regression test in limited times
- * `REPEAT_TIMES`: repeated times for regression test
-* optionally add `--hub` to include hub version in produced test report
- * `HUB_VERSION`: version of hub for controlling devices on GHA
-* optionally add `--dut` to include device under test in produced test report
+* `DEVICE_NAME`: desired Matter device, e.g. `m5stack`
+* `PAIRING_CODE`: pairing code of your Matter device, e.g. `34970112332`
+* `ROOM_NAME`: room that is going to be assigned, e.g. `Office`
+* `--repeat`: Optional. Specifies the number of times to repeat the regression
+ test.
+ * `REPEAT_TIMES`: Number of times to repeat the regression test, e.g.,
+ `10`.
+* `--hub`: Optional. Includes the hub version in the test report.
+ * `HUB_VERSION`: Version of the hub controlling the devices in GHA, e.g.,
+ `1.0.0`
+* `--dut`: Optional. Includes the device under test information in the test
+ report.
* `MODEL`: Model of the device. e.g. `X123123`
* `TYPE`: Type of the device. e.g. `LIGHT`
- * `PROTOCOL`: Used protocol of the device. e.g. `MATTER`
-* optionally add `--fw` to include device firmware in produced test report
+ * `PROTOCOL`: Protocol used by the device. e.g. `MATTER`
+* `--fw`: Optional. Includes the device firmware in the test report.
* `DEVICE_FIRMWARE`: Firmware of test device.
+* `GOOGLE_ACCOUNT`: Optional. Account to use in Google Home App, e.g.
+ `test@gmail.com`
## Roadmap
@@ -111,6 +127,6 @@
## Disclaimer
-This project is not an official Google project. It is not supported by
-Google and Google specifically disclaims all warranties as to its quality,
+This project is not an official Google project. It is not supported by Google
+and Google specifically disclaims all warranties as to its quality,
merchantability, or fitness for a particular purpose.
diff --git a/ui_automator/android/app/snippet.apk b/ui_automator/android/app/snippet.apk
index 74e4c13..656b663 100644
--- a/ui_automator/android/app/snippet.apk
+++ b/ui_automator/android/app/snippet.apk
Binary files differ
diff --git a/ui_automator/ui_automator.py b/ui_automator/ui_automator.py
index 74698f0..8402af3 100644
--- a/ui_automator/ui_automator.py
+++ b/ui_automator/ui_automator.py
@@ -116,6 +116,14 @@
_THIRD_PARTY_LICENSE_FILE_PATH = os.path.join(
os.path.dirname(__file__), 'THIRD_PARTY_NOTICES.txt'
)
+_GOOGLE_ACCOUNT = flags.DEFINE_string(
+ name='google_account',
+ default=None,
+ help=(
+ 'Use --google_account {GOOGLE_ACCOUNT} to specify the GHA account to'
+ ' use.'
+ ),
+)
_NO_DEVICE_CONNECTED_ERROR_MESSAGE = (
'No Android device connected to the host computer.'
)
@@ -332,7 +340,7 @@
try:
self._connected_device.mbs.commissionDevice(
- _GOOGLE_HOME_APP, matter_device
+ _GOOGLE_HOME_APP, matter_device, _GOOGLE_ACCOUNT.value
)
self._logger.info('Successfully commission the device on GHA.')
# TODO(google-home-testsuite-dev+ui-automator): Narrow exception type.
@@ -362,7 +370,9 @@
self._logger.info('Start removing the device.')
try:
- self._connected_device.mbs.removeDevice(device_name)
+ self._connected_device.mbs.removeDevice(
+ device_name, _GOOGLE_ACCOUNT.value
+ )
self._logger.info('Successfully remove the device on GHA.')
# TODO(google-home-testsuite-dev+ui-automator): Narrow exception type.
except Exception as e:
@@ -386,7 +396,9 @@
True if the device exists on GHA.
"""
try:
- return self._connected_device.mbs.isDeviceExist(device_name)
+ return self._connected_device.mbs.isDeviceExist(
+ device_name, _GOOGLE_ACCOUNT.value
+ )
except Exception as e:
raise errors.MoblySnippetError(
f'Unable to check if {device_name} exists on GHA'
diff --git a/ui_automator/ui_automator_test.py b/ui_automator/ui_automator_test.py
index 8c27e91..5663b10 100644
--- a/ui_automator/ui_automator_test.py
+++ b/ui_automator/ui_automator_test.py
@@ -83,6 +83,7 @@
]
_FAKE_PROJECT_FOLDER = '/path/to/'
_EXPECTED_APK_PATH = f'{_FAKE_PROJECT_FOLDER}android/app/snippet.apk'
+_FAKE_GOOGLE_ACCOUNT = 'fake_google_account'
class UIAutomatorTest(unittest.TestCase):
@@ -473,14 +474,17 @@
'roomName': _FAKE_GHA_ROOM,
}
- self.ui_automator.commission_device(
- _FAKE_MATTER_DEVICE_NAME,
- _FAKE_PAIRING_CODE,
- _FAKE_GHA_ROOM,
- )
+ with flagsaver.as_parsed(
+ (ui_automator._GOOGLE_ACCOUNT, _FAKE_GOOGLE_ACCOUNT)
+ ):
+ self.ui_automator.commission_device(
+ _FAKE_MATTER_DEVICE_NAME,
+ _FAKE_PAIRING_CODE,
+ _FAKE_GHA_ROOM,
+ )
self.mock_android_device.mbs.commissionDevice.assert_called_once_with(
- _GOOGLE_HOME_APP, expected_matter_device
+ _GOOGLE_HOME_APP, expected_matter_device, _FAKE_GOOGLE_ACCOUNT
)
@mock.patch.object(android_device, 'get_all_instances', autospec=True)
@@ -664,6 +668,7 @@
self.assertIn(expected_error_message, str(exc.exception))
+ @flagsaver.flagsaver((ui_automator._GOOGLE_ACCOUNT, _FAKE_GOOGLE_ACCOUNT))
@mock.patch.object(android_device, 'get_all_instances', autospec=True)
def test_decommission_device_successfully_removes_a_device(
self, mock_get_all_instances
@@ -674,7 +679,7 @@
self.ui_automator.decommission_device(_FAKE_MATTER_DEVICE_NAME)
self.mock_android_device.mbs.removeDevice.assert_called_once_with(
- _FAKE_MATTER_DEVICE_NAME
+ _FAKE_MATTER_DEVICE_NAME, _FAKE_GOOGLE_ACCOUNT
)
self.assertEqual(
cm.output[2], 'INFO:root:Successfully remove the device on GHA.'
@@ -1021,7 +1026,10 @@
'run_time': 1,
'start_time': re.escape(unit_test_utils.iso_timestamp(0)),
'test_name': 'test_commission',
- 'class_name': 'google3.java.com.google.assistant.verticals.homeautomation.partners.ui_automator.commission_reg_test.CommissionRegTest',
+ 'class_name': (
+ 'google3.java.com.google.assistant.verticals.homeautomation.'
+ 'partners.ui_automator.commission_reg_test.CommissionRegTest'
+ ),
'status': 'run',
'result': 'FAIL',
'message': xml_reporter._escape_xml_attr(str(err[1])),
@@ -1032,7 +1040,10 @@
'run_time': 1,
'start_time': re.escape(unit_test_utils.iso_timestamp(2)),
'test_name': 'test_decommission',
- 'class_name': 'google3.java.com.google.assistant.verticals.homeautomation.partners.ui_automator.commission_reg_test.CommissionRegTest',
+ 'class_name': (
+ 'google3.java.com.google.assistant.verticals.homeautomation.'
+ 'partners.ui_automator.commission_reg_test.CommissionRegTest'
+ ),
'status': 'notrun',
'result': 'N/A',
'properties': (
@@ -1045,7 +1056,10 @@
'run_time': 1,
'start_time': re.escape(unit_test_utils.iso_timestamp(4)),
'test_name': 'test_commission',
- 'class_name': 'google3.java.com.google.assistant.verticals.homeautomation.partners.ui_automator.commission_reg_test.CommissionRegTest',
+ 'class_name': (
+ 'google3.java.com.google.assistant.verticals.homeautomation.'
+ 'partners.ui_automator.commission_reg_test.CommissionRegTest'
+ ),
'status': 'run',
'result': 'PASS',
}
@@ -1053,7 +1067,10 @@
'run_time': 1,
'start_time': re.escape(unit_test_utils.iso_timestamp(6)),
'test_name': 'test_decommission',
- 'class_name': 'google3.java.com.google.assistant.verticals.homeautomation.partners.ui_automator.commission_reg_test.CommissionRegTest',
+ 'class_name': (
+ 'google3.java.com.google.assistant.verticals.homeautomation.'
+ 'partners.ui_automator.commission_reg_test.CommissionRegTest'
+ ),
'status': 'run',
'result': 'PASS',
}
@@ -1061,7 +1078,10 @@
'run_time': 1,
'start_time': re.escape(unit_test_utils.iso_timestamp(8)),
'test_name': 'test_commission',
- 'class_name': 'google3.java.com.google.assistant.verticals.homeautomation.partners.ui_automator.commission_reg_test.CommissionRegTest',
+ 'class_name': (
+ 'google3.java.com.google.assistant.verticals.homeautomation.'
+ 'partners.ui_automator.commission_reg_test.CommissionRegTest'
+ ),
'status': 'run',
'result': 'PASS',
}
@@ -1069,7 +1089,10 @@
'run_time': 1,
'start_time': re.escape(unit_test_utils.iso_timestamp(10)),
'test_name': 'test_decommission',
- 'class_name': 'google3.java.com.google.assistant.verticals.homeautomation.partners.ui_automator.commission_reg_test.CommissionRegTest',
+ 'class_name': (
+ 'google3.java.com.google.assistant.verticals.homeautomation.'
+ 'partners.ui_automator.commission_reg_test.CommissionRegTest'
+ ),
'status': 'run',
'result': 'FAIL',
'message': xml_reporter._escape_xml_attr(str(err[1])),
@@ -1266,6 +1289,7 @@
mock_load_snippet.assert_called_once()
self.assertDictEqual(report_info, {})
+ @flagsaver.flagsaver((ui_automator._GOOGLE_ACCOUNT, _FAKE_GOOGLE_ACCOUNT))
@mock.patch.object(android_device, 'get_all_instances', autospec=True)
def test_is_device_exist_returns_true_when_device_exists(
self, mock_get_all_instances
@@ -1274,6 +1298,9 @@
self.mock_android_device.mbs.isDeviceExist.return_value = True
self.assertTrue(self.ui_automator.is_device_exist(_FAKE_MATTER_DEVICE_NAME))
+ self.mock_android_device.mbs.isDeviceExist.assert_called_once_with(
+ _FAKE_MATTER_DEVICE_NAME, _FAKE_GOOGLE_ACCOUNT
+ )
@mock.patch.object(android_device, 'get_all_instances', autospec=True)
def test_is_device_exist_returns_false_when_device_does_not_exist(
diff --git a/ui_automator/version.py b/ui_automator/version.py
index 36b5370..79de502 100644
--- a/ui_automator/version.py
+++ b/ui_automator/version.py
@@ -17,6 +17,6 @@
from typing import Optional
-_SEMANTIC_VERSION = "1.0.4"
+_SEMANTIC_VERSION = "1.0.5-rc.0"
VERSION = _SEMANTIC_VERSION