use of com.android.ide.common.rendering.api.ViewInfo in project android by JetBrains.
the class NlComponentFixture method requireActualText.
public void requireActualText(@NotNull String expectedText) {
ViewInfo viewInfo = myComponent.viewInfo;
Object viewObject = viewInfo.getViewObject();
try {
Method getText = viewObject.getClass().getMethod("getText");
String actualText = (String) getText.invoke(viewObject);
assertEquals(expectedText, actualText);
} catch (NoSuchMethodException e) {
fail("No getText() method on " + viewObject.getClass().getName());
} catch (InvocationTargetException e) {
fail("Can't invoke getText() method on " + viewObject.getClass().getName());
} catch (IllegalAccessException e) {
fail("Can't access getText() method on " + viewObject.getClass().getName());
}
}
use of com.android.ide.common.rendering.api.ViewInfo in project android by JetBrains.
the class RenderServiceTest method testGetSafeBounds.
public void testGetSafeBounds() {
ViewInfo valid;
ViewInfo invalid;
valid = new ViewInfo("", "", 0, 0, 0, 0);
assertSame(valid, RenderService.getSafeBounds(valid));
valid = new ViewInfo("", "", 0, 0, 1024, 768);
assertSame(valid, RenderService.getSafeBounds(valid));
valid = new ViewInfo("", "", -200, -200, 8000, 8000);
assertSame(valid, RenderService.getSafeBounds(valid));
invalid = new ViewInfo("", "", -(1 << 27), 0, 0, 0);
assertNotSame(invalid, RenderService.getSafeBounds(invalid));
assertEquals(0, RenderService.getSafeBounds(invalid).getLeft());
invalid = new ViewInfo("", "", +(1 << 27), 0, 0, 0);
assertNotSame(invalid, RenderService.getSafeBounds(invalid));
invalid = new ViewInfo("", "", 0, -(1 << 27), 0, 0);
assertNotSame(invalid, RenderService.getSafeBounds(invalid));
invalid = new ViewInfo("", "", 0, +(1 << 27), 0, 0);
assertNotSame(invalid, RenderService.getSafeBounds(invalid));
invalid = new ViewInfo("", "", 0, 0, -(1 << 27), 0);
assertNotSame(invalid, RenderService.getSafeBounds(invalid));
invalid = new ViewInfo("", "", 0, 0, +(1 << 27), 0);
assertNotSame(invalid, RenderService.getSafeBounds(invalid));
invalid = new ViewInfo("", "", 0, 0, 0, -(1 << 27));
assertNotSame(invalid, RenderService.getSafeBounds(invalid));
invalid = new ViewInfo("", "", 0, 0, 0, +(1 << 27));
assertNotSame(invalid, RenderService.getSafeBounds(invalid));
}
use of com.android.ide.common.rendering.api.ViewInfo in project android by JetBrains.
the class GenerateLayoutTestSkeletonAction method getBounds.
@NotNull
private static Rectangle getBounds(@NotNull NlComponent component) {
NlComponent parent = component.getParent();
Rectangle parentBounds = parent != null ? getBounds(parent) : new Rectangle(0, 0, 1000, 1000);
ViewInfo viewInfo = component.viewInfo;
if (viewInfo == null) {
return new Rectangle(parentBounds.x, parentBounds.y, 100, 100);
}
return new Rectangle(viewInfo.getLeft() + parentBounds.x, viewInfo.getTop() + parentBounds.y, viewInfo.getRight() - viewInfo.getLeft(), viewInfo.getBottom() - viewInfo.getTop());
}
use of com.android.ide.common.rendering.api.ViewInfo in project android by JetBrains.
the class MenuTestFactory method mockViewInfo.
@NotNull
static ViewInfo mockViewInfo(@NotNull ViewType viewType) {
ViewInfo view = Mockito.mock(ViewInfo.class);
Mockito.when(view.getViewType()).thenReturn(viewType);
return view;
}
use of com.android.ide.common.rendering.api.ViewInfo in project android by JetBrains.
the class PreferenceScreenDragHandlerLayoutTest method mockEditor.
@NotNull
private static ViewEditor mockEditor(@NotNull NlModel model) {
ListView listView = Mockito.mock(ListView.class);
Mockito.when(listView.getDividerHeight()).thenReturn(2);
ViewInfo view = new ViewInfo(FQCN_LIST_VIEW, null, 0, 0, 0, 0, listView, null);
ViewEditor editor = Mockito.mock(ViewEditor.class);
Mockito.when(editor.getModel()).thenReturn(model);
Mockito.when(editor.getRootViews()).thenReturn(Collections.singletonList(view));
return editor;
}
Aggregations