Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc0972318f | ||
|
|
3a88fa4ae4 | ||
|
|
398a694ccd | ||
|
|
14a29344b8 | ||
|
|
47621a7ccb | ||
|
|
c1d66496fb | ||
|
|
1365ec736b | ||
|
|
4aee17de2d | ||
|
|
5c9ad32522 | ||
|
|
366aa8b3b3 | ||
|
|
905f2c723b | ||
|
|
0e028d9a4a | ||
|
|
ce61b992f9 | ||
|
|
e62573036c | ||
|
|
e27b2e5fdf | ||
|
|
fdd4a86c40 | ||
|
|
15012fd3b4 | ||
|
|
1f440e1a07 | ||
|
|
567a494ccb | ||
|
|
d28c4dc5e0 | ||
|
|
7a052b7e2f | ||
|
|
988397318f | ||
|
|
0d6356ba47 | ||
|
|
1062da3dcc | ||
|
|
c431118465 |
@@ -0,0 +1,22 @@
|
||||
**Please make sure that it is an issue / a feature request. If it is a question / help wanted, please visit [our group chat](https://gitter.im/butomo1989/docker-android). Thank you!**
|
||||
|
||||
Operating System:
|
||||
<!-- OSX Yosemite, Ubuntu 16.04, Windows 10 etc -->
|
||||
|
||||
Docker Image:
|
||||
<!-- butomo1989/docker-android-x86-7.1.1, butomo1989/docker-android-real-device etc -->
|
||||
|
||||
Docker Version:
|
||||
<!-- 17.09.0-ce, 17.06.2-ce etc -->
|
||||
|
||||
Docker-compose version (Only if you use it):
|
||||
<!-- 1.16.1 etc -->
|
||||
|
||||
Docker Command to start docker-android:
|
||||
<!-- docker run ... -->
|
||||
|
||||
## Expected Behavior
|
||||
<!-- Explaination about expected behaviour goes here -->
|
||||
|
||||
## Actual Behavior
|
||||
<!-- Explaination about actual behaviour goes here -->
|
||||
@@ -0,0 +1,12 @@
|
||||
### Purpose of changes
|
||||
<!-- Please describe why this change is required / What problem you want to solve. -->
|
||||
|
||||
### Types of changes
|
||||
_Put an `x` in the boxes that apply_
|
||||
|
||||
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||
- [ ] New feature (non-breaking change which adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
|
||||
|
||||
### How has this been tested?
|
||||
<!-- Please describe in detail how you tested your changes. -->
|
||||
@@ -1,16 +1,18 @@
|
||||
Docker-Android
|
||||
==============
|
||||
<p align="center">
|
||||
<img id="header" src="./images/logo_dockerandroid_small.png" />
|
||||
</p>
|
||||
|
||||
[](https://gitter.im/butomo1989/docker-android?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://travis-ci.org/butomo1989/docker-android)
|
||||
[](https://hub.docker.com/r/butomo1989/docker-android-x86-7.1.1/)
|
||||
[](https://codecov.io/gh/butomo1989/docker-android)
|
||||
[](https://www.codacy.com/app/butomo1989/docker-appium?utm_source=github.com&utm_medium=referral&utm_content=butomo1989/docker-appium&utm_campaign=Badge_Grade)
|
||||
|
||||
Docker-Android is a docker image built to be used for everything related to mobile website testing and Android project.
|
||||
|
||||
Samsung Device | Google Device
|
||||
:---------------------------:|:---------------------------:
|
||||
![][docker android samsung] | ![][docker android nexus]
|
||||
Emulator - Samsung Device | Emulator - Nexus Device | Real Device
|
||||
:---------------------------:|:---------------------------:|:---------------------------:
|
||||
![][emulator samsung] |![][emulator nexus] |![][real device]
|
||||
|
||||
Purpose
|
||||
-------
|
||||
@@ -28,7 +30,9 @@ Advantages compare with other docker-android projects
|
||||
2. Emulator for different devices / skins, such as Samsung Galaxy S6, LG Nexus 4, HTC Nexus One and more.
|
||||
3. Ability to connect to Selenium Grid
|
||||
4. Ability to control emulator from outside container by using adb connect
|
||||
5. Open source with more features coming (monkey test, support real devices with screen mirroring and video recording)
|
||||
5. Support real devices with screen mirroring
|
||||
6. Ability to record video during test execution for debugging
|
||||
7. Open source with more features coming
|
||||
|
||||
List of Docker images
|
||||
---------------------
|
||||
@@ -45,6 +49,7 @@ List of Docker images
|
||||
|OSX / Windows|6.0|23|butomo1989/docker-android-arm-6.0|[](https://microbadger.com/images/butomo1989/docker-android-arm-6.0 "Get your own image badge on microbadger.com")|
|
||||
|OSX / Windows|7.0|24|butomo1989/docker-android-arm-7.0|[](https://microbadger.com/images/butomo1989/docker-android-arm-7.0 "Get your own image badge on microbadger.com")|
|
||||
|OSX / Windows|7.1.1|25|butomo1989/docker-android-arm-7.1.1|[](https://microbadger.com/images/butomo1989/docker-android-arm-7.1.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")|
|
||||
|
||||
List of Devices
|
||||
---------------
|
||||
@@ -127,10 +132,13 @@ If you want to use appium to test UI of your android application, you need to sh
|
||||
docker run --privileged -d -p 6080:6080 -p 4723:4723 -p 5554:5554 -p 5555:5555 -v $PWD/example/sample_apk:/root/tmp -e DEVICE="Nexus 5" -e APPIUM=True -e CONNECT_TO_GRID=True -e APPIUM_HOST="127.0.0.1" -e APPIUM_PORT=4723 -e SELENIUM_HOST="172.17.0.1" -e SELENIUM_PORT=4444 --name android-container butomo1989/docker-android-x86-7.1.1
|
||||
```
|
||||
|
||||
### Video Recording
|
||||
|
||||
You can deactivate auto_record by changing the value to "False" in docker-compose file. e.g. change value to "False" in this [line].
|
||||
|
||||
### Docker-Compose
|
||||
|
||||
![][compose]
|
||||
![][connected_devices]
|
||||
|
||||
There is [example of compose file] to run complete selenium grid and docker-android container as nodes. [docker-compose] version [1.13.0] or higher is required to be able to execute that compose file.
|
||||
|
||||
@@ -138,6 +146,23 @@ There is [example of compose file] to run complete selenium grid and docker-andr
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
Build Android project
|
||||
---------------------
|
||||
|
||||
docker-android can be used for building Android project and executing its unit test. This following steps will illustrate how to build Android project:
|
||||
|
||||
1. Clone [this sample test project](https://github.com/googlesamples/android-testing).
|
||||
|
||||
```bash
|
||||
git clone git@github.com:googlesamples/android-testing.git
|
||||
```
|
||||
|
||||
2. Build the project
|
||||
|
||||
```bash
|
||||
docker run -it --rm -v $PWD/android-testing/ui/espresso/BasicSample:/root/tmp butomo1989/docker-android-x86-7.1.1 tmp/gradlew build
|
||||
```
|
||||
|
||||
Control android emulator outside container
|
||||
------------------------------------------
|
||||
|
||||
@@ -187,6 +212,78 @@ SMS Simulation
|
||||
|
||||
![][sms]
|
||||
|
||||
How to use docker-android in VMWare or Parallels Desktop
|
||||
---------------
|
||||
The following instructions are used for OS X. You'll need [docker-machine-parallels](https://github.com/Parallels/docker-machine-parallels) to create a virtual machine (vm) with tiny core linux for running docker images. After that, you may start the vm you created for VMWare Fusion or Parallels Desktop and run a docker container inside this vm. If you're going to use the android docker of emulator with x86 processor, setup this vm for nested virtualization and kvm support before you run a docker container.
|
||||
|
||||
1. Install docker-machine-parallels via Homebrew:
|
||||
```bash
|
||||
$ brew install docker-machine-parallels
|
||||
```
|
||||
|
||||
2. Create a virtual machine for running docker images based on the virtual machine tool you use
|
||||
|
||||
Create a virtual machine of VMWare Fusion
|
||||
```bash
|
||||
$ docker-machine create --driver=vmwarefusion vmware-dev
|
||||
```
|
||||
|
||||
Create a virtual machine of Parallels Desktop
|
||||
```bash
|
||||
$ docker-machine create --driver=parallels prl-dev
|
||||
```
|
||||
|
||||
This utility `docker-machine-parallels` will fetch boot2docker.iso to create a vm of VMWare fusion or Parallels Desktop. When the vm is created, you'll see it's booted with VMWare fusion or Parallels Desktop where the network of vm is set to NAT and one IP is assigned. You'll be able to connect to vnc service inside the docker image through that IP. Say it's `10.211.55.3` and we'll use it later.
|
||||
|
||||
3. Setup the virtual machine for nested virtualization support
|
||||
|
||||
Shutdown the vm by running the command below in the boot2docker vm before you setup it.
|
||||
```bash
|
||||
# shutdown -h now
|
||||
```
|
||||
|
||||
If you use VMWare Fusion, go to menu bar > Vitual Machine > Settings > Processors and Memory, expand Advanced options, and select `Enable hypervisor applications in this virtual machine`.
|
||||
|
||||
[]
|
||||
|
||||
If you use Parallels Desktop, open settings screen of that vm and go to `CPU & Memory` under `hardware` tab, expand Advanced settings and select `Enable nested virtualization`.
|
||||
|
||||
[]
|
||||
|
||||
4. Enable kvm inside virtual machine
|
||||
Run as an account other than root to install kvm packages using tce-load.
|
||||
```bash
|
||||
# su docker
|
||||
$ tce-load -wi kvm
|
||||
```
|
||||
|
||||
Run as root to load kvm module after kvm packages install.
|
||||
```bash
|
||||
$ sudo modprobe kvm_intel
|
||||
```
|
||||
|
||||
Check if the kvm device is loaded.
|
||||
```bash
|
||||
$ ls /dev/kvm
|
||||
```
|
||||
|
||||
Check if your CPU supports hardware virtualization now
|
||||
```bash
|
||||
$ egrep -c '(vmx|svm)' /proc/cpuinfo
|
||||
```
|
||||
|
||||
If **0** it means that your CPU doesn't support hardware virtualization.
|
||||
|
||||
If **1** or more it does - but you still need to make sure that virtualization is enabled in the BIOS.
|
||||
|
||||
5. You may now run a docker container
|
||||
Let's run a docker image for an emulator with x86 processor.
|
||||
```bash
|
||||
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-7.1.1
|
||||
```
|
||||
|
||||
When the services inside this docker container are running, connect to http://10.211.55.3:6080/vnc.html (the IP we got when the docker machine was created) and login. The emulator with x86 processor should be running on screen.
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
All logs inside container are stored under folder **/var/log/supervisor**. you can print out log file by using **docker exec**. Example:
|
||||
@@ -195,15 +292,21 @@ All logs inside container are stored under folder **/var/log/supervisor**. you c
|
||||
docker exec -it android-container tail -f /var/log/supervisor/docker-android.stdout.log
|
||||
```
|
||||
|
||||
Special Thanks
|
||||
--------------
|
||||
- [Gian Christanto] for creating a great logo!
|
||||
|
||||
[appium]: <https://appium.io>
|
||||
[espresso]: <https://google.github.io/android-testing-support-library/docs/espresso/>
|
||||
[robotium]: <https://github.com/RobotiumTech/robotium>
|
||||
[docker android samsung]: <images/docker_android_samsung.png>
|
||||
[docker android nexus]: <images/docker_android_nexus.png>
|
||||
[emulator samsung]: <images/emulator_samsung_galaxy_s6.png>
|
||||
[emulator nexus]: <images/emulator_nexus_5.png>
|
||||
[real device]: <images/real_device.png>
|
||||
[compose]: <images/compose.png>
|
||||
[connected_devices]: <images/connected_devices.png>
|
||||
[line]: <https://github.com/butomo1989/docker-android/blob/master/docker-compose.yml#L29>
|
||||
[example of compose file]: <docker-compose.yml>
|
||||
[docker-compose]: <https://docs.docker.com/compose/install/>
|
||||
[1.13.0]: <https://github.com/docker/compose/releases/tag/1.13.0>
|
||||
[adb_connection]: <images/adb_connection.png>
|
||||
[sms]: <images/SMS.png>
|
||||
[gian christanto]: <https://www.linkedin.com/in/gian-christanto-0b398b131/>
|
||||
|
||||
@@ -6,16 +6,38 @@ version: "2.2"
|
||||
services:
|
||||
# Selenium hub
|
||||
selenium_hub:
|
||||
image: selenium/hub:3.4.0
|
||||
image: selenium/hub:3.11.0-bismuth
|
||||
ports:
|
||||
- "4444:4444"
|
||||
|
||||
# Real devices
|
||||
real_device:
|
||||
image: butomo1989/docker-android-real-device
|
||||
privileged: true
|
||||
depends_on:
|
||||
- selenium_hub
|
||||
ports:
|
||||
- 6080:6080
|
||||
volumes:
|
||||
- ./video-real-device:/tmp/video
|
||||
- /dev/bus/usb:/dev/bus/usb
|
||||
- ~/.android:/root/.android
|
||||
environment:
|
||||
- CONNECT_TO_GRID=True
|
||||
- APPIUM=true
|
||||
- SELENIUM_HOST=selenium_hub
|
||||
- AUTO_RECORD=True
|
||||
- BROWSER_NAME=chrome
|
||||
|
||||
# Docker-Android for Android application testing
|
||||
nexus_7.1.1:
|
||||
image: butomo1989/docker-android-x86-7.1.1
|
||||
privileged: true
|
||||
# Increase scale number if needed
|
||||
scale: 1
|
||||
depends_on:
|
||||
- selenium_hub
|
||||
- real_device
|
||||
ports:
|
||||
- 6080
|
||||
# Change path of apk that you want to test. I use sample_apk that I provide in folder "example"
|
||||
@@ -36,6 +58,9 @@ services:
|
||||
privileged: true
|
||||
# Increase scale number if needed
|
||||
scale: 1
|
||||
depends_on:
|
||||
- selenium_hub
|
||||
- real_device
|
||||
ports:
|
||||
- 6080
|
||||
volumes:
|
||||
@@ -55,6 +80,9 @@ services:
|
||||
privileged: true
|
||||
# Increase scale number if needed
|
||||
scale: 1
|
||||
depends_on:
|
||||
- selenium_hub
|
||||
- real_device
|
||||
ports:
|
||||
- 6080
|
||||
volumes:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM appium/appium:1.6.6-beta-p0
|
||||
FROM appium/appium:1.7.2-p1
|
||||
|
||||
LABEL maintainer "Budi Utomo <budi.ut.1989@gmail.com>"
|
||||
|
||||
@@ -83,10 +83,12 @@ ENV ANDROID_VERSION=$ANDROID_VERSION \
|
||||
IMG_TYPE=$IMG_TYPE \
|
||||
BROWSER=$BROWSER
|
||||
ENV PATH ${PATH}:${ANDROID_HOME}/build-tools
|
||||
|
||||
RUN echo y | sdkmanager "platforms;android-${API_LEVEL}" && \
|
||||
echo y | sdkmanager "system-images;android-${API_LEVEL};${IMG_TYPE};${SYS_IMG}" && \
|
||||
echo y | sdkmanager "emulator"
|
||||
RUN rm ${ANDROID_HOME}/tools/emulator \
|
||||
&& ln -s ${ANDROID_HOME}/tools/emulator64-${PROCESSOR} ${ANDROID_HOME}/tools/emulator
|
||||
RUN echo y | android update sdk --no-ui -a -t android-${API_LEVEL},sys-img-${SYS_IMG}-${IMG_TYPE}-${API_LEVEL}
|
||||
&& ln -s ${ANDROID_HOME}/emulator/emulator64-${PROCESSOR} ${ANDROID_HOME}/tools/emulator
|
||||
ENV LD_LIBRARY_PATH=$ANDROID_HOME/emulator/lib64:$ANDROID_HOME/emulator/lib64/qt/lib
|
||||
|
||||
#==============================================
|
||||
# Download chrome driver v2.26
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM appium/appium:1.6.6-beta-p0
|
||||
FROM appium/appium:1.7.2-p1
|
||||
|
||||
LABEL maintainer "Budi Utomo <budi.ut.1989@gmail.com>"
|
||||
|
||||
@@ -96,10 +96,13 @@ ENV ANDROID_VERSION=$ANDROID_VERSION \
|
||||
IMG_TYPE=$IMG_TYPE \
|
||||
BROWSER=$BROWSER
|
||||
ENV PATH ${PATH}:${ANDROID_HOME}/build-tools
|
||||
|
||||
RUN echo y | sdkmanager "platforms;android-${API_LEVEL}" && \
|
||||
echo y | sdkmanager "system-images;android-${API_LEVEL};${IMG_TYPE};${SYS_IMG}" && \
|
||||
echo y | sdkmanager "emulator"
|
||||
RUN rm ${ANDROID_HOME}/tools/emulator \
|
||||
&& ln -s ${ANDROID_HOME}/tools/emulator64-${PROCESSOR} ${ANDROID_HOME}/tools/emulator
|
||||
RUN echo y | android update sdk --no-ui -a -t android-${API_LEVEL},sys-img-${SYS_IMG}-${IMG_TYPE}-${API_LEVEL}
|
||||
&& ln -s ${ANDROID_HOME}/emulator/emulator64-${PROCESSOR} ${ANDROID_HOME}/tools/emulator
|
||||
ENV LD_LIBRARY_PATH=$ANDROID_HOME/emulator/lib64:$ANDROID_HOME/emulator/lib64/qt/lib
|
||||
|
||||
|
||||
#==============================================
|
||||
# Download chrome driver v2.26
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM appium/appium:1.6.6-beta-p0
|
||||
FROM appium/appium:1.7.2-p1
|
||||
|
||||
LABEL maintainer "Budi Utomo <budi.ut.1989@gmail.com>"
|
||||
|
||||
@@ -67,14 +67,7 @@ RUN wget -nv -O noVNC.zip "https://github.com/kanaka/noVNC/archive/${NOVNC_SHA}
|
||||
&& rm websockify.zip \
|
||||
&& ln noVNC/vnc_auto.html noVNC/index.html
|
||||
|
||||
#==============================================
|
||||
# Download Adb remote screen
|
||||
#==============================================
|
||||
RUN wget -nv -O asm.zip "http://adakoda.github.io/android-screen-monitor/download/3.0.0/ASM_3_00.zip" \
|
||||
&& unzip asm.zip \
|
||||
&& rm asm.zip
|
||||
|
||||
#================================================
|
||||
#================================================
|
||||
# noVNC Default Configurations
|
||||
# These Configurations can be changed through -e
|
||||
#================================================
|
||||
@@ -110,6 +103,7 @@ EXPOSE 4723 6080 5555
|
||||
#===================
|
||||
# Run docker-appium
|
||||
#===================
|
||||
COPY sm/asm.jar /root/
|
||||
COPY src /root/src
|
||||
COPY supervisord.conf /root/
|
||||
RUN chmod -R +x /root/src && chmod +x /root/supervisord.conf
|
||||
|
||||
|
Before Width: | Height: | Size: 131 KiB After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 607 KiB |
|
Before Width: | Height: | Size: 150 KiB |
|
Before Width: | Height: | Size: 244 KiB |
|
After Width: | Height: | Size: 146 KiB |
|
After Width: | Height: | Size: 229 KiB |
|
After Width: | Height: | Size: 54 KiB |
|
After Width: | Height: | Size: 261 KiB |
|
After Width: | Height: | Size: 183 KiB |
|
After Width: | Height: | Size: 341 KiB |
@@ -163,7 +163,7 @@ function build() {
|
||||
for v in "${versions[@]}"; do
|
||||
# Find image type and default web browser
|
||||
if [ "$v" == "5.0.1" ] || [ "$v" == "5.1.1" ]; then
|
||||
IMG_TYPE=android
|
||||
IMG_TYPE=default
|
||||
BROWSER=browser
|
||||
elif [ "$v" == "6.0" ]; then
|
||||
# It is because there is no ARM EABI v7a System Image for 6.0
|
||||
|
||||
@@ -4,22 +4,24 @@ import json
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import errno
|
||||
|
||||
from src import CONFIG_FILE, ROOT, CHROME_DRIVER
|
||||
from src import CHROME_DRIVER, CONFIG_FILE, ROOT
|
||||
from src import log
|
||||
|
||||
log.init()
|
||||
logger = logging.getLogger('app')
|
||||
|
||||
|
||||
def symlink_force(target, link_name):
|
||||
try:
|
||||
os.symlink(target, link_name)
|
||||
except OSError as e:
|
||||
import errno
|
||||
if e.errno == errno.EEXIST:
|
||||
os.remove(link_name)
|
||||
os.symlink(target, link_name)
|
||||
|
||||
|
||||
def get_or_raise(env: str) -> str:
|
||||
"""
|
||||
Check if needed environment variables are given.
|
||||
@@ -69,22 +71,9 @@ def prepare_avd(device: str, avd_name: str):
|
||||
:param device: Device name
|
||||
:param avd_name: Name of android virtual device / emulator
|
||||
"""
|
||||
cmd = 'echo no | android create avd -f -n {name} -t android-{api} -b {img_type}{sys_img}'.format(
|
||||
name=avd_name, api=API_LEVEL, img_type='google_apis/' if IMG_TYPE == 'google_apis' else '',
|
||||
sys_img=SYS_IMG)
|
||||
|
||||
# Link emulator skins
|
||||
skin_rsc_path = os.path.join(ROOT, 'devices', 'skins')
|
||||
logger.info('Skin ressource path: {rsc}'.format(rsc=skin_rsc_path))
|
||||
skin_dst_path = os.path.join(ANDROID_HOME, 'platforms', 'android-{api}'.format(api=API_LEVEL), 'skins')
|
||||
logger.info('Skin destination path: {dst}'.format(dst=skin_dst_path))
|
||||
for s in os.listdir(skin_rsc_path):
|
||||
symlink_force(os.path.join(skin_rsc_path, s), os.path.join(skin_dst_path, s))
|
||||
|
||||
# Hardware and its skin
|
||||
device_name_bash = device.replace(' ', '\ ')
|
||||
skin_name = device.replace(' ', '_').lower()
|
||||
logger.info('Device name in bash: {db}, Skin name: {skin}'.format(db=device_name_bash, skin=skin_name))
|
||||
|
||||
# For custom hardware profile
|
||||
profile_dst_path = os.path.join(ROOT, '.android', 'devices.xml')
|
||||
@@ -95,10 +84,19 @@ def prepare_avd(device: str, avd_name: str):
|
||||
logger.info('Hardware profile destination path: {dst}'.format(dst=profile_dst_path))
|
||||
symlink_force(profile_src_path, profile_dst_path)
|
||||
|
||||
# Append command
|
||||
cmd += ' -d {device} -s {skin}'.format(device=device_name_bash, skin=skin_name)
|
||||
logger.info('AVD creation command: {cmd}'.format(cmd=cmd))
|
||||
subprocess.check_call(cmd, shell=True)
|
||||
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};' \
|
||||
'{img_type};{sys_img}" -d {device} -p {path}'.format(name=avd_name, img_type=IMG_TYPE, sys_img=SYS_IMG,
|
||||
api_lvl=API_LEVEL, device=device_name_bash,
|
||||
path=avd_path)
|
||||
logger.info('Command to create avd: {command}'.format(command=creation_cmd))
|
||||
subprocess.check_call(creation_cmd, shell=True)
|
||||
|
||||
skin_path = '/'.join([ANDROID_HOME, 'devices', 'skins', skin_name])
|
||||
config_path = '/'.join([avd_path, 'config.ini'])
|
||||
with open(config_path, 'a') as file:
|
||||
file.write('skin.path={sp}'.format(sp=skin_path))
|
||||
logger.info('Skin was added in config.ini')
|
||||
|
||||
|
||||
def appium_run(avd_name: str):
|
||||
@@ -184,8 +182,9 @@ def run():
|
||||
|
||||
logger.info('Preparing emulator...')
|
||||
prepare_avd(device, avd_name)
|
||||
|
||||
logger.info('Run emulator...')
|
||||
cmd = 'emulator -avd {name}'.format(name=avd_name)
|
||||
cmd = 'emulator -avd {name} -gpu off'.format(name=avd_name)
|
||||
subprocess.Popen(cmd.split())
|
||||
|
||||
appium = convert_str_to_bool(str(os.getenv('APPIUM', False)))
|
||||
|
||||
@@ -10,22 +10,24 @@ from src import app
|
||||
class TestApp(TestCase):
|
||||
"""Unit test class to test other methods in the app."""
|
||||
|
||||
#create symlink
|
||||
@classmethod
|
||||
def test_symlink_correct(self):
|
||||
os.mknod(os.path.join("./","testFile1.txt"))
|
||||
app.symlink_force(os.path.join("./","testFile1.txt"),os.path.join("./","link_testFile1.txt"))
|
||||
os.remove(os.path.join("./","testFile1.txt"))
|
||||
os.remove(os.path.join("./","link_testFile1.txt"))
|
||||
def test_symlink(self):
|
||||
res = os.path.join('testFile1.txt')
|
||||
dest = os.path.join('link_testFile1.txt')
|
||||
open(res, 'a').close()
|
||||
app.symlink_force(res, dest)
|
||||
os.remove(res)
|
||||
os.remove(dest)
|
||||
|
||||
#link already exist
|
||||
@classmethod
|
||||
def test_symlink_already_exist(self):
|
||||
os.mknod(os.path.join("./","testFile2.txt"))
|
||||
os.mknod(os.path.join("./","link_testFile2.txt"))
|
||||
app.symlink_force(os.path.join("./","testFile2.txt"),os.path.join("./","link_testFile2.txt"))
|
||||
os.remove(os.path.join("./","testFile2.txt"))
|
||||
os.remove(os.path.join("./","link_testFile2.txt"))
|
||||
res = os.path.join('testFile1.txt')
|
||||
dest = os.path.join('link_testFile1.txt')
|
||||
open(res, 'a').close()
|
||||
open(dest, 'a').close()
|
||||
app.symlink_force(res, dest)
|
||||
os.remove(res)
|
||||
os.remove(dest)
|
||||
|
||||
def test_valid_env(self):
|
||||
key = 'ENV_1'
|
||||
|
||||
@@ -8,34 +8,30 @@ from src import app
|
||||
|
||||
|
||||
@mock.patch('subprocess.check_call')
|
||||
@mock.patch('os.symlink')
|
||||
class TestAvd(TestCase):
|
||||
"""Unit test class to test method create_avd."""
|
||||
|
||||
def setUp(self):
|
||||
self.avd_name = 'test_avd'
|
||||
|
||||
def test_nexus_avd_as_default(self, mocked_suprocess, mocked_sys_link):
|
||||
with mock.patch('os.listdir') as mocked_list_dir:
|
||||
mocked_list_dir.return_value = ['file1', 'file2']
|
||||
self.assertFalse(mocked_list_dir.called)
|
||||
self.assertFalse(mocked_sys_link.called)
|
||||
self.assertFalse(mocked_suprocess.called)
|
||||
app.prepare_avd('Nexus 5', self.avd_name)
|
||||
self.assertTrue(mocked_list_dir.called)
|
||||
self.assertTrue(mocked_sys_link.called)
|
||||
self.assertTrue(mocked_suprocess.called)
|
||||
@mock.patch("builtins.open", create=True)
|
||||
def test_nexus_avd_as_default(self, mocked_suprocess, mocked_open):
|
||||
self.assertFalse(mocked_suprocess.called)
|
||||
self.assertFalse(mocked_open.called)
|
||||
app.prepare_avd('Nexus 5', self.avd_name)
|
||||
self.assertTrue(mocked_suprocess.called)
|
||||
self.assertTrue(mocked_open.called)
|
||||
|
||||
def test_samsung_avd(self, mocked_suprocess, mocked_sys_link):
|
||||
with mock.patch('os.listdir') as mocked_list_dir:
|
||||
mocked_list_dir.return_value = ['file1', 'file2']
|
||||
self.assertFalse(mocked_list_dir.called)
|
||||
self.assertFalse(mocked_sys_link.called)
|
||||
self.assertFalse(mocked_suprocess.called)
|
||||
app.prepare_avd('Samsung Galaxy S6', self.avd_name)
|
||||
self.assertTrue(mocked_list_dir.called)
|
||||
self.assertTrue(mocked_sys_link.called)
|
||||
self.assertTrue(mocked_suprocess.called)
|
||||
@mock.patch('os.symlink')
|
||||
@mock.patch("builtins.open", create=True)
|
||||
def test_samsung_avd(self, mocked_suprocess, mocked_sys_link, mocked_open):
|
||||
self.assertFalse(mocked_sys_link.called)
|
||||
self.assertFalse(mocked_suprocess.called)
|
||||
self.assertFalse(mocked_open.called)
|
||||
app.prepare_avd('Samsung Galaxy S6', self.avd_name)
|
||||
self.assertTrue(mocked_sys_link.called)
|
||||
self.assertTrue(mocked_suprocess.called)
|
||||
self.assertTrue(mocked_open.called)
|
||||
|
||||
def tearDown(self):
|
||||
if os.getenv('DEVICE'):
|
||||
|
||||