use of com.android.tools.idea.wizard.template.TemplateWizardState in project android by JetBrains.
the class TemplateTest method testJdk7.
public void testJdk7() throws Exception {
if (DISABLED) {
return;
}
AndroidSdkData sdkData = AndroidSdks.getInstance().tryToChooseAndroidSdk();
assertNotNull(sdkData);
if (IdeSdks.getInstance().isJdk7Supported(sdkData)) {
IAndroidTarget[] targets = sdkData.getTargets();
IAndroidTarget target = targets[targets.length - 1];
Map<String, Object> overrides = new HashMap<>();
overrides.put(ATTR_JAVA_VERSION, "1.7");
NewProjectWizardState state = createNewProjectState(true, sdkData);
// TODO: Allow null activity state!
File activity = findTemplate("activities", "BasicActivity");
TemplateWizardState activityState = state.getActivityTemplateState();
assertNotNull(activity);
activityState.setTemplateLocation(activity);
checkApiTarget(19, 19, target, state, "Test17", null, overrides, null);
} else {
System.out.println("JDK 7 not supported by current SDK manager: not testing");
}
}
use of com.android.tools.idea.wizard.template.TemplateWizardState in project android by JetBrains.
the class ChooseTemplateStepTest method testGetTemplateList.
public void testGetTemplateList() throws Exception {
TemplateWizardState state = new TemplateWizardState();
// First, list all templates
List<ChooseTemplateStep.MetadataListItem> otherList = ChooseTemplateStep.getTemplateList(state, Template.CATEGORY_OTHER, null);
List<File> templateDirFiles = TemplateManager.getInstance().getTemplates(Template.CATEGORY_OTHER);
int expectedCount = templateDirFiles.size();
// Make sure we have the right number of templates detected
assertEquals(expectedCount, otherList.size());
// Make sure the contents are equal
for (ChooseTemplateStep.MetadataListItem listItem : otherList) {
assertContainsElements(templateDirFiles, listItem.getTemplateFile());
}
// Check for sorted order
for (int i = 1; i < otherList.size(); i++) {
assertTrue(otherList.get(i).compareTo(otherList.get(i - 1)) >= 0);
}
// Now let's exclude one
Set<String> EXCLUDED = ImmutableSet.of("Notification");
otherList = ChooseTemplateStep.getTemplateList(state, Template.CATEGORY_OTHER, EXCLUDED);
expectedCount -= 1;
// Make sure this is a valid thing to exclude (i.e. is a template in the given folder)
boolean hasNotificationTemplate = false;
for (File f : templateDirFiles) {
if (f.getName().equals("Notification")) {
hasNotificationTemplate = true;
}
}
assertTrue(hasNotificationTemplate);
assertEquals(expectedCount, otherList.size());
}
Aggregations