Search in sources :

Example 1 with LayoutPullParser

use of com.android.layoutlib.bridge.intensive.setup.LayoutPullParser in project platform_frameworks_base by android.

the class Main method testScrolling.

/** Test activity.xml */
@Test
public void testScrolling() throws ClassNotFoundException {
    // Create the layout pull parser.
    LayoutPullParser parser = createLayoutPullParser("scrolled.xml");
    // Create LayoutLibCallback.
    LayoutLibTestCallback layoutLibCallback = new LayoutLibTestCallback(getLogger());
    layoutLibCallback.initResources();
    SessionParams params = getSessionParams(parser, ConfigGenerator.NEXUS_5, layoutLibCallback, "Theme.Material.NoActionBar.Fullscreen", false, RenderingMode.V_SCROLL, 22);
    params.setForceNoDecor();
    params.setExtendedViewInfoMode(true);
    RenderResult result = renderAndVerify(params, "scrolled.png");
    assertNotNull(result);
    assertTrue(result.getResult().isSuccess());
    ViewInfo rootLayout = result.getRootViews().get(0);
    // Check the first box in the main LinearLayout
    assertEquals(-90, rootLayout.getChildren().get(0).getTop());
    assertEquals(-30, rootLayout.getChildren().get(0).getLeft());
    assertEquals(90, rootLayout.getChildren().get(0).getBottom());
    assertEquals(150, rootLayout.getChildren().get(0).getRight());
    // Check the first box within the nested LinearLayout
    assertEquals(-450, rootLayout.getChildren().get(5).getChildren().get(0).getTop());
    assertEquals(90, rootLayout.getChildren().get(5).getChildren().get(0).getLeft());
    assertEquals(-270, rootLayout.getChildren().get(5).getChildren().get(0).getBottom());
    assertEquals(690, rootLayout.getChildren().get(5).getChildren().get(0).getRight());
}
Also used : SessionParams(com.android.ide.common.rendering.api.SessionParams) LayoutLibTestCallback(com.android.layoutlib.bridge.intensive.setup.LayoutLibTestCallback) LayoutPullParser(com.android.layoutlib.bridge.intensive.setup.LayoutPullParser) ViewInfo(com.android.ide.common.rendering.api.ViewInfo) Test(org.junit.Test)

Example 2 with LayoutPullParser

use of com.android.layoutlib.bridge.intensive.setup.LayoutPullParser in project platform_frameworks_base by android.

the class Main method testExpand.

/** Test expand_layout.xml */
@Test
public void testExpand() throws ClassNotFoundException {
    // Create the layout pull parser.
    LayoutPullParser parser = createLayoutPullParser("expand_vert_layout.xml");
    // Create LayoutLibCallback.
    LayoutLibTestCallback layoutLibCallback = new LayoutLibTestCallback(getLogger());
    layoutLibCallback.initResources();
    ConfigGenerator customConfigGenerator = new ConfigGenerator().setScreenWidth(300).setScreenHeight(20).setDensity(Density.XHIGH).setNavigation(Navigation.NONAV);
    SessionParams params = getSessionParams(parser, customConfigGenerator, layoutLibCallback, "Theme.Material.Light.NoActionBar.Fullscreen", false, RenderingMode.V_SCROLL, 22);
    renderAndVerify(params, "expand_vert_layout.png");
    customConfigGenerator = new ConfigGenerator().setScreenWidth(20).setScreenHeight(300).setDensity(Density.XHIGH).setNavigation(Navigation.NONAV);
    parser = createLayoutPullParser("expand_horz_layout.xml");
    params = getSessionParams(parser, customConfigGenerator, layoutLibCallback, "Theme.Material.Light.NoActionBar.Fullscreen", false, RenderingMode.H_SCROLL, 22);
    renderAndVerify(params, "expand_horz_layout.png");
}
Also used : SessionParams(com.android.ide.common.rendering.api.SessionParams) ConfigGenerator(com.android.layoutlib.bridge.intensive.setup.ConfigGenerator) LayoutLibTestCallback(com.android.layoutlib.bridge.intensive.setup.LayoutLibTestCallback) LayoutPullParser(com.android.layoutlib.bridge.intensive.setup.LayoutPullParser) Test(org.junit.Test)

Example 3 with LayoutPullParser

use of com.android.layoutlib.bridge.intensive.setup.LayoutPullParser in project platform_frameworks_base by android.

the class Main method testVectorAnimation.

/** Test indeterminate_progressbar.xml */
@Test
public void testVectorAnimation() throws ClassNotFoundException {
    // Create the layout pull parser.
    LayoutPullParser parser = createLayoutPullParser("indeterminate_progressbar.xml");
    // Create LayoutLibCallback.
    LayoutLibTestCallback layoutLibCallback = new LayoutLibTestCallback(getLogger());
    layoutLibCallback.initResources();
    SessionParams params = getSessionParams(parser, ConfigGenerator.NEXUS_5, layoutLibCallback, "Theme.Material.NoActionBar.Fullscreen", false, RenderingMode.V_SCROLL, 22);
    renderAndVerify(params, "animated_vector.png", TimeUnit.SECONDS.toNanos(2));
    parser = createLayoutPullParser("indeterminate_progressbar.xml");
    params = getSessionParams(parser, ConfigGenerator.NEXUS_5, layoutLibCallback, "Theme.Material.NoActionBar.Fullscreen", false, RenderingMode.V_SCROLL, 22);
    renderAndVerify(params, "animated_vector_1.png", TimeUnit.SECONDS.toNanos(3));
}
Also used : SessionParams(com.android.ide.common.rendering.api.SessionParams) LayoutLibTestCallback(com.android.layoutlib.bridge.intensive.setup.LayoutLibTestCallback) LayoutPullParser(com.android.layoutlib.bridge.intensive.setup.LayoutPullParser) Test(org.junit.Test)

Example 4 with LayoutPullParser

use of com.android.layoutlib.bridge.intensive.setup.LayoutPullParser in project android_frameworks_base by DirtyUnicorns.

the class Main method createSessionParams.

private SessionParams createSessionParams(String layoutFileName, ConfigGenerator deviceConfig) throws ClassNotFoundException {
    // Create the layout pull parser.
    LayoutPullParser parser = createLayoutPullParser(layoutFileName);
    // Create LayoutLibCallback.
    LayoutLibTestCallback layoutLibCallback = new LayoutLibTestCallback(getLogger());
    layoutLibCallback.initResources();
    // Create session params.
    return getSessionParams(parser, deviceConfig, layoutLibCallback, "AppTheme", true, RenderingMode.NORMAL, 22);
}
Also used : LayoutLibTestCallback(com.android.layoutlib.bridge.intensive.setup.LayoutLibTestCallback) LayoutPullParser(com.android.layoutlib.bridge.intensive.setup.LayoutPullParser)

Example 5 with LayoutPullParser

use of com.android.layoutlib.bridge.intensive.setup.LayoutPullParser in project android_frameworks_base by DirtyUnicorns.

the class Main method testVectorAnimation.

/** Test indeterminate_progressbar.xml */
@Test
public void testVectorAnimation() throws ClassNotFoundException {
    // Create the layout pull parser.
    LayoutPullParser parser = createLayoutPullParser("indeterminate_progressbar.xml");
    // Create LayoutLibCallback.
    LayoutLibTestCallback layoutLibCallback = new LayoutLibTestCallback(getLogger());
    layoutLibCallback.initResources();
    SessionParams params = getSessionParams(parser, ConfigGenerator.NEXUS_5, layoutLibCallback, "Theme.Material.NoActionBar.Fullscreen", false, RenderingMode.V_SCROLL, 22);
    renderAndVerify(params, "animated_vector.png", TimeUnit.SECONDS.toNanos(2));
    parser = createLayoutPullParser("indeterminate_progressbar.xml");
    params = getSessionParams(parser, ConfigGenerator.NEXUS_5, layoutLibCallback, "Theme.Material.NoActionBar.Fullscreen", false, RenderingMode.V_SCROLL, 22);
    renderAndVerify(params, "animated_vector_1.png", TimeUnit.SECONDS.toNanos(3));
}
Also used : SessionParams(com.android.ide.common.rendering.api.SessionParams) LayoutLibTestCallback(com.android.layoutlib.bridge.intensive.setup.LayoutLibTestCallback) LayoutPullParser(com.android.layoutlib.bridge.intensive.setup.LayoutPullParser) Test(org.junit.Test)

Aggregations

LayoutLibTestCallback (com.android.layoutlib.bridge.intensive.setup.LayoutLibTestCallback)25 LayoutPullParser (com.android.layoutlib.bridge.intensive.setup.LayoutPullParser)25 SessionParams (com.android.ide.common.rendering.api.SessionParams)20 Test (org.junit.Test)20 ViewInfo (com.android.ide.common.rendering.api.ViewInfo)5 ConfigGenerator (com.android.layoutlib.bridge.intensive.setup.ConfigGenerator)5