Merge "Add tests for nativeDecodeFileDescriptor."
diff --git a/tests/Android.mk b/tests/Android.mk
index a4cc38f..0c8f71f 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -30,6 +30,7 @@
# Resource unit tests use a private locale and some densities
LOCAL_AAPT_FLAGS = -c xx_YY -c cs -c small -c normal -c large -c xlarge \
-c 320dpi -c 240dpi -c 160dpi -c 32dpi \
+ -c kok,kok_IN,kok_419,kok_419_VARIANT,kok_Knda_419,kok_Knda_419_VARIANT,kok_VARIANT,kok_Knda \
--preferred-configurations 320dpi --preferred-configurations 240dpi \
--preferred-configurations 160dpi --preferred-configurations 32dpi
diff --git a/tests/res/drawable/google_logo_1.png b/tests/res/drawable/google_logo_1.png
new file mode 100644
index 0000000..6e038fc
--- /dev/null
+++ b/tests/res/drawable/google_logo_1.png
Binary files differ
diff --git a/tests/res/drawable/google_logo_2.webp b/tests/res/drawable/google_logo_2.webp
new file mode 100644
index 0000000..f92c42b
--- /dev/null
+++ b/tests/res/drawable/google_logo_2.webp
Binary files differ
diff --git a/tests/res/layout/inflater_override_theme_layout.xml b/tests/res/layout/inflater_override_theme_layout.xml
index 4440f7c..8c524ba 100644
--- a/tests/res/layout/inflater_override_theme_layout.xml
+++ b/tests/res/layout/inflater_override_theme_layout.xml
@@ -18,8 +18,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- theme="@style/Theme_OverrideOuter"
- android:orientation="vertical" >
+ android:orientation="vertical"
+ android:theme="@style/Theme_OverrideOuter" >
<View
android:id="@+id/view_outer"
@@ -29,13 +29,19 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
- theme="@style/Theme_OverrideInner"
- android:orientation="vertical" >
+ android:orientation="vertical"
+ android:theme="@style/Theme_OverrideInner" >
<View
android:id="@+id/view_inner"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
+
+ <View
+ android:id="@+id/view_attr"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:theme="?attr/themeOverrideAttr" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
diff --git a/tests/res/values-b+kok+419+VARIANT/configVarying.xml b/tests/res/values-b+kok+419+VARIANT/configVarying.xml
new file mode 100644
index 0000000..3560279
--- /dev/null
+++ b/tests/res/values-b+kok+419+VARIANT/configVarying.xml
@@ -0,0 +1,22 @@
+<?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.
+-->
+
+<resources>
+ <item type="configVarying" name="simple">simple kok 419 VARIANT</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag kok 419 VARIANT</item>
+ </bag>
+</resources>
diff --git a/tests/res/values-b+kok+419/configVarying.xml b/tests/res/values-b+kok+419/configVarying.xml
new file mode 100644
index 0000000..b6f37f9
--- /dev/null
+++ b/tests/res/values-b+kok+419/configVarying.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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>
+ <item type="configVarying" name="simple">simple kok 419</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag kok 419</item>
+ </bag>
+</resources>
diff --git a/tests/res/values-b+kok+IN/configVarying.xml b/tests/res/values-b+kok+IN/configVarying.xml
new file mode 100644
index 0000000..967ea47
--- /dev/null
+++ b/tests/res/values-b+kok+IN/configVarying.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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>
+ <item type="configVarying" name="simple">simple kok IN</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag kok IN</item>
+ </bag>
+</resources>
diff --git a/tests/res/values-b+kok+Knda+419+VARIANT/configVarying.xml b/tests/res/values-b+kok+Knda+419+VARIANT/configVarying.xml
new file mode 100644
index 0000000..2b2bcea
--- /dev/null
+++ b/tests/res/values-b+kok+Knda+419+VARIANT/configVarying.xml
@@ -0,0 +1,22 @@
+<?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.
+-->
+
+<resources>
+ <item type="configVarying" name="simple">simple kok Knda 419 VARIANT</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag kok Knda 419 VARIANT</item>
+ </bag>
+</resources>
diff --git a/tests/res/values-b+kok+Knda+419/configVarying.xml b/tests/res/values-b+kok+Knda+419/configVarying.xml
new file mode 100644
index 0000000..cbc53b9
--- /dev/null
+++ b/tests/res/values-b+kok+Knda+419/configVarying.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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>
+ <item type="configVarying" name="simple">simple kok Knda 419</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag kok Knda 419</item>
+ </bag>
+</resources>
diff --git a/tests/res/values-b+kok+Knda/configVarying.xml b/tests/res/values-b+kok+Knda/configVarying.xml
new file mode 100644
index 0000000..f735749
--- /dev/null
+++ b/tests/res/values-b+kok+Knda/configVarying.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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>
+ <item type="configVarying" name="simple">simple kok Knda</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag kok Knda</item>
+ </bag>
+</resources>
diff --git a/tests/res/values-b+kok+VARIANT/configVarying.xml b/tests/res/values-b+kok+VARIANT/configVarying.xml
new file mode 100644
index 0000000..6743b7f
--- /dev/null
+++ b/tests/res/values-b+kok+VARIANT/configVarying.xml
@@ -0,0 +1,22 @@
+<?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.
+-->
+
+<resources>
+ <item type="configVarying" name="simple">simple kok VARIANT</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag kok VARIANT</item>
+ </bag>
+</resources>
diff --git a/tests/res/values-b+kok/configVarying.xml b/tests/res/values-b+kok/configVarying.xml
new file mode 100644
index 0000000..e1bafa1
--- /dev/null
+++ b/tests/res/values-b+kok/configVarying.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2007 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>
+ <item type="configVarying" name="simple">simple kok</item>
+ <bag type="configVarying" name="bag">
+ <item name="testString">bag kok</item>
+ </bag>
+</resources>
diff --git a/tests/res/values/attrs.xml b/tests/res/values/attrs.xml
index 0525cae..404427d 100644
--- a/tests/res/values/attrs.xml
+++ b/tests/res/values/attrs.xml
@@ -127,4 +127,6 @@
</declare-styleable>
<!-- Integer used to uniquely identify theme overrides. -->
<attr name="themeType" format="integer"/>
+ <!-- Theme reference used to override parent theme. -->
+ <attr name="themeOverrideAttr" format="reference"/>
</resources>
diff --git a/tests/res/values/styles.xml b/tests/res/values/styles.xml
index 047e97c..daaed48 100644
--- a/tests/res/values/styles.xml
+++ b/tests/res/values/styles.xml
@@ -144,6 +144,11 @@
<style name="Theme_OverrideInner">
<item name="themeType">2</item>
+ <item name="themeOverrideAttr">@style/Theme_OverrideAttr</item>
+ </style>
+
+ <style name="Theme_OverrideAttr">
+ <item name="themeType">3</item>
</style>
</resources>
diff --git a/tests/src/android/renderscript/cts/foreach.rs b/tests/src/android/renderscript/cts/foreach.rs
index 8747961..08e6bed 100644
--- a/tests/src/android/renderscript/cts/foreach.rs
+++ b/tests/src/android/renderscript/cts/foreach.rs
@@ -1,6 +1,5 @@
#include "shared.rsh"
-int *a;
rs_allocation aRaw;
int dimX;
int dimY;
diff --git a/tests/src/android/renderscript/cts/sample.rs b/tests/src/android/renderscript/cts/sample.rs
index 7a8d5bb..64fb262 100644
--- a/tests/src/android/renderscript/cts/sample.rs
+++ b/tests/src/android/renderscript/cts/sample.rs
@@ -8,46 +8,11 @@
rs_sampler gMipNearest;
rs_sampler gMipLinear;
-uint8_t *gAllocPtr;
-
static uchar4 lod0Color = {255, 255, 0, 0};
static uchar4 lod1Color = {255, 0, 255, 0};
static uchar4 lod2Color = {0, 255, 255, 0};
static uchar4 lod3Color = {255, 255, 255, 0};
-// Allocation has been bound to gAllocPtr
-void init_RGBA(rs_allocation a) {
- // Fill base level with one color, mips with something else
- uchar4 *allocPtr = (uchar4*)gAllocPtr;
- uint32_t dimX = rsAllocationGetDimX(a);
- uint32_t dimY = rsAllocationGetDimY(a);
- uint32_t minSize = 1;
- dimX = max(dimX, minSize);
- dimY = max(dimY, minSize);
-
- uint32_t numPixels = dimX * dimY;
- for (uint32_t i = 0; i < numPixels; i ++) {
- (*allocPtr++) = lod0Color;
- }
- dimX = max(dimX >> 1, minSize);
- dimY = max(dimY >> 1, minSize);
- numPixels = dimX * dimY;
- for (uint32_t i = 0; i < numPixels; i ++) {
- (*allocPtr++) = lod1Color;
- }
- dimX = max(dimX >> 1, minSize);
- dimY = max(dimY >> 1, minSize);
- numPixels = dimX * dimY;
- for (uint32_t i = 0; i < numPixels; i ++) {
- (*allocPtr++) = lod2Color;
- }
- dimX = max(dimX >> 1, minSize);
- dimY = max(dimY >> 1, minSize);
- numPixels = dimX * dimY;
- for (uint32_t i = 0; i < numPixels; i ++) {
- (*allocPtr++) = lod3Color;
- }
-}
static bool compare(float4 expected, float4 value) {
float allowedDelta = 10.0f;
diff --git a/tests/src/android/webkit/cts/WebViewOnUiThread.java b/tests/src/android/webkit/cts/WebViewOnUiThread.java
index 715af12..6e485c3 100644
--- a/tests/src/android/webkit/cts/WebViewOnUiThread.java
+++ b/tests/src/android/webkit/cts/WebViewOnUiThread.java
@@ -378,6 +378,7 @@
* onNewPicture and onProgressChange to reach 100.
* Test fails if the load timeout elapses.
* @param url The URL to load.
+ * @param extraHeaders The additional headers to be used in the HTTP request.
*/
public void loadUrlAndWaitForCompletion(final String url,
final Map<String, String> extraHeaders) {
@@ -407,6 +408,15 @@
});
}
+ public void postUrlAndWaitForCompletion(final String url, final byte[] postData) {
+ callAndWait(new Runnable() {
+ @Override
+ public void run() {
+ mWebView.postUrl(url, postData);
+ }
+ });
+ }
+
public void loadDataAndWaitForCompletion(final String data,
final String mimeType, final String encoding) {
callAndWait(new Runnable() {
diff --git a/tests/tests/content/src/android/content/res/cts/ConfigTest.java b/tests/tests/content/src/android/content/res/cts/ConfigTest.java
index bcfabe1..2f892b0 100644
--- a/tests/tests/content/src/android/content/res/cts/ConfigTest.java
+++ b/tests/tests/content/src/android/content/res/cts/ConfigTest.java
@@ -35,6 +35,8 @@
enum Properties {
LANGUAGE,
COUNTRY,
+ SCRIPT,
+ VARIANT,
MCC,
MNC,
TOUCHSCREEN,
@@ -88,7 +90,7 @@
public TotalConfig() {
mConfig = new Configuration();
mMetrics = new DisplayMetrics();
- mConfig.locale = new Locale("++", "++");
+ mConfig.locale = Locale.ROOT;
}
public void setProperty(final Properties p, final int value) {
@@ -149,12 +151,28 @@
public void setProperty(final Properties p, final String value) {
switch(p) {
case LANGUAGE:
- final String oldCountry = mConfig.locale.getCountry();
- mConfig.locale = new Locale(value, oldCountry);
+ mConfig.locale = new Locale.Builder()
+ .setLocale(mConfig.locale)
+ .setLanguage(value)
+ .build();
break;
case COUNTRY:
- final String oldLanguage = mConfig.locale.getLanguage();
- mConfig.locale = new Locale(oldLanguage, value);
+ mConfig.locale = new Locale.Builder()
+ .setLocale(mConfig.locale)
+ .setRegion(value)
+ .build();
+ break;
+ case SCRIPT:
+ mConfig.locale = new Locale.Builder()
+ .setLocale(mConfig.locale)
+ .setScript(value)
+ .build();
+ break;
+ case VARIANT:
+ mConfig.locale = new Locale.Builder()
+ .setLocale(mConfig.locale)
+ .setVariant(value)
+ .build();
break;
default:
assert(false);
@@ -1131,4 +1149,69 @@
assertEquals("base", mContext.getResources().getString(R.string.version_old));
assertEquals("v3", mContext.getResources().getString(R.string.version_v3));
}
+
+ @MediumTest
+ public void testExtendedLocales() {
+ TotalConfig config = makeClassicConfig();
+ // BCP 47 Locale kok
+ config.setProperty(Properties.LANGUAGE, "kok");
+ Resources res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple kok");
+ checkValue(res, R.configVarying.bag,
+ R.styleable.TestConfig, new String[]{"bag kok"});
+
+ // BCP 47 Locale kok-IN
+ config.setProperty(Properties.COUNTRY, "IN");
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple kok IN");
+ checkValue(res, R.configVarying.bag,
+ R.styleable.TestConfig, new String[]{"bag kok IN"});
+
+ // BCP 47 Locale kok-419
+ config.setProperty(Properties.COUNTRY, "419");
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple kok 419");
+ checkValue(res, R.configVarying.bag,
+ R.styleable.TestConfig, new String[]{"bag kok 419"});
+
+
+ // BCP 47 Locale kok-419-VARIANT
+ config.setProperty(Properties.VARIANT, "VARIANT");
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple kok 419 VARIANT");
+ checkValue(res, R.configVarying.bag,
+ R.styleable.TestConfig, new String[]{"bag kok 419 VARIANT"});
+
+ // BCP 47 Locale kok-Knda
+ config = makeClassicConfig();
+ config.setProperty(Properties.LANGUAGE, "kok");
+ config.setProperty(Properties.SCRIPT, "Knda");
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple kok Knda");
+ checkValue(res, R.configVarying.bag,
+ R.styleable.TestConfig, new String[]{"bag kok Knda"});
+
+ // BCP 47 Locale kok-Knda-419
+ config.setProperty(Properties.COUNTRY, "419");
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple kok Knda 419");
+ checkValue(res, R.configVarying.bag,
+ R.styleable.TestConfig, new String[]{"bag kok Knda 419"});
+
+ // BCP 47 Locale kok-Knda-419-VARIANT
+ config.setProperty(Properties.VARIANT, "VARIANT");
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple kok Knda 419 VARIANT");
+ checkValue(res, R.configVarying.bag,
+ R.styleable.TestConfig, new String[]{"bag kok Knda 419 VARIANT"});
+
+ // BCP 47 Locale kok-VARIANT
+ config = makeClassicConfig();
+ config.setProperty(Properties.LANGUAGE, "kok");
+ config.setProperty(Properties.VARIANT, "VARIANT");
+ res = config.getResources();
+ checkValue(res, R.configVarying.simple, "simple kok VARIANT");
+ checkValue(res, R.configVarying.bag,
+ R.styleable.TestConfig, new String[]{"bag kok VARIANT"});
+ }
}
diff --git a/tests/tests/dpi/src/android/dpi/cts/AspectRatioTest.java b/tests/tests/dpi/src/android/dpi/cts/AspectRatioTest.java
index 74a9f22..572c3f4 100644
--- a/tests/tests/dpi/src/android/dpi/cts/AspectRatioTest.java
+++ b/tests/tests/dpi/src/android/dpi/cts/AspectRatioTest.java
@@ -40,46 +40,27 @@
}
/**
- * Get all the aspect rations in different orientations. They could be
- * different due to the system bar being different sizes. Test that
- * one of the aspect ratios is within the range.
+ * Get the full screen size directly (including system bar) to calculate
+ * aspect ratio. With this, the screen orientation doesn't affect the aspect
+ * ratio value anymore. Test that the aspect ratio is within the range.
*/
public void testAspectRatio() throws Exception {
- List<Double> aspectRatios = getAllAspectRatios();
- for (double aspectRatio : aspectRatios) {
- if (aspectRatio >= 1.333 && aspectRatio <= 1.86) {
- return;
- }
+ double aspectRatio = getRealAspectRatio(getActivity());
+ if (aspectRatio >= 1.333 && aspectRatio <= 1.86) {
+ return;
}
- fail("Aspect ratios were not between 1.333 and 1.86: " + aspectRatios);
+ fail("Aspect ratio was not between 1.333 and 1.86: " + aspectRatio);
}
- private List<Double> getAllAspectRatios() throws Exception {
- List<Double> aspectRatios = new ArrayList<Double>();
- for (int i = 0; i < ORIENTATIONS.length; i++) {
- Activity activity = startOrientationActivity(ORIENTATIONS[i]);
- aspectRatios.add(getAspectRatio(activity));
- tearDown();
- }
- return aspectRatios;
- }
-
- private double getAspectRatio(Context context) {
+ private double getRealAspectRatio(Context context) {
WindowManager windowManager =
(WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Display display = windowManager.getDefaultDisplay();
DisplayMetrics metrics = new DisplayMetrics();
- display.getMetrics(metrics);
+ display.getRealMetrics(metrics);
int max = Math.max(metrics.widthPixels, metrics.heightPixels);
int min = Math.min(metrics.widthPixels, metrics.heightPixels);
return (double) max / min;
}
-
- private Activity startOrientationActivity(int orientation) {
- Intent intent = new Intent();
- intent.putExtra(OrientationActivity.EXTRA_ORIENTATION, orientation);
- setActivityIntent(intent);
- return getActivity();
- }
}
diff --git a/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java b/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
index f942f93..0d3cc9e 100644
--- a/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/BitmapFactoryTest.java
@@ -73,6 +73,10 @@
Config.ARGB_4444};
private static int[] COLOR_TOLS = new int[] {16, 49, 576};
+ private static Config[] COLOR_CONFIGS_RGBA = new Config[] {Config.ARGB_8888,
+ Config.ARGB_4444};
+ private static int[] COLOR_TOLS_RGBA = new int[] {72, 124};
+
private static int[] RAW_COLORS = new int[] {
// raw data from R.drawable.premul_data
Color.argb(255, 0, 0, 0),
@@ -201,11 +205,15 @@
Bitmap bPng = BitmapFactory.decodeStream(iStreamPng, null, options);
assertNotNull(bPng);
assertEquals(bPng.getConfig(), COLOR_CONFIGS[k]);
+ assertFalse(bPng.isPremultiplied());
+ assertFalse(bPng.hasAlpha());
InputStream iStreamWebp1 = obtainInputStream(R.drawable.webp_test);
Bitmap bWebp1 = BitmapFactory.decodeStream(iStreamWebp1, null, options);
assertNotNull(bWebp1);
- compareBitmaps(bPng, bWebp1, COLOR_TOLS[k], true);
+ assertFalse(bWebp1.isPremultiplied());
+ assertFalse(bWebp1.hasAlpha());
+ compareBitmaps(bPng, bWebp1, COLOR_TOLS[k], true, bPng.isPremultiplied());
// Compress the PNG image to WebP format (Quality=90) and decode it back.
// This will test end-to-end WebP encoding and decoding.
@@ -214,7 +222,46 @@
InputStream iStreamWebp2 = new ByteArrayInputStream(oStreamWebp.toByteArray());
Bitmap bWebp2 = BitmapFactory.decodeStream(iStreamWebp2, null, options);
assertNotNull(bWebp2);
- compareBitmaps(bPng, bWebp2, COLOR_TOLS[k], true);
+ assertFalse(bWebp2.isPremultiplied());
+ assertFalse(bWebp2.hasAlpha());
+ compareBitmaps(bPng, bWebp2, COLOR_TOLS[k], true, bPng.isPremultiplied());
+ }
+ }
+
+ public void testDecodeStream5() throws IOException {
+ BitmapFactory.Options options = new BitmapFactory.Options();
+ for (int k = 0; k < COLOR_CONFIGS_RGBA.length; ++k) {
+ options.inPreferredConfig = COLOR_CONFIGS_RGBA[k];
+
+ // Decode the PNG & WebP (google_logo) images. The WebP image has
+ // been encoded from PNG image.
+ InputStream iStreamPng = obtainInputStream(R.drawable.google_logo_1);
+ Bitmap bPng = BitmapFactory.decodeStream(iStreamPng, null, options);
+ assertNotNull(bPng);
+ assertEquals(bPng.getConfig(), COLOR_CONFIGS_RGBA[k]);
+ assertTrue(bPng.isPremultiplied());
+ assertTrue(bPng.hasAlpha());
+
+ // Decode the corresponding WebP (transparent) image (google_logo_2.webp).
+ InputStream iStreamWebP1 = obtainInputStream(R.drawable.google_logo_2);
+ Bitmap bWebP1 = BitmapFactory.decodeStream(iStreamWebP1, null, options);
+ assertNotNull(bWebP1);
+ assertEquals(bWebP1.getConfig(), COLOR_CONFIGS_RGBA[k]);
+ assertTrue(bWebP1.isPremultiplied());
+ assertTrue(bWebP1.hasAlpha());
+ compareBitmaps(bPng, bWebP1, COLOR_TOLS_RGBA[k], true, bPng.isPremultiplied());
+
+ // Compress the PNG image to WebP format (Quality=90) and decode it back.
+ // This will test end-to-end WebP encoding and decoding.
+ ByteArrayOutputStream oStreamWebp = new ByteArrayOutputStream();
+ assertTrue(bPng.compress(CompressFormat.WEBP, 90, oStreamWebp));
+ InputStream iStreamWebp2 = new ByteArrayInputStream(oStreamWebp.toByteArray());
+ Bitmap bWebP2 = BitmapFactory.decodeStream(iStreamWebp2, null, options);
+ assertNotNull(bWebP2);
+ assertEquals(bWebP2.getConfig(), COLOR_CONFIGS_RGBA[k]);
+ assertTrue(bWebP2.isPremultiplied());
+ assertTrue(bWebP2.hasAlpha());
+ compareBitmaps(bPng, bWebP2, COLOR_TOLS_RGBA[k], true, bPng.isPremultiplied());
}
}
@@ -510,7 +557,7 @@
// lessThanMargin is to indicate whether we expect the mean square error
// to be "less than" or "no less than".
private void compareBitmaps(Bitmap expected, Bitmap actual,
- int mseMargin, boolean lessThanMargin) {
+ int mseMargin, boolean lessThanMargin, boolean isPremultiplied) {
final int width = expected.getWidth();
final int height = expected.getHeight();
@@ -523,30 +570,49 @@
int[] expectedColors = new int [width * height];
int[] actualColors = new int [width * height];
+ // Bitmap.getPixels() returns colors with non-premultiplied ARGB values.
expected.getPixels(expectedColors, 0, width, 0, 0, width, height);
actual.getPixels(actualColors, 0, width, 0, 0, width, height);
for (int row = 0; row < height; ++row) {
for (int col = 0; col < width; ++col) {
int idx = row * width + col;
- mse += distance(expectedColors[idx], actualColors[idx]);
+ mse += distance(expectedColors[idx], actualColors[idx], isPremultiplied);
}
}
mse /= width * height;
if (lessThanMargin) {
- assertTrue("MSE too large for normal case: " + mse,
+ assertTrue("MSE " + mse + "larger than the threshold: " + mseMargin,
mse <= mseMargin);
} else {
- assertFalse("MSE too small for abnormal case: " + mse,
+ assertFalse("MSE " + mse + "smaller than the threshold: " + mseMargin,
mse <= mseMargin);
}
}
- private double distance(int expect, int actual) {
- final int r = Color.red(actual) - Color.red(expect);
- final int g = Color.green(actual) - Color.green(expect);
- final int b = Color.blue(actual) - Color.blue(expect);
- return r * r + g * g + b * b;
+ private int multiplyAlpha(int color, int alpha) {
+ return (color * alpha + 127) / 255;
+ }
+
+ // For the Bitmap with Alpha, multiply the Alpha values to get the effective
+ // RGB colors and then compute the color-distance.
+ private double distance(int expect, int actual, boolean isPremultiplied) {
+ if (isPremultiplied) {
+ final int a1 = Color.alpha(actual);
+ final int a2 = Color.alpha(expect);
+ final int r = multiplyAlpha(Color.red(actual), a1) -
+ multiplyAlpha(Color.red(expect), a2);
+ final int g = multiplyAlpha(Color.green(actual), a1) -
+ multiplyAlpha(Color.green(expect), a2);
+ final int b = multiplyAlpha(Color.blue(actual), a1) -
+ multiplyAlpha(Color.blue(expect), a2);
+ return r * r + g * g + b * b;
+ } else {
+ final int r = Color.red(actual) - Color.red(expect);
+ final int g = Color.green(actual) - Color.green(expect);
+ final int b = Color.blue(actual) - Color.blue(expect);
+ return r * r + g * g + b * b;
+ }
}
}
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraCaptureResultTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraCaptureResultTest.java
index f05111b..69eac08 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraCaptureResultTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraCaptureResultTest.java
@@ -287,6 +287,8 @@
resultKeys.add(CaptureResult.EDGE_MODE);
resultKeys.add(CaptureResult.FLASH_MODE);
resultKeys.add(CaptureResult.FLASH_STATE);
+ resultKeys.add(CaptureResult.HOT_PIXEL_MODE);
+ resultKeys.add(CaptureResult.HOT_PIXEL_MAP);
resultKeys.add(CaptureResult.JPEG_GPS_COORDINATES);
resultKeys.add(CaptureResult.JPEG_GPS_PROCESSING_METHOD);
resultKeys.add(CaptureResult.JPEG_GPS_TIMESTAMP);
@@ -310,6 +312,12 @@
resultKeys.add(CaptureResult.SENSOR_SENSITIVITY);
resultKeys.add(CaptureResult.SENSOR_TIMESTAMP);
resultKeys.add(CaptureResult.SENSOR_TEMPERATURE);
+ resultKeys.add(CaptureResult.SENSOR_CALIBRATION_TRANSFORM);
+ resultKeys.add(CaptureResult.SENSOR_COLOR_TRANSFORM);
+ resultKeys.add(CaptureResult.SENSOR_FORWARD_MATRIX);
+ resultKeys.add(CaptureResult.SENSOR_NEUTRAL_COLOR_POINT);
+ resultKeys.add(CaptureResult.SENSOR_PROFILE_HUE_SAT_MAP);
+ resultKeys.add(CaptureResult.SENSOR_PROFILE_TONE_CURVE);
resultKeys.add(CaptureResult.SENSOR_TEST_PATTERN_MODE);
resultKeys.add(CaptureResult.STATISTICS_FACE_DETECT_MODE);
resultKeys.add(CaptureResult.STATISTICS_LENS_SHADING_MAP);
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraCharacteristicsTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraCharacteristicsTest.java
index d694104..2860d23 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CameraCharacteristicsTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CameraCharacteristicsTest.java
@@ -478,6 +478,10 @@
assertNotNull(String.format("Can't get camera characteristics from: ID %s", ids[i]),
props);
+ Integer hwLevel = props.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
+ assertNotNull("No hardware level reported! android.info.supportedHardwareLevel",
+ hwLevel);
+ if (hwLevel == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL)
{
assertNotNull("Invalid property: android.lens.info.hyperfocalDistance",
@@ -540,6 +544,29 @@
}
}
+ public void testCameraCharacteristicsAndroidLensInfoFocusDistanceCalibration() throws Exception {
+ String[] ids = mCameraManager.getCameraIdList();
+ for (int i = 0; i < ids.length; i++) {
+ CameraCharacteristics props = mCameraManager.getCameraCharacteristics(ids[i]);
+ assertNotNull(String.format("Can't get camera characteristics from: ID %s", ids[i]),
+ props);
+
+ {
+
+ assertNotNull("Invalid property: android.lens.info.focusDistanceCalibration",
+ props.get(CameraCharacteristics.LENS_INFO_FOCUS_DISTANCE_CALIBRATION));
+
+ List<Key<?>> allKeys = props.getKeys();
+ assertNotNull(String.format("Can't get camera characteristics keys from: ID %s",
+ ids[i], props));
+ assertTrue("Key not in keys list: android.lens.info.focusDistanceCalibration", allKeys.contains(
+ CameraCharacteristics.LENS_INFO_FOCUS_DISTANCE_CALIBRATION));
+
+ }
+
+ }
+ }
+
public void testCameraCharacteristicsAndroidRequestMaxNumOutputStreams() throws Exception {
String[] ids = mCameraManager.getCameraIdList();
for (int i = 0; i < ids.length; i++) {
@@ -563,6 +590,29 @@
}
}
+ public void testCameraCharacteristicsAndroidRequestMaxNumInputStreams() throws Exception {
+ String[] ids = mCameraManager.getCameraIdList();
+ for (int i = 0; i < ids.length; i++) {
+ CameraCharacteristics props = mCameraManager.getCameraCharacteristics(ids[i]);
+ assertNotNull(String.format("Can't get camera characteristics from: ID %s", ids[i]),
+ props);
+
+ {
+
+ assertNotNull("Invalid property: android.request.maxNumInputStreams",
+ props.get(CameraCharacteristics.REQUEST_MAX_NUM_INPUT_STREAMS));
+
+ List<Key<?>> allKeys = props.getKeys();
+ assertNotNull(String.format("Can't get camera characteristics keys from: ID %s",
+ ids[i], props));
+ assertTrue("Key not in keys list: android.request.maxNumInputStreams", allKeys.contains(
+ CameraCharacteristics.REQUEST_MAX_NUM_INPUT_STREAMS));
+
+ }
+
+ }
+ }
+
public void testCameraCharacteristicsAndroidRequestPipelineMaxDepth() throws Exception {
String[] ids = mCameraManager.getCameraIdList();
for (int i = 0; i < ids.length; i++) {
@@ -609,6 +659,29 @@
}
}
+ public void testCameraCharacteristicsAndroidRequestAvailableCapabilities() throws Exception {
+ String[] ids = mCameraManager.getCameraIdList();
+ for (int i = 0; i < ids.length; i++) {
+ CameraCharacteristics props = mCameraManager.getCameraCharacteristics(ids[i]);
+ assertNotNull(String.format("Can't get camera characteristics from: ID %s", ids[i]),
+ props);
+
+ {
+
+ assertNotNull("Invalid property: android.request.availableCapabilities",
+ props.get(CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES));
+
+ List<Key<?>> allKeys = props.getKeys();
+ assertNotNull(String.format("Can't get camera characteristics keys from: ID %s",
+ ids[i], props));
+ assertTrue("Key not in keys list: android.request.availableCapabilities", allKeys.contains(
+ CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES));
+
+ }
+
+ }
+ }
+
public void testCameraCharacteristicsAndroidScalerAvailableFormats() throws Exception {
String[] ids = mCameraManager.getCameraIdList();
for (int i = 0; i < ids.length; i++) {
@@ -747,6 +820,98 @@
}
}
+ public void testCameraCharacteristicsAndroidScalerAvailableInputOutputFormatsMap() throws Exception {
+ String[] ids = mCameraManager.getCameraIdList();
+ for (int i = 0; i < ids.length; i++) {
+ CameraCharacteristics props = mCameraManager.getCameraCharacteristics(ids[i]);
+ assertNotNull(String.format("Can't get camera characteristics from: ID %s", ids[i]),
+ props);
+
+ {
+
+ assertNotNull("Invalid property: android.scaler.availableInputOutputFormatsMap",
+ props.get(CameraCharacteristics.SCALER_AVAILABLE_INPUT_OUTPUT_FORMATS_MAP));
+
+ List<Key<?>> allKeys = props.getKeys();
+ assertNotNull(String.format("Can't get camera characteristics keys from: ID %s",
+ ids[i], props));
+ assertTrue("Key not in keys list: android.scaler.availableInputOutputFormatsMap", allKeys.contains(
+ CameraCharacteristics.SCALER_AVAILABLE_INPUT_OUTPUT_FORMATS_MAP));
+
+ }
+
+ }
+ }
+
+ public void testCameraCharacteristicsAndroidScalerAvailableStreamConfigurations() throws Exception {
+ String[] ids = mCameraManager.getCameraIdList();
+ for (int i = 0; i < ids.length; i++) {
+ CameraCharacteristics props = mCameraManager.getCameraCharacteristics(ids[i]);
+ assertNotNull(String.format("Can't get camera characteristics from: ID %s", ids[i]),
+ props);
+
+ {
+
+ assertNotNull("Invalid property: android.scaler.availableStreamConfigurations",
+ props.get(CameraCharacteristics.SCALER_AVAILABLE_STREAM_CONFIGURATIONS));
+
+ List<Key<?>> allKeys = props.getKeys();
+ assertNotNull(String.format("Can't get camera characteristics keys from: ID %s",
+ ids[i], props));
+ assertTrue("Key not in keys list: android.scaler.availableStreamConfigurations", allKeys.contains(
+ CameraCharacteristics.SCALER_AVAILABLE_STREAM_CONFIGURATIONS));
+
+ }
+
+ }
+ }
+
+ public void testCameraCharacteristicsAndroidScalerAvailableMinFrameDurations() throws Exception {
+ String[] ids = mCameraManager.getCameraIdList();
+ for (int i = 0; i < ids.length; i++) {
+ CameraCharacteristics props = mCameraManager.getCameraCharacteristics(ids[i]);
+ assertNotNull(String.format("Can't get camera characteristics from: ID %s", ids[i]),
+ props);
+
+ {
+
+ assertNotNull("Invalid property: android.scaler.availableMinFrameDurations",
+ props.get(CameraCharacteristics.SCALER_AVAILABLE_MIN_FRAME_DURATIONS));
+
+ List<Key<?>> allKeys = props.getKeys();
+ assertNotNull(String.format("Can't get camera characteristics keys from: ID %s",
+ ids[i], props));
+ assertTrue("Key not in keys list: android.scaler.availableMinFrameDurations", allKeys.contains(
+ CameraCharacteristics.SCALER_AVAILABLE_MIN_FRAME_DURATIONS));
+
+ }
+
+ }
+ }
+
+ public void testCameraCharacteristicsAndroidScalerAvailableStallDurations() throws Exception {
+ String[] ids = mCameraManager.getCameraIdList();
+ for (int i = 0; i < ids.length; i++) {
+ CameraCharacteristics props = mCameraManager.getCameraCharacteristics(ids[i]);
+ assertNotNull(String.format("Can't get camera characteristics from: ID %s", ids[i]),
+ props);
+
+ {
+
+ assertNotNull("Invalid property: android.scaler.availableStallDurations",
+ props.get(CameraCharacteristics.SCALER_AVAILABLE_STALL_DURATIONS));
+
+ List<Key<?>> allKeys = props.getKeys();
+ assertNotNull(String.format("Can't get camera characteristics keys from: ID %s",
+ ids[i], props));
+ assertTrue("Key not in keys list: android.scaler.availableStallDurations", allKeys.contains(
+ CameraCharacteristics.SCALER_AVAILABLE_STALL_DURATIONS));
+
+ }
+
+ }
+ }
+
public void testCameraCharacteristicsAndroidSensorBaseGainFactor() throws Exception {
String[] ids = mCameraManager.getCameraIdList();
for (int i = 0; i < ids.length; i++) {
@@ -774,6 +939,33 @@
}
}
+ public void testCameraCharacteristicsAndroidSensorBlackLevelPattern() throws Exception {
+ String[] ids = mCameraManager.getCameraIdList();
+ for (int i = 0; i < ids.length; i++) {
+ CameraCharacteristics props = mCameraManager.getCameraCharacteristics(ids[i]);
+ assertNotNull(String.format("Can't get camera characteristics from: ID %s", ids[i]),
+ props);
+
+ Integer hwLevel = props.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
+ assertNotNull("No hardware level reported! android.info.supportedHardwareLevel",
+ hwLevel);
+ if (hwLevel == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL)
+ {
+
+ assertNotNull("Invalid property: android.sensor.blackLevelPattern",
+ props.get(CameraCharacteristics.SENSOR_BLACK_LEVEL_PATTERN));
+
+ List<Key<?>> allKeys = props.getKeys();
+ assertNotNull(String.format("Can't get camera characteristics keys from: ID %s",
+ ids[i], props));
+ assertTrue("Key not in keys list: android.sensor.blackLevelPattern", allKeys.contains(
+ CameraCharacteristics.SENSOR_BLACK_LEVEL_PATTERN));
+
+ }
+
+ }
+ }
+
public void testCameraCharacteristicsAndroidSensorMaxAnalogSensitivity() throws Exception {
String[] ids = mCameraManager.getCameraIdList();
for (int i = 0; i < ids.length; i++) {
@@ -824,6 +1016,33 @@
}
}
+ public void testCameraCharacteristicsAndroidSensorProfileHueSatMapDimensions() throws Exception {
+ String[] ids = mCameraManager.getCameraIdList();
+ for (int i = 0; i < ids.length; i++) {
+ CameraCharacteristics props = mCameraManager.getCameraCharacteristics(ids[i]);
+ assertNotNull(String.format("Can't get camera characteristics from: ID %s", ids[i]),
+ props);
+
+ Integer hwLevel = props.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
+ assertNotNull("No hardware level reported! android.info.supportedHardwareLevel",
+ hwLevel);
+ if (hwLevel == CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL_FULL)
+ {
+
+ assertNotNull("Invalid property: android.sensor.profileHueSatMapDimensions",
+ props.get(CameraCharacteristics.SENSOR_PROFILE_HUE_SAT_MAP_DIMENSIONS));
+
+ List<Key<?>> allKeys = props.getKeys();
+ assertNotNull(String.format("Can't get camera characteristics keys from: ID %s",
+ ids[i], props));
+ assertTrue("Key not in keys list: android.sensor.profileHueSatMapDimensions", allKeys.contains(
+ CameraCharacteristics.SENSOR_PROFILE_HUE_SAT_MAP_DIMENSIONS));
+
+ }
+
+ }
+ }
+
public void testCameraCharacteristicsAndroidSensorAvailableTestPatternModes() throws Exception {
String[] ids = mCameraManager.getCameraIdList();
for (int i = 0; i < ids.length; i++) {
@@ -966,6 +1185,29 @@
}
}
+ public void testCameraCharacteristicsAndroidSensorInfoPixelArraySize() throws Exception {
+ String[] ids = mCameraManager.getCameraIdList();
+ for (int i = 0; i < ids.length; i++) {
+ CameraCharacteristics props = mCameraManager.getCameraCharacteristics(ids[i]);
+ assertNotNull(String.format("Can't get camera characteristics from: ID %s", ids[i]),
+ props);
+
+ {
+
+ assertNotNull("Invalid property: android.sensor.info.pixelArraySize",
+ props.get(CameraCharacteristics.SENSOR_INFO_PIXEL_ARRAY_SIZE));
+
+ List<Key<?>> allKeys = props.getKeys();
+ assertNotNull(String.format("Can't get camera characteristics keys from: ID %s",
+ ids[i], props));
+ assertTrue("Key not in keys list: android.sensor.info.pixelArraySize", allKeys.contains(
+ CameraCharacteristics.SENSOR_INFO_PIXEL_ARRAY_SIZE));
+
+ }
+
+ }
+ }
+
public void testCameraCharacteristicsAndroidStatisticsInfoAvailableFaceDetectModes() throws Exception {
String[] ids = mCameraManager.getCameraIdList();
for (int i = 0; i < ids.length; i++) {
diff --git a/tests/tests/keystore/src/android/keystore/cts/AndroidKeyPairGeneratorTest.java b/tests/tests/keystore/src/android/keystore/cts/AndroidKeyPairGeneratorTest.java
index cbfa34a..284ac83 100644
--- a/tests/tests/keystore/src/android/keystore/cts/AndroidKeyPairGeneratorTest.java
+++ b/tests/tests/keystore/src/android/keystore/cts/AndroidKeyPairGeneratorTest.java
@@ -406,6 +406,8 @@
final PublicKey pubKey = pair.getPublic();
assertNotNull("The PublicKey for the KeyPair should be not null", pubKey);
assertEquals(keyType, pubKey.getAlgorithm());
+ assertEquals("Public keys should be in X.509 format", "X.509", pubKey.getFormat());
+ assertNotNull("Public keys should be encodable", pubKey.getEncoded());
if ("DSA".equalsIgnoreCase(keyType)) {
DSAPublicKey dsaPubKey = (DSAPublicKey) pubKey;
@@ -434,6 +436,8 @@
final PrivateKey privKey = pair.getPrivate();
assertNotNull("The PrivateKey for the KeyPair should be not null", privKey);
assertEquals(keyType, privKey.getAlgorithm());
+ assertNull("getFormat() should return null", privKey.getFormat());
+ assertNull("getEncoded() should return null", privKey.getEncoded());
KeyStore.Entry entry = mKeyStore.getEntry(alias, null);
assertNotNull("Entry should exist", entry);
@@ -471,6 +475,9 @@
chain.length);
assertUsableInSSLConnection(privKey, x509userCert);
+
+ assertEquals("Retrieved key and generated key should be equal", privKey,
+ privEntry.getPrivateKey());
}
private static void assertUsableInSSLConnection(final PrivateKey privKey,
diff --git a/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java b/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java
index 4f8715e..2c926a8 100644
--- a/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java
+++ b/tests/tests/keystore/src/android/keystore/cts/AndroidKeyStoreTest.java
@@ -1468,20 +1468,29 @@
private void assertPrivateKeyEntryEquals(PrivateKeyEntry keyEntry, PrivateKey expectedKey,
Certificate expectedCert, Collection<Certificate> expectedChain) throws Exception {
+ final PrivateKey privKey = keyEntry.getPrivateKey();
+ final PublicKey pubKey = keyEntry.getCertificate().getPublicKey();
+
if (expectedKey instanceof DSAPrivateKey) {
assertEquals("Returned PrivateKey should be what we inserted",
((DSAPrivateKey) expectedKey).getParams(),
- ((DSAPublicKey) keyEntry.getCertificate().getPublicKey()).getParams());
+ ((DSAPublicKey) pubKey).getParams());
} else if (expectedKey instanceof ECPrivateKey) {
assertEquals("Returned PrivateKey should be what we inserted",
((ECPrivateKey) expectedKey).getParams().getCurve(),
- ((ECPublicKey) keyEntry.getCertificate().getPublicKey()).getParams().getCurve());
+ ((ECPublicKey) pubKey).getParams().getCurve());
} else if (expectedKey instanceof RSAPrivateKey) {
assertEquals("Returned PrivateKey should be what we inserted",
((RSAPrivateKey) expectedKey).getModulus(),
- ((RSAPrivateKey) keyEntry.getPrivateKey()).getModulus());
+ ((RSAPrivateKey) privKey).getModulus());
}
+ assertNull("getFormat() should return null", privKey.getFormat());
+ assertNull("getEncoded() should return null", privKey.getEncoded());
+
+ assertEquals("Public keys should be in X.509 format", "X.509", pubKey.getFormat());
+ assertNotNull("Public keys should be encodable", pubKey.getEncoded());
+
assertEquals("Returned Certificate should be what we inserted", expectedCert,
keyEntry.getCertificate());
diff --git a/tests/tests/media/src/android/media/cts/DecoderTest.java b/tests/tests/media/src/android/media/cts/DecoderTest.java
index c4c8465..0fd4ef4 100644
--- a/tests/tests/media/src/android/media/cts/DecoderTest.java
+++ b/tests/tests/media/src/android/media/cts/DecoderTest.java
@@ -42,6 +42,7 @@
private static final int RESET_MODE_NONE = 0;
private static final int RESET_MODE_RECONFIGURE = 1;
private static final int RESET_MODE_FLUSH = 2;
+ private static final int RESET_MODE_EOS_FLUSH = 3;
private static final String[] CSD_KEYS = new String[] { "csd-0", "csd-1" };
@@ -169,7 +170,8 @@
double rmse = Math.sqrt(avgErrorSquared);
assertTrue("decoding error too big: " + rmse, rmse <= maxerror);
- int[] resetModes = new int[] { RESET_MODE_NONE, RESET_MODE_RECONFIGURE, RESET_MODE_FLUSH };
+ int[] resetModes = new int[] { RESET_MODE_NONE, RESET_MODE_RECONFIGURE,
+ RESET_MODE_FLUSH, RESET_MODE_EOS_FLUSH };
int[] configModes = new int[] { CONFIG_MODE_NONE, CONFIG_MODE_QUEUE };
for (int conf : configModes) {
@@ -333,7 +335,8 @@
timestamps.add(info.presentationTimeUs);
}
}
- if (info.size > 0 && resetMode != RESET_MODE_NONE) {
+ if (info.size > 0 &&
+ resetMode != RESET_MODE_NONE && resetMode != RESET_MODE_EOS_FLUSH) {
// once we've gotten some data out of the decoder, reset and start again
if (resetMode == RESET_MODE_RECONFIGURE) {
codec.stop();
@@ -374,7 +377,20 @@
if ((info.flags & MediaCodec.BUFFER_FLAG_END_OF_STREAM) != 0) {
Log.d(TAG, "saw output EOS.");
- sawOutputEOS = true;
+ if (resetMode == RESET_MODE_EOS_FLUSH) {
+ resetMode = RESET_MODE_NONE;
+ codec.flush();
+ extractor.seekTo(0, MediaExtractor.SEEK_TO_NEXT_SYNC);
+ sawInputEOS = false;
+ samplecounter = 0;
+ decoded = new short[0];
+ decodedIdx = 0;
+ if (timestamps != null) {
+ timestamps.clear();
+ }
+ } else {
+ sawOutputEOS = true;
+ }
}
} else if (res == MediaCodec.INFO_OUTPUT_BUFFERS_CHANGED) {
codecOutputBuffers = codec.getOutputBuffers();
diff --git a/tests/tests/media/src/android/media/cts/MediaPlayerTest.java b/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
index 03a5cfd..3a082fd 100644
--- a/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
@@ -968,6 +968,41 @@
assertEquals(4, count);
}
+ /*
+ * This test assumes the resources being tested are between 8 and 14 seconds long
+ * The ones being used here are 10 seconds long.
+ */
+ public void testResumeAtEnd() throws Throwable {
+ testResumeAtEnd(R.raw.loudsoftmp3);
+ testResumeAtEnd(R.raw.loudsoftwav);
+ testResumeAtEnd(R.raw.loudsoftogg);
+ testResumeAtEnd(R.raw.loudsoftitunes);
+ testResumeAtEnd(R.raw.loudsoftfaac);
+ testResumeAtEnd(R.raw.loudsoftaac);
+ }
+
+ private void testResumeAtEnd(int res) throws Throwable {
+
+ loadResource(res);
+ mMediaPlayer.prepare();
+ mOnCompletionCalled.reset();
+ mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
+ @Override
+ public void onCompletion(MediaPlayer mp) {
+ mOnCompletionCalled.signal();
+ mMediaPlayer.start();
+ }
+ });
+ // skip the first part of the file so we reach EOF sooner
+ mMediaPlayer.seekTo(5000);
+ mMediaPlayer.start();
+ // sleep long enough that we restart playback at least once, but no more
+ Thread.sleep(10000);
+ assertTrue("MediaPlayer should still be playing", mMediaPlayer.isPlaying());
+ mMediaPlayer.reset();
+ assertEquals("wrong number of repetitions", 1, mOnCompletionCalled.getNumSignal());
+ }
+
public void testCallback() throws Throwable {
final int mp4Duration = 8484;
diff --git a/tests/tests/net/src/android/net/ipv6/cts/PingTest.java b/tests/tests/net/src/android/net/ipv6/cts/PingTest.java
index 41eb03d..acf474f 100644
--- a/tests/tests/net/src/android/net/ipv6/cts/PingTest.java
+++ b/tests/tests/net/src/android/net/ipv6/cts/PingTest.java
@@ -34,6 +34,21 @@
import java.util.Arrays;
import java.util.Random;
+/**
+ * Checks that the device has kernel support for the IPv6 ping socket. This allows ping6 to work
+ * without root privileges. The necessary kernel code is in Linux 3.11 or above, or the
+ * <code>common/android-3.x</code> kernel trees. If you are not running one of these kernels, the
+ * functionality can be obtained by cherry-picking the following patches from David Miller's
+ * <code>net-next</code> tree:
+ * <ul>
+ * <li>6d0bfe2 net: ipv6: Add IPv6 support to the ping socket.
+ * <li>c26d6b4 ping: always initialize ->sin6_scope_id and ->sin6_flowinfo
+ * <li>fbfe80c net: ipv6: fix wrong ping_v6_sendmsg return value
+ * <li>a1bdc45 net: ipv6: add missing lock in ping_v6_sendmsg
+ * <li>cf970c0 ping: prevent NULL pointer dereference on write to msg_name
+ * </ul>
+ * or the equivalent backports to the <code>common/android-3.x</code> trees.
+ */
public class PingTest extends AndroidTestCase {
/** Maximum size of the packets we're using to test. */
private static final int MAX_SIZE = 4096;
@@ -90,19 +105,25 @@
/**
* Checks that a socket has received a response appropriate to the specified packet.
*/
- private void checkResponse(FileDescriptor s,
- InetAddress dest, byte[] sent) throws ErrnoException, IOException {
- // Receive the response.
- InetSocketAddress from = new InetSocketAddress();
+ private void checkResponse(FileDescriptor s, InetAddress dest,
+ byte[] sent, boolean useRecvfrom) throws ErrnoException, IOException {
ByteBuffer responseBuffer = ByteBuffer.allocate(MAX_SIZE);
- int bytesRead = Libcore.os.recvfrom(s, responseBuffer, 0, from);
+ int bytesRead;
- // Check the source address and scope ID.
- assertTrue(from.getAddress() instanceof Inet6Address);
- Inet6Address fromAddress = (Inet6Address) from.getAddress();
- assertEquals(0, fromAddress.getScopeId());
- assertNull(fromAddress.getScopedInterface());
- assertEquals(dest.getHostAddress(), fromAddress.getHostAddress());
+ // Receive the response.
+ if (useRecvfrom) {
+ InetSocketAddress from = new InetSocketAddress();
+ bytesRead = Libcore.os.recvfrom(s, responseBuffer, 0, from);
+
+ // Check the source address and scope ID.
+ assertTrue(from.getAddress() instanceof Inet6Address);
+ Inet6Address fromAddress = (Inet6Address) from.getAddress();
+ assertEquals(0, fromAddress.getScopeId());
+ assertNull(fromAddress.getScopedInterface());
+ assertEquals(dest.getHostAddress(), fromAddress.getHostAddress());
+ } else {
+ bytesRead = Libcore.os.read(s, responseBuffer);
+ }
// Check the packet length.
assertEquals(sent.length, bytesRead);
@@ -135,8 +156,11 @@
for (int i = 0; i < NUM_PACKETS; i++) {
byte[] packet = pingPacket((int) (Math.random() * MAX_SIZE));
FileDescriptor s = createPingSocket();
+ // Use both recvfrom and read().
sendPing(s, ipv6Loopback, packet);
- checkResponse(s, ipv6Loopback, packet);
+ checkResponse(s, ipv6Loopback, packet, true);
+ sendPing(s, ipv6Loopback, packet);
+ checkResponse(s, ipv6Loopback, packet, false);
// Check closing the socket doesn't raise an exception.
Libcore.os.close(s);
}
diff --git a/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java b/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
index 2580dbe..7faea64 100644
--- a/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
@@ -407,6 +407,10 @@
* To pass this CTS test, a connected WiFi link is required.
*/
public void testWifiWatchdog() throws Exception {
+ if (!WifiFeature.isWifiSupported(getContext())) {
+ // skip the test if WiFi is not supported
+ return;
+ }
// Make sure WiFi is enabled
if (!mWifiManager.isWifiEnabled()) {
setWifiEnabled(true);
diff --git a/tests/tests/provider/src/android/provider/cts/ContactsContract_DataTest.java b/tests/tests/provider/src/android/provider/cts/ContactsContract_DataTest.java
index 7cfb183..bbfa259 100644
--- a/tests/tests/provider/src/android/provider/cts/ContactsContract_DataTest.java
+++ b/tests/tests/provider/src/android/provider/cts/ContactsContract_DataTest.java
@@ -26,10 +26,12 @@
import android.net.Uri;
import android.os.SystemClock;
import android.provider.ContactsContract;
+import android.provider.ContactsContract.CommonDataKinds.Callable;
import android.provider.ContactsContract.CommonDataKinds.Contactables;
import android.provider.ContactsContract.CommonDataKinds.Email;
import android.provider.ContactsContract.CommonDataKinds.Organization;
import android.provider.ContactsContract.CommonDataKinds.Phone;
+import android.provider.ContactsContract.CommonDataKinds.SipAddress;
import android.provider.ContactsContract.CommonDataKinds.StructuredName;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.Data;
@@ -49,6 +51,60 @@
private ContentResolver mResolver;
private ContactsContract_TestDataBuilder mBuilder;
+ private static ContentValues[] sContentValues = new ContentValues[7];
+ static {
+ ContentValues cv1 = new ContentValues();
+ cv1.put(Contacts.DISPLAY_NAME, "Hot Tamale");
+ cv1.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
+ cv1.put(Email.DATA, "tamale@acme.com");
+ cv1.put(Email.TYPE, Email.TYPE_HOME);
+ sContentValues[0] = cv1;
+
+ ContentValues cv2 = new ContentValues();
+ cv2.put(Contacts.DISPLAY_NAME, "Hot Tamale");
+ cv2.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
+ cv2.put(Phone.DATA, "510-123-5769");
+ cv2.put(Phone.TYPE, Phone.TYPE_HOME);
+ sContentValues[1] = cv2;
+
+ ContentValues cv3 = new ContentValues();
+ cv3.put(Contacts.DISPLAY_NAME, "Hot Tamale");
+ cv3.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
+ cv3.put(Email.DATA, "hot@google.com");
+ cv3.put(Email.TYPE, Email.TYPE_WORK);
+ sContentValues[2] = cv3;
+
+ ContentValues cv4 = new ContentValues();
+ cv4.put(Contacts.DISPLAY_NAME, "Cold Tamago");
+ cv4.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
+ cv4.put(Email.DATA, "eggs@farmers.org");
+ cv4.put(Email.TYPE, Email.TYPE_HOME);
+ sContentValues[3] = cv4;
+
+ ContentValues cv5 = new ContentValues();
+ cv5.put(Contacts.DISPLAY_NAME, "John Doe");
+ cv5.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
+ cv5.put(Email.DATA, "doeassociates@deer.com");
+ cv5.put(Email.TYPE, Email.TYPE_WORK);
+ sContentValues[4] = cv5;
+
+ ContentValues cv6 = new ContentValues();
+ cv6.put(Contacts.DISPLAY_NAME, "John Doe");
+ cv6.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
+ cv6.put(Phone.DATA, "518-354-1111");
+ cv6.put(Phone.TYPE, Phone.TYPE_HOME);
+ sContentValues[5] = cv6;
+
+ ContentValues cv7 = new ContentValues();
+ cv7.put(Contacts.DISPLAY_NAME, "Cold Tamago");
+ cv7.put(Data.MIMETYPE, SipAddress.CONTENT_ITEM_TYPE);
+ cv7.put(SipAddress.DATA, "mysip@sipaddress.com");
+ cv7.put(SipAddress.TYPE, SipAddress.TYPE_HOME);
+ sContentValues[6] = cv7;
+ }
+
+ private TestRawContact[] mRawContacts = new TestRawContact[3];
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -182,6 +238,37 @@
assertCursorStoredValuesWithRawContactsFilter(filterUri, ids, new ContentValues[0]);
}
+ /**
+ * Verifies that Callable.CONTENT_URI returns only data items that can be called (i.e.
+ * phone numbers and sip addresses)
+ */
+ public void testCallableUri_returnsCorrectDataRows() throws Exception {
+ long[] ids = setupContactablesTestData();
+ Uri uri = Callable.CONTENT_URI;
+ assertCursorStoredValuesWithRawContactsFilter(uri, ids, sContentValues[1],
+ sContentValues[5], sContentValues[6]);
+ }
+
+ public void testCallableFilterByNameOrOrganization_returnsCorrectDataRows() throws Exception {
+ long[] ids = setupContactablesTestData();
+ Uri uri = Uri.withAppendedPath(Callable.CONTENT_FILTER_URI, "doe");
+ // Only callables belonging to John Doe (name) and Cold Tamago (organization) are returned.
+ assertCursorStoredValuesWithRawContactsFilter(uri, ids, sContentValues[5],
+ sContentValues[6]);
+ }
+
+ public void testCallableFilterByNumber_returnsCorrectDataRows() throws Exception {
+ long[] ids = setupContactablesTestData();
+ Uri uri = Uri.withAppendedPath(Callable.CONTENT_FILTER_URI, "510");
+ assertCursorStoredValuesWithRawContactsFilter(uri, ids, sContentValues[1]);
+ }
+
+ public void testCallableFilterBySipAddress_returnsCorrectDataRows() throws Exception {
+ long[] ids = setupContactablesTestData();
+ Uri uri = Uri.withAppendedPath(Callable.CONTENT_FILTER_URI, "mysip");
+ assertCursorStoredValuesWithRawContactsFilter(uri, ids, sContentValues[6]);
+ }
+
public void testDataInsert_updatesContactLastUpdatedTimestamp() {
DatabaseAsserts.ContactIdPair ids = DatabaseAsserts.assertAndCreateContact(mResolver);
long baseTime = ContactUtil.queryContactLastUpdatedTimestamp(mResolver, ids.mContactId);
@@ -213,6 +300,70 @@
RawContactUtil.delete(mResolver, ids.mRawContactId, true);
}
+ /**
+ * Tests that specifying the {@link android.provider.ContactsContract#REMOVE_DUPLICATE_ENTRIES}
+ * boolean parameter correctly results in deduped phone numbers.
+ */
+ public void testPhoneQuery_removeDuplicateEntries() throws Exception{
+ long[] ids = setupContactablesTestData();
+
+ // Insert duplicate data entry for raw contact 3. (existing phone number 518-354-1111)
+ mRawContacts[2].newDataRow(Phone.CONTENT_ITEM_TYPE)
+ .with(Phone.DATA, "518-354-1111")
+ .with(Phone.TYPE, Phone.TYPE_HOME)
+ .insert();
+
+ ContentValues dupe = new ContentValues();
+ dupe.put(Contacts.DISPLAY_NAME, "John Doe");
+ dupe.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
+ dupe.put(Phone.DATA, "518-354-1111");
+ dupe.put(Phone.TYPE, Phone.TYPE_HOME);
+
+ // Query for all phone numbers in the contacts database (without deduping).
+ // The phone number above should be listed twice, in its duplicated forms.
+ assertCursorStoredValuesWithRawContactsFilter(Phone.CONTENT_URI, ids, sContentValues[1],
+ sContentValues[5], dupe);
+
+ // Now query for all phone numbers in the contacts database but request deduping.
+ // The phone number should now be listed only once.
+ Uri uri = Phone.CONTENT_URI.buildUpon().
+ appendQueryParameter(ContactsContract.REMOVE_DUPLICATE_ENTRIES, "true").build();
+ assertCursorStoredValuesWithRawContactsFilter(uri, ids, sContentValues[1],
+ sContentValues[5]);
+ }
+
+ /**
+ * Tests that specifying the {@link android.provider.ContactsContract#REMOVE_DUPLICATE_ENTRIES}
+ * boolean parameter correctly results in deduped email addresses.
+ */
+ public void testEmailQuery_removeDuplicateEntries() throws Exception{
+ long[] ids = setupContactablesTestData();
+
+ // Insert duplicate data entry for raw contact 3. (existing email doeassociates@deer.com)
+ mRawContacts[2].newDataRow(Email.CONTENT_ITEM_TYPE)
+ .with(Email.DATA, "doeassociates@deer.com")
+ .with(Email.TYPE, Email.TYPE_WORK)
+ .insert();
+
+ ContentValues dupe = new ContentValues();
+ dupe.put(Contacts.DISPLAY_NAME, "John Doe");
+ dupe.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
+ dupe.put(Email.DATA, "doeassociates@deer.com");
+ dupe.put(Email.TYPE, Email.TYPE_WORK);
+
+ // Query for all email addresses in the contacts database (without deduping).
+ // The email address above should be listed twice, in its duplicated forms.
+ assertCursorStoredValuesWithRawContactsFilter(Email.CONTENT_URI, ids, sContentValues[0],
+ sContentValues[2], sContentValues[3], sContentValues[4], dupe);
+
+ // Now query for all email addresses in the contacts database but request deduping.
+ // The email address should now be listed only once.
+ Uri uri = Email.CONTENT_URI.buildUpon().
+ appendQueryParameter(ContactsContract.REMOVE_DUPLICATE_ENTRIES, "true").build();
+ assertCursorStoredValuesWithRawContactsFilter(uri, ids, sContentValues[0],
+ sContentValues[2], sContentValues[3], sContentValues[4]);
+ }
+
public void testDataUpdate_updatesContactLastUpdatedTimestamp() {
DatabaseAsserts.ContactIdPair ids = DatabaseAsserts.assertAndCreateContact(mResolver);
long dataId = createData(ids.mRawContactId);
@@ -277,6 +428,7 @@
.with(Phone.DATA, "510-123-5769")
.with(Email.TYPE, Phone.TYPE_HOME)
.insert();
+ mRawContacts[0] = rawContact;
TestRawContact rawContact2 = mBuilder.newRawContact()
.with(RawContacts.ACCOUNT_TYPE, "test_account")
@@ -289,6 +441,14 @@
.with(Email.DATA, "eggs@farmers.org")
.with(Email.TYPE, Email.TYPE_HOME)
.insert();
+ rawContact2.newDataRow(SipAddress.CONTENT_ITEM_TYPE)
+ .with(SipAddress.DATA, "mysip@sipaddress.com")
+ .with(SipAddress.TYPE, SipAddress.TYPE_HOME)
+ .insert();
+ rawContact2.newDataRow(Organization.CONTENT_ITEM_TYPE)
+ .with(Organization.COMPANY, "Doe Corp")
+ .insert();
+ mRawContacts[1] = rawContact2;
TestRawContact rawContact3 = mBuilder.newRawContact()
.with(RawContacts.ACCOUNT_TYPE, "test_account")
@@ -308,55 +468,12 @@
rawContact3.newDataRow(Organization.CONTENT_ITEM_TYPE)
.with(Organization.DATA, "Doe Industries")
.insert();
+ mRawContacts[2] = rawContact3;
return new long[] {rawContact.getId(), rawContact2.getId(), rawContact3.getId()};
}
// Provides functionality to set up content values for the Contactables tests
private static class ContactablesTestHelper {
- private static ContentValues[] sContentValues = new ContentValues[6];
- static {
- ContentValues cv1 = new ContentValues();
- cv1.put(Contacts.DISPLAY_NAME, "Hot Tamale");
- cv1.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
- cv1.put(Email.DATA, "tamale@acme.com");
- cv1.put(Email.TYPE, Email.TYPE_HOME);
- sContentValues[0] = cv1;
-
- ContentValues cv2 = new ContentValues();
- cv2.put(Contacts.DISPLAY_NAME, "Hot Tamale");
- cv2.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
- cv2.put(Phone.DATA, "510-123-5769");
- cv2.put(Phone.TYPE, Phone.TYPE_HOME);
- sContentValues[1] = cv2;
-
- ContentValues cv3 = new ContentValues();
- cv3.put(Contacts.DISPLAY_NAME, "Hot Tamale");
- cv3.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
- cv3.put(Email.DATA, "hot@google.com");
- cv3.put(Email.TYPE, Email.TYPE_WORK);
- sContentValues[2] = cv3;
-
- ContentValues cv4 = new ContentValues();
- cv4.put(Contacts.DISPLAY_NAME, "Cold Tamago");
- cv4.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
- cv4.put(Email.DATA, "eggs@farmers.org");
- cv4.put(Email.TYPE, Email.TYPE_HOME);
- sContentValues[3] = cv4;
-
- ContentValues cv5 = new ContentValues();
- cv5.put(Contacts.DISPLAY_NAME, "John Doe");
- cv5.put(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE);
- cv5.put(Email.DATA, "doeassociates@deer.com");
- cv5.put(Email.TYPE, Email.TYPE_WORK);
- sContentValues[4] = cv5;
-
- ContentValues cv6 = new ContentValues();
- cv6.put(Contacts.DISPLAY_NAME, "John Doe");
- cv6.put(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE);
- cv6.put(Phone.DATA, "518-354-1111");
- cv6.put(Phone.TYPE, Phone.TYPE_HOME);
- sContentValues[5] = cv6;
- }
/**
* @return An arraylist of contentValues that correspond to the provided raw contacts
diff --git a/tests/tests/provider/src/android/provider/cts/ContactsTest.java b/tests/tests/provider/src/android/provider/cts/ContactsTest.java
index b496007..db1c4f7 100644
--- a/tests/tests/provider/src/android/provider/cts/ContactsTest.java
+++ b/tests/tests/provider/src/android/provider/cts/ContactsTest.java
@@ -413,7 +413,10 @@
final String[] CALLS_PROJECTION = new String[] {
Calls._ID, Calls.NUMBER, Calls.DATE, Calls.DURATION, Calls.TYPE,
Calls.NEW, Calls.CACHED_NAME, Calls.CACHED_NUMBER_TYPE,
- Calls.CACHED_NUMBER_LABEL};
+ Calls.CACHED_NUMBER_LABEL, Calls.CACHED_FORMATTED_NUMBER,
+ Calls.CACHED_MATCHED_NUMBER, Calls.CACHED_NORMALIZED_NUMBER,
+ Calls.CACHED_LOOKUP_URI, Calls.CACHED_PHOTO_ID, Calls.COUNTRY_ISO,
+ Calls.GEOCODED_LOCATION};
final int ID_INDEX = 0;
final int NUMBER_INDEX = 1;
final int DATE_INDEX = 2;
@@ -423,15 +426,30 @@
final int CACHED_NAME_INDEX = 6;
final int CACHED_NUMBER_TYPE_INDEX = 7;
final int CACHED_NUMBER_LABEL_INDEX = 8;
+ final int CACHED_FORMATTED_NUMBER_INDEX = 9;
+ final int CACHED_MATCHED_NUMBER_INDEX = 10;
+ final int CACHED_NORMALIZED_NUMBER_INDEX = 11;
+ final int CACHED_LOOKUP_URI_INDEX = 12;
+ final int CACHED_PHOTO_ID_INDEX = 13;
+ final int COUNTRY_ISO_INDEX = 14;
+ final int GEOCODED_LOCATION_INDEX = 15;
String insertCallsNumber = "0123456789";
int insertCallsDuration = 120;
String insertCallsName = "cached_name_insert";
String insertCallsNumberLabel = "cached_label_insert";
- String updateCallsNumber = "9876543210";
+
+ String updateCallsNumber = "987654321";
int updateCallsDuration = 310;
String updateCallsName = "cached_name_update";
String updateCallsNumberLabel = "cached_label_update";
+ String updateCachedFormattedNumber = "987-654-4321";
+ String updateCachedMatchedNumber = "987-654-4321";
+ String updateCachedNormalizedNumber = "+1987654321";
+ String updateCachedLookupUri = "cached_lookup_uri_update";
+ long updateCachedPhotoId = 100;
+ String updateCountryIso = "hk";
+ String updateGeocodedLocation = "Hong Kong";
try {
// Test: insert
@@ -463,7 +481,8 @@
int id = cursor.getInt(ID_INDEX);
cursor.close();
- // Test: update
+ // Test: update. Also add new cached fields to simulate extra cached fields being
+ // inserted into the call log after the initial lookup.
int now = (int) new Date().getTime();
value.clear();
value.put(Calls.NUMBER, updateCallsNumber);
@@ -474,6 +493,13 @@
value.put(Calls.CACHED_NAME, updateCallsName);
value.put(Calls.CACHED_NUMBER_TYPE, Phones.TYPE_CUSTOM);
value.put(Calls.CACHED_NUMBER_LABEL, updateCallsNumberLabel);
+ value.put(Calls.CACHED_FORMATTED_NUMBER, updateCachedFormattedNumber);
+ value.put(Calls.CACHED_MATCHED_NUMBER, updateCachedMatchedNumber);
+ value.put(Calls.CACHED_NORMALIZED_NUMBER, updateCachedNormalizedNumber);
+ value.put(Calls.CACHED_PHOTO_ID, updateCachedPhotoId);
+ value.put(Calls.COUNTRY_ISO, updateCountryIso);
+ value.put(Calls.GEOCODED_LOCATION, updateGeocodedLocation);
+ value.put(Calls.CACHED_LOOKUP_URI, updateCachedLookupUri);
mCallLogProvider.update(uri, value, null, null);
cursor = mCallLogProvider.query(Calls.CONTENT_URI, CALLS_PROJECTION,
@@ -487,6 +513,15 @@
assertEquals(updateCallsName, cursor.getString(CACHED_NAME_INDEX));
assertEquals(Phones.TYPE_CUSTOM, cursor.getInt(CACHED_NUMBER_TYPE_INDEX));
assertEquals(updateCallsNumberLabel, cursor.getString(CACHED_NUMBER_LABEL_INDEX));
+ assertEquals(updateCachedFormattedNumber,
+ cursor.getString(CACHED_FORMATTED_NUMBER_INDEX));
+ assertEquals(updateCachedMatchedNumber, cursor.getString(CACHED_MATCHED_NUMBER_INDEX));
+ assertEquals(updateCachedNormalizedNumber,
+ cursor.getString(CACHED_NORMALIZED_NUMBER_INDEX));
+ assertEquals(updateCachedPhotoId, cursor.getLong(CACHED_PHOTO_ID_INDEX));
+ assertEquals(updateCountryIso, cursor.getString(COUNTRY_ISO_INDEX));
+ assertEquals(updateGeocodedLocation, cursor.getString(GEOCODED_LOCATION_INDEX));
+ assertEquals(updateCachedLookupUri, cursor.getString(CACHED_LOOKUP_URI_INDEX));
cursor.close();
// Test: delete
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
index 433b7e6..8e82f1f 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
@@ -470,7 +470,6 @@
s.set_dimY(Y);
typeBuilder.setX(X).setY(Y);
Allocation A = Allocation.createTyped(mRS, typeBuilder.create());
- s.bind_a(A);
s.set_aRaw(A);
s.forEach_root(A);
s.invoke_verify_root();
@@ -478,6 +477,7 @@
s.invoke_verify_foo();
s.invoke_foreach_test();
mRS.finish();
+ checkForErrors();
waitForMessage();
}
@@ -491,7 +491,6 @@
s.set_dimY(Y);
typeBuilder.setX(X).setY(Y);
Allocation A = Allocation.createTyped(mRS, typeBuilder.create());
- s.bind_a(A);
s.set_aRaw(A);
s.forEach_foo(A, A);
s.invoke_verify_foo();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/KernelTest.java b/tests/tests/renderscript/src/android/renderscript/cts/KernelTest.java
index 56b5e89..dcfc0ba 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/KernelTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/KernelTest.java
@@ -470,7 +470,6 @@
s.set_dimY(Y);
typeBuilder.setX(X).setY(Y);
Allocation A = Allocation.createTyped(mRS, typeBuilder.create());
- s.bind_a(A);
s.set_aRaw(A);
s.forEach_root(A);
s.invoke_verify_root();
@@ -478,6 +477,7 @@
s.invoke_verify_foo();
s.invoke_foreach_test();
mRS.finish();
+ checkForErrors();
waitForMessage();
}
@@ -491,7 +491,6 @@
s.set_dimY(Y);
typeBuilder.setX(X).setY(Y);
Allocation A = Allocation.createTyped(mRS, typeBuilder.create());
- s.bind_a(A);
s.set_aRaw(A);
s.forEach_foo(A, A);
s.invoke_verify_foo();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/PowTest.java b/tests/tests/renderscript/src/android/renderscript/cts/PowTest.java
index ad3d078..967e52b 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/PowTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/PowTest.java
@@ -88,8 +88,8 @@
}
@Override
- protected void fillRandomFloats(long seed, int fact, int offset, float[] inArray) {
- RSUtils.genRandomFloats(seed, 32, -16, inArray);
+ protected void fillRandomFloats(long seed, float min, float max, float[] inArray) {
+ RSUtils.genRandomFloats(seed, -16.0f, 16.0f, inArray);
}
public void testPowF32() {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/PownTest.java b/tests/tests/renderscript/src/android/renderscript/cts/PownTest.java
index 32308ce..6a47d8f 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/PownTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/PownTest.java
@@ -82,7 +82,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32(mRS), INPUTSIZE);
n = new int[INPUTSIZE];
- RSUtils.genRandomInts(0x12345678, 32, -16, n);
+ RSUtils.genRandomInts(0x12345678, -16, 15, n);
nAlloc.copyFrom(n);
script_f32.set_n1(nAlloc);
@@ -93,7 +93,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32(mRS), INPUTSIZE);
n = new int[INPUTSIZE];
- RSUtils.genRandomInts(0x12345678, 32, -16, n);
+ RSUtils.genRandomInts(0x12345678, -16, 15, n);
nAlloc.copyFrom(n);
script_f32_relaxed.set_n1(nAlloc);
@@ -104,7 +104,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_2(mRS), INPUTSIZE);
n = new int[INPUTSIZE*2];
- RSUtils.genRandomInts(0xacdef1, 32, -16, n);
+ RSUtils.genRandomInts(0xacdef1, -16, 15, n);
nAlloc.copyFrom(n);
script_f32.set_n2(nAlloc);
@@ -115,7 +115,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_2(mRS), INPUTSIZE);
n = new int[INPUTSIZE*2];
- RSUtils.genRandomInts(0xacdef1, 32, -16, n);
+ RSUtils.genRandomInts(0xacdef1, -16, 15, n);
nAlloc.copyFrom(n);
script_f32_relaxed.set_n2(nAlloc);
@@ -126,7 +126,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_3(mRS), INPUTSIZE);
n = new int[INPUTSIZE*4];
- RSUtils.genRandomInts(0xa123f1, 32, -16, n);
+ RSUtils.genRandomInts(0xa123f1, -16, 15, n);
nAlloc.copyFrom(n);
script_f32.set_n3(nAlloc);
@@ -137,7 +137,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_3(mRS), INPUTSIZE);
n = new int[INPUTSIZE*4];
- RSUtils.genRandomInts(0xa123f1, 32, -16, n);
+ RSUtils.genRandomInts(0xa123f1, -16, 15, n);
nAlloc.copyFrom(n);
script_f32_relaxed.set_n3(nAlloc);
@@ -148,7 +148,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_4(mRS), INPUTSIZE);
n = new int[INPUTSIZE*4];
- RSUtils.genRandomInts(0x4323ca, 32, -16, n);
+ RSUtils.genRandomInts(0x4323ca, -16, 15, n);
nAlloc.copyFrom(n);
script_f32.set_n4(nAlloc);
@@ -159,7 +159,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_4(mRS), INPUTSIZE);
n = new int[INPUTSIZE*4];
- RSUtils.genRandomInts(0x4323ca, 32, -16, n);
+ RSUtils.genRandomInts(0x4323ca, -16, 15, n);
nAlloc.copyFrom(n);
script_f32_relaxed.set_n4(nAlloc);
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/PowrTest.java b/tests/tests/renderscript/src/android/renderscript/cts/PowrTest.java
index cebbe24..a957418 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/PowrTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/PowrTest.java
@@ -88,8 +88,8 @@
}
@Override
- protected void fillRandomFloats(long seed, int fact, int offset, float[] inArray) {
- RSUtils.genRandomFloats(seed, 64, 0, inArray);
+ protected void fillRandomFloats(long seed, float min, float max, float[] inArray) {
+ RSUtils.genRandomFloats(seed, 0.0f, 64.0f, inArray);
}
public void testPowrF32() {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RSBaseCompute.java b/tests/tests/renderscript/src/android/renderscript/cts/RSBaseCompute.java
index d7759f1..f2554c4 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/RSBaseCompute.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RSBaseCompute.java
@@ -85,11 +85,11 @@
}
}
- private void baseTestHelper(int testid, Element inElement, Element outElement, long seed, int fact,
- int offset, int rStride, int rSkip, int refStride, int outStride,
+ private void baseTestHelper(int testid, Element inElement, Element outElement, long seed, float min,
+ float max, int rStride, int rSkip, int refStride, int outStride,
int inStride, int skip, int ulp) {
float[] inArray = makeInArray(INPUTSIZE * inStride);
- fillRandomFloats(seed, fact, offset, inArray);
+ fillRandomFloats(seed, min, max, inArray);
float[] refArray = getRefArray(inArray, INPUTSIZE, inStride, skip);
Allocation mAllocationIn = setInAlloc(inElement);
@@ -108,39 +108,39 @@
}
public void baseTest(int testid, long seed, int refStride, int outStride, int inStride, int skip, int ulp) {
- baseTestHelper(testid, null, null, seed, 1, 0, 1, 0, refStride, outStride, inStride, skip, ulp);
+ baseTestHelper(testid, null, null, seed, 0.0f, 1.0f, 1, 0, refStride, outStride, inStride, skip, ulp);
}
public void doF32(long seed, int ulp) {
- baseTestHelper(TEST_F32, Element.F32(mRS), Element.F32(mRS), seed, 1, 0, 1, 0, 1, 1, 1, 0, ulp);
+ baseTestHelper(TEST_F32, Element.F32(mRS), Element.F32(mRS), seed, 0.0f, 1.0f, 1, 0, 1, 1, 1, 0, ulp);
}
public void doF32_2(long seed, int ulp) {
- baseTestHelper(TEST_F32_2, Element.F32_2(mRS), Element.F32_2(mRS), seed, 1, 0, 1, 0, 2, 2, 2, 0, ulp);
+ baseTestHelper(TEST_F32_2, Element.F32_2(mRS), Element.F32_2(mRS), seed, 0.0f, 1.0f, 1, 0, 2, 2, 2, 0, ulp);
}
public void doF32_3(long seed, int ulp) {
- baseTestHelper(TEST_F32_3, Element.F32_3(mRS), Element.F32_3(mRS), seed, 1, 0, 4, 1, 3, 4, 4, 1, ulp);
+ baseTestHelper(TEST_F32_3, Element.F32_3(mRS), Element.F32_3(mRS), seed, 0.0f, 1.0f, 4, 1, 3, 4, 4, 1, ulp);
}
public void doF32_4(long seed, int ulp) {
- baseTestHelper(TEST_F32_4, Element.F32_4(mRS), Element.F32_4(mRS), seed, 1, 0, 1, 0, 4, 4, 4, 0, ulp);
+ baseTestHelper(TEST_F32_4, Element.F32_4(mRS), Element.F32_4(mRS), seed, 0.0f, 1.0f, 1, 0, 4, 4, 4, 0, ulp);
}
public void doF32_relaxed(long seed, int ulp) {
- baseTestHelper(TEST_RELAXED_F32, Element.F32(mRS), Element.F32(mRS), seed, 1, 0, 1, 0, 1, 1, 1, 0, ulp);
+ baseTestHelper(TEST_RELAXED_F32, Element.F32(mRS), Element.F32(mRS), seed, 0.0f, 1.0f, 1, 0, 1, 1, 1, 0, ulp);
}
public void doF32_2_relaxed(long seed, int ulp) {
- baseTestHelper(TEST_RELAXED_F32_2, Element.F32_2(mRS), Element.F32_2(mRS), seed, 1, 0, 1, 0, 2, 2, 2, 0, ulp);
+ baseTestHelper(TEST_RELAXED_F32_2, Element.F32_2(mRS), Element.F32_2(mRS), seed, 0.0f, 1.0f, 1, 0, 2, 2, 2, 0, ulp);
}
public void doF32_3_relaxed(long seed, int ulp) {
- baseTestHelper(TEST_RELAXED_F32_3, Element.F32_3(mRS), Element.F32_3(mRS), seed, 1, 0, 4, 1, 3, 4, 4, 1, ulp);
+ baseTestHelper(TEST_RELAXED_F32_3, Element.F32_3(mRS), Element.F32_3(mRS), seed, 0.0f, 1.0f, 4, 1, 3, 4, 4, 1, ulp);
}
public void doF32_4_relaxed(long seed, int ulp) {
- baseTestHelper(TEST_RELAXED_F32_4, Element.F32_4(mRS), Element.F32_4(mRS), seed, 1, 0, 1, 0, 4, 4, 4, 0, ulp);
+ baseTestHelper(TEST_RELAXED_F32_4, Element.F32_4(mRS), Element.F32_4(mRS), seed, 0.0f, 1.0f, 1, 0, 4, 4, 4, 0, ulp);
}
@@ -173,8 +173,8 @@
return new float[size];
}
- protected void fillRandomFloats(long seed, int fact, int offset, float[] inArray) {
- RSUtils.genRandomFloats(seed, fact, offset, inArray);
+ protected void fillRandomFloats(long seed, float min, float max, float[] inArray) {
+ RSUtils.genRandomFloats(seed, min, max, inArray);
}
protected void fillInAlloc(Allocation mIn, float[] inArray) {
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RSUtils.java b/tests/tests/renderscript/src/android/renderscript/cts/RSUtils.java
index d3fb5d0..9165bdb 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/RSUtils.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RSUtils.java
@@ -28,22 +28,24 @@
public class RSUtils {
/**
- * Fills the array with random floats. Values will be: offset + number between 0 and max.
+ * Fills the array with random floats. Values will be between min (inclusive) and
+ * max (inclusive).
*/
- public static void genRandomFloats(long seed, int max, int offset, float array[]) {
+ public static void genRandomFloats(long seed, float min, float max, float array[]) {
Random r = new Random(seed);
for (int i = 0; i < array.length; i++) {
- array[i] = r.nextFloat() * max + offset;
+ array[i] = min + r.nextFloat() * (max - min);
}
}
/**
- * Fills the array with random ints. Values will be: offset + number between 0 and max (exclusive).
+ * Fills the array with random floats. Values will be between min (inclusive) and
+ * max (inclusive).
*/
- public static void genRandomInts(long seed, int max, int offset, int array[]) {
+ public static void genRandomInts(long seed, int min, int max, int array[]) {
Random r = new Random(seed);
for (int i = 0; i < array.length; i++) {
- array[i] = (r.nextInt(max) + offset);
+ array[i] = min + r.nextInt(max - min + 1);
}
}
}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RootnTest.java b/tests/tests/renderscript/src/android/renderscript/cts/RootnTest.java
index 2c447bb..a253669 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/RootnTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RootnTest.java
@@ -80,7 +80,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32(mRS), INPUTSIZE);
n = new int[INPUTSIZE];
- RSUtils.genRandomInts(0x12345678, 32, 1, n);
+ RSUtils.genRandomInts(0x12345678, 1, 32, n);
nAlloc.copyFrom(n);
script_f32.set_n1(nAlloc);
@@ -91,7 +91,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32(mRS), INPUTSIZE);
n = new int[INPUTSIZE];
- RSUtils.genRandomInts(0x12345678, 32, 1, n);
+ RSUtils.genRandomInts(0x12345678, 1, 32, n);
nAlloc.copyFrom(n);
script_f32_relaxed.set_n1(nAlloc);
@@ -103,7 +103,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_2(mRS), INPUTSIZE);
n = new int[INPUTSIZE*2];
- RSUtils.genRandomInts(0xacdef1, 32, 1, n);
+ RSUtils.genRandomInts(0xacdef1, 1, 32, n);
nAlloc.copyFrom(n);
script_f32.set_n2(nAlloc);
@@ -114,7 +114,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_2(mRS), INPUTSIZE);
n = new int[INPUTSIZE*2];
- RSUtils.genRandomInts(0xacdef1, 32, 1, n);
+ RSUtils.genRandomInts(0xacdef1, 1, 32, n);
nAlloc.copyFrom(n);
script_f32_relaxed.set_n2(nAlloc);
@@ -126,7 +126,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_3(mRS), INPUTSIZE);
n = new int[INPUTSIZE*4];
- RSUtils.genRandomInts(0xa123f1, 32, 1, n);
+ RSUtils.genRandomInts(0xa123f1, 1, 32, n);
nAlloc.copyFrom(n);
script_f32.set_n3(nAlloc);
@@ -137,7 +137,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_3(mRS), INPUTSIZE);
n = new int[INPUTSIZE*4];
- RSUtils.genRandomInts(0xa123f1, 32, 1, n);
+ RSUtils.genRandomInts(0xa123f1, 1, 32, n);
nAlloc.copyFrom(n);
script_f32_relaxed.set_n3(nAlloc);
@@ -148,7 +148,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_4(mRS), INPUTSIZE);
n = new int[INPUTSIZE*4];
- RSUtils.genRandomInts(0x4323ca, 32, 1, n);
+ RSUtils.genRandomInts(0x4323ca, 1, 32, n);
nAlloc.copyFrom(n);
script_f32.set_n4(nAlloc);
@@ -159,7 +159,7 @@
Allocation nAlloc = Allocation.createSized(mRS, Element.I32_4(mRS), INPUTSIZE);
n = new int[INPUTSIZE*4];
- RSUtils.genRandomInts(0x4323ca, 32, 1, n);
+ RSUtils.genRandomInts(0x4323ca, 1, 32, n);
nAlloc.copyFrom(n);
script_f32_relaxed.set_n4(nAlloc);
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RsPackColorTo8888Test.java b/tests/tests/renderscript/src/android/renderscript/cts/RsPackColorTo8888Test.java
index edff5b9..328160a 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/RsPackColorTo8888Test.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RsPackColorTo8888Test.java
@@ -72,7 +72,7 @@
float[] inArray = new float[INPUTSIZE * 4];
byte[] outArray = new byte[INPUTSIZE * 4];
byte[] refArray = new byte[INPUTSIZE * 4];
- RSUtils.genRandomFloats(seed, 1, 0, inArray);
+ RSUtils.genRandomFloats(seed, 0.0f, 1.0f, inArray);
mAllocationIn.copy1DRangeFrom(0, INPUTSIZE, inArray);
try {
forEach(testId, mAllocationIn, mAllocationOut);
@@ -99,7 +99,7 @@
float[] inArray = new float[INPUTSIZE * 4];
byte[] outArray = new byte[INPUTSIZE * 4];
byte[] refArray = new byte[INPUTSIZE * 4];
- RSUtils.genRandomFloats(seed, 1, 0, inArray);
+ RSUtils.genRandomFloats(seed, 0.0f, 1.0f, inArray);
mAllocationIn.copy1DRangeFrom(0, INPUTSIZE, inArray);
try {
forEach(testId, mAllocationIn, mAllocationOut);
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java b/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java
index 3c8650d..1729aeb 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java
@@ -34,6 +34,36 @@
Allocation mAlloc_RGBA_1D;
Allocation mAlloc_RGBA_2D;
+ Allocation createAlloc(Type t) {
+ Allocation a = Allocation.createTyped(mRS, t, Allocation.MipmapControl.MIPMAP_FULL,
+ Allocation.USAGE_SCRIPT);
+
+ int[] tmp = new int[t.getCount()];
+ int idx = 0;
+ int w = t.getY();
+ if (w < 1) {
+ w = 1;
+ }
+
+ for (int ct = 0; ct < (8 * w); ct++) {
+ tmp[idx++] = 0x0000ffff;
+ }
+ w = (w + 1) >> 1;
+ for (int ct = 0; ct < (4 * w); ct++) {
+ tmp[idx++] = 0x00ff00ff;
+ }
+ w = (w + 1) >> 1;
+ for (int ct = 0; ct < (2 * w); ct++) {
+ tmp[idx++] = 0x00ffff00;
+ }
+ w = (w + 1) >> 1;
+ for (int ct = 0; ct < (1 * 1); ct++) {
+ tmp[idx++] = 0xffffff00;
+ }
+ a.copyFromUnchecked(tmp);
+ return a;
+ }
+
@Override
protected void setUp() throws Exception {
super.setUp();
@@ -41,18 +71,10 @@
Element format = Element.RGBA_8888(mRS);
Type.Builder b = new Type.Builder(mRS, format);
b.setMipmaps(true);
- mAlloc_RGBA_1D = Allocation.createTyped(mRS, b.setX(8).create(),
- Allocation.MipmapControl.MIPMAP_FULL,
- Allocation.USAGE_SCRIPT);
- mAlloc_RGBA_2D = Allocation.createTyped(mRS, b.setX(8).setY(8).create(),
- Allocation.MipmapControl.MIPMAP_FULL,
- Allocation.USAGE_SCRIPT);
+ mAlloc_RGBA_1D = createAlloc(b.setX(8).create());
+ mAlloc_RGBA_2D = createAlloc(b.setX(8).setY(8).create());
mScript = new ScriptC_sample(mRS, mRes, R.raw.sample);
- mScript.bind_gAllocPtr(mAlloc_RGBA_1D);
- mScript.invoke_init_RGBA(mAlloc_RGBA_1D);
- mScript.bind_gAllocPtr(mAlloc_RGBA_2D);
- mScript.invoke_init_RGBA(mAlloc_RGBA_2D);
mScript.set_gNearest(Sampler.CLAMP_NEAREST(mRS));
mScript.set_gLinear(Sampler.CLAMP_LINEAR(mRS));
diff --git a/tests/tests/view/src/android/view/cts/LayoutInflaterTest.java b/tests/tests/view/src/android/view/cts/LayoutInflaterTest.java
index 66a86c3..f5247dd 100644
--- a/tests/tests/view/src/android/view/cts/LayoutInflaterTest.java
+++ b/tests/tests/view/src/android/view/cts/LayoutInflaterTest.java
@@ -43,20 +43,21 @@
import android.widget.LinearLayout;
public class LayoutInflaterTest extends AndroidTestCase {
-
private LayoutInflater mLayoutInflater;
- private Context mContext;
- private final Factory mFactory = new Factory() {
- public View onCreateView(String name, Context context,
- AttributeSet attrs) {
+ @SuppressWarnings("hiding")
+ private Context mContext;
+
+ private final Factory mFactory = new Factory() {
+ @Override
+ public View onCreateView(String name, Context context, AttributeSet attrs) {
return null;
}
};
private boolean isOnLoadClass;
private final Filter mFilter = new Filter() {
-
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
public boolean onLoadClass(Class clazz) {
isOnLoadClass = true;
return true;
@@ -149,7 +150,8 @@
mLayoutInflater = LayoutInflater.from(mContext);
isOnLoadClass = false;
mLayoutInflater.setFilter(new Filter() {
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
public boolean onLoadClass(Class clazz) {
isOnLoadClass = true;
return false;
@@ -367,6 +369,7 @@
View container = mLayoutInflater.inflate(R.layout.inflater_override_theme_layout, null);
verifyThemeType(container, "view_outer", R.id.view_outer, 1);
verifyThemeType(container, "view_inner", R.id.view_inner, 2);
+ verifyThemeType(container, "view_attr", R.id.view_attr, 3);
}
private void verifyThemeType(View container, String tag, int id, int type) {
@@ -376,7 +379,7 @@
Theme theme = view.getContext().getTheme();
boolean resolved = theme.resolveAttribute(R.attr.themeType, outValue, true);
assertTrue("Resolved themeType for " + tag, resolved);
- assertEquals(tag + " has themeType " + type, outValue.data, type);
+ assertEquals(tag + " has themeType " + type, type, outValue.data);
}
static class MockLayoutInflater extends LayoutInflater {
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
index 1027a59..458d5be 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewClientTest.java
@@ -126,6 +126,8 @@
childWebViewClient.getLastShouldOverrideUrl());
// Now test a navigation within the page
+ //TODO(hush) Enable this portion when b/12804986 is fixed.
+ /*
WebViewOnUiThread childWebViewOnUiThread = new WebViewOnUiThread(this, childWebView);
final int childCallCount = childWebViewClient.getShouldOverrideUrlLoadingCallCount();
final int mainCallCount = mainWebViewClient.getShouldOverrideUrlLoadingCallCount();
@@ -138,6 +140,7 @@
}.run();
assertEquals(mainCallCount, mainWebViewClient.getShouldOverrideUrlLoadingCallCount());
assertEquals(TEST_URL, childWebViewClient.getLastShouldOverrideUrl());
+ */
}
private void clickOnLinkUsingJs(final String linkId, WebViewOnUiThread webViewOnUiThread) {
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index cfe1a81..bb6944c 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -88,7 +88,11 @@
import java.util.HashMap;
import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpEntityEnclosingRequest;
import org.apache.http.HttpRequest;
+import org.apache.http.util.EncodingUtils;
+import org.apache.http.util.EntityUtils;
public class WebViewTest extends ActivityInstrumentationTestCase2<WebViewStubActivity> {
private static final String LOGTAG = "WebViewTest";
@@ -361,6 +365,36 @@
}
@UiThreadTest
+ public void testPostUrlWithNonNetworkUrl() throws Exception {
+ final String nonNetworkUrl = "file:///android_asset/" + TestHtmlConstants.HELLO_WORLD_URL;
+
+ mOnUiThread.postUrlAndWaitForCompletion(nonNetworkUrl, new byte[1]);
+
+ // Test if the nonNetworkUrl is loaded
+ assertEquals(TestHtmlConstants.HELLO_WORLD_TITLE, mWebView.getTitle());
+ }
+
+ @UiThreadTest
+ public void testPostUrlWithNetworkUrl() throws Exception {
+ startWebServer(false);
+ final String networkUrl = mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL);
+ final String postDataString = "username=my_username&password=my_password";
+ final byte[] postData = EncodingUtils.getBytes(postDataString, "BASE64");
+
+ mOnUiThread.postUrlAndWaitForCompletion(networkUrl, postData);
+
+ HttpRequest request = mWebServer.getLastRequest(TestHtmlConstants.HELLO_WORLD_URL);
+ // The last request should be POST
+ assertEquals(request.getRequestLine().getMethod(), "POST");
+
+ // The last request should have a request body
+ assertTrue(request instanceof HttpEntityEnclosingRequest);
+ HttpEntity entity = ((HttpEntityEnclosingRequest) request).getEntity();
+ String entityString = EntityUtils.toString(entity);
+ assertEquals(entityString, postDataString);
+ }
+
+ @UiThreadTest
public void testLoadUrlDoesNotStripParamsWhenLoadingContentUrls() throws Exception {
Uri.Builder uriBuilder = new Uri.Builder().scheme(
ContentResolver.SCHEME_CONTENT).authority(MockContentProvider.AUTHORITY);
diff --git a/tests/uiautomator/test-apps/CtsUiAutomatorApp/res/layout-land/test5_detail_fragment.xml b/tests/uiautomator/test-apps/CtsUiAutomatorApp/res/layout-land/test5_detail_fragment.xml
new file mode 100644
index 0000000..123ebde
--- /dev/null
+++ b/tests/uiautomator/test-apps/CtsUiAutomatorApp/res/layout-land/test5_detail_fragment.xml
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ * Copyright (C) 2011 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:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:contentDescription="@string/test_5_Widgets_collection"
+ android:orientation="horizontal" >
+
+ <LinearLayout
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <CheckBox
+ android:id="@+id/test_5_checkBox"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/test5_CheckBox" />
+
+ <Spinner
+ android:id="@+id/test_5_spinner"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <ProgressBar
+ android:id="@+id/test_5_progressBar"
+ style="?android:attr/progressBarStyleLarge"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
+
+ <GridLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:columnCount="3" >
+
+ <ImageButton
+ android:id="@+id/test_5_imageButton"
+ android:layout_column="0"
+ android:layout_gravity="left"
+ android:layout_row="0"
+ android:src="@drawable/ic_launcher" />
+
+ <RatingBar
+ android:id="@+id/test_5_ratingBar"
+ android:layout_column="1"
+ android:layout_columnSpan="2"
+ android:layout_gravity="left|bottom"
+ android:layout_row="0" />
+
+ <Button
+ android:id="@+id/test_5_button2"
+ style="?android:attr/buttonStyleSmall"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="left|bottom"
+ android:enabled="false"
+ android:layout_row="0"
+ android:text="@string/test5_Button_Disabled" />
+
+ <Space
+ android:layout_width="21dp"
+ android:layout_height="1dp"
+ android:layout_column="1"
+ android:layout_row="0" />
+
+ <Space
+ android:layout_width="1dp"
+ android:layout_height="21dp"
+ android:layout_column="0"
+ android:layout_row="0" />
+
+ <Space
+ android:layout_width="221dp"
+ android:layout_height="15dp"
+ android:layout_column="2"
+ android:layout_row="1" />
+
+ <ToggleButton
+ android:id="@+id/test_5_toggleButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_column="2"
+ android:text="@string/test5_ToggleButton" />
+ </GridLayout>
+
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <SeekBar
+ android:id="@+id/test_5_seekBar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ <Button
+ android:id="@+id/test_5_button1"
+ style="?android:attr/buttonStyleSmall"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:contentDescription="@string/test5_Button_Description"
+ android:text="@string/test5_Button" />
+
+ </LinearLayout>
+
+</LinearLayout>
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/VMHostTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/VMHostTest.java
index e972640..0ebdeea 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/VMHostTest.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/VMHostTest.java
@@ -33,6 +33,7 @@
public class VMHostTest extends JarHostTest {
private static final String VM_TEST_TEMP_DIR = "/data/local/tmp/vm-tests";
+ private static final String EMULATOR_TEMP_DIR = "/data/local/tmp";
/**
* {@inheritDoc}
@@ -66,7 +67,7 @@
CLog.d("Creating device temp directory, including dalvik-cache.");
createRemoteDir(device, VM_TEST_TEMP_DIR + "/dalvik-cache" );
try {
- File localTmpDir = FileUtil.createTempDir("cts-vm", new File("/tmp/"));
+ File localTmpDir = FileUtil.createTempDir("cts-vm", new File(System.getProperty("java.io.tmpdir")));
CLog.d("Creating host temp dir %s", localTmpDir.getPath());
File jarFile = new File(ctsBuild.getTestCasesDir(), getJarFileName());
if (!jarFile.exists()) {
@@ -119,11 +120,10 @@
if (device.doesFileExist(remoteFilePath)) {
return;
}
- File f = new File(remoteFilePath);
- String parentPath = f.getParent();
- if (parentPath != null) {
- createRemoteDir(device, parentPath);
+ if (!(device.doesFileExist(EMULATOR_TEMP_DIR))) {
+ CLog.e("Error: Can not found the /data/local/tmp directory!!!");
}
+ device.executeShellCommand(String.format("mkdir %s", VM_TEST_TEMP_DIR));
device.executeShellCommand(String.format("mkdir %s", remoteFilePath));
}
}