Skip to content

Commit

Permalink
enable travis ci integration adn add appium test
Browse files Browse the repository at this point in the history
  • Loading branch information
Manabu-GT committed Mar 30, 2015
1 parent 6df917a commit 18ee733
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@ build/
*.iml
.idea

# Python
__pycache__/
*.py[cod]
appium/pytestdebug.log

# Windows thumbnail db
.DS_Store
28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
language: android

android:
components:
# The BuildTools version used by your project
- build-tools-22

# The SDK version used to compile your project
- android-22

# command to install dependencies
install:
- pip install sauceclient
- pip install Appium-Python-Client
- pip install pytest

# command to build and run tests
script:
- ./gradlew assembleDebug
- sh run_tests.sh

addons:
sauce_connect: true

env:
global:
- secure: fJarjAplGGrBQuw8gGiTVnhYK9K1k9g0HBB7OohST9EANHbVUQ/x4umQ2edha1felgleCahGRr4u7Yn0KliLjld4B5cdTdGtDoNy86yiT3nGjJIbgcdPOAuPDZf+1Oy9aWhmVHYmuK26gOBIqOgen5BwOPwvI4mwZePd4DigfkY=
- secure: f/LHDLN6O4ODABk3EHe1X/X7HCBjHZ5QAWkKJVLNZOQCMNLwpMPsHhdSQuqDW/f+rFqjPABuF3JsWaX8jcJqkh8/n9u381AwGxZSY0IDzq2Iluo5UKthoR2E4EekR6vTiJf9mmlWQ1lCG817Jyt+GLgwX1CuWyU9r4LhhBXUOl0=
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<Switch android:id="@+id/grid_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="Grid Switch"
android:layout_alignBaseline="@id/app_title"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"/>
Expand Down
24 changes: 24 additions & 0 deletions appium/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# DesignOverlay UI Test

## Set up

Install sauce labs client library:

```shell
pip install sauceclient
```

Install appium client library:

```shell
pip install Appium-Python-Client
pip install pytest
```

## how to run (SauceLabs)
To see logging statements as they are executed, pass the -s flag to py.test.
For configuration, look at the config_sauce_labs.json.example.

```shell
py.test -s appium/android_sauce_labs.py
```
50 changes: 50 additions & 0 deletions appium/android_sauce_labs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Author : Manabu Shimobe
"""
__author__ = "Manabu Shimobe"

from appium import webdriver
from appium import SauceTestCase, on_platforms

from time import sleep
from logging import getLogger, StreamHandler, Formatter, DEBUG
import json

# load default platform configurations
json_file = open('appium/config_sauce_labs.json')
platforms = json.load(json_file)
json_file.close()

# set up logger
logger = getLogger(__name__)
logger.setLevel(DEBUG)
handler = StreamHandler()
handler.setFormatter(Formatter('%(asctime)s- %(name)s - %(levelname)s - %(message)s'))
handler.setLevel(DEBUG)
logger.addHandler(handler)

# the emulator is sometimes slow
SLEEP_TIME = 1

@on_platforms(platforms)
class SimpleAndroidSauceTests(SauceTestCase):

def test_settings(self):
sleep(SLEEP_TIME)

# Check if successfully started SettingsActivity
self.assertEqual('.activity.SettingsActivity_', self.driver.current_activity)

el_switch = self.driver.find_element_by_accessibility_id('Grid Switch')
self.assertIsNotNone(el_switch)

# Grid should be shown now
el_switch.click()
logger.info('Clicked Grid Switch')

sleep(SLEEP_TIME)
11 changes: 11 additions & 0 deletions appium/config_sauce_labs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"platformName":"Android",
"platformVersion":"4.4",
"deviceName":"Android Emulator",
"appPackage":"com.ms_square.android.design.overlay",
"appActivity":".activity.SettingsActivity_",
"app":"sauce-storage:design_overlay.apk",
"appiumVersion":"1.3.6"
}
]
18 changes: 18 additions & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

echo "Uploading debug apk to SauceLabs..."

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" \
-H "Content-Type: application/octet-stream" --data-binary @app/build/outputs/apk/app-debug.apk`

if [ $res -eq 200 ]
then
echo "APK Uploaded..."
else
echo "APK Upload failed..."
exit 1
fi

echo "Starting tests..."

py.test -s appium/android_sauce_labs.py

0 comments on commit 18ee733

Please sign in to comment.