diff options
author | Diego Perez <diegoperez@google.com> | 2015-07-21 15:28:10 +0100 |
---|---|---|
committer | Diego Perez <diegoperez@google.com> | 2015-07-21 15:32:55 +0100 |
commit | b9935889b1be2aac4a47d1acbf7547a832edf9f3 (patch) | |
tree | 5cac934b7d0920130d5304c7a28381bd3ea27c74 /tools/layoutlib | |
parent | b2eed1d6e11f38c00ce1776ade14dfa004c6119f (diff) | |
parent | 112d8a364126ecf8cf53f6e75a6af051cc47a860 (diff) | |
download | frameworks_base-b9935889b1be2aac4a47d1acbf7547a832edf9f3.zip frameworks_base-b9935889b1be2aac4a47d1acbf7547a832edf9f3.tar.gz frameworks_base-b9935889b1be2aac4a47d1acbf7547a832edf9f3.tar.bz2 |
resolved conflicts for merge of 112d8a36 to mnc-dev
Change-Id: Ic9511a57db8a96f54dba0704800789a8602b9dd2
Diffstat (limited to 'tools/layoutlib')
9 files changed, 132 insertions, 11 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java index 23df3f1..6a9d5dd 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java @@ -526,6 +526,11 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { if (neededWidth > measuredWidth) { mMeasuredScreenWidth += neededWidth - measuredWidth; } + if (mMeasuredScreenWidth < measuredWidth) { + // If the screen width is less than the exact measured width, + // expand to match. + mMeasuredScreenWidth = measuredWidth; + } } if (renderingMode.isVertExpand()) { @@ -534,6 +539,11 @@ public class RenderSessionImpl extends RenderAction<SessionParams> { if (neededHeight > measuredHeight) { mMeasuredScreenHeight += neededHeight - measuredHeight; } + if (mMeasuredScreenHeight < measuredHeight) { + // If the screen height is less than the exact measured height, + // expand to match. + mMeasuredScreenHeight = measuredHeight; + } } } } diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$layout.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$layout.class Binary files differindex e172b2d..6c351da 100644 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$layout.class +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R$layout.class diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R.class b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R.class Binary files differindex d5b81c4..6d7c719 100644 --- a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R.class +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/build/intermediates/classes/debug/com/android/layoutlib/test/myapplication/R.class diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/expand_horz_layout.png b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/expand_horz_layout.png Binary files differnew file mode 100644 index 0000000..92eb3e1 --- /dev/null +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/expand_horz_layout.png diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/expand_vert_layout.png b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/expand_vert_layout.png Binary files differnew file mode 100644 index 0000000..81755ce --- /dev/null +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/golden/expand_vert_layout.png diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/expand_horz_layout.xml b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/expand_horz_layout.xml new file mode 100644 index 0000000..2c66b7f --- /dev/null +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/expand_horz_layout.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:padding="16dp" + android:orientation="horizontal" + android:background="#AAAAAA" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + + <include layout="@layout/expand_layout" + android:layout_height="wrap_content" + android:layout_width="wrap_content" /> + +</LinearLayout> + diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/expand_layout.xml b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/expand_layout.xml new file mode 100644 index 0000000..a255da7 --- /dev/null +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/expand_layout.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="utf-8"?> + +<merge xmlns:android="http://schemas.android.com/apk/res/android"> + <TextView + android:background="#FF0000" + android:textSize="200sp" + android:layout_width="200dp" + android:layout_height="200dp" /> + <TextView + android:background="#00FF00" + android:textSize="200sp" + android:layout_width="200dp" + android:layout_height="200dp" /> + <TextView + android:background="#0000FF" + android:textSize="200sp" + android:layout_width="200dp" + android:layout_height="200dp" /> + <TextView + android:background="#FF00FF" + android:textSize="200sp" + android:layout_width="200dp" + android:layout_height="200dp" /> + <TextView + android:background="#00FFFF" + android:textSize="200sp" + android:layout_width="200dp" + android:layout_height="200dp" /> +</merge> diff --git a/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/expand_vert_layout.xml b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/expand_vert_layout.xml new file mode 100644 index 0000000..5319654 --- /dev/null +++ b/tools/layoutlib/bridge/tests/res/testApp/MyApplication/src/main/res/layout/expand_vert_layout.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:padding="16dp" + android:orientation="vertical" + android:background="#AAAAAA" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + + <include layout="@layout/expand_layout" + android:layout_height="wrap_content" + android:layout_width="wrap_content" /> + +</LinearLayout> + diff --git a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java index 272a2b8..b2909c9 100644 --- a/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java +++ b/tools/layoutlib/bridge/tests/src/com/android/layoutlib/bridge/intensive/Main.java @@ -31,6 +31,8 @@ import com.android.layoutlib.bridge.Bridge; import com.android.layoutlib.bridge.intensive.setup.ConfigGenerator; import com.android.layoutlib.bridge.intensive.setup.LayoutLibTestCallback; import com.android.layoutlib.bridge.intensive.setup.LayoutPullParser; +import com.android.resources.Density; +import com.android.resources.Navigation; import com.android.utils.ILogger; import org.junit.AfterClass; @@ -310,21 +312,52 @@ public class Main { sBridge = null; } + /** Test expand_layout.xml */ + @Test + public void testExpand() throws ClassNotFoundException { + // Create the layout pull parser. + LayoutPullParser parser = new LayoutPullParser(APP_TEST_RES + "/layout/" + + "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.NoActionBar.Fullscreen", RenderingMode.V_SCROLL, + 22); + + renderAndVerify(params, "expand_vert_layout.png"); + + customConfigGenerator = new ConfigGenerator() + .setScreenWidth(20) + .setScreenHeight(300) + .setDensity(Density.XHIGH) + .setNavigation(Navigation.NONAV); + parser = new LayoutPullParser(APP_TEST_RES + "/layout/" + + "expand_horz_layout.xml"); + params = getSessionParams(parser, customConfigGenerator, + layoutLibCallback, "Theme.Material.NoActionBar.Fullscreen", RenderingMode + .H_SCROLL, 22); + + renderAndVerify(params, "expand_horz_layout.png"); + } + /** * Create a new rendering session and test that rendering given layout on nexus 5 * doesn't throw any exceptions and matches the provided image. */ - private void renderAndVerify(String layoutFileName, String goldenFileName) + private void renderAndVerify(SessionParams params, String goldenFileName) throws ClassNotFoundException { - // Create the layout pull parser. - LayoutPullParser parser = new LayoutPullParser(APP_TEST_RES + "/layout/" + layoutFileName); - // Create LayoutLibCallback. - LayoutLibTestCallback layoutLibCallback = new LayoutLibTestCallback(getLogger()); - layoutLibCallback.initResources(); // TODO: Set up action bar handler properly to test menu rendering. // Create session params. - SessionParams params = getSessionParams(parser, ConfigGenerator.NEXUS_5, layoutLibCallback); RenderSession session = sBridge.createSession(params); + if (!session.getResult().isSuccess()) { getLogger().error(session.getResult().getException(), session.getResult().getErrorMessage()); @@ -344,25 +377,44 @@ public class Main { } /** + * Create a new rendering session and test that rendering given layout on nexus 5 + * doesn't throw any exceptions and matches the provided image. + */ + private void renderAndVerify(String layoutFileName, String goldenFileName) + throws ClassNotFoundException { + // Create the layout pull parser. + LayoutPullParser parser = new LayoutPullParser(APP_TEST_RES + "/layout/" + layoutFileName); + // Create LayoutLibCallback. + LayoutLibTestCallback layoutLibCallback = new LayoutLibTestCallback(getLogger()); + layoutLibCallback.initResources(); + // TODO: Set up action bar handler properly to test menu rendering. + // Create session params. + SessionParams params = getSessionParams(parser, ConfigGenerator.NEXUS_5, + layoutLibCallback, "Theme.Material.Light.DarkActionBar", RenderingMode.NORMAL, 22); + renderAndVerify(params, goldenFileName); + } + + /** * Uses Theme.Material and Target sdk version as 22. */ private SessionParams getSessionParams(LayoutPullParser layoutParser, - ConfigGenerator configGenerator, LayoutLibTestCallback layoutLibCallback) { + ConfigGenerator configGenerator, LayoutLibTestCallback layoutLibCallback, + String themeName, RenderingMode renderingMode, int targetSdk) { FolderConfiguration config = configGenerator.getFolderConfig(); ResourceResolver resourceResolver = ResourceResolver.create(sProjectResources.getConfiguredResources(config), sFrameworkRepo.getConfiguredResources(config), - "AppTheme", true); + themeName, true); return new SessionParams( layoutParser, - RenderingMode.NORMAL, + renderingMode, null /*used for caching*/, configGenerator.getHardwareConfig(), resourceResolver, layoutLibCallback, 0, - 22, // TODO: Make it more configurable to run tests for various versions. + targetSdk, getLayoutLog()); } |