Clean some unecessary testing Interfaces
Bug: 3419057
Change-Id: I2ddb4681c4d88d47acbfd932c5d2e2ef28ee2611
diff --git a/src/com/android/tradefed/device/StubDeviceRecovery.java b/src/com/android/tradefed/device/StubDeviceRecovery.java
deleted file mode 100644
index 89eed70..0000000
--- a/src/com/android/tradefed/device/StubDeviceRecovery.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2010 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.tradefed.device;
-
-/**
- * Empty implementation of a {@link IDeviceRecovery}.
- */
-public class StubDeviceRecovery implements IDeviceRecovery {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void recoverDevice(IDeviceStateMonitor monitor, boolean recoverUntilOnline)
- throws DeviceNotAvailableException {
- throw new DeviceNotAvailableException("device recovery not implemented");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void recoverDeviceBootloader(IDeviceStateMonitor monitor)
- throws DeviceNotAvailableException {
- throw new DeviceNotAvailableException("device recovery not implemented");
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void recoverDeviceRecovery(IDeviceStateMonitor monitor)
- throws DeviceNotAvailableException {
- throw new DeviceNotAvailableException("device recovery not implemented");
- }
-}
diff --git a/src/com/android/tradefed/invoker/StubRescheduler.java b/src/com/android/tradefed/invoker/StubRescheduler.java
deleted file mode 100644
index 453c1ea..0000000
--- a/src/com/android/tradefed/invoker/StubRescheduler.java
+++ /dev/null
@@ -1,40 +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.tradefed.invoker;
-
-import com.android.tradefed.config.IConfiguration;
-
-/**
- * A stub implementation of a {@link IRescheduler}.
- */
-public class StubRescheduler implements IRescheduler {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean scheduleConfig(IConfiguration config) {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean rescheduleCommand() {
- return false;
- }
-}
diff --git a/tests/res/testconfigs/global-config.xml b/tests/res/testconfigs/global-config.xml
index dccce20..d05cc61 100644
--- a/tests/res/testconfigs/global-config.xml
+++ b/tests/res/testconfigs/global-config.xml
@@ -16,7 +16,7 @@
<configuration
description="test for global configurations">
- <device_monitor class="com.android.tradefed.device.StubDeviceMonitor" />
- <wtf_handler class="com.android.tradefed.log.StubTerribleFailureHandler" />
+ <device_monitor class="com.android.tradefed.device.DeviceMonitorMultiplexer" />
+ <wtf_handler class="com.android.tradefed.log.TerribleFailureEmailHandler" />
</configuration>
diff --git a/tests/res/testconfigs/mandatory-config.xml b/tests/res/testconfigs/mandatory-config.xml
index ed80a9a..7975092 100644
--- a/tests/res/testconfigs/mandatory-config.xml
+++ b/tests/res/testconfigs/mandatory-config.xml
@@ -16,6 +16,6 @@
<configuration
description="test fixture to help test mandatory options">
- <test class="com.android.tradefed.config.StubMandatoryTest" />
+ <test class="com.android.tradefed.config.StubOptionTest" />
</configuration>
diff --git a/tests/src/com/android/tradefed/config/StubMandatoryTest.java b/tests/src/com/android/tradefed/config/StubMandatoryTest.java
deleted file mode 100644
index 4b9d277..0000000
--- a/tests/src/com/android/tradefed/config/StubMandatoryTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 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.tradefed.config;
-
-import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.result.ITestInvocationListener;
-import com.android.tradefed.testtype.IRemoteTest;
-
-import junit.framework.Assert;
-
-/**
- * Empty implementation use by {@link ConfigurationFactoryTest#testPrintHelpForConfig_mandatory()}.
- */
-public class StubMandatoryTest implements IRemoteTest {
-
- static final String MANDATORY_OPTION_NAME = "mandatory-option";
- static final String MANDATORY_OPTION_DESC = "this is a mandatory option.";
-
- @Option(name = MANDATORY_OPTION_NAME, description = MANDATORY_OPTION_DESC,
- mandatory = true)
- private String mMandatory = null;
-
- @Override
- public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
- Assert.assertNotNull(mMandatory);
- }
-}
diff --git a/tests/src/com/android/tradefed/device/StubDeviceMonitor.java b/tests/src/com/android/tradefed/device/StubDeviceMonitor.java
deleted file mode 100644
index 5053324..0000000
--- a/tests/src/com/android/tradefed/device/StubDeviceMonitor.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2013 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.tradefed.device;
-
-/**
- * Empty implementation of a {@link IDeviceMonitor}
- */
-public class StubDeviceMonitor implements IDeviceMonitor {
-
- @Override
- public void run() {
- // ignore
- }
-
- @Override
- public void setDeviceLister(DeviceLister lister) {
- // ignore
- }
-
- @Override
- public void notifyDeviceStateChange(String serial, DeviceAllocationState oldState,
- DeviceAllocationState newState) {
- // ignore
- }
-}
diff --git a/tests/src/com/android/tradefed/device/StubTestDevice.java b/tests/src/com/android/tradefed/device/StubTestDevice.java
deleted file mode 100644
index a824864..0000000
--- a/tests/src/com/android/tradefed/device/StubTestDevice.java
+++ /dev/null
@@ -1,1141 +0,0 @@
-/*
- * Copyright (C) 2010 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.tradefed.device;
-
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.IShellOutputReceiver;
-import com.android.ddmlib.testrunner.IRemoteAndroidTestRunner;
-import com.android.ddmlib.testrunner.ITestRunListener;
-import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.result.ByteArrayInputStreamSource;
-import com.android.tradefed.result.InputStreamSource;
-import com.android.tradefed.util.CommandResult;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Empty implementation of {@link ITestDevice}.
- * <p/>
- * Needed in order to handle the EasyMock andDelegateTo operation.
- */
-public class StubTestDevice implements IManagedTestDevice {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void executeShellCommand(String command, IShellOutputReceiver receiver)
- throws DeviceNotAvailableException {
- // ignore
- }
-
- @Override
- public String executeShellCommand(String command) throws DeviceNotAvailableException {
- // ignore
- return null;
- }
-
- @Override
- public IDevice getIDevice() {
- // ignore
- return null;
- }
-
- @Override
- public String getSerialNumber() {
- // ignore
- return "stub";
- }
-
- @Override
- public boolean runInstrumentationTests(IRemoteAndroidTestRunner runner,
- Collection<ITestRunListener> listeners) throws DeviceNotAvailableException {
- // ignore
- return true;
- }
-
- @Override
- public boolean runInstrumentationTestsAsUser(IRemoteAndroidTestRunner runner, int userId,
- Collection<ITestRunListener> listeners) throws DeviceNotAvailableException {
- // ignore
- return true;
- }
-
- @Override
- public boolean runInstrumentationTests(IRemoteAndroidTestRunner runner,
- ITestRunListener... listeners) throws DeviceNotAvailableException {
- // ignore
- return true;
- }
-
- @Override
- public boolean runInstrumentationTestsAsUser(IRemoteAndroidTestRunner runner, int userId,
- ITestRunListener... listeners) throws DeviceNotAvailableException {
- // ignore
- return true;
- }
-
- @Override
- public boolean pullFile(String remoteFilePath, File localFile)
- throws DeviceNotAvailableException {
- return false;
- }
-
- @Override
- public File pullFile(String remoteFilePath) throws DeviceNotAvailableException {
- return null;
- }
-
- @Override
- public File pullFileFromExternal(String remoteFilePath) throws DeviceNotAvailableException {
- return null;
- }
-
- @Override
- public boolean pushFile(File localFile, String deviceFilePath)
- throws DeviceNotAvailableException {
- return false;
- }
-
- @Override
- public boolean pushString(String content, String deviceFilePath)
- throws DeviceNotAvailableException {
- return false;
- }
-
- @Override
- public boolean doesFileExist(String deviceFilePath) throws DeviceNotAvailableException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public InputStreamSource getLogcat() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void startLogcat() {
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void stopLogcat() {
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setFastbootEnabled(boolean fastbootEnabled) {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String executeAdbCommand(String... commandArgs) throws DeviceNotAvailableException {
- // ignore
- return "";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public CommandResult executeFastbootCommand(String... commandArgs)
- throws DeviceNotAvailableException {
- // ignore
- return new CommandResult();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public CommandResult executeLongFastbootCommand(String... commandArgs)
- throws DeviceNotAvailableException {
- // ignore
- return new CommandResult();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean getUseFastbootErase() {
- // ignore
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setUseFastbootErase(boolean useFastbootErase) {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public CommandResult fastbootWipePartition(String partition)
- throws DeviceNotAvailableException {
- // ignore
- return new CommandResult();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean enableAdbRoot() throws DeviceNotAvailableException {
- // ignore
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean encryptDevice(boolean inplace) throws DeviceNotAvailableException,
- UnsupportedOperationException {
- // ignore
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean unencryptDevice() throws DeviceNotAvailableException,
- UnsupportedOperationException {
- // ignore
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean unlockDevice() throws DeviceNotAvailableException,
- UnsupportedOperationException {
- // ignore
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isDeviceEncrypted() throws DeviceNotAvailableException {
- // ignore
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isEncryptionSupported() throws DeviceNotAvailableException {
- // ignore
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void postBootSetup() throws DeviceNotAvailableException {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void reboot() throws DeviceNotAvailableException {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void rebootUntilOnline() throws DeviceNotAvailableException {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void rebootIntoBootloader() throws DeviceNotAvailableException {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void waitForDeviceAvailable(long waitTime) throws DeviceNotAvailableException {
- // ignore
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void waitForDeviceAvailable() throws DeviceNotAvailableException {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean waitForBootComplete(long timeOut) throws DeviceNotAvailableException {
- // ignore
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void waitForDeviceOnline() throws DeviceNotAvailableException {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void waitForDeviceOnline(long waitTime) throws DeviceNotAvailableException {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public long getExternalStoreFreeSpace() throws DeviceNotAvailableException {
- return 0;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean syncFiles(File localFileDir, String deviceFilePath)
- throws DeviceNotAvailableException {
- // ignore
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getProductType() {
- // ignore
- return "";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getProductVariant() {
- // ignore
- return "";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getFastbootProductType() {
- // ignore
- return "";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getFastbootProductVariant() {
- // ignore
- return "";
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setIDevice(IDevice device) {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setDeviceState(TestDeviceState deviceState) {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public TestDeviceState getDeviceState() {
- return null;
- }
-
- @Override
- public void clearLastConnectedWifiNetwork() {
- // ignore
- }
-
- @Override
- public boolean connectToWifiNetwork(String wifiSsid, String wifiPsk)
- throws DeviceNotAvailableException {
- // ignore
- return false;
- }
-
- @Override
- public boolean connectToWifiNetworkIfNeeded(String wifiSsid, String wifiPsk)
- throws DeviceNotAvailableException {
- // ignore
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean disconnectFromWifi() throws DeviceNotAvailableException {
- // ignore
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isWifiEnabled() throws DeviceNotAvailableException {
- // ignore
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean enableNetworkMonitor() throws DeviceNotAvailableException {
- // ignore
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
-
- @Override
- public boolean disableNetworkMonitor() throws DeviceNotAvailableException {
- // ignore
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean checkConnectivity() throws DeviceNotAvailableException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean clearErrorDialogs() throws DeviceNotAvailableException {
- // ignore
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean waitForDeviceNotAvailable(long waitTime) {
- // ignore
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String installPackage(File packageFile, boolean reinstall, String... extraArgs)
- throws DeviceNotAvailableException {
- // ignore
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String installPackageForUser(File packageFile, boolean reinstall, int userId,
- String... extraArgs) throws DeviceNotAvailableException {
- // ignore
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String uninstallPackage(String packageName) throws DeviceNotAvailableException {
- // ignore
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getMountPoint(String mountName) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<MountPointInfo> getMountPointInfo() throws DeviceNotAvailableException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public MountPointInfo getMountPointInfo(String mountpoint) throws DeviceNotAvailableException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public InputStreamSource getBugreport() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setRecovery(IDeviceRecovery recovery) {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public IFileEntry getFileEntry(String path) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Deprecated
- @Override
- public void executeShellCommand(String command, IShellOutputReceiver receiver,
- int maxTimeToOutputShellResponse, int retryAttempts)
- throws DeviceNotAvailableException {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void executeShellCommand(String command, IShellOutputReceiver receiver,
- long maxTimeToOutputShellResponse, TimeUnit timeUnit, int retryAttempts)
- throws DeviceNotAvailableException {
- // TODO Auto-generated method stub
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean waitForDeviceInRecovery(long waitTime) {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void rebootIntoRecovery() throws DeviceNotAvailableException {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getBuildAlias() {
- return getBuildId();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getBuildId() {
- return IBuildInfo.UNKNOWN_BUILD_ID;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getBuildFlavor() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getIpAddress() throws DeviceNotAvailableException {
- // ignore
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String switchToAdbTcp() throws DeviceNotAvailableException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean switchToAdbUsb() throws DeviceNotAvailableException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isAdbTcp() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void recoverDevice() throws DeviceNotAvailableException {
- throw new DeviceNotAvailableException();
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public InputStreamSource getScreenshot() throws DeviceNotAvailableException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public InputStreamSource getScreenshot(String format) throws DeviceNotAvailableException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setEmulatorProcess(Process p) {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Process getEmulatorProcess() {
- // ignore
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getBootloaderVersion() throws DeviceNotAvailableException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getBasebandVersion() throws DeviceNotAvailableException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void clearLogcat() {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setRecoveryMode(RecoveryMode mode) {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public RecoveryMode getRecoveryMode() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void nonBlockingReboot() throws DeviceNotAvailableException {
- // ignore
-
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getProperty(String name) throws DeviceNotAvailableException {
- // ignore
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- @Deprecated
- public String getPropertySync(String name) throws DeviceNotAvailableException {
- // ignore
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setOptions(TestDeviceOptions options) {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean pushDir(File localDir, String deviceFilePath)
- throws DeviceNotAvailableException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Set<String> getInstalledPackageNames() throws DeviceNotAvailableException {
- // ignore
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isAdbRoot() throws DeviceNotAvailableException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public TestDeviceOptions getOptions() {
- // ignore
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Set<String> getUninstallablePackageNames() throws DeviceNotAvailableException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public InputStreamSource getLogcatDump() {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public InputStreamSource getLogcat(int maxBytes) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public PackageInfo getAppPackageInfo(String packageName) throws DeviceNotAvailableException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getApiLevel() throws DeviceNotAvailableException {
- return UNKNOWN_API_LEVEL;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean waitForDeviceShell(long waitTime) {
- return false;
- }
-
- @Override
- public DeviceAllocationState getAllocationState() {
- return null;
- }
-
- @Override
- public IDeviceStateMonitor getMonitor() {
- return null;
- }
-
- @Override
- public DeviceEventResponse handleAllocationEvent(DeviceEvent event) {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setDate(Date date) throws DeviceNotAvailableException {
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isMultiUserSupported() throws DeviceNotAvailableException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int createUser(String name) throws DeviceNotAvailableException {
- return 0;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int createUser(String name, boolean guest, boolean ephemeral)
- throws DeviceNotAvailableException {
- return 0;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean removeUser(int userId) throws DeviceNotAvailableException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public ArrayList<Integer> listUsers() throws DeviceNotAvailableException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getMaxNumberOfUsersSupported() throws DeviceNotAvailableException {
- return 0;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean startUser(int userId) throws DeviceNotAvailableException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean stopUser(int userId) throws DeviceNotAvailableException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean stopUser(int userId, boolean waitFlag, boolean forceFlag)
- throws DeviceNotAvailableException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public InputStreamSource getEmulatorOutput() {
- return new ByteArrayInputStreamSource(new byte[0]);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void stopEmulatorOutput() {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String installPackage(File packageFile, boolean reinstall, boolean grantPermissions,
- String... extraArgs) throws DeviceNotAvailableException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String installPackageForUser(File packageFile, boolean reinstall,
- boolean grantPermissions, int userId, String... extraArgs)
- throws DeviceNotAvailableException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void remountSystemWritable() {
- // no-op
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isRuntimePermissionSupported() throws DeviceNotAvailableException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Integer getPrimaryUserId() throws DeviceNotAvailableException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getCurrentUser() throws DeviceNotAvailableException {
- return -1;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getUserFlags(int userId) throws DeviceNotAvailableException {
- return -1;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int getUserSerialNumber(int userId) throws DeviceNotAvailableException {
- return -1;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean switchUser(int userId) throws DeviceNotAvailableException {
- return switchUser(userId, 0);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean switchUser(int userId, long timeout) throws DeviceNotAvailableException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isUserRunning(int userId) throws DeviceNotAvailableException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean hasFeature(String feature) throws DeviceNotAvailableException {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getSetting(int userId, String namespace, String key)
- throws DeviceNotAvailableException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setSetting(int userId, String namespace, String key, String value)
- throws DeviceNotAvailableException {
- // ignore
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getAndroidId(int userId) throws DeviceNotAvailableException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Map<Integer, String> getAndroidIds() throws DeviceNotAvailableException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getBuildSigningKeys() throws DeviceNotAvailableException {
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public String getDeviceClass() {
- return null;
- }
-}
diff --git a/tests/src/com/android/tradefed/invoker/TestInvocationTest.java b/tests/src/com/android/tradefed/invoker/TestInvocationTest.java
index b173b1e..1f72061 100644
--- a/tests/src/com/android/tradefed/invoker/TestInvocationTest.java
+++ b/tests/src/com/android/tradefed/invoker/TestInvocationTest.java
@@ -87,6 +87,7 @@
private IDeviceRecovery mMockRecovery;
private Capture<List<TestSummary>> mUriCapture;
private ILogRegistry mMockLogRegistry;
+ private IRescheduler mockRescheduler;
@Override
protected void setUp() throws Exception {
@@ -106,6 +107,7 @@
mMockLogger = EasyMock.createMock(ILeveledLogOutput.class);
mMockLogRegistry = EasyMock.createMock(ILogRegistry.class);
mMockLogSaver = EasyMock.createMock(ILogSaver.class);
+ mockRescheduler = EasyMock.createMock(IRescheduler.class);
mStubConfiguration.setDeviceRecovery(mMockRecovery);
mStubConfiguration.setTargetPreparer(mMockPreparer);
@@ -157,11 +159,12 @@
public void testInvoke_RemoteTest() throws Throwable {
IRemoteTest test = EasyMock.createMock(IRemoteTest.class);
setupMockSuccessListeners();
-
+
test.run((ITestInvocationListener)EasyMock.anyObject());
setupNormalInvoke(test);
- mTestInvocation.invoke(mMockDevice, mStubConfiguration, new StubRescheduler());
- verifyMocks(test);
+ EasyMock.replay(mockRescheduler);
+ mTestInvocation.invoke(mMockDevice, mStubConfiguration, mockRescheduler);
+ verifyMocks(test, mockRescheduler);
verifySummaryListener();
}
@@ -180,8 +183,9 @@
test.run((ITestInvocationListener)EasyMock.anyObject());
setupNormalInvoke(test);
- mTestInvocation.invoke(mMockDevice, mStubConfiguration, new StubRescheduler());
- verifyMocks(test);
+ EasyMock.replay(mockRescheduler);
+ mTestInvocation.invoke(mMockDevice, mStubConfiguration, mockRescheduler);
+ verifyMocks(test, mockRescheduler);
verifySummaryListener();
}
@@ -201,9 +205,9 @@
.andReturn(new ByteArrayInputStreamSource(new byte[0]));
EasyMock.expect(mMockDevice.getLogcat())
.andReturn(new ByteArrayInputStreamSource(new byte[0])).times(2);
- replayMocks(test);
- mTestInvocation.invoke(mMockDevice, mStubConfiguration, new StubRescheduler());
- verifyMocks(test);
+ replayMocks(test, mockRescheduler);
+ mTestInvocation.invoke(mMockDevice, mStubConfiguration, mockRescheduler);
+ verifyMocks(test, mockRescheduler);
}
/**
@@ -215,8 +219,8 @@
mStubConfiguration.setTest(test);
mMockLogRegistry.dumpToGlobalLog(mMockLogger);
setupInvoke();
- replayMocks(test);
- mTestInvocation.invoke(mMockDevice, mStubConfiguration, new StubRescheduler());
+ replayMocks(test, mockRescheduler);
+ mTestInvocation.invoke(mMockDevice, mStubConfiguration, mockRescheduler);
verifyMocks(test);
}
@@ -229,7 +233,6 @@
IRetriableTest test = EasyMock.createMock(IRetriableTest.class);
EasyMock.expect(test.isRetriable()).andReturn(Boolean.TRUE);
- IRescheduler mockRescheduler = EasyMock.createMock(IRescheduler.class);
EasyMock.expect(mockRescheduler.rescheduleCommand()).andReturn(EasyMock.anyBoolean());
mStubConfiguration.setTest(test);
@@ -244,7 +247,8 @@
}
/**
- * Test the {@link TestInvocation#invoke(ITestDevice, IConfiguration, IRescheduler)} scenario
+ * Test the{@link TestInvocation#invoke(ITestDevice, IConfiguration, IRescheduler,
+ * ITestInvocationListener[])} scenario
* where the test is a {@link IDeviceTest}
*/
public void testInvoke_deviceTest() throws Throwable {
@@ -254,8 +258,9 @@
mockDeviceTest.run((ITestInvocationListener)EasyMock.anyObject());
setupMockSuccessListeners();
setupNormalInvoke(mockDeviceTest);
- mTestInvocation.invoke(mMockDevice, mStubConfiguration, new StubRescheduler());
- verifyMocks(mockDeviceTest);
+ EasyMock.replay(mockRescheduler);
+ mTestInvocation.invoke(mMockDevice, mStubConfiguration, mockRescheduler);
+ verifyMocks(mockDeviceTest, mockRescheduler);
verifySummaryListener();
}
@@ -272,13 +277,14 @@
setupMockFailureListeners(exception);
mMockBuildProvider.buildNotTested(mMockBuildInfo);
setupNormalInvoke(test);
+ EasyMock.replay(mockRescheduler);
try {
- mTestInvocation.invoke(mMockDevice, mStubConfiguration, new StubRescheduler());
+ mTestInvocation.invoke(mMockDevice, mStubConfiguration, mockRescheduler);
fail("IllegalArgumentException was not rethrown");
} catch (IllegalArgumentException e) {
// expected
}
- verifyMocks(test);
+ verifyMocks(test, mockRescheduler);
verifySummaryListener();
}
@@ -295,13 +301,14 @@
setupMockFailureListeners(exception);
mMockBuildProvider.buildNotTested(mMockBuildInfo);
setupNormalInvoke(test);
+ EasyMock.replay(mockRescheduler);
try {
- mTestInvocation.invoke(mMockDevice, mStubConfiguration, new StubRescheduler());
+ mTestInvocation.invoke(mMockDevice, mStubConfiguration, mockRescheduler);
fail("FatalHostError was not rethrown");
} catch (FatalHostError e) {
// expected
}
- verifyMocks(test);
+ verifyMocks(test, mockRescheduler);
verifySummaryListener();
}
@@ -320,13 +327,14 @@
setupMockFailureListeners(exception);
mMockBuildProvider.buildNotTested(mMockBuildInfo);
setupNormalInvoke(test);
+ EasyMock.replay(mockRescheduler);
try {
- mTestInvocation.invoke(mMockDevice, mStubConfiguration, new StubRescheduler());
+ mTestInvocation.invoke(mMockDevice, mStubConfiguration, mockRescheduler);
fail("DeviceNotAvailableException not thrown");
} catch (DeviceNotAvailableException e) {
// expected
}
- verifyMocks(test);
+ verifyMocks(test, mockRescheduler);
verifySummaryListener();
}
@@ -348,8 +356,9 @@
.andReturn(new ByteArrayInputStreamSource(new byte[0]));
setupInvokeWithBuild();
replayMocks(test);
- mTestInvocation.invoke(mMockDevice, mStubConfiguration, new StubRescheduler());
- verifyMocks(test);
+ EasyMock.replay(mockRescheduler);
+ mTestInvocation.invoke(mMockDevice, mStubConfiguration, mockRescheduler);
+ verifyMocks(test, mockRescheduler);
verifySummaryListener();
}
@@ -477,7 +486,8 @@
}
/**
- * Test the {@link TestInvocation#invoke(ITestDevice, IConfiguration, IRescheduler)} scenario
+ * Test the {@link TestInvocation#invoke(ITestDevice, IConfiguration, IRescheduler,
+ * ITestInvocationListener[])} scenario
* when a {@link ITargetCleaner} is part of the config.
*/
public void testInvoke_tearDown() throws Throwable {
@@ -488,14 +498,15 @@
mStubConfiguration.getTargetPreparers().add(mockCleaner);
setupMockSuccessListeners();
setupNormalInvoke(test);
- EasyMock.replay(mockCleaner);
- mTestInvocation.invoke(mMockDevice, mStubConfiguration, new StubRescheduler());
- verifyMocks(mockCleaner);
+ EasyMock.replay(mockCleaner, mockRescheduler);
+ mTestInvocation.invoke(mMockDevice, mStubConfiguration, mockRescheduler);
+ verifyMocks(mockCleaner, mockRescheduler);
verifySummaryListener();
}
/**
- * Test the {@link TestInvocation#invoke(ITestDevice, IConfiguration, IRescheduler)} scenario
+ * Test the {@link TestInvocation#invoke(ITestDevice, IConfiguration, IRescheduler,
+ * ITestInvocationListener[])} scenario
* when a {@link ITargetCleaner} is part of the config, and the test throws a
* {@link DeviceNotAvailableException}.
*/
@@ -511,23 +522,24 @@
EasyMock.expectLastCall();
mMockDevice.setRecoveryMode(RecoveryMode.NONE);
EasyMock.expectLastCall();
- EasyMock.replay(mockCleaner);
+ EasyMock.replay(mockCleaner, mockRescheduler);
mStubConfiguration.getTargetPreparers().add(mockCleaner);
setupMockFailureListeners(exception);
mMockBuildProvider.buildNotTested(mMockBuildInfo);
setupNormalInvoke(test);
try {
- mTestInvocation.invoke(mMockDevice, mStubConfiguration, new StubRescheduler());
+ mTestInvocation.invoke(mMockDevice, mStubConfiguration, mockRescheduler);
fail("DeviceNotAvailableException not thrown");
} catch (DeviceNotAvailableException e) {
// expected
}
- verifyMocks(mockCleaner);
+ verifyMocks(mockCleaner, mockRescheduler);
verifySummaryListener();
}
/**
- * Test the {@link TestInvocation#invoke(ITestDevice, IConfiguration, IRescheduler)} scenario
+ * Test the {@link TestInvocation#invoke(ITestDevice, IConfiguration, IRescheduler,
+ * ITestInvocationListener[])} scenario
* when a {@link ITargetCleaner} is part of the config, and the test throws a
* {@link RuntimeException}.
*/
@@ -544,19 +556,20 @@
setupMockFailureListeners(exception);
mMockBuildProvider.buildNotTested(mMockBuildInfo);
setupNormalInvoke(test);
- EasyMock.replay(mockCleaner);
+ EasyMock.replay(mockCleaner, mockRescheduler);
try {
- mTestInvocation.invoke(mMockDevice, mStubConfiguration, new StubRescheduler());
+ mTestInvocation.invoke(mMockDevice, mStubConfiguration, mockRescheduler);
fail("RuntimeException not thrown");
} catch (RuntimeException e) {
// expected
}
- verifyMocks(mockCleaner);
+ verifyMocks(mockCleaner, mockRescheduler);
verifySummaryListener();
}
/**
- * Test the {@link TestInvocation#invoke(ITestDevice, IConfiguration, IRescheduler)} scenario
+ * Test the {@link TestInvocation#invoke(ITestDevice, IConfiguration, IRescheduler,
+ * ITestInvocationListener[])} scenario
* when there is {@link ITestInvocationListener} which implements the {@link ILogSaverListener}
* interface.
*/
@@ -586,9 +599,9 @@
setupMockSuccessListeners();
test.run((ITestInvocationListener)EasyMock.anyObject());
setupNormalInvoke(test);
- EasyMock.replay(logSaverListener);
- mTestInvocation.invoke(mMockDevice, mStubConfiguration, new StubRescheduler());
- verifyMocks(test, logSaverListener);
+ EasyMock.replay(logSaverListener, mockRescheduler);
+ mTestInvocation.invoke(mMockDevice, mStubConfiguration, mockRescheduler);
+ verifyMocks(test, logSaverListener, mockRescheduler);
assertEquals(2, mUriCapture.getValue().size());
}
diff --git a/tests/src/com/android/tradefed/log/StubTerribleFailureHandler.java b/tests/src/com/android/tradefed/log/StubTerribleFailureHandler.java
deleted file mode 100644
index f5afdc1..0000000
--- a/tests/src/com/android/tradefed/log/StubTerribleFailureHandler.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2013 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.tradefed.log;
-
-/**
- * Empty implementation of a {@link ITerribleFailureHandler}
- */
-public class StubTerribleFailureHandler implements ITerribleFailureHandler {
-
- @Override
- public boolean onTerribleFailure(String description, Throwable cause) {
- // ignore
- return true;
- }
-}
diff --git a/tests/src/com/android/tradefed/targetprep/TestFilePushSetupFuncTest.java b/tests/src/com/android/tradefed/targetprep/TestFilePushSetupFuncTest.java
index 7cfec7d..5429a83 100644
--- a/tests/src/com/android/tradefed/targetprep/TestFilePushSetupFuncTest.java
+++ b/tests/src/com/android/tradefed/targetprep/TestFilePushSetupFuncTest.java
@@ -16,16 +16,19 @@
package com.android.tradefed.targetprep;
+import com.google.common.io.Files;
+
import com.android.tradefed.build.DeviceBuildInfo;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.device.StubTestDevice;
import com.android.tradefed.util.FakeTestsZipFolder;
import com.android.tradefed.util.FakeTestsZipFolder.ItemType;
-import com.google.common.io.Files;
import junit.framework.TestCase;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
@@ -71,29 +74,30 @@
stubBuild.setTestsDir(mFakeTestsZipFolder.getBasePath(), "0");
assertFalse(mFiles.isEmpty());
assertFalse(mDeviceLocationList.isEmpty());
- ITestDevice device = new StubTestDevice() {
- @Override
- public boolean pushDir(File localDir, String deviceFilePath)
- throws DeviceNotAvailableException {
- return mDeviceLocationList.remove(deviceFilePath);
- }
-
- @Override
- public boolean pushFile(File localFile, String deviceFilePath)
- throws DeviceNotAvailableException {
- return mDeviceLocationList.remove(deviceFilePath);
- }
-
- @Override
- public String executeShellCommand(String command) throws DeviceNotAvailableException {
- return "";
- }
- };
+ ITestDevice device = EasyMock.createMock(ITestDevice.class);
+ EasyMock.expect(device.pushDir((File) EasyMock.anyObject(), (String) EasyMock.anyObject()))
+ .andAnswer(new IAnswer<Boolean>() {
+ @Override
+ public Boolean answer() throws Throwable {
+ return mDeviceLocationList.remove(EasyMock.getCurrentArguments()[1]);
+ }
+ });
+ EasyMock.expect(device.pushFile((File) EasyMock.anyObject(),
+ (String) EasyMock.anyObject())).andAnswer(new IAnswer<Boolean>() {
+ @Override
+ public Boolean answer() throws Throwable {
+ return mDeviceLocationList.remove(EasyMock.getCurrentArguments()[1]);
+ }
+ }).times(3);
+ EasyMock.expect(device.executeShellCommand((String) EasyMock.anyObject()))
+ .andReturn("").times(4);
+ EasyMock.replay(device);
for (String file : mFiles.keySet()) {
testFilePushSetup.addTestFileName(file);
}
testFilePushSetup.setUp(device, stubBuild);
assertTrue(mDeviceLocationList.isEmpty());
+ EasyMock.verify(device);
}
/**
diff --git a/tests/src/com/android/tradefed/testtype/testdefs/XmlDefsTestTest.java b/tests/src/com/android/tradefed/testtype/testdefs/XmlDefsTestTest.java
index f88ce3e..560afe9 100644
--- a/tests/src/com/android/tradefed/testtype/testdefs/XmlDefsTestTest.java
+++ b/tests/src/com/android/tradefed/testtype/testdefs/XmlDefsTestTest.java
@@ -17,7 +17,6 @@
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
-import com.android.tradefed.device.StubTestDevice;
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.testtype.InstrumentationTest;
import com.android.tradefed.testtype.MockInstrumentationTest;
@@ -26,6 +25,7 @@
import org.easymock.Capture;
import org.easymock.EasyMock;
+import org.easymock.IAnswer;
import java.io.File;
import java.io.FileOutputStream;
@@ -33,7 +33,7 @@
import java.util.Map;
/**
- * Unit tests for {@link XmlDefTest}.
+ * Unit tests for {@link XmlDefsTest}.
*/
public class XmlDefsTestTest extends TestCase {
@@ -89,14 +89,13 @@
// TODO: it would be nice to mock out the file objects, so this test wouldn't need to do
// IO
mMockTestDevice.pullFile(EasyMock.eq(TEST_PATH), (File)EasyMock.anyObject());
- EasyMock.expectLastCall().andDelegateTo(new StubTestDevice() {
+ EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
@Override
- public boolean pullFile(String remoteFilePath, File localFile)
- throws DeviceNotAvailableException {
- // simulate the pull file by dumping data into local file
+ public Object answer() throws Throwable {
+ // simulate the pull file by dumping data into local file
FileOutputStream outStream;
try {
- outStream = new FileOutputStream(localFile);
+ outStream = new FileOutputStream((File)EasyMock.getCurrentArguments()[1]);
outStream.write(TEST_DEF_DATA.getBytes());
outStream.close();
return true;