Search in sources :

Example 46 with SessionParams

use of com.android.ide.common.rendering.api.SessionParams in project android_frameworks_base by ResurrectionRemix.

the class Main method testVectorDrawable.

/**
     * Test a vector drawable that uses trimStart and trimEnd. It also tests all the primitives
     * for vector drawables (lines, moves and cubic and quadratic curves).
     */
@Test
public void testVectorDrawable() throws ClassNotFoundException {
    // Create the layout pull parser.
    LayoutPullParser parser = createLayoutPullParser("vector_drawable.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, "vector_drawable.png", TimeUnit.SECONDS.toNanos(2));
}
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 47 with SessionParams

use of com.android.ide.common.rendering.api.SessionParams in project android_frameworks_base by ResurrectionRemix.

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 48 with SessionParams

use of com.android.ide.common.rendering.api.SessionParams in project android_frameworks_base by ResurrectionRemix.

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 49 with SessionParams

use of com.android.ide.common.rendering.api.SessionParams in project android_frameworks_base by ResurrectionRemix.

the class Main method testGetResourceNameVariants.

@Test
public void testGetResourceNameVariants() throws Exception {
    // Setup
    SessionParams params = createSessionParams("", ConfigGenerator.NEXUS_4);
    AssetManager assetManager = AssetManager.getSystem();
    DisplayMetrics metrics = new DisplayMetrics();
    Configuration configuration = RenderAction.getConfiguration(params);
    Resources resources = new Resources(assetManager, metrics, configuration);
    resources.mLayoutlibCallback = params.getLayoutlibCallback();
    resources.mContext = new BridgeContext(params.getProjectKey(), metrics, params.getResources(), params.getAssets(), params.getLayoutlibCallback(), configuration, params.getTargetSdkVersion(), params.isRtlSupported());
    // Test
    assertEquals("android:style/ButtonBar", resources.getResourceName(android.R.style.ButtonBar));
    assertEquals("android", resources.getResourcePackageName(android.R.style.ButtonBar));
    assertEquals("ButtonBar", resources.getResourceEntryName(android.R.style.ButtonBar));
    assertEquals("style", resources.getResourceTypeName(android.R.style.ButtonBar));
    int id = resources.mLayoutlibCallback.getResourceId(ResourceType.STRING, "app_name");
    assertEquals("com.android.layoutlib.test.myapplication:string/app_name", resources.getResourceName(id));
    assertEquals("com.android.layoutlib.test.myapplication", resources.getResourcePackageName(id));
    assertEquals("string", resources.getResourceTypeName(id));
    assertEquals("app_name", resources.getResourceEntryName(id));
}
Also used : SessionParams(com.android.ide.common.rendering.api.SessionParams) AssetManager(android.content.res.AssetManager) FolderConfiguration(com.android.ide.common.resources.configuration.FolderConfiguration) Configuration(android.content.res.Configuration) BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) FrameworkResources(com.android.ide.common.resources.FrameworkResources) Resources(android.content.res.Resources) DisplayMetrics(android.util.DisplayMetrics) Test(org.junit.Test)

Example 50 with SessionParams

use of com.android.ide.common.rendering.api.SessionParams in project android_frameworks_base by crdroidandroid.

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

SessionParams (com.android.ide.common.rendering.api.SessionParams)54 Test (org.junit.Test)25 BridgeContext (com.android.layoutlib.bridge.android.BridgeContext)23 LayoutLibTestCallback (com.android.layoutlib.bridge.intensive.setup.LayoutLibTestCallback)20 LayoutPullParser (com.android.layoutlib.bridge.intensive.setup.LayoutPullParser)20 View (android.view.View)12 AbsListView (android.widget.AbsListView)12 AdapterView (android.widget.AdapterView)12 ExpandableListView (android.widget.ExpandableListView)12 ListView (android.widget.ListView)12 Result (com.android.ide.common.rendering.api.Result)11 ActionMenuView (android.widget.ActionMenuView)10 FrameLayout (android.widget.FrameLayout)10 LinearLayout (android.widget.LinearLayout)10 FolderConfiguration (com.android.ide.common.resources.configuration.FolderConfiguration)10 ActionMenuItemView (com.android.internal.view.menu.ActionMenuItemView)10 IconMenuItemView (com.android.internal.view.menu.IconMenuItemView)10 ListMenuItemView (com.android.internal.view.menu.ListMenuItemView)10 MenuView (com.android.internal.view.menu.MenuView)10 ViewGroup (android.view.ViewGroup)7