Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

Commit 18ee733

Browse files
committed
enable travis ci integration adn add appium test
1 parent 6df917a commit 18ee733

7 files changed

Lines changed: 137 additions & 0 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,10 @@ build/
1010
*.iml
1111
.idea
1212

13+
# Python
14+
__pycache__/
15+
*.py[cod]
16+
appium/pytestdebug.log
17+
1318
# Windows thumbnail db
1419
.DS_Store

.travis.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
language: android
2+
3+
android:
4+
components:
5+
# The BuildTools version used by your project
6+
- build-tools-22
7+
8+
# The SDK version used to compile your project
9+
- android-22
10+
11+
# command to install dependencies
12+
install:
13+
- pip install sauceclient
14+
- pip install Appium-Python-Client
15+
- pip install pytest
16+
17+
# command to build and run tests
18+
script:
19+
- ./gradlew assembleDebug
20+
- sh run_tests.sh
21+
22+
addons:
23+
sauce_connect: true
24+
25+
env:
26+
global:
27+
- secure: fJarjAplGGrBQuw8gGiTVnhYK9K1k9g0HBB7OohST9EANHbVUQ/x4umQ2edha1felgleCahGRr4u7Yn0KliLjld4B5cdTdGtDoNy86yiT3nGjJIbgcdPOAuPDZf+1Oy9aWhmVHYmuK26gOBIqOgen5BwOPwvI4mwZePd4DigfkY=
28+
- secure: f/LHDLN6O4ODABk3EHe1X/X7HCBjHZ5QAWkKJVLNZOQCMNLwpMPsHhdSQuqDW/f+rFqjPABuF3JsWaX8jcJqkh8/n9u381AwGxZSY0IDzq2Iluo5UKthoR2E4EekR6vTiJf9mmlWQ1lCG817Jyt+GLgwX1CuWyU9r4LhhBXUOl0=

app/src/main/res/layout/activity_settings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<Switch android:id="@+id/grid_switch"
2727
android:layout_width="wrap_content"
2828
android:layout_height="wrap_content"
29+
android:contentDescription="Grid Switch"
2930
android:layout_alignBaseline="@id/app_title"
3031
android:layout_alignParentEnd="true"
3132
android:layout_alignParentRight="true"/>

appium/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# DesignOverlay UI Test
2+
3+
## Set up
4+
5+
Install sauce labs client library:
6+
7+
```shell
8+
pip install sauceclient
9+
```
10+
11+
Install appium client library:
12+
13+
```shell
14+
pip install Appium-Python-Client
15+
pip install pytest
16+
```
17+
18+
## how to run (SauceLabs)
19+
To see logging statements as they are executed, pass the -s flag to py.test.
20+
For configuration, look at the config_sauce_labs.json.example.
21+
22+
```shell
23+
py.test -s appium/android_sauce_labs.py
24+
```

appium/android_sauce_labs.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
"""
5+
6+
Author : Manabu Shimobe
7+
8+
"""
9+
__author__ = "Manabu Shimobe"
10+
11+
from appium import webdriver
12+
from appium import SauceTestCase, on_platforms
13+
14+
from time import sleep
15+
from logging import getLogger, StreamHandler, Formatter, DEBUG
16+
import json
17+
18+
# load default platform configurations
19+
json_file = open('appium/config_sauce_labs.json')
20+
platforms = json.load(json_file)
21+
json_file.close()
22+
23+
# set up logger
24+
logger = getLogger(__name__)
25+
logger.setLevel(DEBUG)
26+
handler = StreamHandler()
27+
handler.setFormatter(Formatter('%(asctime)s- %(name)s - %(levelname)s - %(message)s'))
28+
handler.setLevel(DEBUG)
29+
logger.addHandler(handler)
30+
31+
# the emulator is sometimes slow
32+
SLEEP_TIME = 1
33+
34+
@on_platforms(platforms)
35+
class SimpleAndroidSauceTests(SauceTestCase):
36+
37+
def test_settings(self):
38+
sleep(SLEEP_TIME)
39+
40+
# Check if successfully started SettingsActivity
41+
self.assertEqual('.activity.SettingsActivity_', self.driver.current_activity)
42+
43+
el_switch = self.driver.find_element_by_accessibility_id('Grid Switch')
44+
self.assertIsNotNone(el_switch)
45+
46+
# Grid should be shown now
47+
el_switch.click()
48+
logger.info('Clicked Grid Switch')
49+
50+
sleep(SLEEP_TIME)

appium/config_sauce_labs.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[
2+
{
3+
"platformName":"Android",
4+
"platformVersion":"4.4",
5+
"deviceName":"Android Emulator",
6+
"appPackage":"com.ms_square.android.design.overlay",
7+
"appActivity":".activity.SettingsActivity_",
8+
"app":"sauce-storage:design_overlay.apk",
9+
"appiumVersion":"1.3.6"
10+
}
11+
]

run_tests.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
echo "Uploading debug apk to SauceLabs..."
4+
5+
res=`curl -w %{http_code} -u $SAUCE_USERNAME:$SAUCE_ACCESS_KEY -X POST "http://saucelabs.com/rest/v1/storage/$SAUCE_USERNAME/design_overlay.apk?overwrite=true" \
6+
-H "Content-Type: application/octet-stream" --data-binary @app/build/outputs/apk/app-debug.apk`
7+
8+
if [ $res -eq 200 ]
9+
then
10+
echo "APK Uploaded..."
11+
else
12+
echo "APK Upload failed..."
13+
exit 1
14+
fi
15+
16+
echo "Starting tests..."
17+
18+
py.test -s appium/android_sauce_labs.py

0 commit comments

Comments
 (0)