use of com.android.SdkConstants.ABSOLUTE_LAYOUT in project android by JetBrains.
the class DesignSurfaceTest method testRenderWhileBuilding.
public void testRenderWhileBuilding() {
ModelBuilder modelBuilder = model("absolute.xml", component(ABSOLUTE_LAYOUT).withBounds(0, 0, 1000, 1000).matchParentWidth().matchParentHeight().children(component("custom.view.not.present.yet").withBounds(100, 100, 100, 100).matchParentWidth().matchParentHeight()));
NlModel model = modelBuilder.build();
// Simulate that we are in the middle of a build
BuildSettings.getInstance(getProject()).setBuildMode(BuildMode.SOURCE_GEN);
// Avoid rendering any other components (nav bar and similar) so we do not have dependencies on the Material theme
model.getConfiguration().setTheme("android:Theme.NoTitleBar.Fullscreen");
mySurface.setModel(model);
assertNull(model.getRenderResult());
mySurface.requestRender();
assertEquals(1, mySurface.getErrorModel().getIssues().size());
assertEquals("The project is still building", mySurface.getErrorModel().getIssues().get(0).getSummary());
// Now finish the build, and try to build again. The "project is still building" should be gone.
BuildSettings.getInstance(getProject()).setBuildMode(null);
model = modelBuilder.build();
model.getConfiguration().setTheme("android:Theme.NoTitleBar.Fullscreen");
mySurface.setModel(model);
mySurface.requestRender();
// Because there is a missing view, some other extra errors will be generated about missing styles. This is caused by
// MockView (which is based on TextView) that depends on some Material styles.
// We only care about the missing class error.
assertTrue(mySurface.getErrorModel().getIssues().stream().anyMatch(issue -> issue.getSummary().startsWith("Missing classes")));
assertFalse(mySurface.getErrorModel().getIssues().stream().anyMatch(issue -> issue.getSummary().startsWith("The project is still building")));
}
Aggregations