Add CTS tests for Theme.getChangingConfigurations()

Bug: 20267825
Change-Id: Ia29f39e0f217030a9897c99cd02aa56acad9a7c2
diff --git a/tests/tests/content/res/values-land/styles.xml b/tests/tests/content/res/values-land/styles.xml
new file mode 100644
index 0000000..7717f10
--- /dev/null
+++ b/tests/tests/content/res/values-land/styles.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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.
+-->
+
+<resources>
+    <style name="Theme_OrientationDependent">
+        <item name="themeDimension">111px</item>
+    </style>
+</resources>
diff --git a/tests/tests/content/res/values-ldltr/styles.xml b/tests/tests/content/res/values-ldltr/styles.xml
new file mode 100644
index 0000000..e17290e
--- /dev/null
+++ b/tests/tests/content/res/values-ldltr/styles.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2015 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.
+-->
+
+<resources>
+    <style name="Theme_LayoutDirectionDependent">
+        <item name="themeInteger">111</item>
+    </style>
+</resources>
diff --git a/tests/tests/content/res/values/styles.xml b/tests/tests/content/res/values/styles.xml
index 20c80f8..72d4047 100644
--- a/tests/tests/content/res/values/styles.xml
+++ b/tests/tests/content/res/values/styles.xml
@@ -169,4 +169,11 @@
         <item name="android:windowSwipeToDismiss">false</item>
     </style>
 
+    <style name="Theme_LayoutDirectionDependent">
+        <item name="themeInteger">999</item>
+    </style>
+
+    <style name="Theme_OrientationDependent">
+        <item name="themeDimension">999px</item>
+    </style>
 </resources>
diff --git a/tests/tests/content/src/android/content/res/cts/Resources_ThemeTest.java b/tests/tests/content/src/android/content/res/cts/Resources_ThemeTest.java
index 349cb47..ba98dc4 100644
--- a/tests/tests/content/src/android/content/res/cts/Resources_ThemeTest.java
+++ b/tests/tests/content/src/android/content/res/cts/Resources_ThemeTest.java
@@ -18,6 +18,7 @@
 
 import org.xmlpull.v1.XmlPullParser;
 
+import android.content.pm.ActivityInfo;
 import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.content.res.Resources.Theme;
@@ -78,4 +79,25 @@
         assertFalse(mResTheme.resolveAttribute(R.raw.testmp3, value, false));
     }
 
+    public void testGetChangingConfigurations() {
+        Resources.Theme theme = getContext().getResources().newTheme();
+        assertEquals("Initial changing configuration mask is empty",
+                0, theme.getChangingConfigurations());
+
+        theme.applyStyle(R.style.Theme_OrientationDependent, true);
+        assertEquals("First call to Theme.applyStyle() sets changing configuration",
+                ActivityInfo.CONFIG_ORIENTATION, theme.getChangingConfigurations());
+
+        theme.applyStyle(R.style.Theme_LayoutDirectionDependent, true);
+        assertEquals("Multiple calls to Theme.applyStyle() update changing configuration",
+                ActivityInfo.CONFIG_ORIENTATION | ActivityInfo.CONFIG_LAYOUT_DIRECTION,
+                theme.getChangingConfigurations());
+
+        Resources.Theme other = getContext().getResources().newTheme();
+        other.setTo(theme);
+        assertEquals("Theme.setTheme() copies changing confguration",
+                ActivityInfo.CONFIG_ORIENTATION | ActivityInfo.CONFIG_LAYOUT_DIRECTION,
+                theme.getChangingConfigurations());
+    }
+
 }