Add CTS tests for gradient radius
BUG: 12191666
Change-Id: Ibc1039e229423b5c4066a777aa211a9794107b77
diff --git a/tests/res/drawable/gradientdrawable_radius_base.xml b/tests/res/drawable/gradientdrawable_radius_base.xml
new file mode 100644
index 0000000..ecd50f8
--- /dev/null
+++ b/tests/res/drawable/gradientdrawable_radius_base.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2014 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.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <gradient
+ android:centerColor="#ffff0000"
+ android:endColor="#0000ffff"
+ android:gradientRadius="50%"
+ android:startColor="#ffffffff"
+ android:type="radial" />
+
+ <corners android:radius="8px" />
+
+ <padding
+ android:bottom="10px"
+ android:left="4px"
+ android:right="6px"
+ android:top="2px" />
+
+ <size
+ android:height="50px"
+ android:width="50px" />
+
+</shape>
\ No newline at end of file
diff --git a/tests/res/drawable/gradientdrawable_radius_parent.xml b/tests/res/drawable/gradientdrawable_radius_parent.xml
new file mode 100644
index 0000000..73d116a
--- /dev/null
+++ b/tests/res/drawable/gradientdrawable_radius_parent.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2014 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.
+-->
+
+<shape xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <gradient
+ android:centerColor="#ffff0000"
+ android:endColor="#0000ffff"
+ android:gradientRadius="50%p"
+ android:startColor="#ffffffff"
+ android:type="radial" />
+
+ <corners android:radius="8px" />
+
+ <padding
+ android:bottom="10px"
+ android:left="4px"
+ android:right="6px"
+ android:top="2px" />
+
+ <size
+ android:height="50px"
+ android:width="50px" />
+
+</shape>
\ No newline at end of file
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/GradientDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/GradientDrawableTest.java
index f2d7b82..979dd8d 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/GradientDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/GradientDrawableTest.java
@@ -248,6 +248,26 @@
}
}
+ public void testInflateGradientRadius() throws XmlPullParserException, IOException {
+ Rect parentBounds = new Rect(0, 0, 100, 100);
+ Resources resources = mContext.getResources();
+
+ GradientDrawable gradientDrawable;
+ float radius;
+
+ gradientDrawable = (GradientDrawable) resources.getDrawable(
+ R.drawable.gradientdrawable_radius_base);
+ gradientDrawable.setBounds(parentBounds);
+ radius = gradientDrawable.getGradientRadius();
+ assertEquals(25, radius);
+
+ gradientDrawable = (GradientDrawable) resources.getDrawable(
+ R.drawable.gradientdrawable_radius_parent);
+ gradientDrawable.setBounds(parentBounds);
+ radius = gradientDrawable.getGradientRadius();
+ assertEquals(50, radius);
+ }
+
public void testGetIntrinsicWidth() {
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setSize(6, 4);