mirror of
https://github.com/budtmo/docker-android.git
synced 2026-07-31 04:07:25 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
852daa4e32 | ||
|
|
bf65a73eb1 | ||
|
|
3577d7e0a1 | ||
|
|
1371744b36 | ||
|
|
cf3b1cf683 | ||
|
|
416a88143f | ||
|
|
55719bb638 | ||
|
|
c22fe34e7c |
@@ -48,6 +48,8 @@ List of Docker images
|
|||||||
|Linux|6.0|23|butomo1989/docker-android-x86-6.0|[](https://microbadger.com/images/butomo1989/docker-android-x86-6.0 "Get your own image badge on microbadger.com")|
|
|Linux|6.0|23|butomo1989/docker-android-x86-6.0|[](https://microbadger.com/images/butomo1989/docker-android-x86-6.0 "Get your own image badge on microbadger.com")|
|
||||||
|Linux|7.0|24|butomo1989/docker-android-x86-7.0|[](https://microbadger.com/images/butomo1989/docker-android-x86-7.0 "Get your own image badge on microbadger.com")|
|
|Linux|7.0|24|butomo1989/docker-android-x86-7.0|[](https://microbadger.com/images/butomo1989/docker-android-x86-7.0 "Get your own image badge on microbadger.com")|
|
||||||
|Linux|7.1.1|25|butomo1989/docker-android-x86-7.1.1|[](https://microbadger.com/images/butomo1989/docker-android-x86-7.1.1 "Get your own image badge on microbadger.com")|
|
|Linux|7.1.1|25|butomo1989/docker-android-x86-7.1.1|[](https://microbadger.com/images/butomo1989/docker-android-x86-7.1.1 "Get your own image badge on microbadger.com")|
|
||||||
|
|Linux|8.0|26|butomo1989/docker-android-x86-8.0|[](https://microbadger.com/images/butomo1989/docker-android-x86-8.0 "Get your own image badge on microbadger.com")|
|
||||||
|
|Linux|8.1|27|butomo1989/docker-android-x86-8.1|[](https://microbadger.com/images/butomo1989/docker-android-x86-8.1 "Get your own image badge on microbadger.com")|
|
||||||
|All |-|-|butomo1989/docker-android-real-device|[](https://microbadger.com/images/butomo1989/docker-android-real-device "Get your own image badge on microbadger.com")|
|
|All |-|-|butomo1989/docker-android-real-device|[](https://microbadger.com/images/butomo1989/docker-android-real-device "Get your own image badge on microbadger.com")|
|
||||||
|Linux|All|All|butomo1989/docker-android-genymotion|[](https://microbadger.com/images/butomo1989/docker-android-genymotion "Get your own image badge on microbadger.com")|
|
|Linux|All|All|butomo1989/docker-android-genymotion|[](https://microbadger.com/images/butomo1989/docker-android-genymotion "Get your own image badge on microbadger.com")|
|
||||||
|
|
||||||
@@ -79,7 +81,7 @@ Quick Start
|
|||||||
docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container butomo1989/docker-android-x86-8.1
|
docker run --privileged -d -p 6080:6080 -p 5554:5554 -p 5555:5555 -e DEVICE="Samsung Galaxy S6" --name android-container butomo1989/docker-android-x86-8.1
|
||||||
```
|
```
|
||||||
|
|
||||||
- For ***OSX*** and ***Windows OS***, please use Virtual Machine that support Virtualization
|
- For ***OSX*** and ***Windows OS***, please use Virtual Machine that support Virtualization with Ubuntu OS
|
||||||
|
|
||||||
|
|
||||||
2. Verify the ip address of docker host.
|
2. Verify the ip address of docker host.
|
||||||
|
|||||||
+1
-1
@@ -151,6 +151,6 @@ COPY supervisord.conf /root/
|
|||||||
RUN chmod -R +x /root/src && chmod +x /root/supervisord.conf
|
RUN chmod -R +x /root/src && chmod +x /root/supervisord.conf
|
||||||
|
|
||||||
HEALTHCHECK --interval=2s --timeout=40s --retries=1 \
|
HEALTHCHECK --interval=2s --timeout=40s --retries=1 \
|
||||||
CMD adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done'
|
CMD timeout 40 adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done'
|
||||||
|
|
||||||
CMD /usr/bin/supervisord --configuration supervisord.conf
|
CMD /usr/bin/supervisord --configuration supervisord.conf
|
||||||
|
|||||||
+3
-1
@@ -57,7 +57,9 @@ function get_android_versions() {
|
|||||||
|
|
||||||
get_android_versions
|
get_android_versions
|
||||||
processor=x86
|
processor=x86
|
||||||
chrome_driver=$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE)
|
#chrome_driver=$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE)
|
||||||
|
#Reason: https://sites.google.com/a/chromium.org/chromedriver/downloads
|
||||||
|
chrome_driver=2.33
|
||||||
|
|
||||||
function test() {
|
function test() {
|
||||||
# Prepare needed parameter to run tests
|
# Prepare needed parameter to run tests
|
||||||
|
|||||||
+24
-6
@@ -49,12 +49,22 @@ def convert_str_to_bool(str: str) -> bool:
|
|||||||
logger.error(err)
|
logger.error(err)
|
||||||
|
|
||||||
|
|
||||||
|
def is_initialized() -> bool:
|
||||||
|
return os.path.exists(INIT_FILE)
|
||||||
|
|
||||||
|
|
||||||
|
def finish_initialization():
|
||||||
|
file = open(INIT_FILE, 'w+')
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
|
||||||
ANDROID_HOME = get_or_raise('ANDROID_HOME')
|
ANDROID_HOME = get_or_raise('ANDROID_HOME')
|
||||||
ANDROID_VERSION = get_or_raise('ANDROID_VERSION')
|
ANDROID_VERSION = get_or_raise('ANDROID_VERSION')
|
||||||
API_LEVEL = get_or_raise('API_LEVEL')
|
API_LEVEL = get_or_raise('API_LEVEL')
|
||||||
PROCESSOR = get_or_raise('PROCESSOR')
|
PROCESSOR = get_or_raise('PROCESSOR')
|
||||||
SYS_IMG = get_or_raise('SYS_IMG')
|
SYS_IMG = get_or_raise('SYS_IMG')
|
||||||
IMG_TYPE = get_or_raise('IMG_TYPE')
|
IMG_TYPE = get_or_raise('IMG_TYPE')
|
||||||
|
INIT_FILE = os.getenv('INIT_FILE', "/root/init")
|
||||||
|
|
||||||
logger.info('Android version: {version} \n'
|
logger.info('Android version: {version} \n'
|
||||||
'API level: {level} \n'
|
'API level: {level} \n'
|
||||||
@@ -86,9 +96,10 @@ def prepare_avd(device: str, avd_name: str):
|
|||||||
|
|
||||||
avd_path = '/'.join([ANDROID_HOME, 'android_emulator'])
|
avd_path = '/'.join([ANDROID_HOME, 'android_emulator'])
|
||||||
creation_cmd = 'avdmanager create avd -f -n {name} -b {img_type}/{sys_img} -k "system-images;android-{api_lvl};' \
|
creation_cmd = 'avdmanager create avd -f -n {name} -b {img_type}/{sys_img} -k "system-images;android-{api_lvl};' \
|
||||||
'{img_type};{sys_img}" -d {device} -p {path}'.format(name=avd_name, img_type=IMG_TYPE, sys_img=SYS_IMG,
|
'{img_type};{sys_img}" -d {device} -p {path}'.format(name=avd_name, img_type=IMG_TYPE,
|
||||||
api_lvl=API_LEVEL, device=device_name_bash,
|
sys_img=SYS_IMG,
|
||||||
path=avd_path)
|
api_lvl=API_LEVEL, device=device_name_bash,
|
||||||
|
path=avd_path)
|
||||||
logger.info('Command to create avd: {command}'.format(command=creation_cmd))
|
logger.info('Command to create avd: {command}'.format(command=creation_cmd))
|
||||||
subprocess.check_call(creation_cmd, shell=True)
|
subprocess.check_call(creation_cmd, shell=True)
|
||||||
|
|
||||||
@@ -186,14 +197,20 @@ def run():
|
|||||||
avd_name = '{device}_{version}'.format(device=device.replace(' ', '_').lower(), version=ANDROID_VERSION)
|
avd_name = '{device}_{version}'.format(device=device.replace(' ', '_').lower(), version=ANDROID_VERSION)
|
||||||
logger.info('AVD name: {avd}'.format(avd=avd_name))
|
logger.info('AVD name: {avd}'.format(avd=avd_name))
|
||||||
|
|
||||||
logger.info('Preparing emulator...')
|
if not is_initialized():
|
||||||
prepare_avd(device, avd_name)
|
logger.info('Preparing emulator...')
|
||||||
|
prepare_avd(device, avd_name)
|
||||||
|
finish_initialization()
|
||||||
|
|
||||||
logger.info('Run emulator...')
|
logger.info('Run emulator...')
|
||||||
dp_size = os.getenv('DATAPARTITION', '550m')
|
dp_size = os.getenv('DATAPARTITION', '550m')
|
||||||
with open("/root/android_emulator/config.ini", "a") as cfg:
|
with open("/root/android_emulator/config.ini", "a") as cfg:
|
||||||
cfg.write('\ndisk.dataPartition.size={dp}'.format(dp=dp_size))
|
cfg.write('\ndisk.dataPartition.size={dp}'.format(dp=dp_size))
|
||||||
cmd = 'emulator/emulator @{name} -gpu off -verbose'.format(name=avd_name)
|
|
||||||
|
if not is_initialized():
|
||||||
|
cmd = 'emulator/emulator @{name} -gpu off -verbose -wipe-data'.format(name=avd_name)
|
||||||
|
else:
|
||||||
|
cmd = 'emulator/emulator @{name} -gpu off -verbose'.format(name=avd_name)
|
||||||
appium = convert_str_to_bool(str(os.getenv('APPIUM', False)))
|
appium = convert_str_to_bool(str(os.getenv('APPIUM', False)))
|
||||||
if appium:
|
if appium:
|
||||||
subprocess.Popen(cmd.split())
|
subprocess.Popen(cmd.split())
|
||||||
@@ -202,5 +219,6 @@ def run():
|
|||||||
else:
|
else:
|
||||||
result = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE).communicate()
|
result = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE).communicate()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
run()
|
run()
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class TestApp(TestCase):
|
|||||||
@mock.patch('src.app.prepare_avd')
|
@mock.patch('src.app.prepare_avd')
|
||||||
@mock.patch('builtins.open')
|
@mock.patch('builtins.open')
|
||||||
@mock.patch('subprocess.Popen')
|
@mock.patch('subprocess.Popen')
|
||||||
def test_run_withhout_appium(self, mocked_avd, mocked_open, mocked_subprocess):
|
def test_run_without_appium(self, mocked_avd, mocked_open, mocked_subprocess):
|
||||||
with mock.patch('src.app.appium_run') as mocked_appium:
|
with mock.patch('src.app.appium_run') as mocked_appium:
|
||||||
os.environ['APPIUM'] = str(False)
|
os.environ['APPIUM'] = str(False)
|
||||||
app.run()
|
app.run()
|
||||||
@@ -75,3 +75,21 @@ class TestApp(TestCase):
|
|||||||
self.assertTrue(mocked_open.called)
|
self.assertTrue(mocked_open.called)
|
||||||
self.assertTrue(mocked_subprocess.called)
|
self.assertTrue(mocked_subprocess.called)
|
||||||
self.assertFalse(mocked_appium.called)
|
self.assertFalse(mocked_appium.called)
|
||||||
|
|
||||||
|
@mock.patch('builtins.open')
|
||||||
|
@mock.patch('subprocess.Popen')
|
||||||
|
@mock.patch('os.path.exists', mock.MagicMock(return_value=False))
|
||||||
|
def test_run_first_run(self, mocked_open, mocked_subprocess):
|
||||||
|
with mock.patch('src.app.prepare_avd') as mocked_prepare_avd:
|
||||||
|
app.run()
|
||||||
|
self.assertFalse(app.is_initialized())
|
||||||
|
self.assertTrue(mocked_prepare_avd.called)
|
||||||
|
|
||||||
|
@mock.patch('builtins.open')
|
||||||
|
@mock.patch('subprocess.Popen')
|
||||||
|
@mock.patch('os.path.exists', mock.MagicMock(return_value=True))
|
||||||
|
def test_run_next_run(self, mocked_open, mocked_subprocess):
|
||||||
|
with mock.patch('src.app.prepare_avd') as mocked_prepare_avd:
|
||||||
|
app.run()
|
||||||
|
self.assertTrue(app.is_initialized())
|
||||||
|
self.assertFalse(mocked_prepare_avd.called)
|
||||||
|
|||||||
Reference in New Issue
Block a user