Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 79062f6f authored by Charlie Tsai's avatar Charlie Tsai
Browse files

Add the test function for rectangle shadow

Add an XML layout file which contains some buttons
with different elevations to test the shadow generation
algorithm.

Test: Added new rectangle shadow
Change-Id: Ifcb5a48200846c33d89f66c162521f2c8565c95d
parent 6013cf64
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -52,6 +52,8 @@ public class RectShadowPainter {
            throw new IllegalArgumentException("Outline is not a rect shadow");
        }

        // TODO replacing the algorithm here to create better shadow

        float shadowSize = elevationToShadow(elevation);
        int saved = modifyCanvas(canvas, shadowSize);
        if (saved == -1) {
+22.1 KiB
Loading image diff...
+97 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2017 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_marginLeft="40dp"
            android:layout_width="48dp"
            android:layout_height="40dp"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:elevation="48dp"
            android:stateListAnimator="@null"/>

        <Button
            android:layout_marginRight="40dp"
            android:layout_width="48dp"
            android:layout_height="40dp"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:elevation="48dp"
            android:stateListAnimator="@null"/>

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1">

        <Button
            android:layout_marginLeft="40dp"
            android:layout_width="48dp"
            android:layout_height="40dp"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:elevation="0dp"
            android:stateListAnimator="@null"/>

        <Button
            android:layout_marginRight="40dp"
            android:layout_width="48dp"
            android:layout_height="40dp"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:elevation="100dp"
            android:stateListAnimator="@null"/>

    </RelativeLayout>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1">

        <Button
            android:layout_marginLeft="40dp"
            android:layout_width="48dp"
            android:layout_height="40dp"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:elevation="12dp"
            android:stateListAnimator="@null"/>

        <Button
            android:layout_marginRight="40dp"
            android:layout_width="48dp"
            android:layout_height="40dp"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:elevation="36dp"
            android:stateListAnimator="@null"/>

    </RelativeLayout>
</LinearLayout>
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -424,4 +424,9 @@ public class RenderTests extends RenderTestBase {
        assertNotEquals(0, outValue.data);
        assertTrue(sRenderMessages.isEmpty());
    }

    @Test
    public void testRectangleShadow() throws Exception {
        renderAndVerify("shadows_test.xml", "shadows_test.png");
    }
}