mirror of
https://github.com/budtmo/docker-android.git
synced 2026-07-31 04:07:25 +00:00
Compare commits
10
Commits
v2.15.0-p1
...
v2.18.0-p0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
602dcf15a7 | ||
|
|
1dd79c6188 | ||
|
|
7abe6c19d8 | ||
|
|
eb91462bd4 | ||
|
|
ac251e7704 | ||
|
|
b997803064 | ||
|
|
88dbde577e | ||
|
|
a51e451a1f | ||
|
|
0f8d8eb98b | ||
|
|
97b3ca2c28 |
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -45,6 +45,7 @@ Phone | Nexus 5
|
||||
Phone | Nexus One
|
||||
Phone | Nexus S
|
||||
Tablet | Nexus 7
|
||||
Tablet | Pixel C
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
@@ -1,4 +1,4 @@
|
||||
FROM appium/appium:v2.15.0-p1
|
||||
FROM appium/appium:v2.18.0-p0
|
||||
|
||||
LABEL maintainer "Budi Utomo <budtmo.os@gmail.com>"
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -28,6 +28,7 @@ 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>|
|
||||
@@ -58,6 +59,7 @@ Phone | Nexus 5
|
||||
Phone | Nexus One
|
||||
Phone | Nexus S
|
||||
Tablet | Nexus 7
|
||||
Tablet | Pixel C
|
||||
|
||||
|
||||
Proxy
|
||||
|
||||
Reference in New Issue
Block a user