diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-05-16 16:35:49 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2024-05-16 16:35:49 +0000 |
commit | 79ffbf1334008d50a5897bb60582666167f4c59b (patch) | |
tree | 875ac9dc363d865c48f2803bab91debe4e8f1a7c | |
parent | 71d6d9c582e1d2365a72b3a3a56dcce66f1cf468 (diff) | |
parent | ccc82ef9309b66806bcc84f75f66af986634247f (diff) | |
download | adt-infra-emu-35-1-release.tar.gz |
Snap for 11848231 from ccc82ef9309b66806bcc84f75f66af986634247f to emu-35-1-releaseemu-35-1-release
Change-Id: Iedb703ba1ef6d2a0345bdafa524f1cc0246651d1
18 files changed, 582 insertions, 25 deletions
diff --git a/pytest/test_embedded/cfg/emulator_darwin_tests.json b/pytest/test_embedded/cfg/emulator_darwin_tests.json index 6be85eb4..b7b4a1d7 100644 --- a/pytest/test_embedded/cfg/emulator_darwin_tests.json +++ b/pytest/test_embedded/cfg/emulator_darwin_tests.json @@ -131,6 +131,44 @@ }, "status": "enabled" }, + "embedded_resizable_test_suite_api_34": { + "description": "Set of tests that verify that the embedded emulator works when launched in landscape mode.", + "launch_flags": [ + "-no-snapshot", + "-qt-hide-window", + "-grpc-use-token" + ], + "pytest_flags": [ + "-m embedded_newresizable" + ], + "avd_config": { + "api": "34", + "tag.id": "google_apis", + "hw.device.name": "resizable", + "hw.resizable.configs": "phone-0-1080-2340-420, foldable-1-2208-1840-420, tablet-2-1920-1200-240, desktop-3-1920-1080-160", + "hw.lcd.density": "420", + "hw.lcd.height": "2340", + "hw.lcd.width": "1080", + "hw.displayRegion.0.1.height": "2092", + "hw.displayRegion.0.1.width": "1080", + "hw.displayRegion.0.1.xOffset": "0", + "hw.displayRegion.0.1.yOffset": "0", + "hw.sensor.hinge": "yes", + "hw.sensor.hinge.areas": "1840-0-0-1840", + "hw.sensor.hinge.count": "1", + "hw.sensor.hinge.defaults": "180", + "hw.sensor.hinge.ranges": "0-180", + "hw.sensor.hinge.sub_type": "1", + "hw.sensor.hinge.type": "1", + "hw.sensor.hinge_angles_posture_definitions": "0-30, 30-150, 150-180", + "hw.sensor.posture_list": "1, 2, 3", + "hw.sensors.orientation": "yes", + "hw.sensors.proximity": "yes", + "skin.name": "1080x2340", + "skin.path": "no_skin" + }, + "status": "enabled" + }, "snapshot_test_suite_api_31": { "description": "Set of tests that verify that snapshots work for the default emulator.", "launch_flags": [], @@ -408,5 +446,55 @@ "tag.id": "google_apis" }, "status": "enabled" + }, + "wear_test_suite_api_33": { + "description": "Set of tests that run on a wear AVD", + "launch_flags": [ + "-no-snapshot" + ], + "pytest_flags": [ + "-m wear" + ], + "avd_config": { + "api": "33", + "AvdId": "Wear", + "PlayStore.enabled": "true", + "avd.ini.displayname": "Wear", + "avd.ini.encoding": "UTF-8", + "disk.dataPartition.size": "6G", + "hw.accelerometer": "yes", + "hw.arc": "false", + "hw.audioInput": "yes", + "hw.battery": "yes", + "hw.camera.back": "None", + "hw.camera.front": "None", + "hw.cpu.ncore": "4", + "hw.dPad": "no", + "hw.gps": "yes", + "hw.gpu.enabled": "yes", + "hw.gpu.mode": "auto", + "hw.initialOrientation": "Portrait", + "hw.keyboard": "yes", + "hw.keyboard.lid": "yes", + "hw.lcd.density": "320", + "hw.lcd.height": "360", + "hw.lcd.width": "360", + "hw.mainKeys": "yes", + "hw.ramSize": "2048", + "hw.rotaryInput": "yes", + "hw.sdCard": "yes", + "hw.sensors.heart_rate": "yes", + "hw.sensors.orientation": "yes", + "hw.sensors.proximity": "yes", + "runtime.network.latency": "none", + "runtime.network.speed": "full", + "sdcard.size": "512M", + "showDeviceFrame": "yes", + "skin.dynamic": "yes", + "tag.display": "Wear OS 3", + "tag.id": "android-wear", + "vm.heapSize": "512" + }, + "status": "enabled" } }
\ No newline at end of file diff --git a/pytest/test_embedded/cfg/emulator_linux_tests.json b/pytest/test_embedded/cfg/emulator_linux_tests.json index 6be85eb4..c395ffc2 100644 --- a/pytest/test_embedded/cfg/emulator_linux_tests.json +++ b/pytest/test_embedded/cfg/emulator_linux_tests.json @@ -131,6 +131,44 @@ }, "status": "enabled" }, + "embedded_resizable_test_suite_api_34": { + "description": "Set of tests that verify that the embedded emulator works when launched in landscape mode.", + "launch_flags": [ + "-no-snapshot", + "-qt-hide-window", + "-grpc-use-token" + ], + "pytest_flags": [ + "-m embedded_newresizable" + ], + "avd_config": { + "api": "34", + "tag.id": "google_apis", + "hw.device.name": "resizable", + "hw.resizable.configs": "phone-0-1080-2340-420, foldable-1-2208-1840-420, tablet-2-1920-1200-240, desktop-3-1920-1080-160", + "hw.lcd.density": "420", + "hw.lcd.height": "2340", + "hw.lcd.width": "1080", + "hw.displayRegion.0.1.height": "2092", + "hw.displayRegion.0.1.width": "1080", + "hw.displayRegion.0.1.xOffset": "0", + "hw.displayRegion.0.1.yOffset": "0", + "hw.sensor.hinge": "yes", + "hw.sensor.hinge.areas": "1840-0-0-1840", + "hw.sensor.hinge.count": "1", + "hw.sensor.hinge.defaults": "180", + "hw.sensor.hinge.ranges": "0-180", + "hw.sensor.hinge.sub_type": "1", + "hw.sensor.hinge.type": "1", + "hw.sensor.hinge_angles_posture_definitions": "0-30, 30-150, 150-180", + "hw.sensor.posture_list": "1, 2, 3", + "hw.sensors.orientation": "yes", + "hw.sensors.proximity": "yes", + "skin.name": "1080x2340", + "skin.path": "no_skin" + }, + "status": "enabled" + }, "snapshot_test_suite_api_31": { "description": "Set of tests that verify that snapshots work for the default emulator.", "launch_flags": [], @@ -408,5 +446,55 @@ "tag.id": "google_apis" }, "status": "enabled" + }, + "wear_test_suite_api_33": { + "description": "Set of tests that run on a wear AVD", + "launch_flags": [ + "-no-snapshot" + ], + "pytest_flags": [ + "-m wear" + ], + "avd_config": { + "api": "33", + "AvdId": "Wear", + "PlayStore.enabled": "true", + "avd.ini.displayname": "Wear", + "avd.ini.encoding": "UTF-8", + "disk.dataPartition.size": "6G", + "hw.accelerometer": "yes", + "hw.arc": "false", + "hw.audioInput": "yes", + "hw.battery": "yes", + "hw.camera.back": "None", + "hw.camera.front": "None", + "hw.cpu.ncore": "4", + "hw.dPad": "no", + "hw.gps": "yes", + "hw.gpu.enabled": "yes", + "hw.gpu.mode": "auto", + "hw.initialOrientation": "Portrait", + "hw.keyboard": "yes", + "hw.keyboard.lid": "yes", + "hw.lcd.density": "320", + "hw.lcd.height": "360", + "hw.lcd.width": "360", + "hw.mainKeys": "yes", + "hw.ramSize": "2048", + "hw.rotaryInput": "yes", + "hw.sdCard": "yes", + "hw.sensors.heart_rate": "yes", + "hw.sensors.orientation": "yes", + "hw.sensors.proximity": "yes", + "runtime.network.latency": "none", + "runtime.network.speed": "full", + "sdcard.size": "512M", + "showDeviceFrame": "yes", + "skin.dynamic": "yes", + "tag.display": "Wear OS 3", + "tag.id": "android-wear", + "vm.heapSize": "512" + }, + "status": "enabled" } }
\ No newline at end of file diff --git a/pytest/test_embedded/cfg/emulator_windows_tests.json b/pytest/test_embedded/cfg/emulator_windows_tests.json index bd396362..4adfc5fd 100644 --- a/pytest/test_embedded/cfg/emulator_windows_tests.json +++ b/pytest/test_embedded/cfg/emulator_windows_tests.json @@ -131,6 +131,44 @@ }, "status": "enabled" }, + "embedded_resizable_test_suite_api_34": { + "description": "Set of tests that verify that the embedded emulator works when launched in landscape mode.", + "launch_flags": [ + "-no-snapshot", + "-qt-hide-window", + "-grpc-use-token" + ], + "pytest_flags": [ + "-m embedded_newresizable" + ], + "avd_config": { + "api": "34", + "tag.id": "google_apis", + "hw.device.name": "resizable", + "hw.resizable.configs": "phone-0-1080-2340-420, foldable-1-2208-1840-420, tablet-2-1920-1200-240, desktop-3-1920-1080-160", + "hw.lcd.density": "420", + "hw.lcd.height": "2340", + "hw.lcd.width": "1080", + "hw.displayRegion.0.1.height": "2092", + "hw.displayRegion.0.1.width": "1080", + "hw.displayRegion.0.1.xOffset": "0", + "hw.displayRegion.0.1.yOffset": "0", + "hw.sensor.hinge": "yes", + "hw.sensor.hinge.areas": "1840-0-0-1840", + "hw.sensor.hinge.count": "1", + "hw.sensor.hinge.defaults": "180", + "hw.sensor.hinge.ranges": "0-180", + "hw.sensor.hinge.sub_type": "1", + "hw.sensor.hinge.type": "1", + "hw.sensor.hinge_angles_posture_definitions": "0-30, 30-150, 150-180", + "hw.sensor.posture_list": "1, 2, 3", + "hw.sensors.orientation": "yes", + "hw.sensors.proximity": "yes", + "skin.name": "1080x2340", + "skin.path": "no_skin" + }, + "status": "enabled" + }, "snapshot_test_suite_api_31": { "description": "Set of tests that verify that snapshots work for the default emulator.", "launch_flags": [], @@ -408,5 +446,55 @@ "tag.id": "google_apis" }, "status": "enabled" + }, + "wear_test_suite_api_33": { + "description": "Set of tests that run on a wear AVD", + "launch_flags": [ + "-no-snapshot" + ], + "pytest_flags": [ + "-m wear" + ], + "avd_config": { + "api": "33", + "AvdId": "Wear", + "PlayStore.enabled": "true", + "avd.ini.displayname": "Wear", + "avd.ini.encoding": "UTF-8", + "disk.dataPartition.size": "6G", + "hw.accelerometer": "yes", + "hw.arc": "false", + "hw.audioInput": "yes", + "hw.battery": "yes", + "hw.camera.back": "None", + "hw.camera.front": "None", + "hw.cpu.ncore": "4", + "hw.dPad": "no", + "hw.gps": "yes", + "hw.gpu.enabled": "yes", + "hw.gpu.mode": "auto", + "hw.initialOrientation": "Portrait", + "hw.keyboard": "yes", + "hw.keyboard.lid": "yes", + "hw.lcd.density": "320", + "hw.lcd.height": "360", + "hw.lcd.width": "360", + "hw.mainKeys": "yes", + "hw.ramSize": "2048", + "hw.rotaryInput": "yes", + "hw.sdCard": "yes", + "hw.sensors.heart_rate": "yes", + "hw.sensors.orientation": "yes", + "hw.sensors.proximity": "yes", + "runtime.network.latency": "none", + "runtime.network.speed": "full", + "sdcard.size": "512M", + "showDeviceFrame": "yes", + "skin.dynamic": "yes", + "tag.display": "Wear OS 3", + "tag.id": "android-wear", + "vm.heapSize": "512" + }, + "status": "enabled" } }
\ No newline at end of file diff --git a/pytest/test_embedded/pytest.ini b/pytest/test_embedded/pytest.ini index 6a79afaa..b3245770 100644 --- a/pytest/test_embedded/pytest.ini +++ b/pytest/test_embedded/pytest.ini @@ -38,6 +38,8 @@ markers = xpass: chrome tests netsim: Netsim emulator tests oldapiboot: marks tests that should run on old api + wear: marks tests that should run on wear OS + embedded_newresizable: marks test that should run on a new resizable embedded emulator api since 34 testpaths = tests diff --git a/pytest/test_embedded/src/emu/adb/adb.py b/pytest/test_embedded/src/emu/adb/adb.py index 062aef0b..9559adc1 100644 --- a/pytest/test_embedded/src/emu/adb/adb.py +++ b/pytest/test_embedded/src/emu/adb/adb.py @@ -266,9 +266,9 @@ class Adb: You usually want to use this like this: - async with adb.stream("some shell cmd") as stream: + async with await adb.stream("some shell cmd") as stream: # do some things. - for line in stream + async for line in stream print(line) Args: diff --git a/pytest/test_embedded/src/emu/avd.py b/pytest/test_embedded/src/emu/avd.py index 5ce4f787..06b82e2d 100644 --- a/pytest/test_embedded/src/emu/avd.py +++ b/pytest/test_embedded/src/emu/avd.py @@ -376,8 +376,10 @@ class AvdWriter: api (str): Api level, usually a number, or first letter of desert abi (str): The abi of the machine. Note that qemu must support this abi! - tag (str): Tag of interest, one of default|google_apis|google_apis_playstore|android-tv - [optional] device.name (str): One of Pixel2|PixelFold, defaults to Pixel2. + tag (str): Tag of interest, one of default|google_apis|google_apis_playstore|android-tv|android-wear + [optional] device.name (str): One of: Pixel2|PixelFold|Nexus7_2013|TV_1080p|WearOS_Square + Defaults to Pixel2. + [optional] AvdId (str): The name of the AVD to be created. Defaults to "{api}_{tag}_{abi}_{device_name}" Note, you will need to look at the actual templates (templates/Pixel2.avd/config.ini) to see which values you can actually pass in as config. @@ -402,7 +404,7 @@ class AvdWriter: f"Abi {abi} is not supported, please use one of: {', '.join(self.SUPPORTED_ABI)}" ) - name = f"{api}_{tag}_{abi}_{device_name}" + name = config.get("AvdId", f"{api}_{tag}_{abi}_{device_name}") avd_cfg = { "AvdId": name, "tag.id": tag, diff --git a/pytest/test_embedded/src/emu/templates/Nexus7_2013.avd/config.ini b/pytest/test_embedded/src/emu/templates/Nexus7_2013.avd/config.ini new file mode 100644 index 00000000..826aeea2 --- /dev/null +++ b/pytest/test_embedded/src/emu/templates/Nexus7_2013.avd/config.ini @@ -0,0 +1,41 @@ +PlayStore.enabled={{playstore}} +avd.ini.encoding=UTF-8 +disk.dataPartition.size=2G +fastboot.chosenSnapshotFile= +fastboot.forceChosenSnapshotBoot=no +fastboot.forceColdBoot=no +fastboot.forceFastBoot=yes +hw.accelerometer=yes +hw.arc=false +hw.audioInput=yes +hw.battery=yes +hw.camera.back=virtualscene +hw.camera.front=emulated +hw.cpu.arch={{host_cpu}} +hw.cpu.ncore=4 +hw.dPad=no +hw.device.hash2=MD5:121629bcfab97028767e9021d5e4cdd1 +hw.device.manufacturer=Google +hw.device.name=nexus_7_2013 +hw.gps=yes +hw.gpu.enabled=yes +hw.gpu.mode=auto +hw.initialOrientation=Portrait +hw.keyboard=yes +hw.lcd.density=320 +hw.lcd.height=1920 +hw.lcd.width=1200 +hw.mainKeys=no +hw.ramSize=1536 +hw.sdCard=yes +hw.sensors.orientation=yes +hw.sensors.proximity=no +hw.trackBall=no +image.sysdir.1={{image_dir}} +runtime.network.latency=none +runtime.network.speed=full +sdcard.size=512M +showDeviceFrame=yes +skin.dynamic=yes +tag.display=Google APIs +vm.heapSize=128 diff --git a/pytest/test_embedded/src/emu/templates/Nexus7_2013.ini b/pytest/test_embedded/src/emu/templates/Nexus7_2013.ini new file mode 100644 index 00000000..b658634a --- /dev/null +++ b/pytest/test_embedded/src/emu/templates/Nexus7_2013.ini @@ -0,0 +1,17 @@ +# Copyright 2024 - 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. + +avd.ini.encoding=UTF-8 +path={{avd_home}}/{{name}}.avd +target=android-{{api}} diff --git a/pytest/test_embedded/src/emu/templates/TV_1080p.avd/config.ini b/pytest/test_embedded/src/emu/templates/TV_1080p.avd/config.ini new file mode 100644 index 00000000..1c0ae9f7 --- /dev/null +++ b/pytest/test_embedded/src/emu/templates/TV_1080p.avd/config.ini @@ -0,0 +1,42 @@ +PlayStore.enabled={{playstore}} +avd.ini.encoding=UTF-8 +disk.dataPartition.size=2G +fastboot.chosenSnapshotFile= +fastboot.forceChosenSnapshotBoot=no +fastboot.forceColdBoot=no +fastboot.forceFastBoot=yes +hw.accelerometer=no +hw.arc=false +hw.audioInput=yes +hw.battery=no +hw.camera.back=None +hw.camera.front=None +hw.cpu.arch={{host_cpu}} +hw.cpu.ncore=4 +hw.dPad=yes +hw.device.hash2=MD5:41e6ce015774b2a310e5fdbbd3964241 +hw.device.manufacturer=Google +hw.device.name=tv_1080p +hw.gps=yes +hw.gpu.enabled=yes +hw.gpu.mode=auto +hw.initialOrientation=landscape +hw.keyboard=yes +hw.keyboard.lid=yes +hw.lcd.density=320 +hw.lcd.height=1080 +hw.lcd.width=1920 +hw.mainKeys=yes +hw.ramSize=1536 +hw.sdCard=yes +hw.sensors.orientation=no +hw.sensors.proximity=no +hw.trackBall=no +image.sysdir.1={{image_dir}} +runtime.network.latency=none +runtime.network.speed=full +sdcard.size=512M +showDeviceFrame=yes +skin.dynamic=yes +tag.display=Android TV +vm.heapSize=48 diff --git a/pytest/test_embedded/src/emu/templates/TV_1080p.ini b/pytest/test_embedded/src/emu/templates/TV_1080p.ini new file mode 100644 index 00000000..b658634a --- /dev/null +++ b/pytest/test_embedded/src/emu/templates/TV_1080p.ini @@ -0,0 +1,17 @@ +# Copyright 2024 - 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. + +avd.ini.encoding=UTF-8 +path={{avd_home}}/{{name}}.avd +target=android-{{api}} diff --git a/pytest/test_embedded/src/emu/templates/WearOS_Square.avd/config.ini b/pytest/test_embedded/src/emu/templates/WearOS_Square.avd/config.ini new file mode 100644 index 00000000..d8e660cf --- /dev/null +++ b/pytest/test_embedded/src/emu/templates/WearOS_Square.avd/config.ini @@ -0,0 +1,44 @@ +PlayStore.enabled={{playstore}} +avd.ini.encoding=UTF-8 +disk.dataPartition.size=2G +fastboot.chosenSnapshotFile= +fastboot.forceChosenSnapshotBoot=no +fastboot.forceColdBoot=no +fastboot.forceFastBoot=yes +hw.accelerometer=yes +hw.arc=false +hw.audioInput=yes +hw.battery=yes +hw.camera.back=None +hw.camera.front=None +hw.cpu.arch={{host_cpu}} +hw.cpu.ncore=4 +hw.dPad=no +hw.device.hash2=MD5:059661d952ddc25d28d7ef26cd0e2067 +hw.device.manufacturer=Google +hw.device.name=wearos_square +hw.gps=yes +hw.gpu.enabled=yes +hw.gpu.mode=auto +hw.initialOrientation=Portrait +hw.keyboard=yes +hw.keyboard.lid=yes +hw.lcd.density=320 +hw.lcd.height=360 +hw.lcd.width=360 +hw.mainKeys=yes +hw.ramSize=512 +hw.rotaryInput=yes +hw.sdCard=yes +hw.sensors.heart_rate=yes +hw.sensors.orientation=yes +hw.sensors.proximity=yes +hw.trackBall=no +image.sysdir.1={{image_dir}} +runtime.network.latency=none +runtime.network.speed=full +sdcard.size=512M +showDeviceFrame=yes +skin.dynamic=yes +tag.display=Wear OS 3 +vm.heapSize=80 diff --git a/pytest/test_embedded/src/emu/templates/WearOS_Square.ini b/pytest/test_embedded/src/emu/templates/WearOS_Square.ini new file mode 100644 index 00000000..b658634a --- /dev/null +++ b/pytest/test_embedded/src/emu/templates/WearOS_Square.ini @@ -0,0 +1,17 @@ +# Copyright 2024 - 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. + +avd.ini.encoding=UTF-8 +path={{avd_home}}/{{name}}.avd +target=android-{{api}} diff --git a/pytest/test_embedded/tests/console/test_multidisplay_console.py b/pytest/test_embedded/tests/console/test_multidisplay_console.py index 2a8f0dc8..e4c3770a 100644 --- a/pytest/test_embedded/tests/console/test_multidisplay_console.py +++ b/pytest/test_embedded/tests/console/test_multidisplay_console.py @@ -50,3 +50,22 @@ async def test_multidisplay_out_of_order_add_no_crash(avd, telnet, ui_controller assert avd.is_alive(); assert "OK" in valid_del_result +@pytest.mark.console +@pytest.mark.multidisplay +@pytest.mark.e2e +async def test_multidisplay_del_empty_no_crash(avd): + """Test adb emu multidisplay del does not crash emulator""" + + del_empty_result =await avd.adb.run(["emu", "multidisplay", "del"]) + await asyncio.sleep(3) + assert avd.is_alive(); + +@pytest.mark.console +@pytest.mark.multidisplay +@pytest.mark.e2e +async def test_multidisplay_del_invalid_display_no_crash(avd): + """Test adb emu multidisplay del invalidid does not crash emulator""" + + del_invalid_display_result =await avd.adb.run(["emu", "multidisplay", "del", "3"]) + await asyncio.sleep(3) + assert avd.is_alive(); diff --git a/pytest/test_embedded/tests/display/test_multi_display.py b/pytest/test_embedded/tests/display/test_multi_display.py index a9bf6301..db58eb8a 100644 --- a/pytest/test_embedded/tests/display/test_multi_display.py +++ b/pytest/test_embedded/tests/display/test_multi_display.py @@ -491,13 +491,10 @@ async def test_add_multidisplay_from_config(emulator, tmp_path): Verify: Three logical displays should appear in the emulator display dump. """ - if emulator.is_alive(): - await emulator.stop() # The test will configure its own emulator. - # Avd configuration containing two secondary displays. - config = {"abi": "x86", - "api": "29", - "tag.id":"google_apis", + config = {"abi": emulator.configuration.hardware.get('abi'), + "api": emulator.configuration.hardware.get('api'), + "tag.id": emulator.configuration.hardware.get('tag.id'), "hw.display1.width": 800, "hw.display1.height": 1200, "hw.display1.density": 320, @@ -516,22 +513,25 @@ async def test_add_multidisplay_from_config(emulator, tmp_path): # Launch the emulator with the specificed multidisplay configuration. logging.info("Launching emulator ...") myflags = ["-no-snapshot-save"] - emulator = Emulator( + emu = Emulator( android_home=emulator.android_home, android_avd_home=tmp_path, exe=emulator.exe, avd_config=config, ) - await emulator.launch(flags=myflags) - await emulator.wait_for_boot(timeout=180) + await emu.launch(flags=myflags) + await emu.wait_for_boot(timeout=180) - async def ensure_logical_displays(n_displays): - # Return True if 'n_displays' logical displays are present. - display_dump = await emulator.adb.shell("dumpsys display", timeout=30) + async def ensure_logical_displays(n, emu): + # Return True if the emulator has 'n' logical displays. + display_dump = await emu.adb.shell("dumpsys display", timeout=30) display_size_pattern = re.search('Logical Displays: size=([0-9]*).*', display_dump) - return display_size_pattern.groups()[0] == str(n_displays) + if display_size_pattern is None: + return False + return display_size_pattern.groups()[0] == str(n) - assert await eventually(partial(ensure_logical_displays, n_displays), timeout=180), \ - 'Wrong number of displays detected' + assert await ( + eventually(partial(ensure_logical_displays, n_displays, emu), timeout=180) + ), 'Wrong number of displays detected' - await emulator.stop() + await emu.stop() diff --git a/pytest/test_embedded/tests/resizable/test_new_resizable.py b/pytest/test_embedded/tests/resizable/test_new_resizable.py index 882679c7..bfda5096 100644 --- a/pytest/test_embedded/tests/resizable/test_new_resizable.py +++ b/pytest/test_embedded/tests/resizable/test_new_resizable.py @@ -95,7 +95,7 @@ async def set_display_mode(emulator_controller, mode, timeout=5): ) @pytest.mark.flaky @pytest.mark.sanity -# @pytest.mark.skipos("all", "reason: b/309463427") +@pytest.mark.embedded_newresizable async def test_new_resizable_changes_resolution( supported_resizable_resolutions, avd, @@ -129,6 +129,7 @@ async def test_new_resizable_changes_resolution( # Eventually the currentMode is equal to the one we have set. # If this is broken the test will timeout await emulator_controller.setDisplayMode(DisplayMode(value=mode)) + await asyncio.sleep(3) assert await wait_until(display_is_set_to_mode, timeout=5) async def screenshot_is_sized_properly(): @@ -186,6 +187,7 @@ async def test_new_resizable_observable_from_streaming( # Start with moving to the intial dimension spec = next(available_dimensions) assert await set_display_mode(emulator_controller, spec.mode) == spec.mode + await asyncio.sleep(3) # Wait until we observe the expected dimension in the stream of screenshots # If we see it we move to the next dimension we are going to check @@ -203,6 +205,7 @@ async def test_new_resizable_observable_from_streaming( assert ( await set_display_mode(emulator_controller, spec.mode) == spec.mode ) + await asyncio.sleep(3) @pytest.mark.newresizable @@ -231,7 +234,7 @@ async def test_new_resizable_folding_observable_from_streaming( # start with unfold await set_device_hinge_angle(emulator_controller, 180) - await asyncio.sleep(1) + await asyncio.sleep(3) foldedw = 1080 foldedh = 2092 @@ -239,13 +242,13 @@ async def test_new_resizable_folding_observable_from_streaming( spec = next(available_dimensions) updated = await set_display_mode(emulator_controller, spec.mode) assert updated == spec.mode - await asyncio.sleep(1) + await asyncio.sleep(3) # Transition to the next. spec = next(available_dimensions) updated = await set_display_mode(emulator_controller, spec.mode) assert updated == DisplayModeValue.FOLDABLE - await asyncio.sleep(1) + await asyncio.sleep(3) # Now fold it await set_device_hinge_angle(emulator_controller, 0) diff --git a/pytest/test_embedded/tests/sensors/test_sensor.py b/pytest/test_embedded/tests/sensors/test_sensor.py index d5351f12..b8c50f81 100644 --- a/pytest/test_embedded/tests/sensors/test_sensor.py +++ b/pytest/test_embedded/tests/sensors/test_sensor.py @@ -14,6 +14,8 @@ import pytest from aemu.proto.emulator_controller_pb2 import ParameterValue, SensorValue +from aemu.proto.emulator_controller_pb2 import PhysicalModelValue +from aemu.proto.emulator_controller_pb2_grpc import EmulatorControllerStub from emu.timing import wait_until @@ -99,3 +101,55 @@ async def test_sensor_value(emulator_controller, test_name, sensor_value, x, y, value=ParameterValue(data=[x, y, z]), ), ) + + +@pytest.mark.fast +@pytest.mark.graphics +@pytest.mark.hardware +async def test_accelerometer_updates_with_model_change(avd): + """Ensure the accelerometer values change when the 3D (rotation) model changes. + + Args: + avd (BaseEmulator): Fixture that gives access to the running emulator. + + Test steps: + 1. Launch an emulator AVD. + 2. Store current acceleration sensor data. + 3. Changing the device's 3D model by applying a rotation (Verify). + + Verify: + Acceleration data changes. + """ + # Store initial orientation and acceleration data. + emulator_controller = EmulatorControllerStub(avd.channel) + initial_orientation = await emulator_controller.getSensor( + SensorValue(target=SensorValue.ORIENTATION) + ) + initial_acceleration = await emulator_controller.getSensor( + SensorValue(target=SensorValue.ACCELERATION) + ) + + # Rotate the emulator (will propagate to the the extended controls ui). + await emulator_controller.setPhysicalModel( + PhysicalModelValue( + target=PhysicalModelValue.ROTATION, + value=ParameterValue(data=[-45, -45, -45]), + ) + ) + + # Check new orientation data. + orientation = await emulator_controller.getSensor( + SensorValue(target=SensorValue.ORIENTATION) + ) + assert initial_orientation.value.data \ + != pytest.approx(orientation.value.data), \ + "Orientation sensor data wasn't updated" + + # Check new acceleration data. + acceleration = await emulator_controller.getSensor( + SensorValue(target=SensorValue.ACCELERATION) + ) + + assert initial_acceleration.value.data \ + != pytest.approx(acceleration.value.data), \ + "Acceleration sensor data didn't change after rotation" diff --git a/pytest/test_embedded/tests/test_boot.py b/pytest/test_embedded/tests/test_boot.py index 168d2df5..7172a736 100644 --- a/pytest/test_embedded/tests/test_boot.py +++ b/pytest/test_embedded/tests/test_boot.py @@ -97,6 +97,7 @@ async def get_booted_notification_time(emulator): @pytest.mark.e2e @pytest.mark.sanity @pytest.mark.fast +@pytest.mark.wear @pytest.mark.async_timeout(1080) async def test_first_time_booted(emulator, record_property): """Make sure the emulator status is set to booted.""" diff --git a/pytest/test_embedded/tests/wifi/test_connectivity.py b/pytest/test_embedded/tests/wifi/test_connectivity.py index 4212832f..95fafc93 100644 --- a/pytest/test_embedded/tests/wifi/test_connectivity.py +++ b/pytest/test_embedded/tests/wifi/test_connectivity.py @@ -40,3 +40,37 @@ async def test_wifi_has_connectivity(avd, pytestconfig, launch_flags): return False assert await wait_until(has_connectivity), "Unable to connect to dns 8.8.8.8" + + +@pytest.mark.e2e +@pytest.mark.boot +@pytest.mark.sanity +@pytest.mark.skipos("win", "reason: ping does not work on windows") +async def test_wifi_connectivity_without_mobile_data(avd): + """Checks internet connectivity via the wifi stack + Args: + avd (BaseEmulator): Fixture that gives access to the running emulator. + + Test UUID: 1f6a0e5a-958a-4a01-86f1-d926c2c39931 + + Test Steps: + 1. Disable the mobile data connectivity + + Verify: + Test internet connectivity via a ping command to www.google.com + """ + + # Disable the mobile data connectivity + await avd.adb.shell("svc data disable") + + async def has_internet_access(): + result = await avd.adb.shell("ping -c 3 www.google.com") + for line in result.rstrip().splitlines(): + if "64 bytes from" in line and "icmp_seq" in line and "ttl" in line: + return True + return False + + assert await wait_until(has_internet_access), "Failed to ping www.google.com" + + # Enable the data connectivity, in case this avd is used for the next test + await avd.adb.shell("svc data enable") |