Add CTS a non regression unit test for bug #11673480 Address bar container padding screwed up on KOT43B

- add a unit test for checking padding after interleaved background/padding changes
- verified that the test was failing before the fix and passing after the fix

See commit 48d2bcf2ce2305356c5a4f0dfbb928dc5a4c8331 for the fix

Change-Id: I7f7b305236fa0e5d5ca6d8c965e879285ba33abd
diff --git a/tests/res/drawable/no_padding.png b/tests/res/drawable/no_padding.png
new file mode 100644
index 0000000..7d4c27c
--- /dev/null
+++ b/tests/res/drawable/no_padding.png
Binary files differ
diff --git a/tests/res/layout/view_layout.xml b/tests/res/layout/view_layout.xml
index cb444a5..d30c733 100644
--- a/tests/res/layout/view_layout.xml
+++ b/tests/res/layout/view_layout.xml
@@ -85,4 +85,12 @@
             android:paddingBottom="0dp"
             android:background="@drawable/padding_0" />
 
+    <android.view.cts.MockView
+            android:id="@+id/mock_view_padding_runtime_updated"
+            android:layout_width="200px"
+            android:layout_height="200px"
+            android:paddingStart="8dp"
+            android:paddingEnd="8dp"
+            android:background="@drawable/no_padding" />
+
 </LinearLayout>
diff --git a/tests/tests/view/src/android/view/cts/ViewTest.java b/tests/tests/view/src/android/view/cts/ViewTest.java
index 5e0dbe9..1066e67 100644
--- a/tests/tests/view/src/android/view/cts/ViewTest.java
+++ b/tests/tests/view/src/android/view/cts/ViewTest.java
@@ -2839,6 +2839,39 @@
         assertEquals(backgroundPadding.top, view.getPaddingTop());
         assertEquals(backgroundPadding.right, view.getPaddingRight());
         assertEquals(0, view.getPaddingBottom());
+
+        // Case for interleaved background/padding changes
+        view = (MockView) mActivity.findViewById(R.id.mock_view_padding_runtime_updated);
+        background = view.getBackground();
+        backgroundPadding = new Rect();
+        background.getPadding(backgroundPadding);
+
+        // There is some background with a null padding
+        assertNotNull(background);
+        assertTrue(backgroundPadding.left == 0);
+        assertTrue(backgroundPadding.right == 0);
+        assertTrue(backgroundPadding.top == 0);
+        assertTrue(backgroundPadding.bottom == 0);
+
+        final int paddingLeft = view.getPaddingLeft();
+        final int paddingRight = view.getPaddingRight();
+        final int paddingTop = view.getPaddingTop();
+        final int paddingBottom = view.getPaddingBottom();
+        assertEquals(24, paddingLeft);
+        assertEquals(0, paddingTop);
+        assertEquals(24, paddingRight);
+        assertEquals(0, paddingBottom);
+
+        // Manipulate background and padding
+        background.setState(view.getDrawableState());
+        background.jumpToCurrentState();
+        view.setBackground(background);
+        view.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
+
+        assertEquals(24, view.getPaddingLeft());
+        assertEquals(0, view.getPaddingTop());
+        assertEquals(24, view.getPaddingRight());
+        assertEquals(0, view.getPaddingBottom());
     }
 
     public void testGetWindowVisibleDisplayFrame() {