Add Configuration load tests
Also clean some of the project warnings.
Bug: 31393228
Change-Id: Ibae428018c0c205cc1f6c1d76cdc552c661205c6
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ConsoleReporter.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ConsoleReporter.java
index 47c13e1..03f8312 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ConsoleReporter.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/result/ConsoleReporter.java
@@ -16,12 +16,10 @@
package com.android.compatibility.common.tradefed.result;
-import com.android.ddmlib.Log;
import com.android.ddmlib.Log.LogLevel;
import com.android.ddmlib.testrunner.TestIdentifier;
import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.config.Option;
-import com.android.tradefed.config.OptionClass;
import com.android.tradefed.config.OptionCopier;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.result.IShardableListener;
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ApkInstrumentationPreparer.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ApkInstrumentationPreparer.java
index 6b87977..323adf6 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ApkInstrumentationPreparer.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ApkInstrumentationPreparer.java
@@ -21,7 +21,6 @@
import com.android.ddmlib.testrunner.TestIdentifier;
import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.config.Option;
-import com.android.tradefed.config.Option.Importance;
import com.android.tradefed.config.OptionClass;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
@@ -33,8 +32,6 @@
import java.io.File;
import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -74,10 +71,12 @@
if (instrument(device, buildInfo)) {
logInfo("Target preparation successful");
} else {
- throw new TargetSetupError("Not all target preparation steps completed");
+ throw new TargetSetupError("Not all target preparation steps completed",
+ device.getDeviceDescriptor());
}
} catch (FileNotFoundException e) {
- throw new TargetSetupError("Couldn't find apk to instrument", e);
+ throw new TargetSetupError("Couldn't find apk to instrument", e,
+ device.getDeviceDescriptor());
}
}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java
index a422525..c1f2d4b 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/DynamicConfigPusher.java
@@ -87,8 +87,8 @@
try {
localConfigFile = DynamicConfig.getConfigFile(buildHelper.getTestsDir(), mModuleName);
} catch (FileNotFoundException e) {
- throw new TargetSetupError(
- "Cannot get local dynamic config file from test directory", e);
+ throw new TargetSetupError("Cannot get local dynamic config file from test directory",
+ e, device.getDeviceDescriptor());
}
if (mVersion == null) {
@@ -119,7 +119,8 @@
src = DynamicConfigHandler.getMergedDynamicConfigFile(
localConfigFile, apfeConfigInJson, mModuleName);
} catch (IOException | XmlPullParserException | JSONException e) {
- throw new TargetSetupError("Cannot get merged dynamic config file", e);
+ throw new TargetSetupError("Cannot get merged dynamic config file", e,
+ device.getDeviceDescriptor());
}
switch (mTarget) {
@@ -128,7 +129,7 @@
if (!device.pushFile(src, deviceDest)) {
throw new TargetSetupError(String.format(
"Failed to push local '%s' to remote '%s'",
- src.getAbsolutePath(), deviceDest));
+ src.getAbsolutePath(), deviceDest), device.getDeviceDescriptor());
} else {
mFilePushed = deviceDest;
buildHelper.addDynamicConfigFile(mModuleName, src);
@@ -145,7 +146,8 @@
FileUtil.copyFile(src, hostDest);
} catch (IOException e) {
throw new TargetSetupError(String.format("Failed to copy file from %s to %s",
- src.getAbsolutePath(), hostDest.getAbsolutePath()), e);
+ src.getAbsolutePath(), hostDest.getAbsolutePath()), e,
+ device.getDeviceDescriptor());
}
mFilePushed = hostDest.getAbsolutePath();
buildHelper.addDynamicConfigFile(mModuleName, src);
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/LocationCheck.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/LocationCheck.java
index 94bc64f..548dd6f8 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/LocationCheck.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/LocationCheck.java
@@ -16,7 +16,6 @@
package com.android.compatibility.common.tradefed.targetprep;
import com.android.tradefed.build.IBuildInfo;
-import com.android.tradefed.config.Option;
import com.android.tradefed.config.OptionClass;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/PropertyCheck.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/PropertyCheck.java
index 79f19d0..192c095 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/PropertyCheck.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/PropertyCheck.java
@@ -41,8 +41,6 @@
description = "Whether to throw an error for an unexpected property value")
protected boolean mThrowError = false;
- private static final String LOG_TAG = PropertyCheck.class.getSimpleName();
-
@Override
public void run(ITestDevice device, IBuildInfo buildInfo) throws TargetSetupError,
BuildError, DeviceNotAvailableException {
@@ -59,7 +57,7 @@
mExpectedPropertyValue, propertyValue, mPropertyName);
// Handle unexpected property value with either exception or warning
if(mThrowError) {
- throw new TargetSetupError(msg);
+ throw new TargetSetupError(msg, device.getDeviceDescriptor());
} else {
logWarning(msg);
}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ReportLogCollector.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ReportLogCollector.java
index 576b15d..7ea48c2 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ReportLogCollector.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/ReportLogCollector.java
@@ -54,10 +54,6 @@
prepareReportLogContainers(device, buildInfo);
}
- private void addBuildInfo(ITestDevice device, IBuildInfo buildInfo, String key, String value)
- throws DeviceNotAvailableException {
- }
-
private void prepareReportLogContainers(ITestDevice device, IBuildInfo buildInfo) {
CompatibilityBuildHelper buildHelper = new CompatibilityBuildHelper(buildInfo);
try {
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/SettingsPreparer.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/SettingsPreparer.java
index d4c9d54..481aef2 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/SettingsPreparer.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/SettingsPreparer.java
@@ -64,18 +64,18 @@
if (mSettingName == null) {
throw new TargetSetupError("The \"device-setting\" option must be defined for the " +
- "SettingsPreparer class");
+ "SettingsPreparer class", device.getDeviceDescriptor());
}
if (mSettingType == null) {
throw new TargetSetupError("The \"setting-type\" option must be defined for the " +
- "SettingsPreparer class");
+ "SettingsPreparer class", device.getDeviceDescriptor());
}
/* At least one of the options "set-value" and "expected-values" must be set */
if (mSetValue == null && mExpectedSettingValues.isEmpty()) {
throw new TargetSetupError("At least one of the options \"set-value\" and " +
- "\"expected-values\" must be set");
+ "\"expected-values\" must be set", device.getDeviceDescriptor());
}
String shellCmdGet = (!mExpectedSettingValues.isEmpty()) ?
@@ -90,7 +90,8 @@
if (!mExpectedSettingValues.contains(mSetValue)) {
throw new TargetSetupError(String.format(
"set-value for %s is %s, but value not found in expected-values: %s",
- mSettingName, mSetValue, mExpectedSettingValues.toString()));
+ mSettingName, mSetValue, mExpectedSettingValues.toString()),
+ device.getDeviceDescriptor());
}
String currentSettingValue = device.executeShellCommand(shellCmdGet).trim();
// only change unexpected setting value
@@ -117,7 +118,7 @@
"Device setting \"%s\" returned \"%s\", not found in %s",
mSettingName, currentSettingValue, mExpectedSettingValues.toString());
}
- throw new TargetSetupError(mFailureMessage);
+ throw new TargetSetupError(mFailureMessage, device.getDeviceDescriptor());
}
}
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/StayAwakePreparer.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/StayAwakePreparer.java
index d804146..ca9bdcf 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/StayAwakePreparer.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/StayAwakePreparer.java
@@ -22,8 +22,6 @@
import com.android.tradefed.targetprep.BuildError;
import com.android.tradefed.targetprep.TargetSetupError;
-import java.util.Arrays;
-
/**
* Modifies the 'Stay Awake' setting of the device, so that the device's screen stays on
* whenever charging via USB
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/SystemStatusChecker.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/SystemStatusChecker.java
index 41ab510..45992ac 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/SystemStatusChecker.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/SystemStatusChecker.java
@@ -100,8 +100,7 @@
}
/**
- * Returns failure message set by the failed system status check
- * @return
+ * Returns failure message set by the failed system status check.
*/
public String getFailureMessage() {
return mFailureMessage;
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/TokenRequirement.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/TokenRequirement.java
index 54b6bc0..102d9c8 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/TokenRequirement.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/TokenRequirement.java
@@ -45,7 +45,8 @@
@Override
public void setUp(ITestDevice device, IBuildInfo buildInfo) throws TargetSetupError,
BuildError, DeviceNotAvailableException {
- throw new TargetSetupError("TokenRequirement is not expected to run");
+ throw new TargetSetupError("TokenRequirement is not expected to run",
+ device.getDeviceDescriptor());
}
/**
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/WifiCheck.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/WifiCheck.java
index cfc4d7c..5b53ba4 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/WifiCheck.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/targetprep/WifiCheck.java
@@ -23,9 +23,6 @@
import com.android.tradefed.targetprep.BuildError;
import com.android.tradefed.targetprep.TargetSetupError;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* This preparer ensures that the device is connected to a network.
* The options "wifi-ssid" and "wifi-psk" allow users of the preparer to attempt connection
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
index 5f622f3..5072bc2 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/CompatibilityTest.java
@@ -499,7 +499,7 @@
* Resolve the inclusion and exclusion logic of system status checkers
*
* @param s the {@link SystemStatusChecker} to perform filtering logic on
- * @return
+ * @return True if the {@link SystemStatusChecker} should be included, false otherwise.
*/
private boolean shouldIncludeSystemStatusChecker(SystemStatusChecker s) {
String clazz = s.getClass().getCanonicalName();
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleDef.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleDef.java
index 14427ca..544f305 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleDef.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/IModuleDef.java
@@ -22,7 +22,6 @@
import com.android.tradefed.testtype.IRemoteTest;
import com.android.tradefed.testtype.IRuntimeHintProvider;
-import java.io.File;
import java.util.Set;
/**
@@ -60,7 +59,7 @@
* Set a list of preparers to allow to run before or after a test.
* If this list is empty, then all configured preparers will run.
*
- * @param a list containing the simple name of the preparer to run.
+ * @param preparerWhitelist list containing the simple name of the preparer to run.
*/
void setPreparerWhitelist(Set<String> preparerWhitelist);
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ISubPlan.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ISubPlan.java
index adc0227..e0ff83a 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ISubPlan.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ISubPlan.java
@@ -16,6 +16,8 @@
package com.android.compatibility.common.tradefed.testtype;
import com.android.compatibility.common.util.IInvocationResult;
+import com.android.compatibility.common.util.ITestResult;
+import com.android.compatibility.common.util.TestStatus;
import com.android.tradefed.testtype.ITestFilterReceiver;
import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/JarHostTest.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/JarHostTest.java
index 8d663e4..b9b0181 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/JarHostTest.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/JarHostTest.java
@@ -29,7 +29,6 @@
import com.android.tradefed.testtype.IBuildReceiver;
import com.android.tradefed.testtype.IRemoteTest;
import com.android.tradefed.testtype.IRuntimeHintProvider;
-import com.android.tradefed.util.TimeVal;
import junit.framework.Test;
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java
index 8324d35..26b9b3b 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/ModuleDef.java
@@ -40,7 +40,6 @@
import com.android.tradefed.testtype.ITestCollector;
import com.android.tradefed.testtype.ITestFilterReceiver;
-import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/SubPlan.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/SubPlan.java
index 80ca30e..774c51e 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/SubPlan.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/testtype/SubPlan.java
@@ -19,7 +19,6 @@
import com.android.compatibility.common.util.IInvocationResult;
import com.android.compatibility.common.util.IModuleResult;
import com.android.compatibility.common.util.ITestResult;
-
import com.android.compatibility.common.util.TestFilter;
import com.android.compatibility.common.util.TestStatus;
import com.android.tradefed.util.xml.AbstractXmlParser;
@@ -30,7 +29,6 @@
import org.xml.sax.helpers.DefaultHandler;
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Collections;
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/CollectorUtil.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/CollectorUtil.java
index 1321f22..c488f51 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/CollectorUtil.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/CollectorUtil.java
@@ -16,6 +16,8 @@
package com.android.compatibility.common.tradefed.util;
+import com.android.compatibility.common.tradefed.targetprep.DeviceInfoCollector;
+import com.android.compatibility.common.tradefed.targetprep.ReportLogCollector;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.log.LogUtil.CLog;
@@ -34,7 +36,7 @@
import java.util.regex.Pattern;
/**
- * Util class for {@link ReportLogCollector} and {@link DeviceInfoCollector}.
+ * Utility class for {@link ReportLogCollector} and {@link DeviceInfoCollector}.
*/
public class CollectorUtil {
diff --git a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/NoOpTestInvocationListener.java b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/NoOpTestInvocationListener.java
index 06f493d..05683b2 100644
--- a/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/NoOpTestInvocationListener.java
+++ b/common/host-side/tradefed/src/com/android/compatibility/common/tradefed/util/NoOpTestInvocationListener.java
@@ -16,11 +16,10 @@
package com.android.compatibility.common.tradefed.util;
import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.ddmlib.testrunner.ITestRunListener;
import com.android.tradefed.build.IBuildInfo;
+import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.result.InputStreamSource;
import com.android.tradefed.result.LogDataType;
-import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.result.TestSummary;
import java.util.Map;
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/UnitTests.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/UnitTests.java
index a7a31f6..1752e20 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/UnitTests.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/UnitTests.java
@@ -17,6 +17,7 @@
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelperTest;
import com.android.compatibility.common.tradefed.command.CompatibilityConsoleTest;
+import com.android.compatibility.common.tradefed.config.ConfigurationFactoryTest;
import com.android.compatibility.common.tradefed.result.ConsoleReporterTest;
import com.android.compatibility.common.tradefed.result.ResultReporterTest;
import com.android.compatibility.common.tradefed.result.SubPlanCreatorTest;
@@ -44,9 +45,9 @@
addTestSuite(CompatibilityBuildHelperTest.class);
addTestSuite(CompatibilityConsoleTest.class);
addTestSuite(CompatibilityTestTest.class);
+ addTestSuite(ConfigurationFactoryTest.class);
addTestSuite(ConsoleReporterTest.class);
addTestSuite(ResultReporterTest.class);
- addTestSuite(CompatibilityTestTest.class);
addTestSuite(OptionHelperTest.class);
addTestSuite(CollectorUtilTest.class);
addTestSuite(ModuleDefTest.class);
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/config/ConfigurationFactoryTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/config/ConfigurationFactoryTest.java
new file mode 100644
index 0000000..3a59387
--- /dev/null
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/config/ConfigurationFactoryTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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 com.android.compatibility.common.tradefed.config;
+
+import com.android.tradefed.config.ConfigurationException;
+import com.android.tradefed.config.ConfigurationFactory;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for {@link ConfigurationFactory} imported from Trade Federation to check cts
+ * configuration loading.
+ */
+public class ConfigurationFactoryTest extends TestCase {
+
+ private ConfigurationFactory mConfigFactory;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ mConfigFactory = (ConfigurationFactory) ConfigurationFactory.getInstance();
+ }
+
+ /**
+ * Sanity test to ensure all config names on classpath are loadable.
+ */
+ public void testLoadAllConfigs() throws ConfigurationException {
+ // we dry-run the templates otherwise it will always fail.
+ mConfigFactory.loadAllConfigs(false);
+ }
+
+ /**
+ * Sanity test to ensure all configs on classpath can be fully loaded and parsed.
+ */
+ public void testLoadAndPrintAllConfigs() throws ConfigurationException {
+ // Printing the help involves more checks since it tries to resolve the config objects.
+ mConfigFactory.loadAndPrintAllConfigs();
+ }
+}
\ No newline at end of file
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ConsoleReporterTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ConsoleReporterTest.java
index 928379e..f0de3e1 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ConsoleReporterTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/result/ConsoleReporterTest.java
@@ -16,29 +16,20 @@
package com.android.compatibility.common.tradefed.result;
-import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
import com.android.compatibility.common.util.AbiUtils;
-import com.android.compatibility.common.util.ICaseResult;
-import com.android.compatibility.common.util.IInvocationResult;
-import com.android.compatibility.common.util.IModuleResult;
-import com.android.compatibility.common.util.ITestResult;
-import com.android.compatibility.common.util.TestStatus;
import com.android.ddmlib.testrunner.TestIdentifier;
-import com.android.tradefed.build.BuildInfo;
import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.config.OptionSetter;
-import com.android.tradefed.util.FileUtil;
import junit.framework.TestCase;
-import java.io.File;
-import java.io.FileFilter;
import java.util.HashMap;
-import java.util.List;
+/**
+ * Tests for {@link ConsoleReporter}.
+ */
public class ConsoleReporterTest extends TestCase {
- private static final String TESTCASES = "testcases";
private static final String NAME = "ModuleName";
private static final String NAME2 = "ModuleName2";
private static final String ABI = "mips64";
@@ -48,19 +39,11 @@
private static final String METHOD_1 = "testBlah1";
private static final String METHOD_2 = "testBlah2";
private static final String METHOD_3 = "testBlah3";
- private static final String TEST_1 = String.format("%s#%s", CLASS, METHOD_1);
- private static final String TEST_2 = String.format("%s#%s", CLASS, METHOD_2);
- private static final String TEST_3 = String.format("%s#%s", CLASS, METHOD_3);
private static final String STACK_TRACE = "Something small is not alright\n " +
"at four.big.insects.Marley.sing(Marley.java:10)";
private ConsoleReporter mReporter;
private IBuildInfo mBuildInfo;
- private CompatibilityBuildHelper mBuildHelper;
-
- private File mRoot = null;
- private File mBase = null;
- private File mTests = null;
@Override
public void setUp() throws Exception {
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/targetprep/PropertyCheckTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/targetprep/PropertyCheckTest.java
index a309a47..617fde6 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/targetprep/PropertyCheckTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/targetprep/PropertyCheckTest.java
@@ -45,6 +45,7 @@
mMockBuildInfo = new DeviceBuildInfo("0", "", "");
mOptionSetter = new OptionSetter(mPropertyCheck);
EasyMock.expect(mMockDevice.getProperty(PROPERTY)).andReturn(ACTUAL_VALUE).anyTimes();
+ EasyMock.expect(mMockDevice.getDeviceDescriptor()).andReturn(null).anyTimes();
}
public void testWarningMatch() throws Exception {
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/targetprep/SettingsPreparerTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/targetprep/SettingsPreparerTest.java
index 739662e..7fbb39e 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/targetprep/SettingsPreparerTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/targetprep/SettingsPreparerTest.java
@@ -16,7 +16,6 @@
package com.android.compatibility.common.tradefed.targetprep;
-import com.android.tradefed.build.DeviceBuildInfo;
import com.android.tradefed.build.BuildInfo;
import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.config.OptionSetter;
@@ -27,6 +26,9 @@
import org.easymock.EasyMock;
+/**
+ * Tests for {@link SettingsPreparer}
+ */
public class SettingsPreparerTest extends TestCase {
private SettingsPreparer mSettingsPreparer;
@@ -43,6 +45,7 @@
super.setUp();
mSettingsPreparer = new SettingsPreparer();
mMockDevice = EasyMock.createMock(ITestDevice.class);
+ EasyMock.expect(mMockDevice.getDeviceDescriptor()).andReturn(null).anyTimes();
mMockBuildInfo = new BuildInfo("0", "", "");
mOptionSetter = new OptionSetter(mSettingsPreparer);
mOptionSetter.setOptionValue("device-setting", "stay_on_while_plugged_in");
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ModuleDefTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ModuleDefTest.java
index 7ea5ccd..a271b59 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ModuleDefTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ModuleDefTest.java
@@ -13,10 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package com.android.compatibility.common.tradefed.testtype;
-import com.android.compatibility.common.tradefed.util.NoOpTestInvocationListener;
import com.android.compatibility.common.util.AbiUtils;
import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.result.ITestInvocationListener;
@@ -40,9 +38,6 @@
private static final String NAME = "ModuleName";
private static final String ABI = "mips64";
private static final String ID = AbiUtils.createId(ABI, NAME);
- private static final String CLASS = "android.test.FoorBar";
- private static final String METHOD_1 = "testBlah1";
- private static final String TEST_1 = String.format("%s#%s", CLASS, METHOD_1);
public void testAccessors() throws Exception {
IAbi abi = new Abi(ABI, "");
@@ -99,6 +94,4 @@
// Do nothing
}
}
-
- private class MockListener extends NoOpTestInvocationListener {}
}
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ShardableTestStub.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ShardableTestStub.java
index f638da8..1b3f955 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ShardableTestStub.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/ShardableTestStub.java
@@ -32,7 +32,6 @@
import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
import java.util.Set;
public class ShardableTestStub implements IRemoteTest, IShardableTest, IBuildReceiver,
@@ -58,7 +57,7 @@
}
/**
- * {@inheritdoc}
+ * {@inheritDoc}
*/
@Override
public void run(ITestInvocationListener listener) throws DeviceNotAvailableException {
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/SubPlanTest.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/SubPlanTest.java
index f6ec507..fa24b32 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/SubPlanTest.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/SubPlanTest.java
@@ -25,12 +25,14 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
-import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashSet;
import java.util.Set;
+/**
+ * Tests for {@link SubPlan}
+ */
public class SubPlanTest extends TestCase {
private static final String ABI = "armeabi-v7a";
@@ -74,24 +76,28 @@
}
public void testParsing() throws Exception {
- File subPlanFile = FileUtil.createTempFile("test-subPlan-parsing", ".txt");
- FileWriter writer = new FileWriter(subPlanFile);
- Set<String> entries = new HashSet<String>();
- entries.add(generateEntryXml(ABI, MODULE_A, TEST_1, true)); // include format 1
- entries.add(generateEntryXml(ABI, MODULE_A, TEST_2, true));
- entries.add(generateEntryXml(null, null,
- new TestFilter(ABI, MODULE_A, TEST_3).toString(), true)); // include format 2
- entries.add(generateEntryXml(null, MODULE_B, null, true));
- entries.add(generateEntryXml(null, null,
- new TestFilter(null, MODULE_B, TEST_1).toString(), false));
- entries.add(generateEntryXml(null, null,
- new TestFilter(null, MODULE_B, TEST_2).toString(), false));
- entries.add(generateEntryXml(null, null,
- new TestFilter(null, MODULE_B, TEST_3).toString(), false));
- String xml = String.format(XML_BASE, String.join("\n", entries));
- writer.write(xml);
- writer.flush();
- checkSubPlan(subPlanFile);
+ File planFile = FileUtil.createTempFile("test-plan-parsing", ".txt");
+ FileWriter writer = new FileWriter(planFile);
+ try {
+ Set<String> entries = new HashSet<String>();
+ entries.add(generateEntryXml(ABI, MODULE_A, TEST_1, true)); // include format 1
+ entries.add(generateEntryXml(ABI, MODULE_A, TEST_2, true));
+ entries.add(generateEntryXml(null, null,
+ new TestFilter(ABI, MODULE_A, TEST_3).toString(), true)); // include format 2
+ entries.add(generateEntryXml(null, MODULE_B, null, true));
+ entries.add(generateEntryXml(null, null,
+ new TestFilter(null, MODULE_B, TEST_1).toString(), false));
+ entries.add(generateEntryXml(null, null,
+ new TestFilter(null, MODULE_B, TEST_2).toString(), false));
+ entries.add(generateEntryXml(null, null,
+ new TestFilter(null, MODULE_B, TEST_3).toString(), false));
+ String xml = String.format(XML_BASE, String.join("\n", entries));
+ writer.write(xml);
+ writer.flush();
+ checkSubPlan(planFile);
+ } finally {
+ writer.close();
+ }
}
private void checkSubPlan(File subPlanFile) throws Exception {
diff --git a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/TestStub.java b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/TestStub.java
index 729fda2..dbd7d30 100644
--- a/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/TestStub.java
+++ b/common/host-side/tradefed/tests/src/com/android/compatibility/common/tradefed/testtype/TestStub.java
@@ -20,14 +20,11 @@
import com.android.tradefed.result.ITestInvocationListener;
import com.android.tradefed.testtype.IAbi;
import com.android.tradefed.testtype.IAbiReceiver;
-import com.android.tradefed.testtype.IBuildReceiver;
import com.android.tradefed.testtype.IRemoteTest;
import com.android.tradefed.testtype.IRuntimeHintProvider;
-import com.android.tradefed.testtype.IShardableTest;
import com.android.tradefed.testtype.ITestCollector;
import com.android.tradefed.testtype.ITestFilterReceiver;
-import java.util.List;
import java.util.Set;
public class TestStub implements IRemoteTest, IAbiReceiver, IRuntimeHintProvider, ITestCollector,