Search in sources :

Example 6 with DisplayList

use of com.android.tools.idea.uibuilder.scene.draw.DisplayList in project android by JetBrains.

the class SceneDecoratorTest method testBasicScene.

public void testBasicScene() {
    myScreen.get("@+id/a").expectXml("<ProgressBar\n" + "    android:id=\"@+id/a\"\n" + "    android:layout_width=\"100dp\"\n" + "    android:layout_height=\"20dp\"\n" + "    app:layout_constraintLeft_toLeftOf=\"parent\"\n" + "    app:layout_constraintRight_toLeftOf=\"@+id/b\"\n" + "    app:layout_constraintTop_toTopOf=\"parent\"\n" + "    app:layout_constraintBottom_toBottomOf=\"parent\"/>");
    String list = myInteraction.getDisplayList().serialize();
    assertEquals(myInteraction.getDisplayList().serialize(), list);
    DisplayList disp = DisplayList.getDisplayList(list);
    assertEquals(list, DisplayList.getDisplayList(list).serialize());
    //noinspection UndesirableClassUsage
    BufferedImage img = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
    disp.paint(img.createGraphics(), SceneContext.get());
    assertEquals(42, disp.getCommands().size());
    disp.clear();
}
Also used : DisplayList(com.android.tools.idea.uibuilder.scene.draw.DisplayList) BufferedImage(java.awt.image.BufferedImage)

Example 7 with DisplayList

use of com.android.tools.idea.uibuilder.scene.draw.DisplayList in project android by JetBrains.

the class SceneDisplayListTest method testBasicScene.

public void testBasicScene() {
    myScreen.get("@id/button").expectXml("<TextView\n" + "    android:id=\"@id/button\"\n" + "    android:layout_width=\"100dp\"\n" + "    android:layout_height=\"20dp\"\n" + "    tools:layout_editor_absoluteX=\"100dp\"\n" + "    tools:layout_editor_absoluteY=\"200dp\"/>");
    String simpleList = "DrawComponentFrame,0,0,1000,1000,1\n" + "Clip,0,0,1000,1000\n" + "DrawComponentBackground,100,200,100,20,1\n" + "DrawTextRegion,100,200,100,20,0,false,false,5,5,\"\"\n" + "DrawComponentFrame,100,200,100,20,1\n" + "UNClip\n";
    assertEquals(simpleList, myInteraction.getDisplayList().serialize());
    DisplayList disp = DisplayList.getDisplayList(simpleList);
    assertEquals(simpleList, DisplayList.getDisplayList(simpleList).serialize());
    //noinspection UndesirableClassUsage
    BufferedImage img = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
    disp.paint(img.createGraphics(), SceneContext.get());
}
Also used : DisplayList(com.android.tools.idea.uibuilder.scene.draw.DisplayList) BufferedImage(java.awt.image.BufferedImage)

Example 8 with DisplayList

use of com.android.tools.idea.uibuilder.scene.draw.DisplayList in project android by JetBrains.

the class SceneDisplayListTest3 method testBasicScene.

public void testBasicScene() {
    myScreen.get("@+id/button1").expectXml("<TextView\n" + "    android:id=\"@+id/button1\"\n" + "    android:layout_width=\"100dp\"\n" + "    android:layout_height=\"20dp\"\n" + "    app:layout_constraintLeft_toLeftOf=\"parent\"\n" + "    app:layout_constraintRight_toRightOf=\"parent\"\n" + "    app:layout_constraintTop_toTopOf=\"parent\"\n" + "    app:layout_constraintBottom_toBottomOf=\"parent\"/>");
    String simpleList = "DrawComponentFrame,0,0,1000,1000,1\n" + "Clip,0,0,1000,1000\n" + "DrawComponentBackground,450,490,100,20,1\n" + "DrawTextRegion,450,490,100,20,0,false,false,5,5,\"\"\n" + "DrawComponentFrame,450,490,100,20,1\n" + "DrawConnection,2,450x490x100x20,0,0x0x1000x1000,0,1,false,0,0,false,0.5\n" + "DrawConnection,2,450x490x100x20,1,0x0x1000x1000,1,1,false,0,0,false,0.5\n" + "DrawConnection,2,450x490x100x20,2,0x0x1000x1000,2,1,false,0,0,false,0.5\n" + "DrawConnection,2,450x490x100x20,3,0x0x1000x1000,3,1,false,0,0,false,0.5\n" + "DrawComponentBackground,450,490,100,20,1\n" + "DrawTextRegion,450,490,100,20,0,false,false,5,5,\"\"\n" + "DrawComponentFrame,450,490,100,20,1\n" + "DrawConnection,4,450x490x100x20,0,450x490x100x20,0,0,true,0,0,false,0.5\n" + "DrawConnection,4,450x490x100x20,1,450x490x100x20,1,0,true,0,0,false,0.5\n" + "DrawConnection,2,450x490x100x20,2,450x490x100x20,3,0,true,0,0,false,0.5\n" + "DrawConnection,2,450x490x100x20,3,0x0x1000x1000,3,1,false,0,0,false,0.5\n" + "UNClip\n";
    assertEquals(simpleList, myInteraction.getDisplayList().serialize());
    DisplayList disp = DisplayList.getDisplayList(simpleList);
    assertEquals(simpleList, DisplayList.getDisplayList(simpleList).serialize());
    //noinspection UndesirableClassUsage
    BufferedImage img = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
    disp.paint(img.createGraphics(), SceneContext.get());
    assertEquals(17, disp.getCommands().size());
    disp.clear();
}
Also used : DisplayList(com.android.tools.idea.uibuilder.scene.draw.DisplayList) BufferedImage(java.awt.image.BufferedImage)

Example 9 with DisplayList

use of com.android.tools.idea.uibuilder.scene.draw.DisplayList in project android by JetBrains.

the class SceneDisplayListTest6 method testBasicScene.

public void testBasicScene() {
    myScreen.get("@+id/textview").expectXml("<TextView\n" + "    android:id=\"@+id/textview\"\n" + "    android:layout_width=\"100dp\"\n" + "    android:layout_height=\"20dp\"\n" + "    app:layout_constraintLeft_toLeftOf=\"@id/content_main\"\n" + "    app:layout_constraintRight_toRightOf=\"@id/content_main\"\n" + "    app:layout_constraintTop_toTopOf=\"@+id/content_main\"\n" + "    app:layout_constraintBottom_toBottomOf=\"@+id/content_main\"/>");
    String simpleList = "DrawComponentFrame,0,0,1000,1000,1\n" + "Clip,0,0,1000,1000\n" + "DrawComponentBackground,450,490,100,20,1\n" + "DrawTextRegion,450,490,100,20,0,false,false,5,5,\"\"\n" + "DrawComponentFrame,450,490,100,20,1\n" + "DrawConnection,2,450x490x100x20,0,0x0x1000x1000,0,1,false,0,0,false,0.5\n" + "DrawConnection,2,450x490x100x20,1,0x0x1000x1000,1,1,false,0,0,false,0.5\n" + "DrawConnection,2,450x490x100x20,2,0x0x1000x1000,2,1,false,0,0,false,0.5\n" + "DrawConnection,2,450x490x100x20,3,0x0x1000x1000,3,1,false,0,0,false,0.5\n" + "UNClip\n";
    assertEquals(simpleList, myInteraction.getDisplayList().serialize());
    DisplayList disp = DisplayList.getDisplayList(simpleList);
    assertEquals(simpleList, DisplayList.getDisplayList(simpleList).serialize());
    //noinspection UndesirableClassUsage
    BufferedImage img = new BufferedImage(1000, 1000, BufferedImage.TYPE_INT_ARGB);
    disp.paint(img.createGraphics(), SceneContext.get());
    assertEquals(10, disp.getCommands().size());
    String result = disp.generateSortedDisplayList(SceneContext.get());
    String sorted = "DrawComponentFrame,0,0,1000,1000,1\n" + "Clip,0,0,1000,1000\n" + "DrawConnection,2,450x490x100x20,0,0x0x1000x1000,0,1,false,0,0,false,0.5\n" + "DrawConnection,2,450x490x100x20,1,0x0x1000x1000,1,1,false,0,0,false,0.5\n" + "DrawConnection,2,450x490x100x20,2,0x0x1000x1000,2,1,false,0,0,false,0.5\n" + "DrawConnection,2,450x490x100x20,3,0x0x1000x1000,3,1,false,0,0,false,0.5\n" + "DrawComponentBackground,450,490,100,20,1\n" + "DrawComponentFrame,450,490,100,20,1\n" + "DrawTextRegion,450,490,100,20,0,false,false,5,5,\"\"\n" + "UNClip\n\n";
    assertEquals(sorted, result);
    disp.clear();
}
Also used : DisplayList(com.android.tools.idea.uibuilder.scene.draw.DisplayList) BufferedImage(java.awt.image.BufferedImage)

Aggregations

DisplayList (com.android.tools.idea.uibuilder.scene.draw.DisplayList)9 BufferedImage (java.awt.image.BufferedImage)8 SceneComponent (com.android.tools.idea.uibuilder.scene.SceneComponent)1