Search in sources :

Example 16 with EditedStyleItem

use of com.android.tools.idea.editors.theme.datamodels.EditedStyleItem in project android by JetBrains.

the class ThemeEditorUtilsTest method testGenerateToolTipText.

public void testGenerateToolTipText() throws IOException {
    if (SystemInfo.isWindows) {
        // Do not run tests on Windows (see http://b.android.com/222904)
        return;
    }
    VirtualFile myFile = myFixture.copyFileToProject("themeEditor/styles_1.xml", "res/values/styles.xml");
    myFixture.copyFileToProject("themeEditor/attrs.xml", "res/values/attrs.xml");
    Configuration configuration = myFacet.getConfigurationManager().getConfiguration(myFile);
    IAndroidTarget androidTarget = configuration.getTarget();
    assertNotNull(androidTarget);
    sdkPlatformPath = androidTarget.getLocation();
    if (LayoutLibraryLoader.USE_SDK_LAYOUTLIB) {
        if (!sdkPlatformPath.endsWith("/"))
            sdkPlatformPath += "/";
        sdkPlatformPath += "platforms/android-" + androidTarget.getVersion().getApiString();
    }
    sdkPlatformPath = Files.simplifyPath(sdkPlatformPath);
    ThemeResolver themeResolver = new ThemeResolver(configuration);
    ConfiguredThemeEditorStyle theme = themeResolver.getTheme("AppTheme");
    assertNotNull(theme);
    Collection<EditedStyleItem> values = ThemeEditorTestUtils.getStyleLocalValues(theme);
    assertEquals(7, values.size());
    configuration.setTheme("AppTheme");
    for (EditedStyleItem item : values) {
        String doc = ThemeEditorUtils.generateToolTipText(item.getSelectedValue(), myModule, configuration);
        compareWithGoldenFile(doc, myFixture.getTestDataPath() + "/themeEditor/tooltipDocAns/" + item.getName() + ".ans");
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Configuration(com.android.tools.idea.configurations.Configuration) IAndroidTarget(com.android.sdklib.IAndroidTarget) ConfiguredThemeEditorStyle(com.android.tools.idea.editors.theme.datamodels.ConfiguredThemeEditorStyle) EditedStyleItem(com.android.tools.idea.editors.theme.datamodels.EditedStyleItem)

Example 17 with EditedStyleItem

use of com.android.tools.idea.editors.theme.datamodels.EditedStyleItem in project android by JetBrains.

the class AttributesGrouperTest method fromList.

/**
   * Creates a list of {@link EditedStyleItem} mocks from the given list of pairs (attribute name, attribute group)
   */
@NotNull
private static List<EditedStyleItem> fromList(String... args) {
    assert args.length % 2 == 0;
    ImmutableList.Builder<EditedStyleItem> builder = ImmutableList.builder();
    for (int i = 0; i < args.length; i += 2) {
        String attributeName = args[i];
        String attributeGroup = args[i + 1];
        EditedStyleItem styleItem = mock(EditedStyleItem.class);
        when(styleItem.getName()).thenReturn(attributeName);
        when(styleItem.getAttrGroup()).thenReturn(attributeGroup);
        builder.add(styleItem);
    }
    return builder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) EditedStyleItem(com.android.tools.idea.editors.theme.datamodels.EditedStyleItem) Assert.assertNotNull(org.junit.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

EditedStyleItem (com.android.tools.idea.editors.theme.datamodels.EditedStyleItem)17 ConfiguredThemeEditorStyle (com.android.tools.idea.editors.theme.datamodels.ConfiguredThemeEditorStyle)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)6 NotNull (org.jetbrains.annotations.NotNull)6 Configuration (com.android.tools.idea.configurations.Configuration)5 ItemResourceValue (com.android.ide.common.rendering.api.ItemResourceValue)4 AttributesTableModel (com.android.tools.idea.editors.theme.attributes.AttributesTableModel)4 ResourceResolver (com.android.ide.common.resources.ResourceResolver)2 FolderConfiguration (com.android.ide.common.resources.configuration.FolderConfiguration)2 ImmutableList (com.google.common.collect.ImmutableList)2 Project (com.intellij.openapi.project.Project)2 PsiElement (com.intellij.psi.PsiElement)2 ResourceValue (com.android.ide.common.rendering.api.ResourceValue)1 Configurable (com.android.ide.common.resources.configuration.Configurable)1 IAndroidTarget (com.android.sdklib.IAndroidTarget)1 AttributesModelColorPaletteModel (com.android.tools.idea.editors.theme.attributes.AttributesModelColorPaletteModel)1 ConfiguredElement (com.android.tools.idea.editors.theme.datamodels.ConfiguredElement)1 ThemeEditorStyle (com.android.tools.idea.editors.theme.datamodels.ThemeEditorStyle)1 AndroidThemePreviewPanel (com.android.tools.idea.editors.theme.preview.AndroidThemePreviewPanel)1 RestrictedConfiguration (com.android.tools.idea.editors.theme.qualifiers.RestrictedConfiguration)1