use of com.android.ide.common.rendering.api.ItemResourceValue in project android by JetBrains.
the class ConfiguredThemeEditorStyleTest method testSetValueCopy.
/**
* Tests setValue method for copying from right FolderConfiguration
* Tests following cases:
* values, values-v17, values-v19, values-v22
* setValue("android:colorAccent", "#000000");
* Should create values-v21 based on values-v19, and modify values-v22
*/
public void testSetValueCopy() {
VirtualFile file = myFixture.copyFileToProject("themeEditor/themeEditorStyle/styles_3.xml", "res/values/styles.xml");
myFixture.copyFileToProject("themeEditor/themeEditorStyle/styles_3.xml", "res/values-v17/styles.xml");
myFixture.copyFileToProject("themeEditor/themeEditorStyle/styles_4.xml", "res/values-v19/styles.xml");
myFixture.copyFileToProject("themeEditor/themeEditorStyle/styles_3.xml", "res/values-v22/styles.xml");
ItemResourceValue item = new ItemResourceValue("colorAccent", true, "#000000", false, null);
checkSetValue(file, item, "-v21", "-v22");
myFixture.checkResultByFile("res/values-v21/styles.xml", "themeEditor/themeEditorStyle/styles_4_modified.xml", true);
myFixture.checkResultByFile("res/values-v22/styles.xml", "themeEditor/themeEditorStyle/styles_3_modified.xml", true);
}
use of com.android.ide.common.rendering.api.ItemResourceValue in project android by JetBrains.
the class ConfiguredThemeEditorStyleTest method checkSetValue.
private void checkSetValue(VirtualFile file, ItemResourceValue item, String... answerFolders) {
Configuration configuration = myFacet.getConfigurationManager().getConfiguration(file);
ThemeResolver themeResolver = new ThemeResolver(configuration);
ConfiguredThemeEditorStyle style = themeResolver.getTheme("AppTheme");
assertNotNull(style);
style.setValue(ResolutionUtils.getQualifiedItemName(item), item.getValue());
// ResourceFolderRepository needs to rescan the files to pick up the changes.
UIUtil.dispatchAllInvocationEvents();
HashSet<String> modifiedFolders = new HashSet<>(Arrays.asList(answerFolders));
int valuesFound = 0;
for (ConfiguredElement<ItemResourceValue> value : style.getConfiguredValues()) {
if (item.equals(value.getElement())) {
valuesFound++;
assertTrue(modifiedFolders.contains(value.getConfiguration().getUniqueKey()));
}
}
assertEquals(modifiedFolders.size(), valuesFound);
}
use of com.android.ide.common.rendering.api.ItemResourceValue in project android by JetBrains.
the class ConfiguredThemeEditorStyleTest method testSetValueAndroidAttribute.
/**
* Tests setValue method for following cases:
* values, values-v21, values-night, value-port, values-port-v21
* setValue("android:colorAccent", "#000000"), android:colorAccent is defined in API 21
*/
public void testSetValueAndroidAttribute() {
VirtualFile file = myFixture.copyFileToProject("themeEditor/themeEditorStyle/styles_2.xml", "res/values/styles.xml");
myFixture.copyFileToProject("themeEditor/themeEditorStyle/styles_3.xml", "res/values-v21/styles.xml");
myFixture.copyFileToProject("themeEditor/themeEditorStyle/styles_2.xml", "res/values-night/styles.xml");
myFixture.copyFileToProject("themeEditor/themeEditorStyle/styles_2.xml", "res/values-port/styles.xml");
myFixture.copyFileToProject("themeEditor/themeEditorStyle/styles_2.xml", "res/values-port-v21/styles.xml");
ItemResourceValue item = new ItemResourceValue("colorAccent", true, "#000000", false, null);
checkSetValue(file, item, "-night-v21", "-v21", "-port-v21");
}
Aggregations