use of com.android.tools.idea.configurations.Configuration in project android by JetBrains.
the class IncludeReferenceTest method testGetSet.
public void testGetSet() {
VirtualFile included = myFixture.copyFileToProject("designer/included.xml", "res/layout/included.xml");
assertNotNull(included);
VirtualFile includer = myFixture.copyFileToProject("designer/included.xml", "res/layout/includer.xml");
assertNotNull(includer);
XmlFile psiFile = (XmlFile) PsiManager.getInstance(getProject()).findFile(included);
assertNotNull(psiFile);
assertEquals("@layout/includer", IncludeReference.getIncludingLayout(psiFile));
ConfigurationManager manager = myFacet.getConfigurationManager();
Configuration configuration = manager.getConfiguration(included);
ResourceResolver resourceResolver = configuration.getResourceResolver();
assertNotNull(resourceResolver);
IncludeReference reference = IncludeReference.get(myModule, psiFile, resourceResolver);
assertEquals("includer.xml", reference.getFromDisplayName());
assertEquals("includer", reference.getFromResourceName());
assertEquals("@layout/includer", reference.getFromResourceUrl());
assertEquals(reference.getFromFile(), includer);
assertEquals(reference.getToFile(), included);
IncludeReference.setIncludingLayout(getProject(), psiFile, null);
assertEquals(IncludeReference.NONE, IncludeReference.get(myModule, psiFile, resourceResolver));
VirtualFile other = myFixture.copyFileToProject("xmlpull/designtime.xml", "res/layout-land/designtime.xml");
assertNotNull(other);
IncludeReference.setIncludingLayout(getProject(), psiFile, "@layout/designtime");
assertEquals("@layout/designtime", IncludeReference.getIncludingLayout(psiFile));
}
use of com.android.tools.idea.configurations.Configuration in project android by JetBrains.
the class GraphicsLayoutRendererTest method testInflateAndRender.
public void testInflateAndRender() throws InitializationException, ParserConfigurationException, IOException, SAXException {
VirtualFile layout = myFixture.copyFileToProject("themeEditor/theme_preview_layout.xml", "res/layout/theme_preview_layout.xml");
Configuration configuration = myFacet.getConfigurationManager().getConfiguration(layout);
DomPullParser parser = new DomPullParser(DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(layout.getInputStream()).getDocumentElement());
AndroidFacet facet = AndroidFacet.getInstance(configuration.getModule());
assertNotNull(facet);
AndroidPlatform platform = AndroidPlatform.getInstance(myModule);
assertNotNull(platform);
//noinspection UndesirableClassUsage
BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
GraphicsLayoutRenderer renderer = GraphicsLayoutRenderer.create(facet, platform, myModule.getProject(), configuration, parser, Color.BLACK, SessionParams.RenderingMode.V_SCROLL, false);
// The first render triggers a render (to a NOP Graphics object) so we expect sizes to have been initialized.
Dimension initialSize = renderer.getPreferredSize();
assertNotEquals("Expected layout dimensions after create", EMPTY_DIMENSION, initialSize);
assertTrue(renderer.render((Graphics2D) image.getGraphics()));
// We haven't changed the layout so, after the render, we expect the same dimensions.
assertEquals(initialSize, renderer.getPreferredSize());
renderer.setSize(new Dimension(50, 50));
assertTrue(renderer.render((Graphics2D) image.getGraphics()));
}
use of com.android.tools.idea.configurations.Configuration in project android by JetBrains.
the class NlPropertiesTest method testSrcCompatIncludedWithRelativeContextName.
public void testSrcCompatIncludedWithRelativeContextName() {
Configuration configuration = myModel.getConfiguration();
configuration.setActivity(".MyActivity");
when(myDependencyManager.dependsOn(myModule, APPCOMPAT_LIB_ARTIFACT)).thenReturn(true);
addAppCompatActivity();
addMyActivityAsAppCompatActivity();
Table<String, String, NlPropertyItem> properties = NlProperties.getInstance().getProperties(myFacet, ImmutableList.of(myImageView), myDependencyManager);
assertPresent("ImageView", properties, ANDROID_URI, ATTR_SRC);
assertPresent("ImageView", properties, AUTO_URI, ATTR_SRC_COMPAT);
}
use of com.android.tools.idea.configurations.Configuration in project android by JetBrains.
the class NlPalettePanelTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
Configuration configuration = mock(Configuration.class);
when(configuration.getModule()).thenReturn(myModule);
DesignSurface surface = mock(DesignSurface.class);
when(surface.getLayoutType()).thenReturn(NlLayoutType.LAYOUT);
when(surface.getConfiguration()).thenReturn(configuration);
myCopyPasteManager = mock(CopyPasteManager.class);
myPanel = new NlPalettePanel(getProject(), surface, myCopyPasteManager);
}
use of com.android.tools.idea.configurations.Configuration in project android by JetBrains.
the class NlPreviewImagePanelTest method testConfigurationChangesInvalidatesUI.
public void testConfigurationChangesInvalidatesUI() {
Configuration configuration = mySurface.getConfiguration();
configuration.updated(CFG_DEVICE);
verify(myRepaintManager).addDirtyRegion(myPanel, 0, 0, WIDTH, HEIGHT);
}
Aggregations