Adding tests for failed qualities
I was studying the qualities a bit more, then learned more cases where
shadows kind of fails. Spent some time trying to fix it but wasn't very
successful. Documenting the tests at least.
Bug: 74062470
Test: unittests
Change-Id: I83f6ee9ec84e43563b43cdf523d7f045efac3660
diff --git a/bridge/tests/res/testApp/MyApplication/golden/large_shadows_test_high_quality.png b/bridge/tests/res/testApp/MyApplication/golden/large_shadows_test_high_quality.png
index afc5085..0e2848e 100644
--- a/bridge/tests/res/testApp/MyApplication/golden/large_shadows_test_high_quality.png
+++ b/bridge/tests/res/testApp/MyApplication/golden/large_shadows_test_high_quality.png
Binary files differ
diff --git a/bridge/tests/res/testApp/MyApplication/golden/shadow_sizes_test_high_quality.png b/bridge/tests/res/testApp/MyApplication/golden/shadow_sizes_test_high_quality.png
new file mode 100644
index 0000000..d219a1b
--- /dev/null
+++ b/bridge/tests/res/testApp/MyApplication/golden/shadow_sizes_test_high_quality.png
Binary files differ
diff --git a/bridge/tests/res/testApp/MyApplication/golden/shadows_test_high_quality.png b/bridge/tests/res/testApp/MyApplication/golden/shadows_test_high_quality.png
index 7d0b8c8..1639a1a 100644
--- a/bridge/tests/res/testApp/MyApplication/golden/shadows_test_high_quality.png
+++ b/bridge/tests/res/testApp/MyApplication/golden/shadows_test_high_quality.png
Binary files differ
diff --git a/bridge/tests/res/testApp/MyApplication/golden/shadows_test_high_quality_rounded_edge.png b/bridge/tests/res/testApp/MyApplication/golden/shadows_test_high_quality_rounded_edge.png
index 78abc9a..c5ba2c9 100644
--- a/bridge/tests/res/testApp/MyApplication/golden/shadows_test_high_quality_rounded_edge.png
+++ b/bridge/tests/res/testApp/MyApplication/golden/shadows_test_high_quality_rounded_edge.png
Binary files differ
diff --git a/bridge/tests/res/testApp/MyApplication/src/main/res/layout/shadow_sizes_test.xml b/bridge/tests/res/testApp/MyApplication/src/main/res/layout/shadow_sizes_test.xml
new file mode 100644
index 0000000..5c53ca0
--- /dev/null
+++ b/bridge/tests/res/testApp/MyApplication/src/main/res/layout/shadow_sizes_test.xml
@@ -0,0 +1,165 @@
+<!--
+ ~ Copyright (C) 2019 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" >
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1">
+ <Button
+ android:layout_width="100dp"
+ android:layout_height="200dp"
+ android:layout_marginTop="28dp"
+ android:layout_marginLeft="28dp"
+ android:layout_alignParentLeft="true"
+ android:elevation="5.5dp"
+ android:stateListAnimator="@null"
+ android:text="5.5"/>
+ <Button
+ android:layout_width="100dp"
+ android:layout_height="200dp"
+ android:layout_marginTop="28dp"
+ android:layout_marginRight="61dp"
+ android:layout_alignParentRight="true"
+ android:elevation="36dp"
+ android:stateListAnimator="@null"
+ android:text="36"/>
+ </RelativeLayout>
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1">
+ <Button
+ android:layout_width="46dp"
+ android:layout_height="22dp"
+ android:layout_marginTop="28dp"
+ android:layout_marginLeft="103dp"
+ android:layout_alignParentLeft="true"
+ android:elevation="15dp"
+ android:stateListAnimator="@null"
+ android:text="15"/>
+ <Button
+ android:id="@+id/button14"
+ android:layout_width="23dp"
+ android:layout_height="21dp"
+ android:layout_marginTop="28dp"
+ android:layout_marginLeft="54dp"
+ android:layout_alignParentLeft="true"
+ android:elevation="15dp"
+ android:stateListAnimator="@null"
+ android:text="15"/>
+ <Button
+ android:id="@+id/button12"
+ android:layout_width="76dp"
+ android:layout_height="20dp"
+ android:layout_marginTop="28dp"
+ android:layout_marginLeft="176dp"
+ android:layout_alignParentLeft="true"
+ android:elevation="15dp"
+ android:stateListAnimator="@null"
+ android:text="15"/>
+ <Button
+ android:id="@+id/button11"
+ android:layout_width="15dp"
+ android:layout_height="23dp"
+ android:layout_marginTop="28dp"
+ android:layout_marginLeft="28dp"
+ android:layout_alignParentLeft="true"
+ android:elevation="15dp"
+ android:stateListAnimator="@null"
+ android:text="15"/>
+ <Button
+ android:layout_width="39dp"
+ android:layout_height="21dp"
+ android:layout_marginTop="28dp"
+ android:layout_marginStart="278dp"
+ android:layout_marginLeft="278dp"
+ android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"
+ android:elevation="5dp"
+ android:stateListAnimator="@null"
+ android:text="5"/>
+ </RelativeLayout>
+
+ <RelativeLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1">
+ <Button
+ android:layout_width="20dp"
+ android:layout_height="36dp"
+ android:layout_marginTop="28dp"
+ android:layout_marginLeft="136dp"
+ android:layout_alignParentLeft="true"
+ android:elevation="5.5dp"
+ android:stateListAnimator="@null"
+ android:text="5.5"/>
+ <Button
+ android:id="@+id/button17"
+ android:layout_width="22dp"
+ android:layout_height="85dp"
+ android:layout_marginTop="28dp"
+ android:layout_marginLeft="77dp"
+ android:layout_alignParentLeft="true"
+ android:elevation="5.5dp"
+ android:stateListAnimator="@null"
+ android:text="5.5"/>
+ <Button
+ android:id="@+id/button16"
+ android:layout_width="23dp"
+ android:layout_height="131dp"
+ android:layout_marginTop="28dp"
+ android:layout_marginLeft="28dp"
+ android:layout_alignParentLeft="true"
+ android:elevation="5.5dp"
+ android:stateListAnimator="@null"
+ android:text="5.5"/>
+ <Button
+ android:layout_width="33dp"
+ android:layout_height="115dp"
+ android:layout_marginTop="28dp"
+ android:layout_marginRight="155dp"
+ android:layout_alignParentRight="true"
+ android:elevation="36dp"
+ android:stateListAnimator="@null"
+ android:text="36"/>
+ <Button
+ android:id="@+id/button20"
+ android:layout_width="29dp"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="28dp"
+ android:layout_marginRight="92dp"
+ android:layout_alignParentRight="true"
+ android:elevation="36dp"
+ android:stateListAnimator="@null"
+ android:text="36"/>
+ <Button
+ android:id="@+id/button18"
+ android:layout_width="14dp"
+ android:layout_height="23dp"
+ android:layout_marginTop="28dp"
+ android:layout_marginRight="50dp"
+ android:layout_alignParentRight="true"
+ android:elevation="36dp"
+ android:stateListAnimator="@null"
+ android:text="36"/>
+ </RelativeLayout>
+</LinearLayout>
diff --git a/bridge/tests/src/com/android/layoutlib/bridge/intensive/RenderTests.java b/bridge/tests/src/com/android/layoutlib/bridge/intensive/RenderTests.java
index 6adb7c8..2c91ade 100644
--- a/bridge/tests/src/com/android/layoutlib/bridge/intensive/RenderTests.java
+++ b/bridge/tests/src/com/android/layoutlib/bridge/intensive/RenderTests.java
@@ -1121,6 +1121,24 @@
}
@Test
+ public void testHighQualityShadowSizes() throws Exception {
+ LayoutPullParser parser = createParserFromPath("shadow_sizes_test.xml");
+ LayoutLibTestCallback layoutLibCallback =
+ new LayoutLibTestCallback(getLogger(), mDefaultClassLoader);
+ layoutLibCallback.initResources();
+ layoutLibCallback.setShadowQuality(true);
+ SessionParams params = getSessionParamsBuilder()
+ .setParser(parser)
+ .setConfigGenerator(ConfigGenerator.NEXUS_5)
+ .setCallback(layoutLibCallback)
+ .build();
+
+ renderAndVerify(params, "shadow_sizes_test_high_quality.png");
+ // We expect fidelity warnings for Path.isConvex. Fail for anything else.
+ sRenderMessages.removeIf(message -> message.equals("Path.isConvex is not supported."));
+ }
+
+ @Test
public void testResourcesGetIdentifier() throws Exception {
// Setup
// Create the layout pull parser for our resources (empty.xml can not be part of the test