diff options
author | Kevin Jin <kjin@google.com> | 2014-10-30 17:45:01 -0700 |
---|---|---|
committer | Kevin Jin <kjin@google.com> | 2014-10-30 17:45:01 -0700 |
commit | 7eaedea1d7ac9a4103c616a85351599a290df37f (patch) | |
tree | 2591bc16a0a67a1fdeb7d7947f76fde42ff7b873 /manualtest | |
parent | b8c4f2e950ab8132196dd644d7cfc892f75a8441 (diff) | |
download | droiddriver-7eaedea1d7ac9a4103c616a85351599a290df37f.tar.gz |
add manualtest for DroidDriver
It's a convenient way to reproduce and debug failures without the
dependency on real apps.
Change-Id: Ib8d84b5f2c501e04cf95205c3943d0baf56346ef
Diffstat (limited to 'manualtest')
-rw-r--r-- | manualtest/.classpath | 10 | ||||
-rw-r--r-- | manualtest/.project | 33 | ||||
-rw-r--r-- | manualtest/Android.mk | 18 | ||||
-rw-r--r-- | manualtest/AndroidManifest.xml | 19 | ||||
-rw-r--r-- | manualtest/BUILD | 63 | ||||
-rw-r--r-- | manualtest/project.properties | 14 | ||||
-rw-r--r-- | manualtest/res/.README.txt | 2 | ||||
-rw-r--r-- | manualtest/src/com/google/android/droiddriver/manualtest/ManualTest.java | 45 |
8 files changed, 204 insertions, 0 deletions
diff --git a/manualtest/.classpath b/manualtest/.classpath new file mode 100644 index 0000000..fe82c97 --- /dev/null +++ b/manualtest/.classpath @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="gen"/> + <classpathentry combineaccessrules="false" exported="true" kind="src" path="/DroidDriver"/> + <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/> + <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/> + <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> + <classpathentry kind="output" path="bin/classes"/> +</classpath> diff --git a/manualtest/.project b/manualtest/.project new file mode 100644 index 0000000..8c53fde --- /dev/null +++ b/manualtest/.project @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>ManualDD</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>com.android.ide.eclipse.adt.ApkBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>com.android.ide.eclipse.adt.AndroidNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/manualtest/Android.mk b/manualtest/Android.mk new file mode 100644 index 0000000..57f9bb2 --- /dev/null +++ b/manualtest/Android.mk @@ -0,0 +1,18 @@ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) +LOCAL_PACKAGE_NAME := ManualDD + +LOCAL_MODULE_TAGS := tests + +LOCAL_SRC_FILES := \ + $(call all-java-files-under, src) + +LOCAL_STATIC_JAVA_LIBRARIES := \ + droiddriver + +LOCAL_INSTRUMENTATION_FOR := ManualDD + +LOCAL_SDK_VERSION := 19 + +include $(BUILD_PACKAGE) + diff --git a/manualtest/AndroidManifest.xml b/manualtest/AndroidManifest.xml new file mode 100644 index 0000000..702627e --- /dev/null +++ b/manualtest/AndroidManifest.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="com.google.android.droiddriver.manualtest" + android:versionCode="1" + android:versionName="1.0" > + + <uses-sdk + android:minSdkVersion="7" + android:targetSdkVersion="19" /> + + <instrumentation + android:name="com.google.android.droiddriver.runner.TestRunner" + android:targetPackage="com.google.android.droiddriver.manualtest" /> + + <application> + <uses-library android:name="android.test.runner" /> + </application> + +</manifest> diff --git a/manualtest/BUILD b/manualtest/BUILD new file mode 100644 index 0000000..8c5411e --- /dev/null +++ b/manualtest/BUILD @@ -0,0 +1,63 @@ +# +# Description: +# Tests for DroidDriver test framework + +licenses(["notice"]) # Apache License 2.0, Google-owned + +filegroup( + name = "opensource_filegroup", + srcs = glob(["src/**/*.java"]) + ["AndroidManifest.xml"], + visibility = ["//third_party/java_src/android_libs/droiddriver/opensource:__pkg__"], +) + +android_resources( + name = "resources", + custom_package = "com.google.android.apps.common.testing.ui.testapp.tests", + inline_constants = 0, + manifest = "AndroidManifest.xml", + resources = glob(["res/**"]), + resources_dir = "res", +) + +android_library( + name = "resource_compiletime", + srcs = [":resources"], + neverlink = 1, +) + +# Common android test library, containing: +# project under test library and resources compile-time targets, and +# test project dependencies. +android_library( + name = "test_lib", + srcs = [":resources"], + resources = ":resources", + deps = [ + "//third_party/java/android_libs/droiddriver", + "//third_party/java_src/android_libs/droiddriver/samples/testapp:test_lib", + ], +) + +android_test( + name = "LocalAttachedTests", + size = "medium", + srcs = glob( + ["src/**/*.java"], + ), + args = [ + "--device_broker_type=LOCAL_ADB_SERVER", + ], + resources = ":resources", + shard_count = 1, + tags = [ + "local", + "manual", + "notap", + ], + # unused - actually we used whatever we're attached to. + target_devices = ["//tools/android/emulated_devices/generic_phone:android_7_arm"], + deps = [ + ":test_lib", + "//third_party/java_src/android_libs/droiddriver/samples/testapp", + ], +) diff --git a/manualtest/project.properties b/manualtest/project.properties new file mode 100644 index 0000000..4ab1256 --- /dev/null +++ b/manualtest/project.properties @@ -0,0 +1,14 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +# Project target. +target=android-19 diff --git a/manualtest/res/.README.txt b/manualtest/res/.README.txt new file mode 100644 index 0000000..912f51b --- /dev/null +++ b/manualtest/res/.README.txt @@ -0,0 +1,2 @@ +This file keeps eclipse happy as it doesn't seem able to create the res folder it doesn't actually need. It can be removed if the res folder ever gets real content. +Starting the file with a dot keeps aapt (res compiler) happy. diff --git a/manualtest/src/com/google/android/droiddriver/manualtest/ManualTest.java b/manualtest/src/com/google/android/droiddriver/manualtest/ManualTest.java new file mode 100644 index 0000000..e7e16ce --- /dev/null +++ b/manualtest/src/com/google/android/droiddriver/manualtest/ManualTest.java @@ -0,0 +1,45 @@ +package com.google.android.droiddriver.manualtest; + +import android.app.Activity; + +import com.google.android.droiddriver.actions.TextAction; +import com.google.android.droiddriver.finders.By; +import com.google.android.droiddriver.finders.Finder; +import com.google.android.droiddriver.helpers.BaseDroidDriverTest; +import com.google.android.droiddriver.helpers.DroidDrivers; + +/** + * This is for manually testing DroidDriver. It is not meant for continuous + * testing. Instead it is used for debugging failures. It assumes the device is + * in a condition that is ready to reproduce a failure. For example, + * {@link #testSetTextForPassword} assumes the password_edit field is displayed + * on screen. + * <p> + * Run it as (optionally with -e debug true) + * + * <pre> + * adb shell am instrument -w com.google.android.droiddriver.manualtest/com.google.android.droiddriver.runner.TestRunner + * </pre> + */ +public class ManualTest extends BaseDroidDriverTest<Activity> { + public ManualTest() { + super(Activity.class); + } + + public void testSetTextForPassword() { + Finder password_edit = By.resourceId("com.google.android.gsf.login:id/password_edit"); + driver.on(password_edit).perform( + new TextAction("A fake password that is not empty and needs to be cleared by setText")); + String password = "1"; + driver.on(password_edit).setText(password); + // This won't work because password_edit does not reveal text to + // Accessibility service. But you can see the length changed on screen. + // assertEquals(password, driver.on(password_edit).getText()); + assertEquals(null, driver.on(password_edit).getText()); + } + + @Override + protected final void classSetUp() { + DroidDrivers.init(DroidDrivers.newDriver(getInstrumentation())); + } +} |