Remove unused code
The real code has already been moved under /vendor/google
Change-Id: Ia0877ec5ffbd4409a56d4c3eb9828d0c9ece46d0
diff --git a/UiAutomation/Android.mk b/UiAutomation/Android.mk
deleted file mode 100644
index 16acb3a..0000000
--- a/UiAutomation/Android.mk
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-# Build service apk
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_SRC_FILES := $(call all-java-files-under, service/src)
-LOCAL_SRC_FILES += \
- service/src/com/android/testing/uiautomation/Provider.aidl
-LOCAL_MANIFEST_FILE := service/AndroidManifest.xml
-LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/service/res
-LOCAL_PACKAGE_NAME := UiAutomationService
-LOCAL_CERTIFICATE := platform
-include $(BUILD_PACKAGE)
-
-# Build embeddable jar
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := tests
-LOCAL_SRC_FILES := $(call all-java-files-under, library/src)
-LOCAL_SRC_FILES += \
- service/src/com/android/testing/uiautomation/Provider.aidl
-LOCAL_JAVA_LIBRARIES := android.test.runner
-LOCAL_MODULE := UiAutomationLibrary
-include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/UiAutomation/library/src/com/android/testing/uiautomation/AutomationProvider.java b/UiAutomation/library/src/com/android/testing/uiautomation/AutomationProvider.java
deleted file mode 100644
index db13824..0000000
--- a/UiAutomation/library/src/com/android/testing/uiautomation/AutomationProvider.java
+++ /dev/null
@@ -1,410 +0,0 @@
-package com.android.testing.uiautomation;
-
-import android.content.ComponentName;
-import android.content.Context;
-import android.content.Intent;
-import android.content.ServiceConnection;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.util.Log;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-
-/**
- * A convenient class for accessing UI automation service
- *
- * This class hides implementation details of starting Android services.
- * It provides identical interface to the service. However each function
- * still throws {@link RemoteException}
- *
- */
-public class AutomationProvider {
-
- private static final String LOGTAG = "UiAutomationClientLibrary";
- private static final String SERVICE_NAME = "com.android.testing.uiautomation";
- private static final long SERVICE_BIND_TIMEOUT = 3000;
-
- private Provider mService = null;
- private Object mServiceLock = null;
- private TraceLogger mTraceLogger = new TraceLogger();
- private ServiceConnection mServiceConnection = new ServiceConnection() {
- @Override
- public void onServiceDisconnected(ComponentName name) {
- synchronized (mServiceLock) {
- mService = null;
- Log.e(LOGTAG, "Provider service disconnected unexptectedly.");
- mServiceLock.notifyAll();
- }
- }
-
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- synchronized (mServiceLock) {
- mService = Provider.Stub.asInterface(service);
- mServiceLock.notifyAll();
- }
- }
- };
-
- /**
- *
- * Initializes the UI automation provider instance.
- *
- * The constructor will attempt to bind the UI automation service
- *
- * @param context
- * @throws IOException if the provider failed to bind the service
- */
- public AutomationProvider(Context context) throws IOException {
- mServiceLock = new Object();
- if (!context.bindService(new Intent(SERVICE_NAME),
- mServiceConnection, Context.BIND_AUTO_CREATE)) {
- throw new IOException("Failed to connect to Provider service");
- }
- synchronized (mServiceLock) {
- if (mService == null) {
- try {
- // wait 3s for the service to finish connecting, should take less than that
- mServiceLock.wait(SERVICE_BIND_TIMEOUT);
- } catch (InterruptedException ie) {
- }
- }
- }
- if (mService == null) {
- throw new IOException("Failed to connect to Provider service");
- }
- try {
- if (!mService.checkUiVerificationEnabled()) {
- throw new IOException("dependent services are not running");
- }
- } catch (RemoteException re) {
- throw new IOException("error checking dependent services", re);
- }
- }
-
- /**
- * Retrieves the name (or textual information) of current foreground activity
- * @return the name
- * @throws RemoteException
- */
- public String getCurrentActivityName() throws RemoteException {
- String result = null;
- try {
- result = mService.getCurrentActivityName();
- } catch (RemoteException re) {
- mTraceLogger.logTrace(TraceLogger.FUNC_GET_CURR_ACTIVITY_NAME, re);
- throw re;
- }
- mTraceLogger.logTrace(TraceLogger.FUNC_GET_CURR_ACTIVITY_NAME, result);
- return result;
- }
-
- /**
- * Retrieves the Android package name of current foreground activity
- * @return the Android package name
- * @throws RemoteException
- */
- public String getCurrentActivityPackage() throws RemoteException {
- String result = null;
- try {
- result = mService.getCurrentActivityPackage();
- } catch (RemoteException re) {
- mTraceLogger.logTrace(TraceLogger.FUNC_GET_CURR_ACTIVITY_PKG, re);
- throw re;
- }
- mTraceLogger.logTrace(TraceLogger.FUNC_GET_CURR_ACTIVITY_PKG, result);
- return result;
- }
-
- /**
- * Retrieves the class name of current foreground activity
- * @return the class name
- * @throws RemoteException
- */
- public String getCurrentActivityClass() throws RemoteException {
- String result = null;
- try {
- result = mService.getCurrentActivityClass();
- } catch (RemoteException re) {
- mTraceLogger.logTrace(TraceLogger.FUNC_GET_CURR_ACTIVITY_CLASS, re);
- throw re;
- }
- mTraceLogger.logTrace(TraceLogger.FUNC_GET_CURR_ACTIVITY_CLASS, result);
- return result;
- }
-
- /**
- * Check if the UI widget is enabled
- * @param selector a selector to identify the UI widget
- * @return if it's enabled or not
- * @throws RemoteException when the UI widget cannot be found or other service errors
- */
- public boolean isEnabled(String selector) throws RemoteException {
- boolean result = false;
- try {
- result = mService.isEnabled(selector);
- } catch (RemoteException re) {
- mTraceLogger.logTrace(TraceLogger.FUNC_IS_ENABLED, selector, re);
- throw re;
- }
- mTraceLogger.logTrace(TraceLogger.FUNC_IS_ENABLED, selector, result);
- return result;
- }
-
- /**
- * Check if the UI widget is focused
- * @param selector a selector to identify the UI widget
- * @return if it's focused or not
- * @throws RemoteException when the UI widget cannot be found or other service errors
- */
- public boolean isFocused(String selector) throws RemoteException {
- boolean result = false;
- try {
- result = mService.isFocused(selector);
- } catch (RemoteException re) {
- mTraceLogger.logTrace(TraceLogger.FUNC_IS_FOCUSED, selector, re);
- throw re;
- }
- mTraceLogger.logTrace(TraceLogger.FUNC_IS_FOCUSED, selector, result);
- return result;
- }
-
- /**
- * Get the number of children of the UI widget
- * @param selector a selector to identify the UI widget
- * @return the number of children
- * @throws RemoteException when the UI widget cannot be found or other service errors
- */
- public int getChildCount(String selector) throws RemoteException {
- int result = 0;
- try {
- result = mService.getChildCount(selector);
- } catch (RemoteException re) {
- mTraceLogger.logTrace(TraceLogger.FUNC_GET_CHILD_COUNT, selector, re);
- throw re;
- }
- mTraceLogger.logTrace(TraceLogger.FUNC_GET_CHILD_COUNT, selector, result);
- return result;
- }
-
- /**
- * Get the text of the UI widget
- * @param selector a selector to identify the UI widget
- * @return the text, or null when the UI widget cannot be found
- * @throws RemoteException
- */
- public String getText(String selector) throws RemoteException {
- String result = null;
- try {
- result = mService.getText(selector);
- } catch (RemoteException re) {
- mTraceLogger.logTrace(TraceLogger.FUNC_GET_TEXT, selector, re);
- throw re;
- }
- mTraceLogger.logTrace(TraceLogger.FUNC_GET_TEXT, selector, result);
- return result;
- }
-
- /**
- * Get the class name of the UI widget
- * @param selector a selector to identify the UI widget
- * @return the class name, or null when the UI widget cannot be found
- * @throws RemoteException
- */
- public String getClassName(String selector) throws RemoteException {
- String result = null;
- try {
- result = mService.getClassName(selector);
- } catch (RemoteException re) {
- mTraceLogger.logTrace(TraceLogger.FUNC_GET_CLASS_NAME, selector, re);
- throw re;
- }
- mTraceLogger.logTrace(TraceLogger.FUNC_GET_CLASS_NAME, selector, result);
- return result;
- }
-
- /**
- * Perform a click on the UI widget
- * @param selector a selector to identify the UI widget
- * @return true if the click succeeded, false if the widget cannot be found or other errors
- * @throws RemoteException
- */
- public boolean click(String selector) throws RemoteException {
- boolean result = false;
- try {
- result = mService.click(selector);
- } catch (RemoteException re) {
- mTraceLogger.logTrace(TraceLogger.FUNC_CLICK, selector, re);
- throw re;
- }
- mTraceLogger.logTrace(TraceLogger.FUNC_CLICK, selector, result);
- return result;
- }
-
- /**
- * Set the text of a text field identified by the preceding label
- * @param label the text content of the label preceding the text field
- * @param text the text to fill into the text field
- * @return true if setting text succeeded, false if the widget cannot be found or other errors
- * @throws RemoteException
- */
- public boolean setTextFieldByLabel(String label, String text) throws RemoteException {
- boolean result = false;
- try {
- result = mService.setTextFieldByLabel(label, text);
- } catch (RemoteException re) {
- mTraceLogger.logTrace(TraceLogger.FUNC_SET_TEXT_BY_LABEL, label, text, re);
- throw re;
- }
- mTraceLogger.logTrace(TraceLogger.FUNC_SET_TEXT_BY_LABEL, label, text, result);
- return result;
- }
-
- /**
- * Send the text via key presses, the caller is responsible for moving input focus to proper
- * UI widget first
- * @param text the text to fill into the text field
- * @return true if input succeeded
- * @throws RemoteException
- */
- public boolean sendText(String text) throws RemoteException {
- boolean result = false;
- try {
- result = mService.sendText(text);
- } catch (RemoteException re) {
- mTraceLogger.logTrace(TraceLogger.FUNC_INPUT_TEXT, text, re);
- throw re;
- }
- mTraceLogger.logTrace(TraceLogger.FUNC_INPUT_TEXT, text, result);
- return result;
- }
-
- /**
- * Enable trace logging of all calls to UI automation service
- * @param pw a {@link PrintWriter} to receive log entries
- */
- public void setTraceLoggerOutput(Writer writer) {
- mTraceLogger.setOutput(writer);
- }
-
- /**
- * A utility class that logs calls to AutomationProvider
- *
- */
- private class TraceLogger {
-
- private Writer mWriter;
- private String mLastLog;
- private boolean mWroteDot = false;
- public static final int FUNC_CLICK = 0;
- public static final int FUNC_GET_CHILD_COUNT = 1;
- public static final int FUNC_GET_CLASS_NAME = 2;
- public static final int FUNC_GET_CURR_ACTIVITY_CLASS = 3;
- public static final int FUNC_GET_CURR_ACTIVITY_NAME = 4;
- public static final int FUNC_GET_CURR_ACTIVITY_PKG = 5;
- public static final int FUNC_GET_TEXT = 6;
- public static final int FUNC_INPUT_TEXT = 7;
- public static final int FUNC_IS_ENABLED = 8;
- public static final int FUNC_IS_FOCUSED = 9;
- public static final int FUNC_SET_TEXT_BY_LABEL = 10;
-
- public void setOutput(Writer writer) {
- mWriter = writer;
- }
-
- /**
- * Log the function call
- * @param function the int id to identify the call
- * @param args arguments passed to the function AND the return value as last argument
- */
- public void logTrace(int function, Object...args) {
- if (mWriter != null) {
- Object result = null;
- // strip out argument list
- String argList = "[]";
- if (args != null && args.length > 0) {
- result = args[args.length - 1];
- if (args.length > 1) {
- StringBuffer sb = new StringBuffer();
- sb.append('[');
- for (int i = 0; i < args.length - 1; i++) {
- if (args[i] != null) {
- sb.append(args[i].toString());
- } else {
- sb.append("null");
- }
- sb.append(',');
- }
- sb.append(']');
- argList = sb.toString();
- }
- }
- // separate out return value, or exception
- String str = null;
- if (result == null) {
- result = "null";
- } else if (result instanceof Throwable) {
- Throwable t = (Throwable)result;
- str = String.format("%s(%s)", t.getClass().toString(), t.getMessage());
- } else {
- str = result.toString();
- }
- try {
- // avoid spamming with duplicate log entries
- String log = String.format("func:[%s] args:%s return:[%s]",
- getFunctionName(function), argList, str);
- if (log.equals(mLastLog)) {
- mWriter.write('.');
- mWroteDot = true;
- } else {
- if (mWroteDot) mWriter.write('\n');
- mWroteDot = false;
- mWriter.write(String.format("%s %s\n", now(), log));
- mWriter.flush();
- }
- mLastLog = log;
- } catch (IOException e) {
- }
- }
- }
-
- private String now() {
- Calendar cal = Calendar.getInstance();
- SimpleDateFormat sdf = new SimpleDateFormat("MM-dd hh:mm:ss.SSS");
- return sdf.format(cal.getTime());
- }
-
- private String getFunctionName(int func) {
- switch (func) {
- case FUNC_CLICK:
- return "click";
- case FUNC_GET_CHILD_COUNT:
- return "getChildCount";
- case FUNC_GET_CLASS_NAME:
- return "getClassName";
- case FUNC_GET_CURR_ACTIVITY_CLASS:
- return "getCurrentActivityClass";
- case FUNC_GET_CURR_ACTIVITY_NAME:
- return "getCurrentActivityName";
- case FUNC_GET_CURR_ACTIVITY_PKG:
- return "getCurrentActivityPackage";
- case FUNC_GET_TEXT:
- return "getText";
- case FUNC_INPUT_TEXT:
- return "inputText";
- case FUNC_IS_ENABLED:
- return "isEnabled";
- case FUNC_IS_FOCUSED:
- return "isFocused";
- case FUNC_SET_TEXT_BY_LABEL:
- return "setTextFieldByLabel";
- default:
- return "unknown";
- }
- }
- }
-}
diff --git a/UiAutomation/library/src/com/android/testing/uiautomation/InjectAutomationProvider.java b/UiAutomation/library/src/com/android/testing/uiautomation/InjectAutomationProvider.java
deleted file mode 100644
index 2889b2a..0000000
--- a/UiAutomation/library/src/com/android/testing/uiautomation/InjectAutomationProvider.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.android.testing.uiautomation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface InjectAutomationProvider {
-
-}
diff --git a/UiAutomation/library/src/com/android/testing/uiautomation/InjectParams.java b/UiAutomation/library/src/com/android/testing/uiautomation/InjectParams.java
deleted file mode 100644
index c35e9eb..0000000
--- a/UiAutomation/library/src/com/android/testing/uiautomation/InjectParams.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.android.testing.uiautomation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface InjectParams {
-}
diff --git a/UiAutomation/library/src/com/android/testing/uiautomation/UiAutomationTestRunner.java b/UiAutomation/library/src/com/android/testing/uiautomation/UiAutomationTestRunner.java
deleted file mode 100644
index 157623d..0000000
--- a/UiAutomation/library/src/com/android/testing/uiautomation/UiAutomationTestRunner.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package com.android.testing.uiautomation;
-
-import android.os.Bundle;
-import android.test.AndroidTestRunner;
-import android.test.InstrumentationTestRunner;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.Test;
-import junit.framework.TestListener;
-
-public class UiAutomationTestRunner extends InstrumentationTestRunner {
-
- // there's nothing fan
- private Bundle mParams;
- private AutomationProvider mAutomationProvider;
-
- @Override
- public void onCreate(Bundle arguments) {
- mParams = new Bundle(arguments);
- super.onCreate(arguments);
- }
-
- public Bundle getInitialParams() {
- return mParams;
- }
-
- private AutomationProvider getAutomationProvider() throws IOException {
- if (mAutomationProvider == null) {
- mAutomationProvider = new AutomationProvider(getTargetContext());
- }
- return mAutomationProvider;
- }
-
- @Override
- protected AndroidTestRunner getAndroidTestRunner() {
- // TODO Auto-generated method stub
- AndroidTestRunner testRunner = super.getAndroidTestRunner();
- testRunner.addTestListener(new TestListener() {
-
- @Override
- public void startTest(Test test) {
- Field[] fields = test.getClass().getDeclaredFields();
- for (Field field : fields) {
- if (field.getAnnotation(InjectParams.class) != null) {
- if (Bundle.class.equals(field.getType())) {
- field.setAccessible(true);
- try {
- field.set(test, mParams);
- } catch (IllegalAccessException e) {
- throw new RuntimeException("failed to inject Bundle parameter", e);
- }
- } else {
- throw new IllegalArgumentException("Need Bundle type for injection");
- }
- }
- if (field.getAnnotation(InjectAutomationProvider.class) != null) {
- if (AutomationProvider.class.equals(field.getType())) {
- field.setAccessible(true);
- try {
- field.set(test, getAutomationProvider());
- } catch (IllegalAccessException e) {
- throw new RuntimeException("failed to inject AutomationProvider", e);
- } catch (IOException e) {
- throw new RuntimeException("failed to init AutomationProvider", e);
- }
- }
- }
- }
- }
-
- @Override
- public void endTest(Test test) {
- }
-
- @Override
- public void addFailure(Test test, AssertionFailedError t) {
- }
-
- @Override
- public void addError(Test test, Throwable t) {
- }
- });
- return testRunner;
- }
-}
diff --git a/UiAutomation/library/src/com/android/testing/uiautomation/UiTestHelper.java b/UiAutomation/library/src/com/android/testing/uiautomation/UiTestHelper.java
deleted file mode 100644
index fc096ea..0000000
--- a/UiAutomation/library/src/com/android/testing/uiautomation/UiTestHelper.java
+++ /dev/null
@@ -1,98 +0,0 @@
-
-package com.android.testing.uiautomation;
-
-import android.content.Context;
-import android.content.Intent;
-import android.content.pm.IPackageManager;
-import android.content.pm.ResolveInfo;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.os.SystemClock;
-import android.util.Log;
-
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-public class UiTestHelper {
-
- private static final String LOGTAG = "UiTestHelper";
-
- private static final long DEFAULT_WAIT_TIMEOUT = 5000;
-
- private static final long POLL_INTERVAL = 250;
-
- private Context mContext;
- private AutomationProvider mProvider;
- private Map<String, Intent> mLauncherAppList;
-
- public UiTestHelper(Context context, AutomationProvider provider) {
- mContext = context;
- mProvider = provider;
- reloadLauncherAppList();
- }
-
- public boolean waitForWindow(String title) {
- return waitForWindow(title, DEFAULT_WAIT_TIMEOUT);
- }
-
- public boolean waitForWindow(String title, long timeout) {
- long startMills = SystemClock.uptimeMillis();
- boolean titleMatch = false;
- while (SystemClock.uptimeMillis() - startMills < timeout) {
- try {
- titleMatch = title.equals(mProvider.getCurrentActivityName());
- } catch (RemoteException e) {
- Log.e(LOGTAG, "failed to get current activity name", e);
- break;
- }
- if (titleMatch)
- break;
- try {
- Thread.sleep(POLL_INTERVAL);
- } catch (InterruptedException e) {
- }
- }
- return titleMatch;
- }
-
- public void reloadLauncherAppList() {
- mLauncherAppList = getLauncherAppList();
- }
-
- public boolean launchApplication(String appName) {
- Intent intent = mLauncherAppList.get(appName);
- if (intent == null)
- return false;
- mContext.startActivity(intent);
- return true;
- }
-
- private Map<String, Intent> getLauncherAppList() {
- final Intent queryIntent = new Intent();
- final Map<String, Intent> launchIntents = new TreeMap<String, Intent>();
- // get package manager and query pm for intents declared by apps as
- // launcher and main
- // basically those shown as icons in all apps screen
- IPackageManager mPm = IPackageManager.Stub
- .asInterface(ServiceManager.getService("package"));
- queryIntent.addCategory(Intent.CATEGORY_LAUNCHER);
- queryIntent.setAction(Intent.ACTION_MAIN);
- final List<ResolveInfo> results;
- try {
- results = mPm.queryIntentActivities(queryIntent, null, 0);
- } catch (RemoteException e) {
- e.printStackTrace();
- return null;
- }
- for (ResolveInfo info : results) {
- Intent tmpIntent = new Intent(queryIntent);
- tmpIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- tmpIntent.setClassName(info.activityInfo.applicationInfo.packageName,
- info.activityInfo.name);
- String appName = info.activityInfo.loadLabel(mContext.getPackageManager()).toString();
- launchIntents.put(appName, tmpIntent);
- }
- return launchIntents;
- }
-}
diff --git a/UiAutomation/service/AndroidManifest.xml b/UiAutomation/service/AndroidManifest.xml
deleted file mode 100644
index ee35b6d..0000000
--- a/UiAutomation/service/AndroidManifest.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project Licensed under the
- Apache License, Version 2.0 (the "License"); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software distributed
- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- OR CONDITIONS OF ANY KIND, either express or implied. See the License for
- the specific language governing permissions and limitations under the License. -->
-
-<!-- Declare the contents of this Android application. The namespace attribute
- brings in the Android platform namespace, and the package supplies a unique
- name for the application. When writing your own application, the package
- name must be changed from "com.example.*" to come from a domain that you
- own or have control over. -->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.testing.uiautomation"
- android:sharedUserId="android.uid.system">
-
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <application android:label="UI Automation Provider">
- <service android:name="ProviderService"
- android:label="UI Automation Provider"
- android:exported="true"
- android:enabled="true">
- <intent-filter>
- <action android:name="com.android.testing.uiautomation" />
- </intent-filter>
- </service>
- </application>
-
-</manifest>
diff --git a/UiAutomation/service/src/com/android/testing/uiautomation/AccessibilityNodeInfoHelper.java b/UiAutomation/service/src/com/android/testing/uiautomation/AccessibilityNodeInfoHelper.java
deleted file mode 100644
index 9426814..0000000
--- a/UiAutomation/service/src/com/android/testing/uiautomation/AccessibilityNodeInfoHelper.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package com.android.testing.uiautomation;
-
-import org.xmlpull.v1.XmlSerializer;
-
-import android.graphics.Rect;
-import android.os.Environment;
-import android.os.SystemClock;
-import android.util.Log;
-import android.util.Xml;
-import android.view.accessibility.AccessibilityNodeInfo;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.LinkedList;
-import java.util.Queue;
-
-public class AccessibilityNodeInfoHelper {
-
- private static final String LOGTAG = "AccessibilityNodeInfoHelper";
-
- public static void dumpWindowToFile(AccessibilityNodeInfo info) {
- AccessibilityNodeInfo root = getRootAccessibilityNodeInfo(info);
- if (root == null) {
- return;
- }
- final long startTime = SystemClock.uptimeMillis();
- try {
- File baseDir = new File(Environment.getDataDirectory(), "uidump");
- if (!baseDir.exists()) {
- baseDir.mkdir();
- baseDir.setExecutable(true, false);
- baseDir.setWritable(true, false);
- baseDir.setReadable(true, false);
- }
- FileWriter writer = new FileWriter(
- new File(baseDir, "window_dump.xml"));
- XmlSerializer serializer = Xml.newSerializer();
- StringWriter stringWriter = new StringWriter();
- serializer.setOutput(stringWriter);
- serializer.startDocument("UTF-8", true);
- serializer.startTag("", "hierarchy");
- dumpNodeRec(root, serializer, 0);
- if (root != info)
- root.recycle();
- serializer.endTag("", "hierarchy");
- serializer.endDocument();
- writer.write(stringWriter.toString());
- writer.close();
- } catch (IOException e) {
- Log.e(LOGTAG, "failed to dump window to file", e);
- }
- final long endTime = SystemClock.uptimeMillis();
- Log.w(LOGTAG, "Fetch time: " + (endTime - startTime) + "ms");
- }
-
- public static void dumpNodeRec(AccessibilityNodeInfo node, XmlSerializer serializer, int index)
- throws IOException {
- serializer.startTag("", "node");
- serializer.attribute("", "index", Integer.toString(index));
- serializer.attribute("", "text", safeCharSeqToString(node.getText()));
- serializer.attribute("", "class", safeCharSeqToString(node.getClassName()));
- serializer.attribute("", "package", safeCharSeqToString(node.getPackageName()));
- serializer.attribute("", "content-desc", safeCharSeqToString(node.getContentDescription()));
- serializer.attribute("", "checkable", Boolean.toString(node.isCheckable()));
- serializer.attribute("", "checked", Boolean.toString(node.isChecked()));
- serializer.attribute("", "clickable", Boolean.toString(node.isClickable()));
- serializer.attribute("", "enabled", Boolean.toString(node.isEnabled()));
- serializer.attribute("", "focusable", Boolean.toString(node.isFocusable()));
- serializer.attribute("", "focused", Boolean.toString(node.isFocused()));
- serializer.attribute("", "long-clickable", Boolean.toString(node.isLongClickable()));
- serializer.attribute("", "password", Boolean.toString(node.isPassword()));
- serializer.attribute("", "selected", Boolean.toString(node.isSelected()));
- Rect bounds = new Rect();
- node.getBoundsInScreen(bounds);
- serializer.attribute("", "bounds", bounds.toShortString());
- for (int i = 0; i < node.getChildCount(); i++) {
- AccessibilityNodeInfo child = node.getChild(i);
- if (child != null) {
- dumpNodeRec(child, serializer, i);
- child.recycle();
- }
- }
- serializer.endTag("", "node");
- }
-
- public static void dumpWindow(AccessibilityNodeInfo info) {
- AccessibilityNodeInfo root = getRootAccessibilityNodeInfo(info);
- if (root == null) {
- return;
- }
- final long startTime = SystemClock.uptimeMillis();
- Queue<AccessibilityNodeInfo> mFringe = new LinkedList<AccessibilityNodeInfo>();
- mFringe.add(root);
- int fetchedNodeCount = 0;
- while (!mFringe.isEmpty()) {
- AccessibilityNodeInfo current = mFringe.poll();
- Log.d(LOGTAG, String.format("class: %s; text: %s; content-desc: %s",
- current.getClassName(),
- current.getText(),
- current.getContentDescription()));
- fetchedNodeCount++;
- final int childCount = current.getChildCount();
- for (int i = 0; i < childCount; i++) {
- AccessibilityNodeInfo child = current.getChild(i);
- if (child != null) {
- mFringe.add(child);
- }
- }
- }
- final long endTime = SystemClock.uptimeMillis();
- Log.w(LOGTAG, "Fetch time: " + (endTime - startTime) + "ms; fetchedNodeCount: "
- + fetchedNodeCount);
- }
-
- public static void dumpNode(AccessibilityNodeInfo node) {
- Log.d(LOGTAG, String.format("class: %s; text: %s; content-desc: %s",
- node.getClassName(),
- node.getText(),
- node.getContentDescription()));
- }
-
- public static void dumpChildren(AccessibilityNodeInfo node) {
- int count = node.getChildCount();
- for (int i = 0; i < count; i++) {
- AccessibilityNodeInfo child = node.getChild(i);
- dumpNode(child);
- child.recycle();
- }
- }
-
- public static AccessibilityNodeInfo getRootAccessibilityNodeInfo(AccessibilityNodeInfo info) {
- if (info == null)
- return null;
- AccessibilityNodeInfo root = info.getParent();
- while (root != null) {
- AccessibilityNodeInfo parent = root.getParent();
- if (parent != null) {
- root.recycle();
- root = parent;
- } else {
- break;
- }
- }
- return root == null ? info : root;
- }
-
- public static String safeCharSeqToString(CharSequence cs) {
- if (cs == null)
- return "[null]";
- else
- return cs.toString();
- }
-}
diff --git a/UiAutomation/service/src/com/android/testing/uiautomation/InteractionProvider.java b/UiAutomation/service/src/com/android/testing/uiautomation/InteractionProvider.java
deleted file mode 100644
index c2c93bb..0000000
--- a/UiAutomation/service/src/com/android/testing/uiautomation/InteractionProvider.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package com.android.testing.uiautomation;
-
-import android.content.Context;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.os.SystemClock;
-import android.util.Log;
-import android.view.IWindowManager;
-import android.view.KeyCharacterMap;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-
-public class InteractionProvider {
-
- private static final String LOGTAG = "InteractionProvider";
- private IWindowManager mWm;
- private long mEventThrottle = 10;
-
- public InteractionProvider() {
- mWm = IWindowManager.Stub.asInterface(ServiceManager.getService(Context.WINDOW_SERVICE));
- if (mWm == null) {
- throw new RuntimeException("Unable to connect to WindowManager, "
- + "is the system running?");
- }
- }
-
- public boolean tap(int x, int y) {
- MotionEvent event = MotionEvent.obtain(
- SystemClock.uptimeMillis(), SystemClock.uptimeMillis(),
- MotionEvent.ACTION_DOWN, x, y, 0);
-
- boolean ret = true;
- try {
- mWm.injectPointerEvent(event, false);
- } catch (RemoteException e) {
- Log.w(LOGTAG, "failed to inject DOWN event", e);
- ret = false;
- }
- doEventThrottle();
- event.setAction(MotionEvent.ACTION_UP);
- try {
- mWm.injectPointerEvent(event, false);
- } catch (RemoteException e) {
- Log.w(LOGTAG, "failed to inject UP event", e);
- ret = false;
- }
- return ret;
- }
-
- public boolean sendText(String text) {
- if (text == null) {
- return false;
- }
- boolean ret = true;
- KeyCharacterMap keyCharacterMap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
-
- KeyEvent[] events = keyCharacterMap.getEvents(text.toCharArray());
-
- if (events != null) {
- for (int i = 0; i < events.length; i++) {
- ret &= sendKey(events[i]);
- doEventThrottle();
- }
- }
- return ret;
- }
-
- public boolean sendKey(KeyEvent event) {
- boolean ret = true;
- try {
- mWm.injectKeyEvent(event, false);
- } catch (RemoteException e) {
- ret = false;
- }
- return ret;
- }
-
- public void setEventThrottle(long millis) {
- mEventThrottle = millis;
- }
-
- private void doEventThrottle() {
- try {
- Thread.sleep(mEventThrottle);
- } catch (InterruptedException e) {
- }
- }
-}
diff --git a/UiAutomation/service/src/com/android/testing/uiautomation/Provider.aidl b/UiAutomation/service/src/com/android/testing/uiautomation/Provider.aidl
deleted file mode 100644
index 17d7ef5..0000000
--- a/UiAutomation/service/src/com/android/testing/uiautomation/Provider.aidl
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.testing.uiautomation;
-
-interface Provider {
-
- String getCurrentActivityName();
- String getCurrentActivityPackage();
- String getCurrentActivityClass();
-
- boolean isEnabled(String selector);
- boolean isFocused(String selector);
- int getChildCount(String selector);
- String getText(String selector);
- String getClassName(String selector);
-
- boolean click(String selector);
- boolean setTextFieldByLabel(String label, String text);
- boolean sendText(String text);
-
- boolean checkUiVerificationEnabled();
-}
diff --git a/UiAutomation/service/src/com/android/testing/uiautomation/ProviderImpl.java b/UiAutomation/service/src/com/android/testing/uiautomation/ProviderImpl.java
deleted file mode 100644
index e3ef9b8..0000000
--- a/UiAutomation/service/src/com/android/testing/uiautomation/ProviderImpl.java
+++ /dev/null
@@ -1,286 +0,0 @@
-
-package com.android.testing.uiautomation;
-
-import android.accessibilityservice.AccessibilityServiceInfo;
-import android.accessibilityservice.IAccessibilityServiceConnection;
-import android.accessibilityservice.IEventListener;
-import android.content.Context;
-import android.graphics.Rect;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.os.SystemProperties;
-import android.util.Log;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.accessibility.AccessibilityManager;
-import android.view.accessibility.AccessibilityNodeInfo;
-import android.view.accessibility.IAccessibilityManager;
-import android.widget.EditText;
-
-import java.util.List;
-
-public class ProviderImpl extends Provider.Stub {
-
- private static final String LOGTAG = "ProviderImpl";
-
- private static final String TYPE_CLASSNAME = "classname";
-
- private static final String TYPE_TEXT = "text";
-
- private Context mContext;
-
- private InteractionProvider mInteractionProvider;
-
- private IAccessibilityServiceConnection mAccessibilityServiceConnection;
-
- protected AccessibilityNodeInfo mCurrentWindow = null;
-
- protected AccessibilityNodeInfo mCurrentFocused = null;
-
- protected String mCurrentActivityName = null;
-
- protected String mCurrentActivityClass = null;
-
- protected String mCurrentActivityPackage = null;
-
- public ProviderImpl(Context context) throws RemoteException {
- IEventListener listener = new IEventListener.Stub() {
- @Override
- public void setConnection(IAccessibilityServiceConnection connection)
- throws RemoteException {
- AccessibilityServiceInfo info = new AccessibilityServiceInfo();
- info.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
- info.feedbackType = AccessibilityServiceInfo.FEEDBACK_VISUAL;
- info.notificationTimeout = 0;
- info.flags = AccessibilityServiceInfo.DEFAULT;
- connection.setServiceInfo(info);
- }
-
- @Override
- public void onInterrupt() {
- }
-
- @Override
- public void onAccessibilityEvent(AccessibilityEvent event) throws RemoteException {
- // delegate the call to parent
- ProviderImpl.this.onAccessibilityEvent(event);
- }
- };
- IAccessibilityManager manager = IAccessibilityManager.Stub.asInterface(ServiceManager
- .getService(Context.ACCESSIBILITY_SERVICE));
- mContext = context;
- mAccessibilityServiceConnection = manager.registerEventListener(listener);
- mInteractionProvider = new InteractionProvider();
- }
-
- private IAccessibilityServiceConnection getConnection() {
- return mAccessibilityServiceConnection;
- }
-
- private void onAccessibilityEvent(AccessibilityEvent event) throws RemoteException {
- Log.d(LOGTAG, "ProviderImpl=" + this.toString());
- Log.d(LOGTAG, event.toString());
- switch (event.getEventType()) {
- case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
- if (mCurrentWindow != null) {
- mCurrentWindow.recycle();
- }
- mCurrentWindow = event.getSource();
- if (shouldDumpWindow())
- AccessibilityNodeInfoHelper.dumpWindowToFile(mCurrentWindow);
- mCurrentActivityClass = event.getClassName().toString();
- mCurrentActivityPackage = event.getPackageName().toString();
- if (event.getText().size() > 0) {
- mCurrentActivityName = event.getText().get(0).toString();
- } else {
- mCurrentActivityName = null;
- }
- break;
- case AccessibilityEvent.TYPE_VIEW_FOCUSED:
- if (mCurrentFocused != null) {
- mCurrentFocused.recycle();
- }
- mCurrentFocused = event.getSource();
- default:
- break;
- }
- }
-
- @Override
- public boolean isEnabled(String selector) throws RemoteException {
- AccessibilityNodeInfo node = findNodeOrThrow(getConnection(), selector);
- boolean b = node.isEnabled();
- node.recycle();
- return b;
- }
-
- @Override
- public boolean isFocused(String selector) throws RemoteException {
- AccessibilityNodeInfo node = findNodeOrThrow(getConnection(), selector);
- boolean b = node.isFocused();
- node.recycle();
- return b;
- }
-
- @Override
- public int getChildCount(String selector) throws RemoteException {
- AccessibilityNodeInfo node = findNodeOrThrow(getConnection(), selector);
- int count = node.getChildCount();
- node.recycle();
- return count;
- }
-
- @Override
- public String getText(String selector) throws RemoteException {
- AccessibilityNodeInfo node = findNode(getConnection(), selector);
- if (node == null) {
- Log.w(LOGTAG, "node not found, selector=" + selector);
- return null;
- } else {
- String s = node.getText().toString();
- node.recycle();
- return s;
- }
- }
-
- @Override
- public String getClassName(String selector) throws RemoteException {
- AccessibilityNodeInfo node = findNode(getConnection(), selector);
- if (node == null) {
- Log.w(LOGTAG, "node not found, selector=" + selector);
- return null;
- } else {
- String s = node.getClassName().toString();
- node.recycle();
- return s;
- }
- }
-
- @Override
- public boolean click(String selector) throws RemoteException {
- AccessibilityNodeInfo node = findNode(getConnection(), selector);
- if (node == null) {
- Log.w(LOGTAG, "node not found, selector=" + selector);
- return false;
- }
- return click(node);
- }
-
- protected boolean click(AccessibilityNodeInfo node) throws RemoteException {
- // TODO: do a click here
- Rect b = new Rect();
- node.getBoundsInScreen(b);
- return mInteractionProvider.tap(b.centerX(), b.centerY());
- }
-
- @Override
- public String getCurrentActivityName() throws RemoteException {
- return mCurrentActivityName;
- }
-
- @Override
- public String getCurrentActivityPackage() throws RemoteException {
- return mCurrentActivityPackage;
- }
-
- @Override
- public String getCurrentActivityClass() throws RemoteException {
- return mCurrentActivityClass;
- }
-
- @Override
- public boolean sendText(String text) throws RemoteException {
- return mInteractionProvider.sendText(text);
- }
-
- @Override
- public boolean setTextFieldByLabel(String label, String text) throws RemoteException {
- // first index of a text field, first index of a text field after the
- // matching label
- int firstIndex = -1, firstAfterIndex = -1, labelIndex = -1;
- Log.d(LOGTAG, "I'm here...");
- AccessibilityNodeInfo node = findNode(getConnection(), "text:" + label);
- if (node == null) {
- Log.w(LOGTAG, "label node not found: " + label);
- return false;
- }
- AccessibilityNodeInfo parent = node.getParent();
- node.recycle();
- node = null;
- int count = parent.getChildCount();
- for (int i = 0; i < count; i++) {
- AccessibilityNodeInfo child = parent.getChild(i);
- CharSequence csText = child.getText();
- CharSequence csClass = child.getClassName();
- if (csText != null && label.contentEquals(csText)) {
- labelIndex = i;
- }
- if (csClass != null && EditText.class.getName().contentEquals(csClass)) {
- if (labelIndex == -1) {
- firstIndex = i;
- } else {
- firstAfterIndex = i;
- }
- }
- child.recycle();
- }
- if (firstAfterIndex != -1)
- node = parent.getChild(firstAfterIndex);
- else if (firstIndex != -1)
- node = parent.getChild(firstIndex);
- parent.recycle();
- if (node == null) {
- Log.w(LOGTAG, "Cannot find an EditorText for label: " + label);
- return false;
- }
- AccessibilityNodeInfoHelper.dumpNode(node);
- click(node);
- node.recycle();
- return mInteractionProvider.sendText(text);
- }
-
- @Override
- public boolean checkUiVerificationEnabled() throws RemoteException {
- return AccessibilityManager.getInstance(mContext).isEnabled();
- }
-
- private AccessibilityNodeInfo findNodeOrThrow(IAccessibilityServiceConnection connection,
- String selector) throws RemoteException {
- AccessibilityNodeInfo node = findNode(connection, selector);
- if (node == null) {
- Log.e(LOGTAG, "node not found, selector=" + selector);
- throw new RemoteException();
- }
- return node;
- }
-
- private AccessibilityNodeInfo findNode(IAccessibilityServiceConnection connection,
- String selector) throws RemoteException {
- // a selector should be in the format of "[selector type]:[matcher]
- // example:
- // classname:android.widget.Text
- // text:Click Me
- // id:id/username
- int pos = selector.indexOf(':');
- if (pos != -1) {
- String selectorType = selector.substring(0, pos);
- String matcher = selector.substring(pos + 1);
- if (TYPE_TEXT.equals(selectorType)) {
- List<AccessibilityNodeInfo> nodes = connection
- .findAccessibilityNodeInfosByViewTextInActiveWindow(matcher);
- if (nodes != null && nodes.size() > 0) {
- // keep the first one, recycle the rest
- // TODO: find better way to handle multiple matches
- for (int i = 1; i < nodes.size(); i++) {
- nodes.get(i).recycle();
- }
- return nodes.get(0);
- }
- } // more type matchers to be added here
- }
- return null;
- }
-
- private static boolean shouldDumpWindow() {
- return SystemProperties.getBoolean("uiauto.dump", false);
- }
-}
diff --git a/UiAutomation/service/src/com/android/testing/uiautomation/ProviderService.java b/UiAutomation/service/src/com/android/testing/uiautomation/ProviderService.java
deleted file mode 100644
index b2f06e0..0000000
--- a/UiAutomation/service/src/com/android/testing/uiautomation/ProviderService.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.android.testing.uiautomation;
-
-import android.app.Service;
-import android.content.Intent;
-import android.os.IBinder;
-import android.os.RemoteException;
-import android.util.Log;
-
-public class ProviderService extends Service {
-
- private static final String LOGTAG = "ProviderService";
- private ProviderImpl mProviderImpl;
-
- @Override
- public IBinder onBind(Intent intent) {
- if (mProviderImpl == null) {
- try {
- mProviderImpl = new ProviderImpl(this);
- } catch (RemoteException e) {
- Log.e(LOGTAG, "Failed to initialize implementation.");
- return null;
- }
- }
- return mProviderImpl;
- }
-}
diff --git a/UiAutomationDemo/Android.mk b/UiAutomationDemo/Android.mk
deleted file mode 100644
index 78e46b6..0000000
--- a/UiAutomationDemo/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-#
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-#LOCAL_CERTIFICATE := platform
-LOCAL_MODULE_TAGS := tests
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_LIBRARIES := android.test.runner
-LOCAL_STATIC_JAVA_LIBRARIES := UiAutomationLibrary
-
-LOCAL_PACKAGE_NAME := UiAutomationDemo
-
-include $(BUILD_PACKAGE)
diff --git a/UiAutomationDemo/AndroidManifest.xml b/UiAutomationDemo/AndroidManifest.xml
deleted file mode 100644
index 438f6bc..0000000
--- a/UiAutomationDemo/AndroidManifest.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 The Android Open Source Project Licensed under the
- Apache License, Version 2.0 (the "License"); you may not use this file except
- in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software distributed
- under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
- OR CONDITIONS OF ANY KIND, either express or implied. See the License for
- the specific language governing permissions and limitations under the License. -->
-
-<!-- Declare the contents of this Android application. The namespace attribute
- brings in the Android platform namespace, and the package supplies a unique
- name for the application. When writing your own application, the package
- name must be changed from "com.example.*" to come from a domain that you
- own or have control over. -->
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.testing.uiautomation.demo">
-
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <application android:label="UI Automation Test Case Demo">
- <uses-library android:name="android.test.runner" />
- </application>
-
- <instrumentation
- android:name="com.android.testing.uiautomation.UiAutomationTestRunner"
- android:targetPackage="com.android.testing.uiautomation.demo"
- android:label="Self Instrumenter"/>
-
-</manifest>
diff --git a/UiAutomationDemo/src/com/android/testing/uiautomation/demo/EmailTest.java b/UiAutomationDemo/src/com/android/testing/uiautomation/demo/EmailTest.java
deleted file mode 100644
index b62ffdb..0000000
--- a/UiAutomationDemo/src/com/android/testing/uiautomation/demo/EmailTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package com.android.testing.uiautomation.demo;
-
-import com.android.testing.uiautomation.AutomationProvider;
-import com.android.testing.uiautomation.InjectAutomationProvider;
-import com.android.testing.uiautomation.InjectParams;
-import com.android.testing.uiautomation.UiTestHelper;
-
-import android.os.Bundle;
-import android.os.Environment;
-import android.test.AndroidTestCase;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.Writer;
-
-public class EmailTest extends AndroidTestCase {
-
- @InjectParams
- private Bundle mParams;
-
- @InjectAutomationProvider
- private AutomationProvider mProvider;
-
- private Writer mWriter;
- private String mUsername, mPassword;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- assertNotNull(mParams);
- assertNotNull(mProvider);
- mWriter = new FileWriter(new File(Environment.getExternalStorageDirectory(),
- "ui_trace_log.txt"));
- mProvider.setTraceLoggerOutput(mWriter);
- mUsername = mParams.getString("username");
- mPassword = mParams.getString("password");
- assertNotNull("need username from command line", mUsername);
- assertNotNull("need password from command line", mPassword);
- }
-
- public void testEmail() throws Exception {
- UiTestHelper helper = new UiTestHelper(getContext(), mProvider);
- assertTrue("failed to launch Email", helper.launchApplication("Email"));
- assertTrue("not in Account setup",
- helper.waitForWindow("Account setup"));
- assertTrue("failed to set username",
- mProvider.setTextFieldByLabel("Email address", mUsername));
- assertTrue("failed to set password", mProvider.setTextFieldByLabel("Password", mPassword));
- assertTrue("Next button not enabled", mProvider.isEnabled("text:Next"));
- assertTrue("failed to invoke next button", mProvider.click("text:Next"));
- assertTrue("not in Account settings",
- helper.waitForWindow("Account settings", 60000));
- assertTrue("Next button not enabled", mProvider.isEnabled("text:Next"));
- assertTrue("failed to invoke next button", mProvider.click("text:Next"));
- assertTrue("not in Account setup",
- helper.waitForWindow("Account setup"));
- assertTrue("failed to set display name", mProvider.setTextFieldByLabel(
- "Your name", "AOL"));
- assertTrue("Next button not enabled", mProvider.isEnabled("text:Next"));
- assertTrue("failed to invoke next button", mProvider.click("text:Next"));
- }
-
- @Override
- protected void tearDown() throws Exception {
- mWriter.flush();
- mWriter.close();
- super.tearDown();
- }
-}