Search in sources :

Example 6 with TemplateWizardState

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");
    }
}
Also used : AndroidSdkData(org.jetbrains.android.sdk.AndroidSdkData) TemplateWizardState(com.android.tools.idea.wizard.template.TemplateWizardState) IAndroidTarget(com.android.sdklib.IAndroidTarget) NewProjectWizardState(com.android.tools.idea.npw.NewProjectWizardState) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File)

Example 7 with TemplateWizardState

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());
}
Also used : TemplateWizardState(com.android.tools.idea.wizard.template.TemplateWizardState) File(java.io.File)

Aggregations

TemplateWizardState (com.android.tools.idea.wizard.template.TemplateWizardState)7 NewProjectWizardState (com.android.tools.idea.npw.NewProjectWizardState)4 File (java.io.File)4 IAndroidTarget (com.android.sdklib.IAndroidTarget)3 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 AndroidSdkData (org.jetbrains.android.sdk.AndroidSdkData)3 TemplateMetadata (com.android.tools.idea.templates.TemplateMetadata)2 Element (org.w3c.dom.Element)2 AssetStudioAssetGenerator (com.android.tools.idea.npw.AssetStudioAssetGenerator)1 RenderingContext (com.android.tools.idea.templates.recipe.RenderingContext)1 IOException (java.io.IOException)1 Map (java.util.Map)1