new Main().run(args);
}
+ /** Used by tests to set the sdk manager. */
+ @VisibleForTesting(visibility=Visibility.PRIVATE)
+ void setSdkManager(SdkManager sdkManager) {
+ mSdkManager = sdkManager;
+ }
+
/**
* Runs the sdk manager app
*/
public void printf(String msgFormat, Object... args) {
System.out.printf(msgFormat, args);
- if (!msgFormat.endsWith("\n")) {
- System.out.printf("\n");
- }
}
};
}
/**
* Displays the list of available Targets (Platforms and Add-ons)
*/
- private void displayTargetList() {
+ @VisibleForTesting(visibility=Visibility.PRIVATE)
+ void displayTargetList() {
// Compact output, suitable for scripts.
if (mSdkCommandLine != null && mSdkCommandLine.getFlagCompact()) {
/**
* Displays the skins valid for the given target.
*/
- private void displaySkinList(IAndroidTarget target, String message) {
+ @VisibleForTesting(visibility=Visibility.PRIVATE)
+ void displaySkinList(IAndroidTarget target, String message) {
String[] skins = target.getSkins();
String defaultSkin = target.getDefaultSkin();
mSdkLog.printf(message);
/**
* Displays the ABIs valid for the given target.
*/
- private void displayAbiList(IAndroidTarget target, String message) {
+ @VisibleForTesting(visibility=Visibility.PRIVATE)
+ void displayAbiList(IAndroidTarget target, String message) {
ISystemImage[] systemImages = target.getSystemImages();
mSdkLog.printf(message);
if (systemImages.length > 0) {
*
* @param avdManager
*/
- public void displayAvdList(AvdManager avdManager) {
+ @VisibleForTesting(visibility=Visibility.PRIVATE)
+ void displayAvdList(AvdManager avdManager) {
AvdInfo[] avds = avdManager.getValidAvds();
if (systemImages != null && systemImages.length == 1) {
// Auto-select the single ABI available
abiType = systemImages[0].getAbiType();
- mSdkLog.printf("Auto-selecting single ABI %1$s", abiType);
+ mSdkLog.printf("Auto-selecting single ABI %1$s\n", abiType);
} else {
displayAbiList(target, "Valid ABIs: ");
errorAndExit("This platform has more than one ABI. Please specify one using --%1$s.",
getLog().toString());
}
+ public void testDisplayTargetList() {
+ Main main = new Main();
+ main.setLogger(getLog());
+ main.setSdkManager(getSdkManager());
+ getLog().clear();
+ main.displayTargetList();
+ assertEquals(
+ "[P Available Android targets:\n" +
+ ", P ----------\n" +
+ ", P id: 1 or \"android-0\"\n" +
+ ", P Name: Android 0.0\n" +
+ ", P Type: Platform\n" +
+ ", P API level: 0\n" +
+ ", P Revision: 1\n" +
+ ", P Skins: , P \n" +
+ ", P ABIs : , P armeabi, P \n" +
+ "]",
+ getLog().toString());
+ }
+
+ public void testDisplayAbiList() {
+ Main main = new Main();
+ main.setLogger(getLog());
+ main.setSdkManager(getSdkManager());
+ getLog().clear();
+ main.displayAbiList(mTarget, "message");
+ assertEquals(
+ "[P message, P armeabi, P \n" +
+ "]",
+ getLog().toString());
+ }
+
+ public void testDisplaySkinList() {
+ Main main = new Main();
+ main.setLogger(getLog());
+ main.setSdkManager(getSdkManager());
+ getLog().clear();
+ main.displaySkinList(mTarget, "message");
+ assertEquals(
+ "[P message, P \n" +
+ "]",
+ getLog().toString());
+ }
+
public void testCheckFilterValues() {
// These are the values we expect checkFilterValues() to match.
String[] expectedValues = {
if (createSnapshot) {
File snapshotDest = new File(avdFolder, SNAPSHOTS_IMG);
if (snapshotDest.isFile() && editExisting) {
- log.printf("Snapshot image already present, was not changed.");
+ log.printf("Snapshot image already present, was not changed.\n");
} else {
String toolsLib = mSdkManager.getLocation() + File.separator
// There's already an sdcard file with the right size and we're
// not overriding it... so don't remove it.
runMkSdcard = false;
- log.printf("SD Card already present with same size, was not changed.");
+ log.printf("SD Card already present with same size, was not changed.\n");
}
}