diff options
author | Hyungtae Tim Kim <hyungtaekim@google.com> | 2016-09-28 14:30:16 +0900 |
---|---|---|
committer | Hyungtae Tim Kim <hyungtaekim@google.com> | 2016-09-28 14:33:16 +0900 |
commit | 140587ee96067287cfa78368307e5b4bc75791d6 (patch) | |
tree | fe9335bd112adc940a754e2061184dad717ecc34 | |
parent | 079833855b826fde1661f52ec26cd813d466787d (diff) | |
download | platform_testing-140587ee96067287cfa78368307e5b4bc75791d6.tar.gz |
Remove unused helpers for functional test
DPadHelper moved to the utils dir
CommandHelper replaced with the one in system-helpers
Bug: 31636187
Bug: 31635441
Change-Id: I63a3e97fb5d6145baeb85cdf84e9033c18bfc794
3 files changed, 0 insertions, 250 deletions
diff --git a/libraries/base-app-helpers/src/android/platform/test/helpers/AbstractLeanbackAppHelper.java b/libraries/base-app-helpers/src/android/platform/test/helpers/AbstractLeanbackAppHelper.java index afe3c04b7..f8ea94f44 100644 --- a/libraries/base-app-helpers/src/android/platform/test/helpers/AbstractLeanbackAppHelper.java +++ b/libraries/base-app-helpers/src/android/platform/test/helpers/AbstractLeanbackAppHelper.java @@ -55,16 +55,12 @@ public abstract class AbstractLeanbackAppHelper extends AbstractStandardAppHelpe } protected DPadUtil mDPadUtil; - // TODO: Delete DPadHelper once migrated to using DPadUtil - protected DPadHelper mDPadHelper; public ILeanbackLauncherStrategy mLauncherStrategy; public AbstractLeanbackAppHelper(Instrumentation instr) { super(instr); mDPadUtil = new DPadUtil(instr); - // TODO: Delete DPadHelper once migrated to using DPadUtil - mDPadHelper = DPadHelper.getInstance(instr); mLauncherStrategy = LauncherStrategyFactory.getInstance( mDevice).getLeanbackLauncherStrategy(); } diff --git a/libraries/base-app-helpers/src/android/platform/test/helpers/CommandHelper.java b/libraries/base-app-helpers/src/android/platform/test/helpers/CommandHelper.java deleted file mode 100644 index cc4f3dfe1..000000000 --- a/libraries/base-app-helpers/src/android/platform/test/helpers/CommandHelper.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2016 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 android.platform.test.helpers; - -import android.app.Instrumentation; -import android.support.test.uiautomator.UiDevice; -import android.util.Log; - -import java.io.IOException; - -/** - * Utility class to execute the shell command. - */ -public final class CommandHelper { - private static final String TAG = CommandHelper.class.getSimpleName(); - - private UiDevice mDevice; - - - public CommandHelper(Instrumentation instrumentation) { - mDevice = UiDevice.getInstance(instrumentation); - } - - public void executeAmStackMovetask(int taskId, int stackId) { - executeShellCommand( - String.format("am stack movetask %d %d true", taskId, stackId)); - } - - public String executeAmStackInfo(int stackId) { - return executeShellCommand(String.format("am stack info %d", stackId)); - } - - public String executeAmStackList() { - return executeShellCommand("am stack list"); - } - - public String executeDumpsysMediaSession() { - return executeShellCommand("dumpsys media_session"); - } - - public String executeGetProp(String prop) { - return executeShellCommand(String.format("getprop %s", prop), true); - } - - public String executeShellCommand(String command) { - return executeShellCommand(command, false); - } - - private String executeShellCommand(String command, boolean trim) { - try { - String output = mDevice.executeShellCommand(command); - return output.trim(); - } catch (IOException e) { - // ignore - Log.w(TAG, String.format("The shell command failed to run: %s exception: %s", - command, e.getMessage())); - return ""; - } - } -} diff --git a/libraries/base-app-helpers/src/android/platform/test/helpers/DPadHelper.java b/libraries/base-app-helpers/src/android/platform/test/helpers/DPadHelper.java deleted file mode 100644 index c3ee0d181..000000000 --- a/libraries/base-app-helpers/src/android/platform/test/helpers/DPadHelper.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (C) 2016 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 android.platform.test.helpers; - -import android.app.Instrumentation; -import android.os.SystemClock; -import android.support.test.uiautomator.Direction; -import android.support.test.uiautomator.EventCondition; -import android.support.test.uiautomator.UiDevice; -import android.util.Log; -import android.view.KeyEvent; - -import java.io.IOException; - - -public class DPadHelper { - - private static final String TAG = DPadHelper.class.getSimpleName(); - private static final long DPAD_DEFAULT_WAIT_TIME_MS = 1000; // 1 sec - private static DPadHelper mInstance; - private UiDevice mDevice; - - - private DPadHelper(Instrumentation instrumentation) { - mDevice = UiDevice.getInstance(instrumentation); - } - - public static DPadHelper getInstance(Instrumentation instrumentation) { - if (mInstance == null) { - mInstance = new DPadHelper(instrumentation); - } - return mInstance; - } - - public boolean pressDPad(Direction direction) { - return pressDPad(direction, 1, DPAD_DEFAULT_WAIT_TIME_MS); - } - - public void pressDPad(Direction direction, long repeat) { - pressDPad(direction, repeat, DPAD_DEFAULT_WAIT_TIME_MS); - } - - /** - * Presses DPad button of the same direction for the count times. - * It sleeps between each press for DPAD_DEFAULT_WAIT_TIME_MS. - * - * @param direction the direction of the button to press. - * @param repeat the number of times to press the button. - * @param timeout the timeout for the wait. - * @return true if the last key simulation is successful, else return false - */ - public boolean pressDPad(Direction direction, long repeat, long timeout) { - int iteration = 0; - boolean result = false; - while (iteration++ < repeat) { - switch (direction) { - case LEFT: - result = mDevice.pressDPadLeft(); - break; - case RIGHT: - result = mDevice.pressDPadRight(); - break; - case UP: - result = mDevice.pressDPadUp(); - break; - case DOWN: - result = mDevice.pressDPadDown(); - break; - } - SystemClock.sleep(timeout); - } - return result; - } - - public boolean pressDPadLeft() { - return mDevice.pressDPadLeft(); - } - - public boolean pressDPadRight() { - return mDevice.pressDPadRight(); - } - - public boolean pressDPadUp() { - return mDevice.pressDPadUp(); - } - - public boolean pressDPadDown() { - return mDevice.pressDPadDown(); - } - - public boolean pressHome() { - return mDevice.pressHome(); - } - - public boolean pressBack() { - return mDevice.pressBack(); - } - - public boolean pressDPadCenter() { - return mDevice.pressDPadCenter(); - } - - public boolean pressEnter() { - return mDevice.pressEnter(); - } - - public boolean pressPipKey() { - return mDevice.pressKeyCode(KeyEvent.KEYCODE_WINDOW); - } - - public boolean pressKeyCode(int keyCode) { - return mDevice.pressKeyCode(keyCode); - } - - public boolean longPressKeyCode(int keyCode) { - try { - mDevice.executeShellCommand(String.format("input keyevent --longpress %d", keyCode)); - return true; - } catch (IOException e) { - // Ignore - Log.w(TAG, String.format("Failed to long press the key code: %d", keyCode)); - return false; - } - } - - /** - * Press the key code, and waits for the given condition to become true. - * @param condition - * @param keyCode - * @param timeout - * @param <R> - * @return - */ - public <R> R pressKeyCodeAndWait(int keyCode, EventCondition<R> condition, long timeout) { - return mDevice.performActionAndWait(new KeyEventRunnable(keyCode), condition, timeout); - } - - public <R> R pressDPadCenterAndWait(EventCondition<R> condition, long timeout) { - return mDevice.performActionAndWait(new KeyEventRunnable(KeyEvent.KEYCODE_DPAD_CENTER), - condition, timeout); - } - - public <R> R pressEnterAndWait(EventCondition<R> condition, long timeout) { - return mDevice.performActionAndWait(new KeyEventRunnable(KeyEvent.KEYCODE_ENTER), - condition, timeout); - } - - private class KeyEventRunnable implements Runnable { - private int mKeyCode; - public KeyEventRunnable(int keyCode) { - mKeyCode = keyCode; - } - @Override - public void run() { - mDevice.pressKeyCode(mKeyCode); - } - } -} |