Compare commits

..
11 Commits
Author SHA1 Message Date
budi 602dcf15a7 Updated ubuntu on the runner 2025-04-28 11:15:58 +02:00
budi 1dd79c6188 Updated base image 2025-04-28 11:10:20 +02:00
budi 7abe6c19d8 Updated ubuntu on the runner 2025-04-28 11:09:42 +02:00
Jiří ČernýandGitHub eb91462bd4 Allow to override emulator config from config file defined by path in EVN (#492) 2025-04-28 11:08:52 +02:00
Budi UtomoandGitHub ac251e7704 Merge pull request #493 from jirkace/device_pixel
Allow to use Pixel C as emulator device
2025-03-11 08:37:56 +01:00
blackie b997803064 Allow to use Pixel C as emulator device 2025-03-11 00:07:47 +01:00
Budi UtomoandGitHub 88dbde577e Merge pull request #491 from budtmo/dependabot/pip/master/mock-5.2.0
[pip] Bump mock from 5.1.0 to 5.2.0
2025-03-04 14:41:52 +01:00
dependabot[bot]andGitHub a51e451a1f [pip] Bump mock from 5.1.0 to 5.2.0
Bumps [mock](https://github.com/testing-cabal/mock) from 5.1.0 to 5.2.0.
- [Changelog](https://github.com/testing-cabal/mock/blob/master/CHANGELOG.rst)
- [Commits](https://github.com/testing-cabal/mock/compare/5.1.0...5.2.0)

---
updated-dependencies:
- dependency-name: mock
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-04 00:45:42 +00:00
budi 0f8d8eb98b Updated base image 2025-02-21 13:48:42 +01:00
budtmo 97b3ca2c28 Updated documentation 2025-01-27 16:38:31 +01:00
budtmo 7b599fe7ea Updated base image 2025-01-27 16:35:20 +01:00
10 changed files with 80 additions and 10 deletions
+4 -4
View File
@@ -7,7 +7,7 @@ on:
jobs:
run_test:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
strategy:
matrix:
python-version: ["3.8"]
@@ -31,7 +31,7 @@ jobs:
cd cli && nosetests -v
release_base:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
needs: run_test
steps:
- name: Checkout the repo
@@ -47,7 +47,7 @@ jobs:
docker logout
release_emulator:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
needs: release_base
strategy:
matrix:
@@ -66,7 +66,7 @@ jobs:
docker logout
release_genymotion:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
needs: release_base
steps:
- name: Checkout the repo
+1 -1
View File
@@ -10,7 +10,7 @@ on:
jobs:
build_and_test:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
steps:
- name: Checkout the repo
uses: actions/checkout@v4
+2
View File
@@ -45,6 +45,7 @@ Phone | Nexus 5
Phone | Nexus One
Phone | Nexus S
Tablet | Nexus 7
Tablet | Pixel C
Requirements
------------
@@ -162,6 +163,7 @@ The differences between normal version and pro version are:
|user-behavior-analytics|Yes|No|-|
|proxy|No|Yes|Set up company proxy on Android emulator on fly|
|language|No|Yes|Set up language on Android emulator on fly|
|Newer Android version|No|Yes|Support other newer Android version e.g. Android 15, etc|
|root-privileged|No|Yes|Able to run command with security privileged|
|headless-mode|No|Yes|Save resources by using headless mode|
|Selenium 4.x integration|No|Yes|Running Appium UI-Tests againt one (Selenium Hub) endpoint for Android- and iOS emulator(s) / device(s)|
+1 -1
View File
@@ -1,6 +1,6 @@
autopep8==2.3.1
click==8.1.8
coverage==7.6.1
mock==5.1.0
mock==5.2.0
nose==1.3.7
requests==2.32.3
+1
View File
@@ -30,6 +30,7 @@ EMULATOR_IMG_TYPE = "EMULATOR_IMG_TYPE"
EMULATOR_NAME = "EMULATOR_NAME"
EMULATOR_NO_SKIN = "EMULATOR_NO_SKIN"
EMULATOR_SYS_IMG = "EMULATOR_SYS_IMG"
EMULATOR_CONFIG_PATH = "EMULATOR_CONFIG_PATH"
# Device (Genymotion - General)
GENYMOTION_TEMPLATE_PATH = "GENYMOTION_TEMPLATE_PATH"
+27 -1
View File
@@ -22,7 +22,8 @@ class Emulator(Device):
"Samsung Galaxy S7 Edge",
"Samsung Galaxy S8",
"Samsung Galaxy S9",
"Samsung Galaxy S10"
"Samsung Galaxy S10",
"Pixel C"
)
API_LEVEL = {
@@ -107,6 +108,30 @@ class Emulator(Device):
symlink_force(path_device_profile_source, self.path_device_profile_target)
self.logger.info("Samsung device profile is linked")
def _use_override_config(self) -> None:
override_confg_path = os.getenv(ENV.EMULATOR_CONFIG_PATH)
if override_confg_path is None:
self.logger.info(f"The environment variable 'EMULATOR_CONFIG_PATH' is not set")
return
self.logger.info(f"Environment variable 'EMULATOR_CONFIG_PATH' found: {override_confg_path}")
if not os.path.isfile(override_confg_path):
self.logger.warning(f"Source file '{override_confg_path}' does not exist.")
return
if not os.access(override_confg_path, os.R_OK):
self.logger.warning(f"Source file '{override_confg_path}' is not readable.")
return
try:
with open(override_confg_path, 'r') as src, open(self.path_emulator_config, 'a') as dst:
dst.write(src.read())
self.logger.info(f"Content from '{override_confg_path}' successfully appended to '{self.path_emulator_config}'.")
except Exception as e:
self.logger.error(f"An error occurred while copying file content: {e}")
def _add_skin(self) -> None:
device_skin_path = os.path.join(
self.path_emulator_skins, "{fn}".format(fn=self.file_name))
@@ -131,6 +156,7 @@ class Emulator(Device):
self.logger.info(f"Command to create emulator: '{creation_cmd}'")
subprocess.check_call(creation_cmd, shell=True)
self._add_skin()
self._use_override_config()
self.logger.info(f"{self.device_type} is created!")
def change_permission(self) -> None:
+27 -2
View File
@@ -56,20 +56,23 @@ class TestEmulator(BaseDeviceTest):
@mock.patch("src.device.emulator.Emulator._add_profile")
@mock.patch("subprocess.check_call")
@mock.patch("src.device.emulator.Emulator._add_skin")
@mock.patch("src.device.emulator.Emulator._use_override_config")
@mock.patch("src.device.emulator.Emulator.is_initialized", mock.MagicMock(return_value=False))
def test_create_device_not_exist(self, mocked_status, mocked_profile, mocked_subprocess, mocked_skin):
def test_create_device_not_exist(self, mocked_status, mocked_profile, mocked_subprocess, mocked_skin, mocked_override_config):
self.emu.create()
self.assertEqual(mocked_status.called, True)
self.assertEqual(mocked_profile.called, True)
self.assertEqual(mocked_subprocess.called, True)
self.assertEqual(mocked_skin.called, True)
self.assertEqual(mocked_override_config.called, True)
@mock.patch("src.device.Device.set_status")
@mock.patch("src.device.emulator.Emulator._add_profile")
@mock.patch("subprocess.check_call")
@mock.patch("src.device.emulator.Emulator._add_skin")
@mock.patch("src.device.emulator.Emulator._use_override_config")
@mock.patch("src.device.emulator.Emulator.is_initialized", mock.MagicMock(return_value=True))
def test_create_device_exists(self, mocked_status, mocked_profile, mocked_subprocess, mocked_skin):
def test_create_device_exists(self, mocked_status, mocked_profile, mocked_subprocess, mocked_skin, mocked_override_config):
self.emu.create()
self.assertEqual(mocked_status.called, False)
self.assertEqual(mocked_profile.called, False)
@@ -85,3 +88,25 @@ class TestEmulator(BaseDeviceTest):
with self.assertRaises(RuntimeError):
self.emu.check_adb_command(
self.emu.ReadinessCheck.BOOTED, "mocked_command", "1", 3, 0)
def test_use_override_config_no_env(self):
with mock.patch("os.getenv", return_value=None):
self.emu._use_override_config()
def test_use_override_config_file_not_exist(self):
with mock.patch("os.getenv", return_value="mock/path/to/config"):
with mock.patch("os.path.isfile", return_value=False):
self.emu._use_override_config()
def test_use_override_config_file_not_readable(self):
with mock.patch("os.getenv", return_value="mock/path/to/config"):
with mock.patch("os.path.isfile", return_value=True):
with mock.patch("os.access", return_value=False):
self.emu._use_override_config()
def test_use_override_config_malformed_content(self):
with mock.patch("os.getenv", return_value="mock/path/to/config"):
with mock.patch("os.path.isfile", return_value=True):
with mock.patch("os.access", return_value=True):
with mock.patch("builtins.open", mock.mock_open(read_data="malformed data")):
self.emu._use_override_config()
+1 -1
View File
@@ -1,4 +1,4 @@
FROM appium/appium:v2.15.0-p0
FROM appium/appium:v2.18.0-p0
LABEL maintainer "Budi Utomo <budtmo.os@gmail.com>"
+13
View File
@@ -57,5 +57,18 @@ Possible environment variable to configure the Emulator:
The user can also pass needed arguments to android emulator through environment variable ***EMULATOR_ADDITIONAL_ARGS***. Please check [this page](https://developer.android.com/studio/run/emulator-commandline) for possible arguments that can be passed.
EMULATOR - OVERRIDE CONFIG FILE
-------------------------------
To utilize this feature, ensure the following setup:
- Set the config file path into environment variable EMULATOR_CONFIG_PATH, eg. `/tmp/emulator-override-config.ini` (the file name doesn't matter)
- Mount the file as Docker volume (parameter `-v` for Docker run command) to the path as you set into ENV
Example:
```shell
docker run -d -p 6080:6080 -e /tmp/emulator-override-config.ini -v /path/on/your/machine/emulator-override-config.ini:/tmp/emulator-override-config.ini -e EMULATOR_DEVICE="Samsung Galaxy S10" -e WEB_VNC=true --device /dev/kvm --name android-container budtmo/docker-android:emulator_14.0
```
[<- BACK TO README](../README.md)
+3
View File
@@ -28,12 +28,14 @@ List of Docker-Images
|12.0|32|Normal|budtmo2/docker-android-pro:emulator_12.0|budtmo2/docker-android-pro:emulator_12.0_<release_version>|
|13.0|33|Normal|budtmo2/docker-android-pro:emulator_13.0|budtmo2/docker-android-pro:emulator_13.0_<release_version>|
|14.0|34|Normal|budtmo2/docker-android-pro:emulator_14.0|budtmo2/docker-android-pro:emulator_14.0_<release_version>|
|15.0|35|Normal|budtmo2/docker-android-pro:emulator_15.0|budtmo2/docker-android-pro:emulator_15.0_<release_version>|
|9.0|28|Headless|budtmo2/docker-android-pro:emulator_headless_9.0|budtmo2/docker-android-pro:emulator_headless_9.0_<release_version>|
|10.0|29|Headless|budtmo2/docker-android-pro:emulator_headless_10.0|budtmo2/docker-android-pro:emulator_headless_10.0_<release_version>|
|11.0|30|Headless|budtmo2/docker-android-pro:emulator_headless_11.0|budtmo2/docker-android-pro:emulator_headless_11.0_<release_version>|
|12.0|32|Headless|budtmo2/docker-android-pro:emulator_headless_12.0|budtmo2/docker-android-pro:emulator_headless_12.0_<release_version>|
|13.0|33|Headless|budtmo2/docker-android-pro:emulator_headless_13.0|budtmo2/docker-android-pro:emulator_headless_13.0_<release_version>|
|14.0|34|Headless|budtmo2/docker-android-pro:emulator_headless_14.0|budtmo2/docker-android-pro:emulator_headless_14.0_<release_version>|
|15.0|35|Headless|budtmo2/docker-android-pro:emulator_headless_15.0|budtmo2/docker-android-pro:emulator_headless_15.0_<release_version>|
|-|-|Selenium|budtmo2/docker-android-pro:selenium|budtmo2/docker-android-pro:selenium_<release_version>|
***Note: Headless mode does not have any Web-UI***
@@ -57,6 +59,7 @@ Phone | Nexus 5
Phone | Nexus One
Phone | Nexus S
Tablet | Nexus 7
Tablet | Pixel C
Proxy