use of com.android.tools.idea.uibuilder.surface.DesignSurface in project android by JetBrains.
the class NlEditorFixture method resizeToAndroidSize.
/**
* Moves the mouse to resize the screen view to correspond to a device of size {@code (width, height)}, expressed in dp
*
* @see #startResizeInteraction()
* @see #endResizeInteraction()
*/
public NlEditorFixture resizeToAndroidSize(@AndroidDpCoordinate int width, @AndroidDpCoordinate int height) {
DesignSurface surface = myDesignSurfaceFixture.target();
ScreenView screenView = surface.getCurrentScreenView();
robot().moveMouse(surface, Coordinates.getSwingXDip(screenView, width), Coordinates.getSwingYDip(screenView, height));
return this;
}
use of com.android.tools.idea.uibuilder.surface.DesignSurface in project android by JetBrains.
the class ResizeFixture method releaseKey.
public ResizeFixture releaseKey(@MagicConstant(flagsFromClass = KeyEvent.class) int keyCode, char keyChar) {
if (keyCode == KeyEvent.VK_SHIFT) {
myModifiers |= InputEvent.SHIFT_MASK;
}
if (keyCode == KeyEvent.VK_META) {
myModifiers |= InputEvent.META_MASK;
}
if (keyCode == KeyEvent.VK_CONTROL) {
myModifiers |= InputEvent.CTRL_MASK;
}
if (keyCode == KeyEvent.VK_ALT) {
myModifiers |= InputEvent.ALT_MASK;
}
DesignSurface surface = myScreen.getSurface();
KeyEvent event = new KeyEventBuilder(keyCode, keyChar).withSource(surface).build();
myInteraction.keyReleased(event);
return this;
}
use of com.android.tools.idea.uibuilder.surface.DesignSurface in project android by JetBrains.
the class MockupTest method testGetBounds_nullPosition.
public void testGetBounds_nullPosition() {
final NlModel model = createModel1Mockup(MOCKUP_PSD, null, null);
final NlComponent component = model.getComponents().get(0);
final Mockup mockup = Mockup.create(component);
assertNotNull(mockup);
DesignSurface mockSurface = mock(DesignSurface.class);
when(mockSurface.getScale()).thenReturn(1.0);
final ScreenView screenView = new ScreenView(mockSurface, ScreenView.ScreenViewType.BLUEPRINT, model);
final Rectangle destinationRectangle = mockup.getScreenBounds(screenView);
assertEquals(new Rectangle(0, 0, component.w, component.h), destinationRectangle);
}
use of com.android.tools.idea.uibuilder.surface.DesignSurface in project android by JetBrains.
the class MockupTest method testGetBounds_Normal_Position.
public void testGetBounds_Normal_Position() {
final NlModel model = createModel1Mockup(MOCKUP_PSD, "0 0 -1 -1 10 10 120 50");
DesignSurface mockSurface = mock(DesignSurface.class);
when(mockSurface.getScale()).thenReturn(1.0);
Configuration configuration = mock(Configuration.class);
when(configuration.getDensity()).thenReturn(Density.DPI_280);
ScreenView screenView = mock(ScreenView.class);
when(screenView.getX()).thenReturn(0);
when(screenView.getY()).thenReturn(0);
when(screenView.getSize()).thenReturn(new Dimension(1000, 2000));
when(screenView.getSize(anyObject())).thenReturn(new Dimension(1000, 2000));
when(screenView.getScale()).thenReturn(2.);
when(screenView.getConfiguration()).thenReturn(configuration);
final Mockup mockup = Mockup.create(model.getComponents().get(0));
assertNotNull(mockup);
assertEquals(new Rectangle(10, 10, 120, 50), mockup.getBounds());
final Rectangle swingBounds = mockup.getScreenBounds(screenView);
assertEquals(Coordinates.getSwingXDip(screenView, 10), swingBounds.x, 2.);
assertEquals(Coordinates.getSwingXDip(screenView, 10), swingBounds.y, 2.);
assertEquals(Coordinates.getSwingDimensionDip(screenView, 110), swingBounds.width, 2.);
assertEquals(Coordinates.getSwingDimensionDip(screenView, 40), swingBounds.height, 2.);
}
use of com.android.tools.idea.uibuilder.surface.DesignSurface in project android by JetBrains.
the class GenerateLayoutTestSkeletonAction method getModel.
@Nullable
private static NlModel getModel(@Nullable Project project) {
if (project == null) {
return null;
}
DesignSurface surface = getSurface(project);
if (surface == null) {
return null;
}
ScreenView screenView = surface.getCurrentScreenView();
if (screenView == null) {
return null;
}
return screenView.getModel();
}
Aggregations