diff --git a/.gitignore b/.gitignore index c07e74d..5b9d56d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,5 +10,10 @@ build/ *.iml .idea +# Python +__pycache__/ +*.py[cod] +appium/pytestdebug.log + # Windows thumbnail db .DS_Store \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..2542004 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,29 @@ +language: android + +android: + components: + # The BuildTools version used by your project + - build-tools-22.0.1 + + # The SDK version used to compile your project + - android-22 + + # Additional components + - extra-android-m2repository + +# command to install dependencies +install: + - sudo pip install -r requirements.txt + +# command to build and run tests +script: + - ./gradlew assembleDebug + - sh run_tests.sh + +addons: + sauce_connect: true + +env: + global: + - secure: A1jbSplRPc7lRcjT6yY3Z33ynAEmiSzub5ADEXys4VtzjhenRCejkYAyLmNLm4ywbWWhmmZqXT70YPJQTBr5tbZlfHx5P2GRU1MtBvcXSUO+5RJ3swc80UOVvllhfHNuiiraqwSNcWl7skPHxDfBPBe8QOLp4A17JpJEJ8nFqpc= + - secure: fFmQjyp/tTloQmWFnNb7CZQsk92kZV7a78J0y0XW1kW+NPauxQ7MHsI9GAsOrEByyGF4xz2eKq37Z+LoMZtvcCgPWz5mt62QFQ2jXDxXckVeYr6JQW6gnXMcCR96V7RYLPHW9HbfOYcchiS2lu5ytogNh3NU35OgAscOTfO0Gtc= \ No newline at end of file diff --git a/README.md b/README.md index a358344..cc64db4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ -DesignOverlay - for developers and designers [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-DesignOverlay-brightgreen.svg?style=flat)](http://android-arsenal.com/details/3/1654) +DesignOverlay - for developers and designers =============== + +[![Build Status](https://travis-ci.org/Manabu-GT/DesignOverlay-Android.svg?branch=master)](https://travis-ci.org/Manabu-GT/DesignOverlay-Android) +[![Sauce Test Status](https://saucelabs.com/buildstatus/design-overlay)](https://saucelabs.com/u/design-overlay) +[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-DesignOverlay-brightgreen.svg?style=flat)](http://android-arsenal.com/details/3/1654) + DesignOverlay is an android app which displays a design image with grid lines to facilitate the tedious layout process. The grid is especially useful to align to baseline grids as described in [Android Design Guidelines][1]. diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 4d86f96..b718201 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -26,6 +26,7 @@ diff --git a/appium/README.md b/appium/README.md new file mode 100644 index 0000000..0301fc0 --- /dev/null +++ b/appium/README.md @@ -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 +``` \ No newline at end of file diff --git a/appium/android_sauce_labs.py b/appium/android_sauce_labs.py new file mode 100644 index 0000000..4c30319 --- /dev/null +++ b/appium/android_sauce_labs.py @@ -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) \ No newline at end of file diff --git a/appium/config_sauce_labs.json b/appium/config_sauce_labs.json new file mode 100644 index 0000000..d2cb3d7 --- /dev/null +++ b/appium/config_sauce_labs.json @@ -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" + } +] \ No newline at end of file diff --git a/build.gradle b/build.gradle index d3c94bd..cf3999e 100644 --- a/build.gradle +++ b/build.gradle @@ -22,13 +22,13 @@ allprojects { // http://www.gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html project.ext { ANDROID_BUILD_SDK_VERSION = 22 - ANDROID_BUILD_TOOLS_VERSION = "22" + ANDROID_BUILD_TOOLS_VERSION = "22.0.1" ANDROID_BUILD_MIN_SDK_VERSION = 14 ANDROID_BUILD_TARGET_SDK_VERSION = 22 // Google Stuffs - supportPackageVersion = "21.0.3" + supportPackageVersion = "22.0.0" // APT plugin and Android Annotations daggerVersion = "1.2.1" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..40da80e --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +# requirements.txt for pip install +sauceclient +Appium-Python-Client +pytest \ No newline at end of file diff --git a/run_tests.sh b/run_tests.sh new file mode 100644 index 0000000..792b5a7 --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +echo "Uploading debug apk to SauceLabs..." + +res=`curl -w %{http_code} --output /dev/null -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 \ No newline at end of file