Merge "Support for nested bundles in setApplicationRestrictions"
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 32a1bfa..7eab3a3 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -1278,6 +1278,7 @@
<action android:name="com.android.cts.verifier.managedprovisioning.BYOD_QUERY" />
<action android:name="com.android.cts.verifier.managedprovisioning.BYOD_REMOVE" />
<action android:name="com.android.cts.verifier.managedprovisioning.BYOD_INSTALL_APK" />
+ <action android:name="com.android.cts.verifier.managedprovisioning.action.CHECK_INTENT_FILTERS" />
<category android:name="android.intent.category.DEFAULT"></category>
</intent-filter>
</activity>
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 3aa6557..036ed1b 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -1350,6 +1350,7 @@
Then use the Back button to return to this test and mark accordingly.
</string>
+ <string name="provisioning_byod_cross_profile_intent_filters">Cross profile intent filters are set</string>
<string name="provisioning_byod_no_activity">Cannot communicate with activity in the work profile.</string>
<string name="provisioning_byod_delete_profile">Initiate deletion of work profile.</string>
<string name="provisioning_byod_profile_deleted">Work profile deleted.</string>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
index fc7dad3..628ff3e 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodFlowTestActivity.java
@@ -58,7 +58,8 @@
public class ByodFlowTestActivity extends PassFailButtons.ListActivity {
private final String TAG = "ByodFlowTestActivity";
- private static final int REQUEST_STATUS = 1;
+ private static final int REQUEST_PROFILE_OWNER_STATUS = 1;
+ private static final int REQUEST_INTENT_FILTERS_STATUS = 2;
private ComponentName mAdminReceiverComponent;
@@ -80,6 +81,7 @@
private TestItem mLocationSettingsVisibleTest;
private TestItem mCredSettingsVisibleTest;
private TestItem mPrintSettingsVisibleTest;
+ private TestItem mIntentFiltersTest;
private int mCurrentTestPosition;
@@ -137,10 +139,13 @@
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- // Called after queryProfileOwner()
super.onActivityResult(requestCode, resultCode, data);
- if (requestCode == REQUEST_STATUS && resultCode == RESULT_OK) {
+ // Called after queryProfileOwner()
+ if (requestCode == REQUEST_PROFILE_OWNER_STATUS && resultCode == RESULT_OK) {
handleStatusUpdate(data);
+ // Called after checkIntentFilters()
+ } else if (requestCode == REQUEST_INTENT_FILTERS_STATUS) {
+ handleIntentFiltersStatus(resultCode);
}
}
@@ -224,6 +229,15 @@
R.string.provisioning_byod_cross_profile_instruction,
chooser);
+ // Test for checking if the required intent filters are set during managed provisioning.
+ mIntentFiltersTest = new TestItem(this,
+ R.string.provisioning_byod_cross_profile_intent_filters) {
+ @Override
+ public void performTest(ByodFlowTestActivity activity) {
+ checkIntentFilters();
+ }
+ };
+
mTests.add(mProfileOwnerInstalled);
// Badge related tests
@@ -241,6 +255,7 @@
mTests.add(mCrossProfileIntentFiltersTest);
mTests.add(mDisableNonMarketTest);
mTests.add(mEnableNonMarketTest);
+ mTests.add(mIntentFiltersTest);
}
@Override
@@ -336,7 +351,7 @@
private void queryProfileOwner(boolean showToast) {
try {
Intent intent = new Intent(ByodHelperActivity.ACTION_QUERY_PROFILE_OWNER);
- startActivityForResult(intent, REQUEST_STATUS);
+ startActivityForResult(intent, REQUEST_PROFILE_OWNER_STATUS);
}
catch (ActivityNotFoundException e) {
Log.d(TAG, "queryProfileOwner: ActivityNotFoundException", e);
@@ -358,6 +373,35 @@
}
}
+ private void checkIntentFilters() {
+ try {
+ // We disable the ByodHelperActivity in the primary profile. So, this intent
+ // will be handled by the ByodHelperActivity in the managed profile.
+ Intent intent = new Intent(ByodHelperActivity.ACTION_CHECK_INTENT_FILTERS);
+ startActivityForResult(intent, REQUEST_INTENT_FILTERS_STATUS);
+ } catch (ActivityNotFoundException e) {
+ Log.d(TAG, "checkIntentFilters: ActivityNotFoundException", e);
+ setTestResult(mIntentFiltersTest, TestResult.Failed);
+ showToast(R.string.provisioning_byod_no_activity);
+ }
+ }
+
+ private void handleIntentFiltersStatus(int resultCode) {
+ // we use the resultCode from ByodHelperActivity in the managed profile to know if certain
+ // intents fired from the managed profile are forwarded.
+ final boolean intentFiltersSetForManagedIntents = (resultCode == RESULT_OK);
+ // Since the ByodFlowTestActivity is running in the primary profile, we directly use
+ // the IntentFiltersTestHelper to know if certain intents fired from the primary profile
+ // are forwarded.
+ final boolean intentFiltersSetForPrimaryIntents =
+ new IntentFiltersTestHelper(this).checkCrossProfileIntentFilters(
+ IntentFiltersTestHelper.FLAG_INTENTS_FROM_PRIMARY);
+ final boolean intentFiltersSet =
+ intentFiltersSetForPrimaryIntents & intentFiltersSetForManagedIntents;
+ setTestResult(mIntentFiltersTest,
+ intentFiltersSet ? TestResult.Passed : TestResult.Failed);
+ }
+
private void disableComponent() {
// Disable app components in the current profile, so only the counterpart in the other profile
// can respond (via cross-profile intent filter)
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
index 277324c..13af890 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/ByodHelperActivity.java
@@ -61,6 +61,12 @@
public static final String ACTION_INSTALL_APK = "com.android.cts.verifier.managedprovisioning.BYOD_INSTALL_APK";
public static final String EXTRA_ALLOW_NON_MARKET_APPS = INSTALL_NON_MARKET_APPS;
+ // Primary -> managed intent: check if the required cross profile intent filters are set.
+ public static final String ACTION_CHECK_INTENT_FILTERS =
+ "com.android.cts.verifier.managedprovisioning.action.CHECK_INTENT_FILTERS";
+
+ public static final int RESULT_FAILED = RESULT_FIRST_USER;
+
private static final int REQUEST_INSTALL_PACKAGE = 1;
private static final String ORIGINAL_SETTINGS_NAME = "original settings";
@@ -120,6 +126,12 @@
// Not yet ready to finish- wait until the result comes back
return;
+ // Queried by CtsVerifier in the primary side using startActivityForResult.
+ } else if (action.equals(ACTION_CHECK_INTENT_FILTERS)) {
+ final boolean intentFiltersSetForManagedIntents =
+ new IntentFiltersTestHelper(this).checkCrossProfileIntentFilters(
+ IntentFiltersTestHelper.FLAG_INTENTS_FROM_MANAGED);
+ setResult(intentFiltersSetForManagedIntents? RESULT_OK : RESULT_FAILED, null);
}
// This activity has no UI and is only used to respond to CtsVerifier in the primary side.
finish();
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java
index fa7bc4c..58c068f 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/DeviceAdminTestReceiver.java
@@ -49,6 +49,7 @@
filter.addAction(ByodHelperActivity.ACTION_QUERY_PROFILE_OWNER);
filter.addAction(ByodHelperActivity.ACTION_REMOVE_PROFILE_OWNER);
filter.addAction(ByodHelperActivity.ACTION_INSTALL_APK);
+ filter.addAction(ByodHelperActivity.ACTION_CHECK_INTENT_FILTERS);
filter.addAction(CrossProfileTestActivity.ACTION_CROSS_PROFILE);
filter.addAction(WorkNotificationTestActivity.ACTION_WORK_NOTIFICATION);
filter.addAction(WorkNotificationTestActivity.ACTION_CLEAR_WORK_NOTIFICATION);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java
new file mode 100644
index 0000000..579cbcc
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/managedprovisioning/IntentFiltersTestHelper.java
@@ -0,0 +1,309 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.cts.verifier.managedprovisioning;
+
+import android.app.Activity;
+import android.app.admin.DevicePolicyManager;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.media.audiofx.AudioEffect;
+import android.net.Uri;
+import android.nfc.cardemulation.CardEmulation;
+import android.os.Bundle;
+import android.os.UserHandle;
+import android.provider.AlarmClock;
+import android.provider.CalendarContract.Events;
+import android.provider.MediaStore;
+import android.provider.Settings;
+import android.speech.RecognizerIntent;
+import android.util.Log;
+import android.widget.Toast;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Helper class for testing if the required cross profile intent filters are set during the
+ * managed provisioning.
+ */
+public class IntentFiltersTestHelper {
+
+ private static final String TAG = "IntentFiltersTestHelper";
+
+ // These are the intents which can be forwarded to the managed profile.
+ private static final Intent[] forwardedIntentsFromPrimary = new Intent[] {
+ new Intent(Intent.ACTION_SEND).setType("*/*"),
+ new Intent(Intent.ACTION_SEND_MULTIPLE).setType("*/*")
+ };
+
+ // These are the intents which can be forwarded to the primary profile.
+ private static final Intent[] forwardedIntentsFromManaged = new Intent[] {
+ new Intent(AlarmClock.ACTION_SET_ALARM),
+ new Intent(AlarmClock.ACTION_SET_TIMER),
+ new Intent(AlarmClock.ACTION_SHOW_ALARMS),
+ new Intent(MediaStore.ACTION_IMAGE_CAPTURE),
+ new Intent(MediaStore.ACTION_VIDEO_CAPTURE),
+ new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA),
+ new Intent(MediaStore.INTENT_ACTION_VIDEO_CAMERA),
+ new Intent(MediaStore.ACTION_IMAGE_CAPTURE_SECURE),
+ new Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA_SECURE),
+ new Intent(Intent.ACTION_SENDTO).setData(Uri.parse("sms:07700900100")),
+ new Intent(Intent.ACTION_SENDTO).setData(Uri.parse("smsto:07700900100")),
+ new Intent(Intent.ACTION_SENDTO).setData(Uri.parse("mms:07700900100")),
+ new Intent(Intent.ACTION_SENDTO).setData(Uri.parse("mmsto:07700900100")),
+ new Intent(Intent.ACTION_VIEW).setData(
+ Uri.parse("sms:07700900100?body=Hello%20world")).addCategory(
+ Intent.CATEGORY_BROWSABLE),
+ new Intent(Intent.ACTION_VIEW).setData(
+ Uri.parse("smsto:07700900100?body=Hello%20world")).addCategory(
+ Intent.CATEGORY_BROWSABLE),
+ new Intent(Intent.ACTION_VIEW).setData(
+ Uri.parse("mms:07700900100?body=Hello%20world")).addCategory(
+ Intent.CATEGORY_BROWSABLE),
+ new Intent(Intent.ACTION_VIEW).setData(
+ Uri.parse("mmsto:07700900100?body=Hello%20world")).addCategory(
+ Intent.CATEGORY_BROWSABLE),
+ new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS),
+ new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS),
+ new Intent(Settings.ACTION_APN_SETTINGS),
+ new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS),
+ new Intent(Settings.ACTION_CAPTIONING_SETTINGS),
+ new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS),
+ new Intent(Settings.ACTION_DATE_SETTINGS),
+ new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS),
+ new Intent(Settings.ACTION_DISPLAY_SETTINGS),
+ new Intent(Settings.ACTION_DREAM_SETTINGS),
+ new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS),
+ new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS),
+ new Intent(Settings.ACTION_LOCALE_SETTINGS),
+ new Intent(Settings.ACTION_NETWORK_OPERATOR_SETTINGS),
+ new Intent(Settings.ACTION_NFC_SETTINGS),
+ new Intent(Settings.ACTION_NFCSHARING_SETTINGS),
+ new Intent(Settings.ACTION_PRIVACY_SETTINGS),
+ new Intent(Settings.ACTION_SETTINGS),
+ new Intent(Settings.ACTION_SOUND_SETTINGS),
+ new Intent(Settings.ACTION_WIRELESS_SETTINGS),
+ new Intent(DevicePolicyManager.ACTION_SET_NEW_PASSWORD),
+ new Intent("android.net.vpn.SETTINGS"),
+ new Intent(CardEmulation.ACTION_CHANGE_DEFAULT),
+ new Intent("android.settings.ACCOUNT_SYNC_SETTINGS"),
+ new Intent(Settings.ACTION_BATTERY_SAVER_SETTINGS),
+ new Intent(Settings.ACTION_HOME_SETTINGS),
+ new Intent("android.settings.LICENSE"),
+ new Intent("android.settings.NOTIFICATION_SETTINGS"),
+ new Intent(Settings.ACTION_SHOW_REGULATORY_INFO),
+ new Intent("android.settings.USER_SETTINGS"),
+ new Intent("android.settings.ZEN_MODE_SETTINGS"),
+ new Intent("com.android.settings.ACCESSIBILITY_COLOR_SPACE_SETTINGS"),
+ new Intent("com.android.settings.STORAGE_USB_SETTINGS"),
+ new Intent("com.android.settings.TTS_SETTINGS"),
+ new Intent("com.android.settings.USER_DICTIONARY_EDIT"),
+ new Intent(Intent.ACTION_CALL).setData(Uri.parse("tel:123")),
+ new Intent("android.intent.action.CALL_EMERGENCY").setData(Uri.parse("tel:123")),
+ new Intent("android.intent.action.CALL_PRIVILEGED").setData(Uri.parse("tel:123")),
+ new Intent(Intent.ACTION_DIAL).setData(Uri.parse("tel:123")),
+ new Intent(Intent.ACTION_VIEW).setData(Uri.parse("tel:123")).addCategory(
+ Intent.CATEGORY_BROWSABLE),
+ new Intent(Settings.ACTION_MEMORY_CARD_SETTINGS),
+ new Intent(Settings.ACTION_NFC_PAYMENT_SETTINGS),
+ new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS),
+ new Intent(Settings.ACTION_INTERNAL_STORAGE_SETTINGS),
+ new Intent(Settings.ACTION_SYNC_SETTINGS),
+ new Intent(Settings.ACTION_ADD_ACCOUNT),
+ new Intent(Intent.ACTION_GET_CONTENT).setType("*/*").addCategory(
+ Intent.CATEGORY_OPENABLE),
+ new Intent(Intent.ACTION_OPEN_DOCUMENT).setType("*/*").addCategory(
+ Intent.CATEGORY_OPENABLE),
+ new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)
+ };
+
+ // These are the intents which cannot be forwarded to the primary profile.
+ private static final Intent[] notForwardedIntentsFromManaged = new Intent[] {
+ new Intent(Intent.ACTION_INSERT).setData(
+ Uri.parse("content://browser/bookmarks")),
+ new Intent(Intent.ACTION_VIEW).setData(
+ Uri.parse("http://www.example.com")).addCategory(
+ Intent.CATEGORY_BROWSABLE),
+ new Intent(Intent.ACTION_SENDTO).setData(
+ Uri.parse("mailto:user@example.com")),
+ new Intent(Intent.ACTION_VIEW).setData(
+ Uri.parse("mailto:user@example.com")).addCategory(
+ Intent.CATEGORY_BROWSABLE),
+ new Intent(Intent.ACTION_VIEW).setData(
+ Uri.parse("geo:0,0?q=BuckinghamPalace")),
+ new Intent(Intent.ACTION_VIEW).setData(
+ Uri.parse("http://example.com/oceans.mp4")).setType("video/mp4"),
+ new Intent(Intent.ACTION_VIEW).setData(
+ Uri.parse("http://www.example.com/horse.mp3")).setType("audio/*"),
+ new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH),
+ new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION),
+ new Intent(Intent.ACTION_VIEW).setData(
+ Uri.parse("market://details?id=com.android.chrome")).addCategory(
+ Intent.CATEGORY_BROWSABLE),
+ new Intent(Intent.ACTION_WEB_SEARCH),
+ new Intent(Settings.ACTION_SEARCH_SETTINGS),
+ new Intent(Settings.ACTION_PRINT_SETTINGS),
+ new Intent(Intent.ACTION_MANAGE_NETWORK_USAGE),
+ new Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS),
+ new Intent(Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS),
+ new Intent(Settings.ACTION_APPLICATION_SETTINGS),
+ new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).setData(
+ Uri.parse("package:com.android.chrome")),
+ new Intent("android.settings.ACTION_OTHER_SOUND_SETTINGS"),
+ new Intent(Settings.ACTION_WIFI_IP_SETTINGS),
+ new Intent(Settings.ACTION_WIFI_SETTINGS),
+ new Intent("android.settings.SHOW_INPUT_METHOD_PICKER"),
+ new Intent(Intent.ACTION_INSERT).setData(Events.CONTENT_URI),
+ new Intent(AudioEffect.ACTION_DISPLAY_AUDIO_EFFECT_CONTROL_PANEL)
+ };
+
+ // This flag specifies we are dealing with intents fired from the primary profile.
+ public static final int FLAG_INTENTS_FROM_PRIMARY = 1;
+ // This flag specifies we are dealing with intents fired from the managed profile.
+ public static final int FLAG_INTENTS_FROM_MANAGED = 2;
+
+ private Context mContext;
+
+ IntentFiltersTestHelper(Context context) {
+ mContext = context;
+ }
+
+ public boolean checkCrossProfileIntentFilters(int flag) {
+ boolean crossProfileIntentFiltersSet;
+ if (flag == FLAG_INTENTS_FROM_PRIMARY) {
+ crossProfileIntentFiltersSet = checkForIntentsFromPrimary();
+ } else {
+ crossProfileIntentFiltersSet = checkForIntentsFromManaged();
+ }
+ return crossProfileIntentFiltersSet;
+ }
+
+ /**
+ * Checks if required cross profile intent filters are set for the intents fired from the
+ * primary profile.
+ */
+ private boolean checkForIntentsFromPrimary() {
+ // Get the class name of the intentForwarderActivity in the primary profile by firing an
+ // intent which we know will be forwarded from primary profile to managed profile.
+ ActivityInfo forwarderActivityInfo =
+ getForwarderActivityInfo(ByodHelperActivity.ACTION_QUERY_PROFILE_OWNER);
+ if (forwarderActivityInfo == null) {
+ return false;
+ }
+
+ // Check for intents which can be forwarded to the managed profile.
+ Intent intent = checkForIntentsNotHandled(forwardedIntentsFromPrimary,
+ forwarderActivityInfo, true);
+ if (intent != null) {
+ Log.d(TAG, intent + " from primary profile should be forwarded to the " +
+ "managed profile but is not.");
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Checks if required cross profile intent filters are set for the intents fired from the
+ * managed profile.
+ */
+ private boolean checkForIntentsFromManaged() {
+ // Get the class name of the intentForwarderActivity in the managed profile by firing an
+ // intent which we know will be forwarded from managed profile to primary profile.
+ ActivityInfo forwarderActivityInfo =
+ getForwarderActivityInfo(ByodHelperActivity.ACTION_PROFILE_OWNER_STATUS);
+ if (forwarderActivityInfo == null) {
+ return false;
+ }
+
+ // Check for intents which can be forwarded to the primary profile.
+ Intent intent = checkForIntentsNotHandled(forwardedIntentsFromManaged,
+ forwarderActivityInfo, true);
+ if (intent != null) {
+ Log.d(TAG, intent + " from managed profile should be forwarded to the " +
+ "primary profile but is not.");
+ return false;
+ }
+
+ // Check for intents which cannot be forwarded to the primary profile.
+ intent = checkForIntentsNotHandled(notForwardedIntentsFromManaged,
+ forwarderActivityInfo, false);
+ if (intent != null) {
+ Log.d(TAG, intent + " from managed profile should not be forwarded to the " +
+ "primary profile but it is.");
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Checks if the intentForwarderActivity can handle the intent passed.
+ */
+ private boolean canForwarderActivityHandleIntent(Intent intent,
+ ActivityInfo forwarderActivityInfo) {
+ // Get all the activities which can handle the intent.
+ List<ResolveInfo> resolveInfoList =
+ mContext.getPackageManager().queryIntentActivities(intent,
+ PackageManager.MATCH_DEFAULT_ONLY);
+ // Check if intentForwarderActivity is part of the list.
+ for (ResolveInfo resolveInfo : resolveInfoList) {
+ if (forwarderActivityInfo.packageName.equals(resolveInfo.activityInfo.packageName)
+ && forwarderActivityInfo.name.equals(resolveInfo.activityInfo.name)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns the class name of the intentForwarderActivity.
+ */
+ private ActivityInfo getForwarderActivityInfo(String action) {
+ Intent intent = new Intent(action);
+ List<ResolveInfo> resolveInfoList =
+ mContext.getPackageManager().queryIntentActivities(intent,
+ PackageManager.MATCH_DEFAULT_ONLY);
+ if (resolveInfoList.isEmpty() || resolveInfoList.size() > 1) {
+ Log.d(TAG, "There should be exactly one activity IntentForwarder which " +
+ "handles the intent " + intent);
+ return null;
+ }
+ return resolveInfoList.get(0).activityInfo;
+ }
+
+ /**
+ * Checks if the intents passed are correctly handled.
+ * @return {@code null} if all the intents are correctly handled
+ * otherwise, the first intent in the list which is not handled correctly.
+ */
+ private Intent checkForIntentsNotHandled(Intent[] intentList,
+ ActivityInfo expectedForwarderActivityInfo, boolean canResolve) {
+ for (Intent intent : intentList) {
+ if (canForwarderActivityHandleIntent(intent,
+ expectedForwarderActivityInfo) != canResolve) {
+ return intent;
+ }
+ }
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/hostsidetests/appsecurity/src/com/android/cts/appsecurity/AppSecurityTests.java b/hostsidetests/appsecurity/src/com/android/cts/appsecurity/AppSecurityTests.java
index 81a9608..206bdbe 100644
--- a/hostsidetests/appsecurity/src/com/android/cts/appsecurity/AppSecurityTests.java
+++ b/hostsidetests/appsecurity/src/com/android/cts/appsecurity/AppSecurityTests.java
@@ -585,7 +585,10 @@
final String output = device.executeShellCommand("pm create-user " + name);
if (output.startsWith("Success")) {
try {
- return Integer.parseInt(output.substring(output.lastIndexOf(" ")).trim());
+ final int userId = Integer.parseInt(
+ output.substring(output.lastIndexOf(" ")).trim());
+ device.executeShellCommand("am start-user " + userId);
+ return userId;
} catch (NumberFormatException e) {
fail("Failed to parse result: " + output);
}
diff --git a/hostsidetests/appsecurity/test-apps/ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java b/hostsidetests/appsecurity/test-apps/ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java
index eac4405..aa09f75 100644
--- a/hostsidetests/appsecurity/test-apps/ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java
+++ b/hostsidetests/appsecurity/test-apps/ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java
@@ -327,7 +327,9 @@
}
File[] dirs = removeWhiteList(dir.listFiles());
- assertEquals(0, dirs.length);
+ if (dirs.length != 0) {
+ fail("Expected wiped storage but found: " + Arrays.toString(dirs));
+ }
}
}
diff --git a/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/src/com/android/cts/writeexternalstorageapp/WriteExternalStorageTest.java b/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/src/com/android/cts/writeexternalstorageapp/WriteExternalStorageTest.java
index 6857236..afee8541 100644
--- a/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/src/com/android/cts/writeexternalstorageapp/WriteExternalStorageTest.java
+++ b/hostsidetests/appsecurity/test-apps/WriteExternalStorageApp/src/com/android/cts/writeexternalstorageapp/WriteExternalStorageTest.java
@@ -93,6 +93,17 @@
assertEquals(readInt(TEST_FILE), 32);
}
+ public void testWriteExternalStorageDirs() throws Exception {
+ final File probe = new File(
+ Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM),
+ "100CTS");
+
+ assertFalse(probe.exists());
+ assertTrue(probe.mkdirs());
+
+ assertDirReadWriteAccess(probe);
+ }
+
/**
* Verify that legacy filesystem paths continue working, and that they all
* point to same location.
diff --git a/tests/core/libcore/tzdata/Android.mk b/tests/core/libcore/tzdata/Android.mk
new file mode 100644
index 0000000..ecbd070
--- /dev/null
+++ b/tests/core/libcore/tzdata/Android.mk
@@ -0,0 +1,24 @@
+# Copyright (C) 2015 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+ifeq ($(BUILD_CTSCORE_PACKAGE),)
+ $(error BUILD_CTSCORE_PACKAGE must be defined)
+endif
+
+include $(CLEAR_VARS)
+LOCAL_PACKAGE_NAME := android.core.tests.libcore.package.tzdata
+LOCAL_STATIC_JAVA_LIBRARIES := tzdata_update-tests
+include $(BUILD_CTSCORE_PACKAGE)
diff --git a/tests/core/libcore/tzdata/AndroidManifest.xml b/tests/core/libcore/tzdata/AndroidManifest.xml
new file mode 100644
index 0000000..8a4fad8
--- /dev/null
+++ b/tests/core/libcore/tzdata/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="android.core.tests.libcore.package.tzdata">
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ android:targetPackage="android.core.tests.runner"
+ android:label="cts framework tests">
+ <meta-data android:name="listener"
+ android:value="com.android.cts.runner.CtsTestRunListener" />
+ </instrumentation>
+
+</manifest>
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java
index f8b3bc3..b2194fd 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/RecordingTest.java
@@ -438,6 +438,7 @@
* given camera. preview size is set to the video size.
*/
private void basicRecordingTestByCamera(int[] camcorderProfileList) throws Exception {
+ Size maxPreviewSize = mOrderedPreviewSizes.get(0);
for (int profileId : camcorderProfileList) {
int cameraId = Integer.valueOf(mCamera.getId());
if (!CamcorderProfile.hasProfile(cameraId, profileId) ||
@@ -447,6 +448,12 @@
CamcorderProfile profile = CamcorderProfile.get(cameraId, profileId);
Size videoSz = new Size(profile.videoFrameWidth, profile.videoFrameHeight);
+ if (mStaticInfo.isHardwareLevelLegacy() &&
+ (videoSz.getWidth() > maxPreviewSize.getWidth() ||
+ videoSz.getHeight() > maxPreviewSize.getHeight())) {
+ // Skip. Legacy mode can only do recording up to max preview size
+ continue;
+ }
assertTrue("Video size " + videoSz.toString() + " for profile ID " + profileId +
" must be one of the camera device supported video size!",
mSupportedVideoSizes.contains(videoSz));
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/StillCaptureTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/StillCaptureTest.java
index b4113e5..b40b350 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/StillCaptureTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/StillCaptureTest.java
@@ -1000,9 +1000,23 @@
}
// Validate capture result vs. request
+ Size resultThumbnailSize = stillResult.get(CaptureResult.JPEG_THUMBNAIL_SIZE);
+ int orientationTested = EXIF_TEST_DATA[i].jpegOrientation;
+ if ((orientationTested == 90 || orientationTested == 270)) {
+ int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
+ /*defaultValue*/-1);
+ if (exifOrientation == ExifInterface.ORIENTATION_UNDEFINED) {
+ // Device physically rotated image+thumbnail data
+ // Expect thumbnail size to be also rotated
+ resultThumbnailSize = new Size(
+ resultThumbnailSize.getHeight(),
+ resultThumbnailSize.getWidth());
+ }
+ }
+
mCollector.expectEquals("JPEG thumbnail size result and request should match",
testThumbnailSizes[i],
- stillResult.get(CaptureResult.JPEG_THUMBNAIL_SIZE));
+ resultThumbnailSize);
if (mCollector.expectKeyValueNotNull(stillResult, CaptureResult.JPEG_GPS_LOCATION) !=
null) {
mCollector.expectTrue("GPS location result and request should match.",
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopyPaddedTest.java b/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopyPaddedTest.java
new file mode 100644
index 0000000..c74dbc0
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopyPaddedTest.java
@@ -0,0 +1,1117 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.renderscript.cts;
+
+import android.renderscript.Allocation;
+import android.renderscript.Element;
+import android.renderscript.Type;
+import java.util.Random;
+
+public class AllocationCopyPaddedTest extends RSBaseCompute {
+ public void test_AllocationPadded_Byte3_1D() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(128);;
+ int arr_len = width * 3;
+
+ byte[] inArray = new byte[arr_len];
+ byte[] outArray = new byte[arr_len];
+ random.nextBytes(inArray);
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I8_3(mRS));
+ typeBuilder.setX(width);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_AllocationCopyTo_1D_Padded_Byte Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_Byte3_2D() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(128);
+ int height = random.nextInt(128);
+ int arr_len = width * height * 3;
+
+ byte[] inArray = new byte[arr_len];
+ byte[] outArray = new byte[arr_len];
+ random.nextBytes(inArray);
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I8_3(mRS));
+ typeBuilder.setX(width).setY(height);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_2D_AllocationCopyTo_Padded_Byte Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_Byte3_3D() {
+ Random random = new Random(0x172d8ab9);
+ int w = random.nextInt(32);
+ int h = random.nextInt(32);
+ int d = random.nextInt(32);
+ int arr_len = w * d * h * 3;
+
+ byte[] inArray = new byte[arr_len];
+ byte[] outArray = new byte[arr_len];
+ random.nextBytes(inArray);
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I8_3(mRS));
+ typeBuilder.setX(w).setY(h).setZ(d);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_AllocationCopyTo_3D_Padded_Byte Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_Short3_1D() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(512);
+ int arr_len = width * 3;
+
+ short[] inArray = new short[arr_len];
+ short[] outArray = new short[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = (short)random.nextInt();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I16_3(mRS));
+ typeBuilder.setX(width);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_AllocationCopyTo_1D_Padded_Short Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_Short3_2D() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(128);
+ int height = random.nextInt(128);
+ int arr_len = width * height * 3;
+
+ short[] inArray = new short[arr_len];
+ short[] outArray = new short[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = (short)random.nextInt();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I16_3(mRS));
+ typeBuilder.setX(width).setY(height);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_AllocationCopyTo_2D_Padded_Short Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_Short3_3D() {
+ Random random = new Random(0x172d8ab9);
+ int w = random.nextInt(32);
+ int h = random.nextInt(32);
+ int d = random.nextInt(32);
+ int arr_len = w * d * h * 3;
+
+ short[] inArray = new short[arr_len];
+ short[] outArray = new short[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = (short)random.nextInt();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I16_3(mRS));
+ typeBuilder.setX(w).setY(h).setZ(d);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_AllocationCopyTo_3D_Padded_Short Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_Int3_1D() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(512);
+ int arr_len = width * 3;
+
+ int[] inArray = new int[arr_len];
+ int[] outArray = new int[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextInt();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32_3(mRS));
+ typeBuilder.setX(width);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_AllocationCopyTo_1D_Padded_Int Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_Int3_2D() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(128);
+ int height = random.nextInt(128);
+ int arr_len = width * height * 3;
+
+ int[] inArray = new int[arr_len];
+ int[] outArray = new int[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextInt();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32_3(mRS));
+ typeBuilder.setX(width).setY(height);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_AllocationCopyTo_2D_Padded_Int Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_Int3_3D() {
+ Random random = new Random(0x172d8ab9);
+ int w = random.nextInt(32);
+ int h = random.nextInt(32);
+ int d = random.nextInt(32);
+ int arr_len = w * d * h * 3;
+
+ int[] inArray = new int[arr_len];
+ int[] outArray = new int[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextInt();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32_3(mRS));
+ typeBuilder.setX(w).setY(h).setZ(d);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_AllocationCopyTo_3D_Padded_Int Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_Float3_1D() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(512);
+ int arr_len = width * 3;
+
+ float[] inArray = new float[arr_len];
+ float[] outArray = new float[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextFloat();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.F32_3(mRS));
+ typeBuilder.setX(width);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_AllocationCopyTo_1D_Padded_Float Failed, output array does not match input",
+ result);
+ }
+ public void test_AllocationPadded_Float3_2D() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(128);
+ int height = random.nextInt(128);
+ int arr_len = width * height * 3;
+
+ float[] inArray = new float[arr_len];
+ float[] outArray = new float[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextFloat();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.F32_3(mRS));
+ typeBuilder.setX(width).setY(height);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_AllocationCopyTo_2D_Padded_Float Failed, output array does not match input",
+ result);
+ }
+ public void test_AllocationPadded_Float3_3D() {
+ Random random = new Random(0x172d8ab9);
+ int w = random.nextInt(32);
+ int h = random.nextInt(32);
+ int d = random.nextInt(32);
+ int arr_len = w * d * h * 3;
+
+ float[] inArray = new float[arr_len];
+ float[] outArray = new float[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextFloat();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.F32_3(mRS));
+ typeBuilder.setX(w).setY(h).setZ(d);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_AllocationCopyTo_3D_Padded_Float Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_Double3_1D() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(512);
+ int arr_len = width * 3;
+
+ double[] inArray = new double[arr_len];
+ double[] outArray = new double[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = (double)random.nextFloat();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.F64_3(mRS));
+ typeBuilder.setX(width);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_AllocationCopyTo_1D_Padded_Double Failed, output array does not match input",
+ result);
+ }
+ public void test_AllocationPadded_Double3_2D() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(128);
+ int height = random.nextInt(128);
+ int arr_len = width * height * 3;
+
+ double[] inArray = new double[arr_len];
+ double[] outArray = new double[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = (double)random.nextFloat();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.F64_3(mRS));
+ typeBuilder.setX(width).setY(height);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_AllocationCopyTo_2D_Padded_Double Failed, output array does not match input",
+ result);
+ }
+ public void test_AllocationPadded_Double3_3D() {
+ Random random = new Random(0x172d8ab9);
+ int w = random.nextInt(32);
+ int h = random.nextInt(32);
+ int d = random.nextInt(32);
+ int arr_len = w * d * h * 3;
+
+ double[] inArray = new double[arr_len];
+ double[] outArray = new double[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = (double)random.nextFloat();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.F64_3(mRS));
+ typeBuilder.setX(w).setY(h).setZ(d);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_AllocationCopyTo_3D_Padded_Double Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_Long3_1D() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(512);
+ int arr_len = width * 3;
+
+ long[] inArray = new long[arr_len];
+ long[] outArray = new long[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextLong();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I64_3(mRS));
+ typeBuilder.setX(width);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_AllocationCopyTo_1D_Padded_Long Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_Long3_2D() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(128);
+ int height = random.nextInt(128);
+ int arr_len = width * height * 3;
+
+ long[] inArray = new long[arr_len];
+ long[] outArray = new long[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextLong();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I64_3(mRS));
+ typeBuilder.setX(width).setY(height);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_AllocationCopyTo_2D_Padded_Long Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_Long3_3D() {
+ Random random = new Random(0x172d8ab9);
+ int w = random.nextInt(32);
+ int h = random.nextInt(32);
+ int d = random.nextInt(32);
+ int arr_len = w * d * h * 3;
+
+ long[] inArray = new long[arr_len];
+ long[] outArray = new long[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextLong();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I64_3(mRS));
+ typeBuilder.setX(w).setY(h).setZ(d);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copyFrom(inArray);
+ alloc.copyTo(outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_AllocationCopyTo_3D_Padded_Long Failed, output array does not match input",
+ result);
+ }
+
+
+ public void test_AllocationPadded_copy1DRangeTo_Byte3() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(512);
+ int arr_len = width * 3;
+
+ byte[] inArray = new byte[arr_len];
+ byte[] outArray = new byte[arr_len];
+ random.nextBytes(inArray);
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I8_3(mRS));
+ typeBuilder.setX(width);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ int offset = random.nextInt(width);
+ int count = width - offset;
+ alloc.copy1DRangeFrom(offset, count, inArray);
+ alloc.copy1DRangeTo(offset, count, outArray);
+
+ boolean result = true;
+ for (int i = 0; i < count * 3; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ for (int i = count * 3; i < arr_len; i++) {
+ if (outArray[i] != 0) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_copy1DRangeTo_Padded_Byte Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_copy1DRangeTo_Short3() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(512);
+ int arr_len = width * 3;
+
+ short[] inArray = new short[arr_len];
+ short[] outArray = new short[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = (short)random.nextInt();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I16_3(mRS));
+ typeBuilder.setX(width);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ int offset = random.nextInt(width);
+ int count = width - offset;
+ alloc.copy1DRangeFrom(offset, count, inArray);
+ alloc.copy1DRangeTo(offset, count, outArray);
+
+ boolean result = true;
+ for (int i = 0; i < count * 3; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ for (int i = count * 3; i < arr_len; i++) {
+ if (outArray[i] != 0) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_copy1DRangeTo_Padded_Short Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_copy1DRangeTo_Int3() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(512);
+ int arr_len = width * 3;
+
+ int[] inArray = new int[arr_len];
+ int[] outArray = new int[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextInt();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32_3(mRS));
+ typeBuilder.setX(width);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ int offset = random.nextInt(width);
+ int count = width - offset;
+ alloc.copy1DRangeFrom(offset, count, inArray);
+ alloc.copy1DRangeTo(offset, count, outArray);
+
+ boolean result = true;
+ for (int i = 0; i < count * 3; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ for (int i = count * 3; i < arr_len; i++) {
+ if (outArray[i] != 0) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_copy1DRangeTo_Padded_Int Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_copy1DRangeTo_Float3() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(512);
+ int arr_len = width * 3;
+
+ float[] inArray = new float[arr_len];
+ float[] outArray = new float[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextFloat();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.F32_3(mRS));
+ typeBuilder.setX(width);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ int offset = random.nextInt(width);
+ int count = width - offset;
+ alloc.copy1DRangeFrom(offset, count, inArray);
+ alloc.copy1DRangeTo(offset, count, outArray);
+
+ boolean result = true;
+ for (int i = 0; i < count * 3; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ for (int i = count * 3; i < arr_len; i++) {
+ if (outArray[i] != 0f) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_copy1DRangeTo_Padded_Float Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_copy1DRangeTo_Long3() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(512);
+ int arr_len = width * 3;
+
+ long[] inArray = new long[arr_len];
+ long[] outArray = new long[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextLong();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I64_3(mRS));
+ typeBuilder.setX(width);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ int offset = random.nextInt(width);
+ int count = width - offset;
+ alloc.copy1DRangeFrom(offset, count, inArray);
+ alloc.copy1DRangeTo(offset, count, outArray);
+
+ boolean result = true;
+ for (int i = 0; i < count * 3; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ for (int i = count * 3; i < arr_len; i++) {
+ if (outArray[i] != 0) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_copy1DRangeTo_Padded_Long Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_copy2DRangeTo_Byte3() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(128);
+ int height = random.nextInt(128);
+ int xoff = random.nextInt(width);
+ int yoff = random.nextInt(height);
+ int xcount = width - xoff;
+ int ycount = height - yoff;
+ int arr_len = xcount * ycount * 3;
+
+ byte[] inArray = new byte[arr_len];
+ byte[] outArray = new byte[arr_len];
+ random.nextBytes(inArray);
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I8_3(mRS));
+ typeBuilder.setX(width).setY(height);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copy2DRangeFrom(xoff, yoff, xcount, ycount, inArray);
+ alloc.copy2DRangeTo(xoff, yoff, xcount, ycount, outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_copy2DRangeTo_Padded_Byte Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_copy2DRangeTo_Short3() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(128);
+ int height = random.nextInt(128);
+ int xoff = random.nextInt(width);
+ int yoff = random.nextInt(height);
+ int xcount = width - xoff;
+ int ycount = height - yoff;
+ int arr_len = xcount * ycount * 3;
+
+ short[] inArray = new short[arr_len];
+ short[] outArray = new short[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = (short)random.nextInt();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I16_3(mRS));
+ typeBuilder.setX(width).setY(height);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copy2DRangeFrom(xoff, yoff, xcount, ycount, inArray);
+ alloc.copy2DRangeTo(xoff, yoff, xcount, ycount, outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_copy2DRangeTo_Padded_Short Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_copy2DRangeTo_Int3() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(128);
+ int height = random.nextInt(128);
+ int xoff = random.nextInt(width);
+ int yoff = random.nextInt(height);
+ int xcount = width - xoff;
+ int ycount = height - yoff;
+ int arr_len = xcount * ycount * 3;
+
+ int[] inArray = new int[arr_len];
+ int[] outArray = new int[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextInt();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32_3(mRS));
+ typeBuilder.setX(width).setY(height);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copy2DRangeFrom(xoff, yoff, xcount, ycount, inArray);
+ alloc.copy2DRangeTo(xoff, yoff, xcount, ycount, outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_copy2DRangeTo_Padded_Int Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_copy2DRangeTo_Float3() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(128);
+ int height = random.nextInt(128);
+ int xoff = random.nextInt(width);
+ int yoff = random.nextInt(height);
+ int xcount = width - xoff;
+ int ycount = height - yoff;
+ int arr_len = xcount * ycount * 3;
+
+ float[] inArray = new float[arr_len];
+ float[] outArray = new float[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextFloat();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.F32_3(mRS));
+ typeBuilder.setX(width).setY(height);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copy2DRangeFrom(xoff, yoff, xcount, ycount, inArray);
+ alloc.copy2DRangeTo(xoff, yoff, xcount, ycount, outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_copy2DRangeTo_Padded_Float Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_copy2DRangeTo_Long3() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(128);
+ int height = random.nextInt(128);
+ int xoff = random.nextInt(width);
+ int yoff = random.nextInt(height);
+ int xcount = width - xoff;
+ int ycount = height - yoff;
+ int arr_len = xcount * ycount * 3;
+
+ long[] inArray = new long[arr_len];
+ long[] outArray = new long[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextLong();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I64_3(mRS));
+ typeBuilder.setX(width).setY(height);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ alloc.copy2DRangeFrom(xoff, yoff, xcount, ycount, inArray);
+ alloc.copy2DRangeTo(xoff, yoff, xcount, ycount, outArray);
+
+ boolean result = true;
+ for (int i = 0; i < arr_len; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_copy2DRangeTo_Padded_Long Failed, output array does not match input",
+ result);
+ }
+
+
+ public void test_AllocationPadded_copy1DRangeToUnchecked_Byte3() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(512);
+ int arr_len = width * 3;
+
+ byte[] inArray = new byte[arr_len];
+ byte[] outArray = new byte[arr_len];
+ random.nextBytes(inArray);
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I8_3(mRS));
+ typeBuilder.setX(width);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ int offset = random.nextInt(width);
+ int count = width - offset;
+ alloc.copy1DRangeFrom(offset, count, inArray);
+ alloc.copy1DRangeToUnchecked(offset, count, outArray);
+
+ boolean result = true;
+ for (int i = 0; i < count * 3; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ for (int i = count * 3; i < arr_len; i++) {
+ if (outArray[i] != 0) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_copy1DRangeToUnchecked_Padded_Byte Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_copy1DRangeToUnchecked_Short3() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(512);
+ int arr_len = width * 3;
+
+ short[] inArray = new short[arr_len];
+ short[] outArray = new short[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = (short)random.nextInt();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I16_3(mRS));
+ typeBuilder.setX(width);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ int offset = random.nextInt(width);
+ int count = width - offset;
+ alloc.copy1DRangeFrom(offset, count, inArray);
+ alloc.copy1DRangeToUnchecked(offset, count, outArray);
+
+ boolean result = true;
+ for (int i = 0; i < count * 3; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ for (int i = count * 3; i < arr_len; i++) {
+ if (outArray[i] != 0) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_copy1DRangeToUnchecked_Padded_Short Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_copy1DRangeToUnchecked_Int3() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(512);
+ int arr_len = width * 3;
+
+ int[] inArray = new int[arr_len];
+ int[] outArray = new int[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextInt();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32_3(mRS));
+ typeBuilder.setX(width);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ int offset = random.nextInt(width);
+ int count = width - offset;
+ alloc.copy1DRangeFrom(offset, count, inArray);
+ alloc.copy1DRangeToUnchecked(offset, count, outArray);
+
+ boolean result = true;
+ for (int i = 0; i < count * 3; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ for (int i = count * 3; i < arr_len; i++) {
+ if (outArray[i] != 0) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_copy1DRangeToUnchecked_1D_Padded_Int Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_copy1DRangeToUnchecked_Float3() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(512);
+ int arr_len = width * 3;
+
+ float[] inArray = new float[arr_len];
+ float[] outArray = new float[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextFloat();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.F32_3(mRS));
+ typeBuilder.setX(width);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ int offset = random.nextInt(width);
+ int count = width - offset;
+ alloc.copy1DRangeFrom(offset, count, inArray);
+ alloc.copy1DRangeToUnchecked(offset, count, outArray);
+
+ boolean result = true;
+ for (int i = 0; i < count * 3; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ for (int i = count * 3; i < arr_len; i++) {
+ if (outArray[i] != 0f) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_copy1DRangeToUnchecked_Padded_Float Failed, output array does not match input",
+ result);
+ }
+
+ public void test_AllocationPadded_copy1DRangeToUnchecked_Long3() {
+ Random random = new Random(0x172d8ab9);
+ int width = random.nextInt(512);
+ int arr_len = width * 3;
+
+ long[] inArray = new long[arr_len];
+ long[] outArray = new long[arr_len];
+
+ for (int i = 0; i < arr_len; i++) {
+ inArray[i] = random.nextLong();
+ }
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I64_3(mRS));
+ typeBuilder.setX(width);
+ Allocation alloc = Allocation.createTyped(mRS, typeBuilder.create());
+ alloc.setAutoPadding(true);
+ int offset = random.nextInt(width);
+ int count = width - offset;
+ alloc.copy1DRangeFrom(offset, count, inArray);
+ alloc.copy1DRangeToUnchecked(offset, count, outArray);
+
+ boolean result = true;
+ for (int i = 0; i < count * 3; i++) {
+ if (inArray[i] != outArray[i]) {
+ result = false;
+ break;
+ }
+ }
+ for (int i = count * 3; i < arr_len; i++) {
+ if (outArray[i] != 0) {
+ result = false;
+ break;
+ }
+ }
+ assertTrue("test_copy1DRangeToUnchecked_Padded_Long Failed, output array does not match input",
+ result);
+ }
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestCtxDim.java b/tests/tests/renderscript/src/android/renderscript/cts/TestCtxDim.java
new file mode 100644
index 0000000..4a2af00
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestCtxDim.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.renderscript.cts;
+
+import android.renderscript.*;
+
+public class TestCtxDim extends RSBaseCompute {
+
+ public void test() {
+ ScriptC_TestCtxDim script = new ScriptC_TestCtxDim(mRS);
+
+ Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32(mRS));
+ int X = 2;
+ script.set_gDimX(X);
+ typeBuilder.setX(X);
+ int Y = 5;
+ script.set_gDimY(Y);
+ typeBuilder.setY(Y);
+ int Z = 11;
+ script.set_gDimZ(Z);
+ typeBuilder.setZ(Z);
+
+ Allocation A = Allocation.createTyped(mRS, typeBuilder.create());
+
+ script.forEach_check_kernel(A);
+ script.invoke_check_result();
+ mRS.finish();
+ waitForMessage();
+ }
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestCtxDim.rs b/tests/tests/renderscript/src/android/renderscript/cts/TestCtxDim.rs
new file mode 100644
index 0000000..a3bbf3e
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestCtxDim.rs
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma version(1)
+#pragma rs java_package_name(android.renderscript.cts)
+
+#include "shared.rsh"
+
+int gDimX, gDimY, gDimZ;
+static bool failed = false;
+
+void __attribute__((kernel)) check_kernel(int32_t in /* dummy */, rs_kernel_context ctxt) {
+ uint32_t dimX = rsGetDimX(ctxt);
+ _RS_ASSERT(gDimX == dimX);
+ uint32_t dimY = rsGetDimY(ctxt);
+ _RS_ASSERT(gDimY == dimY);
+ uint32_t dimZ = rsGetDimZ(ctxt);
+ _RS_ASSERT(gDimZ == dimZ);
+}
+
+void check_result() {
+ if (failed) {
+ rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+ }
+ else {
+ rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+ }
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ThunkerCreateTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ThunkerCreateTest.java
new file mode 100644
index 0000000..735519c
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ThunkerCreateTest.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.renderscript.cts;
+
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import android.content.Context;
+import android.renderscript.RSRuntimeException;
+
+public class ThunkerCreateTest extends RSBase {
+
+ public void testCreateReflection() {
+ int sdkVersion = mCtx.getApplicationInfo().targetSdkVersion;
+
+ try {
+ Class<?> javaRS = Class.forName("android.renderscript.RenderScript");
+ Class[] signature = {Context.class, Integer.TYPE};
+ Object[] args = {mCtx, new Integer(sdkVersion)};
+ Method create = javaRS.getDeclaredMethod("create", signature);
+
+ assertTrue (create.invoke(null, args) != null);
+ }
+ catch (Exception e) {
+ throw new RSRuntimeException("Failure to create platform RenderScript context");
+ }
+
+ }
+}
+
+
diff --git a/tests/tests/rscpp/librscpptest/rs_jni.cpp b/tests/tests/rscpp/librscpptest/rs_jni.cpp
index f5946f5..edfd7cc6 100644
--- a/tests/tests/rscpp/librscpptest/rs_jni.cpp
+++ b/tests/tests/rscpp/librscpptest/rs_jni.cpp
@@ -51,6 +51,18 @@
}
}
+sp<const Element> makeElement(sp<RS> rs, RsDataType dt, int vecSize) {
+ if (vecSize > 1) {
+ return Element::createVector(rs, dt, vecSize);
+ } else {
+ if (dt == RS_TYPE_UNSIGNED_8) {
+ return Element::U8(rs);
+ } else {
+ return Element::F32(rs);
+ }
+ }
+}
+
extern "C" JNIEXPORT jboolean JNICALL Java_android_cts_rscpp_RSInitTest_initTest(JNIEnv * env,
jclass obj,
jstring pathObj)
@@ -371,4 +383,64 @@
}
+extern "C" JNIEXPORT jboolean JNICALL Java_android_cts_rscpp_RSResizeTest_resizeTest(JNIEnv * env,
+ jclass obj,
+ jstring pathObj,
+ jint X,
+ jint Y,
+ jfloat scaleX,
+ jfloat scaleY,
+ jboolean useByte,
+ jint vecSize,
+ jbyteArray inputByteArray,
+ jbyteArray outputByteArray,
+ jfloatArray inputFloatArray,
+ jfloatArray outputFloatArray
+ )
+{
+ const char * path = env->GetStringUTFChars(pathObj, NULL);
+
+ sp<RS> rs = new RS();
+ rs->init(path);
+
+ RsDataType dt = RS_TYPE_UNSIGNED_8;
+ if (!useByte) {
+ dt = RS_TYPE_FLOAT_32;
+ }
+ sp<const Element> e = makeElement(rs, dt, vecSize);
+ sp<Allocation> inputAlloc = Allocation::createSized2D(rs, e, X, Y);
+
+ int outX = (int) (X * scaleX);
+ int outY = (int) (Y * scaleY);
+ sp<Allocation> outputAlloc = Allocation::createSized2D(rs, e, outX, outY);
+ sp<ScriptIntrinsicResize> resize = ScriptIntrinsicResize::create(rs);
+
+ if (useByte) {
+ jbyte * input = (jbyte *) env->GetPrimitiveArrayCritical(inputByteArray, 0);
+ inputAlloc->copy2DRangeFrom(0, 0, X, Y, input);
+ env->ReleasePrimitiveArrayCritical(inputByteArray, input, 0);
+ } else {
+ jfloat * input = (jfloat *) env->GetPrimitiveArrayCritical(inputFloatArray, 0);
+ inputAlloc->copy2DRangeFrom(0, 0, X, Y, input);
+ env->ReleasePrimitiveArrayCritical(inputFloatArray, input, 0);
+ }
+
+ resize->setInput(inputAlloc);
+ resize->forEach_bicubic(outputAlloc);
+
+ if (useByte) {
+ jbyte * output = (jbyte *) env->GetPrimitiveArrayCritical(outputByteArray, 0);
+ outputAlloc->copy2DRangeTo(0, 0, outX, outY, output);
+ env->ReleasePrimitiveArrayCritical(outputByteArray, output, 0);
+ } else {
+ jfloat * output = (jfloat *) env->GetPrimitiveArrayCritical(outputFloatArray, 0);
+ outputAlloc->copy2DRangeTo(0, 0, outX, outY, output);
+ env->ReleasePrimitiveArrayCritical(outputFloatArray, output, 0);
+ }
+
+ env->ReleaseStringUTFChars(pathObj, path);
+ return (rs->getError() == RS_SUCCESS);
+
+}
+
diff --git a/tests/tests/rscpp/librscpptest/rs_jni_allocation.cpp b/tests/tests/rscpp/librscpptest/rs_jni_allocation.cpp
index 4157026..4b8b8a8 100644
--- a/tests/tests/rscpp/librscpptest/rs_jni_allocation.cpp
+++ b/tests/tests/rscpp/librscpptest/rs_jni_allocation.cpp
@@ -31,8 +31,8 @@
using namespace android::RSC;
-static void createTypedHelper (sp<RS> mRS, sp<const Element> e) {
- Type::Builder typeBuilder(mRS, e);
+static void createTypedHelper (sp<RS> rs, sp<const Element> e) {
+ Type::Builder typeBuilder(rs, e);
for (int mips = 0; mips <= 1; mips ++) {
bool useMips = (mips == 1);
@@ -45,7 +45,7 @@
typeBuilder.setFaces(useFaces);
typeBuilder.setX(x);
typeBuilder.setY(y);
- Allocation::createTyped(mRS, typeBuilder.create());
+ Allocation::createTyped(rs, typeBuilder.create());
}
}
}
@@ -58,236 +58,147 @@
jstring pathObj)
{
const char * path = env->GetStringUTFChars(pathObj, NULL);
- sp<RS> mRS = new RS();
- mRS->init(path);
+ sp<RS> rs = new RS();
+ rs->init(path);
env->ReleaseStringUTFChars(pathObj, path);
- createTypedHelper(mRS, Element::A_8(mRS));
- createTypedHelper(mRS, Element::RGBA_4444(mRS));
- createTypedHelper(mRS, Element::RGBA_5551(mRS));
- createTypedHelper(mRS, Element::RGB_565(mRS));
- createTypedHelper(mRS, Element::RGB_888(mRS));
- createTypedHelper(mRS, Element::RGBA_8888(mRS));
- createTypedHelper(mRS, Element::F32(mRS));
- createTypedHelper(mRS, Element::F32_2(mRS));
- createTypedHelper(mRS, Element::F32_3(mRS));
- createTypedHelper(mRS, Element::F32_4(mRS));
- createTypedHelper(mRS, Element::F64(mRS));
- createTypedHelper(mRS, Element::F64_2(mRS));
- createTypedHelper(mRS, Element::F64_3(mRS));
- createTypedHelper(mRS, Element::F64_4(mRS));
- createTypedHelper(mRS, Element::I8(mRS));
- createTypedHelper(mRS, Element::I8_2(mRS));
- createTypedHelper(mRS, Element::I8_3(mRS));
- createTypedHelper(mRS, Element::I8_4(mRS));
- createTypedHelper(mRS, Element::I16(mRS));
- createTypedHelper(mRS, Element::I16_2(mRS));
- createTypedHelper(mRS, Element::I16_3(mRS));
- createTypedHelper(mRS, Element::I16_4(mRS));
- createTypedHelper(mRS, Element::I32(mRS));
- createTypedHelper(mRS, Element::I32_2(mRS));
- createTypedHelper(mRS, Element::I32_3(mRS));
- createTypedHelper(mRS, Element::I32_4(mRS));
- createTypedHelper(mRS, Element::I64(mRS));
- createTypedHelper(mRS, Element::I64_2(mRS));
- createTypedHelper(mRS, Element::I64_3(mRS));
- createTypedHelper(mRS, Element::I64_4(mRS));
- createTypedHelper(mRS, Element::U8(mRS));
- createTypedHelper(mRS, Element::U8_2(mRS));
- createTypedHelper(mRS, Element::U8_3(mRS));
- createTypedHelper(mRS, Element::U8_4(mRS));
- createTypedHelper(mRS, Element::U16(mRS));
- createTypedHelper(mRS, Element::U16_2(mRS));
- createTypedHelper(mRS, Element::U16_3(mRS));
- createTypedHelper(mRS, Element::U16_4(mRS));
- createTypedHelper(mRS, Element::U32(mRS));
- createTypedHelper(mRS, Element::U32_2(mRS));
- createTypedHelper(mRS, Element::U32_3(mRS));
- createTypedHelper(mRS, Element::U32_4(mRS));
- createTypedHelper(mRS, Element::U64(mRS));
- createTypedHelper(mRS, Element::U64_2(mRS));
- createTypedHelper(mRS, Element::U64_3(mRS));
- createTypedHelper(mRS, Element::U64_4(mRS));
- createTypedHelper(mRS, Element::MATRIX_2X2(mRS));
- createTypedHelper(mRS, Element::MATRIX_3X3(mRS));
- createTypedHelper(mRS, Element::MATRIX_4X4(mRS));
- createTypedHelper(mRS, Element::SAMPLER(mRS));
- createTypedHelper(mRS, Element::SCRIPT(mRS));
- createTypedHelper(mRS, Element::TYPE(mRS));
- createTypedHelper(mRS, Element::BOOLEAN(mRS));
- createTypedHelper(mRS, Element::ELEMENT(mRS));
- createTypedHelper(mRS, Element::ALLOCATION(mRS));
+ createTypedHelper(rs, Element::A_8(rs));
+ createTypedHelper(rs, Element::RGBA_4444(rs));
+ createTypedHelper(rs, Element::RGBA_5551(rs));
+ createTypedHelper(rs, Element::RGB_565(rs));
+ createTypedHelper(rs, Element::RGB_888(rs));
+ createTypedHelper(rs, Element::RGBA_8888(rs));
+ createTypedHelper(rs, Element::F32(rs));
+ createTypedHelper(rs, Element::F32_2(rs));
+ createTypedHelper(rs, Element::F32_3(rs));
+ createTypedHelper(rs, Element::F32_4(rs));
+ createTypedHelper(rs, Element::F64(rs));
+ createTypedHelper(rs, Element::F64_2(rs));
+ createTypedHelper(rs, Element::F64_3(rs));
+ createTypedHelper(rs, Element::F64_4(rs));
+ createTypedHelper(rs, Element::I8(rs));
+ createTypedHelper(rs, Element::I8_2(rs));
+ createTypedHelper(rs, Element::I8_3(rs));
+ createTypedHelper(rs, Element::I8_4(rs));
+ createTypedHelper(rs, Element::I16(rs));
+ createTypedHelper(rs, Element::I16_2(rs));
+ createTypedHelper(rs, Element::I16_3(rs));
+ createTypedHelper(rs, Element::I16_4(rs));
+ createTypedHelper(rs, Element::I32(rs));
+ createTypedHelper(rs, Element::I32_2(rs));
+ createTypedHelper(rs, Element::I32_3(rs));
+ createTypedHelper(rs, Element::I32_4(rs));
+ createTypedHelper(rs, Element::I64(rs));
+ createTypedHelper(rs, Element::I64_2(rs));
+ createTypedHelper(rs, Element::I64_3(rs));
+ createTypedHelper(rs, Element::I64_4(rs));
+ createTypedHelper(rs, Element::U8(rs));
+ createTypedHelper(rs, Element::U8_2(rs));
+ createTypedHelper(rs, Element::U8_3(rs));
+ createTypedHelper(rs, Element::U8_4(rs));
+ createTypedHelper(rs, Element::U16(rs));
+ createTypedHelper(rs, Element::U16_2(rs));
+ createTypedHelper(rs, Element::U16_3(rs));
+ createTypedHelper(rs, Element::U16_4(rs));
+ createTypedHelper(rs, Element::U32(rs));
+ createTypedHelper(rs, Element::U32_2(rs));
+ createTypedHelper(rs, Element::U32_3(rs));
+ createTypedHelper(rs, Element::U32_4(rs));
+ createTypedHelper(rs, Element::U64(rs));
+ createTypedHelper(rs, Element::U64_2(rs));
+ createTypedHelper(rs, Element::U64_3(rs));
+ createTypedHelper(rs, Element::U64_4(rs));
+ createTypedHelper(rs, Element::MATRIX_2X2(rs));
+ createTypedHelper(rs, Element::MATRIX_3X3(rs));
+ createTypedHelper(rs, Element::MATRIX_4X4(rs));
+ createTypedHelper(rs, Element::SAMPLER(rs));
+ createTypedHelper(rs, Element::SCRIPT(rs));
+ createTypedHelper(rs, Element::TYPE(rs));
+ createTypedHelper(rs, Element::BOOLEAN(rs));
+ createTypedHelper(rs, Element::ELEMENT(rs));
+ createTypedHelper(rs, Element::ALLOCATION(rs));
- mRS->finish();
+ rs->finish();
return true;
}
-static bool helperFloatCopy(sp<RS> mRS, int nElems, int offset, int count, int copyMode) {
+static sp<const Element> makeElement(sp<RS> rs, RsDataType dt, int vecSize) {
+ if (vecSize > 1) {
+ return Element::createVector(rs, dt, vecSize);
+ } else {
+ return Element::createUser(rs, dt);
+ }
+}
+
+/**
+ * Test copyTo and copyFrom for all or part of a 1D Allocation.
+ *
+ * @param rs RS Context.
+ * @param cellCount Total number of elements in this Allocation.
+ * @param offset Offset of this Allocation for copy.
+ * @param count Number of elements need to copy.
+ * @param copyRange Copy the entire allocation or part of it (using different API).
+ * @param dt DataType intended to test.
+ * @param autoPadding Enable autoPadding or not.
+*/
+template <class T>
+static bool helperCopy1D(sp<RS> rs, int cellCount, int offset, int count, bool copyRange,
+ RsDataType dt, bool autoPadding = false) {
bool passed = true;
- sp<Allocation> A = Allocation::createSized(mRS, Element::F32(mRS), nElems);
+ int arrLen = cellCount;
+ int copyCount = count;
+ int iOffset = offset;
+ sp<Allocation> alloc = nullptr;
+
+ if (autoPadding) {
+ arrLen = cellCount * 3;
+ copyCount = count * 3;
+ iOffset = offset * 3;
+ alloc = Allocation::createSized(rs, makeElement(rs, dt, 3), cellCount);
+ alloc->setAutoPadding(autoPadding);
+ } else {
+ alloc = Allocation::createSized(rs, makeElement(rs, dt, 1), cellCount);
+ }
+
+ T* src = new T[arrLen];
+ T* dst = new T[arrLen];
+
+ for (int i = 0; i < copyCount; i++) {
+ src[i] = (T)rand();
+ dst[iOffset + i] = (T)(-1);
+ }
+
+ if (!copyRange) {
+ alloc->copy1DFrom(src);
+ } else {
+ alloc->copy1DRangeFrom(offset, count, src);
+ }
+ alloc->copy1DTo(dst);
+
+ for (int i = 0; i < copyCount; i++) {
+ if (dst[iOffset + i] != src[i]) {
+ passed = false;
+ break;
+ }
+ }
+
+ delete[] src;
+ delete[] dst;
+ return passed;
+}
+
+//Corresponding 1D allocation to allocation copy.
+static bool helperFloatAllocationCopy1D(sp<RS> rs, int cellCount, int offset, int count) {
+
+ bool passed = true;
+ sp<Allocation> srcA = Allocation::createSized(rs, Element::F32(rs), cellCount);
+ sp<Allocation> dstA = Allocation::createSized(rs, Element::F32(rs), cellCount);
float *src, *dst;
- src = new float[nElems];
- dst = new float[nElems];
-
- for (int i = 0; i < count; i++) {
- src[i] = (float)i;
- dst[offset + i] = -1.0f;
- }
-
- switch (copyMode) {
- case 0: A->copy1DFrom(src); break;
- case 1: A->copy1DRangeFrom(offset, count, src); break;
- }
- A->copy1DTo(dst);
-
- for (int i = 0; i < count; i++) {
- if (dst[offset + i] != src[i]) {
- passed = false;
- break;
- }
- }
-
- delete[] src;
- delete[] dst;
- return passed;
-}
-
-static bool helperCharCopy(sp<RS> mRS, int nElems, int offset, int count, int copyMode) {
- bool passed = true;
- sp<Allocation> A = Allocation::createSized(mRS, Element::I8(mRS), nElems);
-
- char *src, *dst;
- src = new char[nElems];
- dst = new char[nElems];
-
- for (int i = 0; i < count; i++) {
- src[i] = (char)i;
- dst[offset + i] = -1;
- }
-
- switch (copyMode) {
- case 0: A->copy1DFrom(src); break;
- case 1: A->copy1DRangeFrom(offset, count, src); break;
- }
- A->copy1DTo(dst);
-
- for (int i = 0; i < count; i++) {
- if (dst[offset + i] != src[i]) {
- passed = false;
- break;
- }
- }
-
- delete[] src;
- delete[] dst;
- return passed;
-}
-
-static bool helperShortCopy(sp<RS> mRS, int nElems, int offset, int count, int copyMode) {
- bool passed = true;
- sp<Allocation> A = Allocation::createSized(mRS, Element::I16(mRS), nElems);
-
- short *src, *dst;
- src = new short[nElems];
- dst = new short[nElems];
-
- for (int i = 0; i < count; i++) {
- src[i] = (short)i;
- dst[offset + i] = -1;
- }
-
- switch (copyMode) {
- case 0: A->copy1DFrom(src); break;
- case 1: A->copy1DRangeFrom(offset, count, src); break;
- }
- A->copy1DTo(dst);
-
- for (int i = 0; i < count; i++) {
- if (dst[offset + i] != src[i]) {
- passed = false;
- break;
- }
- }
-
- delete[] src;
- delete[] dst;
- return passed;
-}
-
-static bool helperIntCopy(sp<RS> mRS, int nElems, int offset, int count, int copyMode) {
- bool passed = true;
- sp<Allocation> A = Allocation::createSized(mRS, Element::I32(mRS), nElems);
-
- int *src, *dst;
- src = new int[nElems];
- dst = new int[nElems];
-
- for (int i = 0; i < count; i++) {
- src[i] = (int)i;
- dst[offset + i] = -1;
- }
-
- switch (copyMode) {
- case 0: A->copy1DFrom(src); break;
- case 1: A->copy1DRangeFrom(offset, count, src); break;
- }
- A->copy1DTo(dst);
-
- for (int i = 0; i < count; i++) {
- if (dst[offset + i] != src[i]) {
- passed = false;
- break;
- }
- }
-
- delete[] src;
- delete[] dst;
- return passed;
-}
-
-static bool helperDoubleCopy(sp<RS> mRS, int nElems, int offset, int count, int copyMode) {
- bool passed = true;
- sp<Allocation> A = Allocation::createSized(mRS, Element::F64(mRS), nElems);
-
- double *src, *dst;
- src = new double[nElems];
- dst = new double[nElems];
-
- for (int i = 0; i < count; i++) {
- src[i] = (double)i;
- dst[offset + i] = -1;
- }
-
- switch (copyMode) {
- case 0: A->copy1DFrom(src); break;
- case 1: A->copy1DRangeFrom(offset, count, src); break;
- }
- A->copy1DTo(dst);
-
- for (int i = 0; i < count; i++) {
- if (dst[offset + i] != src[i]) {
- passed = false;
- break;
- }
- }
-
- delete[] src;
- delete[] dst;
- return passed;
-}
-
-static bool helperFloatAllocationCopy(sp<RS> mRS, int nElems, int offset, int count) {
-
- bool passed = true;
- sp<Allocation> srcA = Allocation::createSized(mRS, Element::F32(mRS), nElems);
- sp<Allocation> dstA = Allocation::createSized(mRS, Element::F32(mRS), nElems);
-
- float *src, *dst;
- src = new float[nElems];
- dst = new float[nElems];
- for (int i = 0; i < nElems; i++) {
- src[i] = (float)i;
+ src = new float[cellCount];
+ dst = new float[cellCount];
+ for (int i = 0; i < cellCount; i++) {
+ src[i] = (float)rand();
dst[i] = -1.0f;
}
@@ -309,6 +220,205 @@
return passed;
}
+/**
+ * Test copyTo and copyFrom for all or part of a 2D Allocation.
+ *
+ * @param rs RS Context.
+ * @param xElems Number of elements in X dimension in this Allocation.
+ * @param yElems Number of elements in Y dimension in this Allocation.
+ * @param xOffset Offset in X dimension of this Allocation for copy.
+ * @param yOffset Offset in Y dimension of this Allocation for copy.
+ * @param xCount Number of elements in X dimension need to copy.
+ * @param yCount Number of elements in Y dimension need to copy.
+ * @param dt DataType intended to test.
+ * @param autoPadding Enable autoPadding or not.
+*/
+template <class T>
+static bool helperCopy2D(sp<RS> rs, int xElems, int yElems,
+ int xOffset, int yOffset, int xCount, int yCount,
+ RsDataType dt, bool autoPadding = false) {
+ bool passed = true;
+ int arrLen = xElems * yElems;
+ int copyCount = xCount * yCount;
+ sp<Allocation> alloc = nullptr;
+
+ if (autoPadding) {
+ arrLen = arrLen * 3;
+ copyCount = copyCount * 3;
+ alloc = Allocation::createSized2D(rs, makeElement(rs, dt, 3), xElems, yElems);
+ alloc->setAutoPadding(autoPadding);
+ } else {
+ alloc = Allocation::createSized2D(rs, makeElement(rs, dt, 1), xElems, yElems);
+ }
+
+ T* src = new T[arrLen];
+ T* dst = new T[arrLen];
+
+ for (int i = 0; i < copyCount; i++) {
+ src[i] = (T)rand();
+ dst[i] = (T)(-1);
+ }
+
+ alloc->copy2DRangeFrom(xOffset, yOffset, xCount, yCount, src);
+ alloc->copy2DRangeTo(xOffset, yOffset, xCount, yCount, dst);
+
+ for (int i = 0; i < copyCount; i++) {
+ if (dst[i] != src[i]) {
+ passed = false;
+ break;
+ }
+ }
+
+ delete[] src;
+ delete[] dst;
+ return passed;
+}
+
+//Corresponding 2D allocation to allocation copy.
+static bool helperFloatAllocationCopy2D(sp<RS> rs, int xElems, int yElems,
+ int xOffset, int yOffset, int xCount, int yCount) {
+
+ bool passed = true;
+ sp<Allocation> srcA = Allocation::createSized2D(rs, Element::F32(rs), xElems, yElems);
+ sp<Allocation> dstA = Allocation::createSized2D(rs, Element::F32(rs), xElems, yElems);
+
+ float *src, *dst;
+ src = new float[xElems * yElems];
+ dst = new float[xElems * yElems];
+ for (int i = 0; i < xCount * yCount; i++) {
+ src[i] = (float)rand();
+ dst[i] = -1.0f;
+ }
+
+ // First populate the source allocation
+ srcA->copy2DRangeFrom(xOffset, yOffset, xCount, yCount, src);
+ // Now test allocation to allocation copy
+ dstA->copy2DRangeFrom(xOffset, yOffset, xCount, yCount, srcA, xOffset, yOffset);
+ dstA->copy2DRangeTo(xOffset, yOffset, xCount, yCount, dst);
+
+ for (int i = 0; i < xCount * yCount; i++) {
+ if (dst[i] != src[i]) {
+ passed = false;
+ break;
+ }
+ }
+
+ delete[] src;
+ delete[] dst;
+ return passed;
+}
+
+/**
+ * Test copyTo and copyFrom for all or part of a 2D Allocation.
+ *
+ * @param rs RS Context.
+ * @param xElems Number of elements in X dimension in this Allocation.
+ * @param yElems Number of elements in Y dimension in this Allocation.
+ * @param zElems Number of elements in Z dimension in this Allocation.
+ * @param xOffset Offset in X dimension of this Allocation for copy.
+ * @param yOffset Offset in Y dimension of this Allocation for copy.
+ * @param zOffset Offset in Z dimension of this Allocation for copy.
+ * @param xCount Number of elements in X dimension need to copy.
+ * @param yCount Number of elements in Y dimension need to copy.
+ * @param zCount Number of elements in Z dimension need to copy.
+ * @param dt DataType intended to test.
+ * @param autoPadding Enable autoPadding or not.
+*/
+template <class T>
+static bool helperCopy3D(sp<RS> rs, int xElems, int yElems, int zElems,
+ int xOffset, int yOffset, int zOffset,
+ int xCount, int yCount, int zCount,
+ RsDataType dt, bool autoPadding = false) {
+ bool passed = true;
+ int arrLen = xElems * yElems * zElems;
+ int copyCount = xCount * yCount * zCount;
+ sp<Allocation> alloc = nullptr;
+
+ if (autoPadding) {
+ arrLen = arrLen * 3;
+ copyCount = copyCount * 3;
+
+ Type::Builder typeBuilder(rs, makeElement(rs, dt, 3));
+ typeBuilder.setX(xElems);
+ typeBuilder.setY(yElems);
+ typeBuilder.setZ(zElems);
+
+ alloc = Allocation::createTyped(rs, typeBuilder.create());
+ alloc->setAutoPadding(autoPadding);
+ } else {
+ Type::Builder typeBuilder(rs, makeElement(rs, dt, 1));
+ typeBuilder.setX(xElems);
+ typeBuilder.setY(yElems);
+ typeBuilder.setZ(zElems);
+
+ alloc = Allocation::createTyped(rs, typeBuilder.create());
+ }
+
+ T* src = new T[arrLen];
+ T* dst = new T[arrLen];
+
+ for (int i = 0; i < copyCount; i++) {
+ src[i] = (T)rand();
+ dst[i] = (T)(-1);
+ }
+
+ alloc->copy3DRangeFrom(xOffset, yOffset, zOffset, xCount, yCount, zCount, src);
+ alloc->copy3DRangeTo(xOffset, yOffset, zOffset, xCount, yCount, zCount, dst);
+
+ for (int i = 0; i < copyCount; i++) {
+ if (dst[i] != src[i]) {
+ passed = false;
+ break;
+ }
+ }
+
+ delete[] src;
+ delete[] dst;
+ return passed;
+}
+
+//Corresponding 3D allocation to allocation copy.
+static bool helperFloatAllocationCopy3D(sp<RS> rs, int xElems, int yElems, int zElems,
+ int xOffset, int yOffset, int zOffset,
+ int xCount, int yCount, int zCount) {
+
+ bool passed = true;
+ Type::Builder typeBuilder(rs, Element::F32(rs));
+
+ typeBuilder.setX(xElems);
+ typeBuilder.setY(yElems);
+ typeBuilder.setZ(zElems);
+
+ sp<Allocation> srcA = Allocation::createTyped(rs, typeBuilder.create());
+ sp<Allocation> dstA = Allocation::createTyped(rs, typeBuilder.create());
+
+ float *src, *dst;
+ src = new float[xElems * yElems * zElems];
+ dst = new float[xElems * yElems * zElems];
+ for (int i = 0; i < xCount * yCount * zCount; i++) {
+ src[i] = (float)rand();
+ dst[i] = -1.0f;
+ }
+
+ // First populate the source allocation
+ srcA->copy3DRangeFrom(xOffset, yOffset, zOffset, xCount, yCount, zCount, src);
+ // Now test allocation to allocation copy
+ dstA->copy3DRangeFrom(xOffset, yOffset, zOffset, xCount, yCount, zCount,
+ srcA, xOffset, yOffset, zOffset);
+ dstA->copy3DRangeTo(xOffset, yOffset, zOffset, xCount, yCount, zCount, dst);
+
+ for (int i = 0; i < xCount * yCount * zCount; i++) {
+ if (dst[i] != src[i]) {
+ passed = false;
+ break;
+ }
+ }
+
+ delete[] src;
+ delete[] dst;
+ return passed;
+}
+
static int elemsToTest = 20;
extern "C" JNIEXPORT jboolean JNICALL Java_android_cts_rscpp_RSAllocationTest_test1DCopy(JNIEnv * env,
@@ -316,37 +426,180 @@
jstring pathObj)
{
const char * path = env->GetStringUTFChars(pathObj, NULL);
- sp<RS> mRS = new RS();
- mRS->init(path);
+ sp<RS> rs = new RS();
+ rs->init(path);
env->ReleaseStringUTFChars(pathObj, path);
bool passed = true;
for (int s = 8; s <= elemsToTest; s += 2) {
- for (int mode = 0; mode < 1; mode ++) {
- passed &= helperFloatCopy(mRS, s, 0, s, mode);
- passed &= helperCharCopy(mRS, s, 0, s, mode);
- passed &= helperShortCopy(mRS, s, 0, s, mode);
- passed &= helperIntCopy(mRS, s, 0, s, mode);
- //helperBaseObjCopy(mRS, s, 0, s, mode);
- }
+ passed &= helperCopy1D<float>(rs, s, 0, s, false, RS_TYPE_FLOAT_32);
+ passed &= helperCopy1D<char>(rs, s, 0, s, false, RS_TYPE_SIGNED_8);
+ passed &= helperCopy1D<short>(rs, s, 0, s, false, RS_TYPE_SIGNED_16);
+ passed &= helperCopy1D<int>(rs, s, 0, s, false, RS_TYPE_SIGNED_32);
+ passed &= helperCopy1D<double>(rs, s, 0, s, false, RS_TYPE_FLOAT_64);
// now test copy range
- for (int mode = 1; mode < 2; mode ++) {
- for (int off = 0; off < s; off ++) {
- for (int count = 1; count <= s - off; count ++) {
- passed &= helperFloatCopy(mRS, s, off, count, mode);
- passed &= helperCharCopy(mRS, s, off, count, mode);
- passed &= helperShortCopy(mRS, s, off, count, mode);
- passed &= helperIntCopy(mRS, s, off, count, mode);
- //helperBaseObjCopy(mRS, s, off, count, mode);
- }
+ for (int off = 0; off < s; off ++) {
+ for (int count = 1; count <= s - off; count ++) {
+ passed &= helperCopy1D<float>(rs, s, off, count, true, RS_TYPE_FLOAT_32);
+ passed &= helperCopy1D<char>(rs, s, off, count, true, RS_TYPE_SIGNED_8);
+ passed &= helperCopy1D<short>(rs, s, off, count, true, RS_TYPE_SIGNED_16);
+ passed &= helperCopy1D<int>(rs, s, off, count, true, RS_TYPE_SIGNED_32);
+ passed &= helperCopy1D<double>(rs, s, off, count, true, RS_TYPE_FLOAT_64);
}
}
for (int off = 0; off < s; off ++) {
for (int count = 1; count <= s - off; count ++) {
- passed &= helperFloatAllocationCopy(mRS, s, off, count);
- //helperByteAllocationCopy(mRS, s, off, count);
+ passed &= helperFloatAllocationCopy1D(rs, s, off, count);
+ }
+ }
+ }
+ return passed;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL Java_android_cts_rscpp_RSAllocationTest_test2DCopy(JNIEnv * env,
+ jclass obj,
+ jstring pathObj)
+{
+ const char * path = env->GetStringUTFChars(pathObj, NULL);
+ sp<RS> rs = new RS();
+ rs->init(path);
+ env->ReleaseStringUTFChars(pathObj, path);
+ bool passed = true;
+
+ for (int s = 8; s <= elemsToTest; s += 2) {
+ // now test copy range
+ for (int off = 0; off < s; off ++) {
+ for (int count = 1; count <= s - off; count ++) {
+ passed &= helperCopy2D<float>(rs, s, s, off, off, count, count, RS_TYPE_FLOAT_32);
+ passed &= helperCopy2D<char>(rs, s, s, off, off, count, count, RS_TYPE_SIGNED_8);
+ passed &= helperCopy2D<short>(rs, s, s, off, off, count, count, RS_TYPE_SIGNED_16);
+ passed &= helperCopy2D<int>(rs, s, s, off, off, count, count, RS_TYPE_SIGNED_32);
+ passed &= helperCopy2D<double>(rs, s, s, off, off, count, count, RS_TYPE_FLOAT_64);
+ }
+ }
+
+ for (int off = 0; off < s; off ++) {
+ for (int count = 1; count <= s - off; count ++) {
+ passed &= helperFloatAllocationCopy2D(rs, s, s, off, off, count, count);
+ }
+ }
+ }
+ return passed;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL Java_android_cts_rscpp_RSAllocationTest_test3DCopy(JNIEnv * env,
+ jclass obj,
+ jstring pathObj)
+{
+ const char * path = env->GetStringUTFChars(pathObj, NULL);
+ sp<RS> rs = new RS();
+ rs->init(path);
+ env->ReleaseStringUTFChars(pathObj, path);
+ bool passed = true;
+
+ for (int s = 8; s <= elemsToTest; s += 2) {
+ // now test copy range
+ for (int off = 0; off < s; off ++) {
+ for (int count = 1; count <= s - off; count ++) {
+ passed &= helperCopy3D<float>(rs, s, s, s, off, off, off, count, count, count, RS_TYPE_FLOAT_32);
+ passed &= helperCopy3D<char>(rs, s, s, s, off, off, off, count, count, count, RS_TYPE_SIGNED_8);
+ passed &= helperCopy3D<short>(rs, s, s, s, off, off, off, count, count, count, RS_TYPE_SIGNED_16);
+ passed &= helperCopy3D<int>(rs, s, s, s, off, off, off, count, count, count, RS_TYPE_SIGNED_32);
+ passed &= helperCopy3D<double>(rs, s, s, s, off, off, off, count, count, count, RS_TYPE_FLOAT_64);
+ }
+ }
+
+ for (int off = 0; off < s; off ++) {
+ for (int count = 1; count <= s - off; count ++) {
+ passed &= helperFloatAllocationCopy3D(rs, s, s, s, off, off, off, count, count, count);
+ }
+ }
+ }
+ return passed;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL Java_android_cts_rscpp_RSAllocationTest_test1DCopyPadded(JNIEnv * env,
+ jclass obj,
+ jstring pathObj)
+{
+ const char * path = env->GetStringUTFChars(pathObj, NULL);
+ sp<RS> rs = new RS();
+ rs->init(path);
+ env->ReleaseStringUTFChars(pathObj, path);
+ bool passed = true;
+
+ for (int s = 8; s <= elemsToTest; s += 2) {
+ passed &= helperCopy1D<float>(rs, s, 0, s, false, RS_TYPE_FLOAT_32, true);
+ passed &= helperCopy1D<char>(rs, s, 0, s, false, RS_TYPE_SIGNED_8, true);
+ passed &= helperCopy1D<short>(rs, s, 0, s, false, RS_TYPE_SIGNED_16, true);
+ passed &= helperCopy1D<int>(rs, s, 0, s, false, RS_TYPE_SIGNED_32, true);
+ passed &= helperCopy1D<double>(rs, s, 0, s, false, RS_TYPE_FLOAT_64, true);
+
+ // now test copy range
+ for (int off = 0; off < s; off ++) {
+ for (int count = 1; count <= s - off; count ++) {
+ passed &= helperCopy1D<float>(rs, s, off, count, true, RS_TYPE_FLOAT_32, true);
+ passed &= helperCopy1D<char>(rs, s, off, count, true, RS_TYPE_SIGNED_8, true);
+ passed &= helperCopy1D<short>(rs, s, off, count, true, RS_TYPE_SIGNED_16, true);
+ passed &= helperCopy1D<int>(rs, s, off, count, true, RS_TYPE_SIGNED_32, true);
+ passed &= helperCopy1D<double>(rs, s, off, count, true, RS_TYPE_FLOAT_64, true);
+ }
+ }
+ }
+ return passed;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL Java_android_cts_rscpp_RSAllocationTest_test2DCopyPadded(JNIEnv * env,
+ jclass obj,
+ jstring pathObj)
+{
+ const char * path = env->GetStringUTFChars(pathObj, NULL);
+ sp<RS> rs = new RS();
+ rs->init(path);
+ env->ReleaseStringUTFChars(pathObj, path);
+ bool passed = true;
+
+ for (int s = 8; s <= elemsToTest; s += 2) {
+ // now test copy range
+ for (int off = 0; off < s; off ++) {
+ for (int count = 1; count <= s - off; count ++) {
+ passed &= helperCopy2D<float>(rs, s, s, off, off, count, count, RS_TYPE_FLOAT_32, true);
+ passed &= helperCopy2D<char>(rs, s, s, off, off, count, count, RS_TYPE_SIGNED_8, true);
+ passed &= helperCopy2D<short>(rs, s, s, off, off, count, count, RS_TYPE_SIGNED_16, true);
+ passed &= helperCopy2D<int>(rs, s, s, off, off, count, count, RS_TYPE_SIGNED_32, true);
+ passed &= helperCopy2D<double>(rs, s, s, off, off, count, count, RS_TYPE_FLOAT_64, true);
+ }
+ }
+ }
+ return passed;
+}
+
+extern "C" JNIEXPORT jboolean JNICALL Java_android_cts_rscpp_RSAllocationTest_test3DCopyPadded(JNIEnv * env,
+ jclass obj,
+ jstring pathObj)
+{
+ const char * path = env->GetStringUTFChars(pathObj, NULL);
+ sp<RS> rs = new RS();
+ rs->init(path);
+ env->ReleaseStringUTFChars(pathObj, path);
+ bool passed = true;
+
+ for (int s = 8; s <= elemsToTest; s += 2) {
+ // now test copy range
+ for (int off = 0; off < s; off ++) {
+ for (int count = 1; count <= s - off; count ++) {
+ passed &= helperCopy3D<float>(rs, s, s, s, off, off, off, count, count, count,
+ RS_TYPE_FLOAT_32, true);
+ passed &= helperCopy3D<char>(rs, s, s, s, off, off, off, count, count, count,
+ RS_TYPE_SIGNED_8, true);
+ passed &= helperCopy3D<short>(rs, s, s, s, off, off, off, count, count, count,
+ RS_TYPE_SIGNED_16, true);
+ passed &= helperCopy3D<int>(rs, s, s, s, off, off, off, count, count, count,
+ RS_TYPE_SIGNED_32, true);
+ passed &= helperCopy3D<double>(rs, s, s, s, off, off, off, count, count, count,
+ RS_TYPE_FLOAT_64, true);
}
}
}
@@ -358,19 +611,19 @@
jstring pathObj)
{
const char * path = env->GetStringUTFChars(pathObj, NULL);
- sp<RS> mRS = new RS();
- mRS->init(path);
+ sp<RS> rs = new RS();
+ rs->init(path);
env->ReleaseStringUTFChars(pathObj, path);
bool passed = true;
- Type::Builder b(mRS, Element::I32(mRS));
+ Type::Builder b(rs, Element::I32(rs));
b.setX(48);
- sp<Allocation> largeArray = Allocation::createTyped(mRS, b.create());
+ sp<Allocation> largeArray = Allocation::createTyped(rs, b.create());
b.setX(1);
- sp<Allocation> singleElement = Allocation::createTyped(mRS, b.create());
+ sp<Allocation> singleElement = Allocation::createTyped(rs, b.create());
- sp<ScriptC_setelementat> script = new ScriptC_setelementat(mRS);
+ sp<ScriptC_setelementat> script = new ScriptC_setelementat(rs);
script->set_memset_toValue(1);
script->forEach_memset(singleElement);
diff --git a/tests/tests/rscpp/src/android/cts/rscpp/RSAllocationTest.java b/tests/tests/rscpp/src/android/cts/rscpp/RSAllocationTest.java
index 76dbfee..012e731 100644
--- a/tests/tests/rscpp/src/android/cts/rscpp/RSAllocationTest.java
+++ b/tests/tests/rscpp/src/android/cts/rscpp/RSAllocationTest.java
@@ -33,14 +33,39 @@
}
native boolean test1DCopy(String path);
- public void testRSAllocationCopy() {
+ public void testRSAllocationCopy1D() {
assertTrue(test1DCopy(this.getContext().getCacheDir().toString()));
}
+ native boolean test2DCopy(String path);
+ public void testRSAllocationCopy2D() {
+ assertTrue(test2DCopy(this.getContext().getCacheDir().toString()));
+ }
+
+ native boolean test3DCopy(String path);
+ public void testRSAllocationCopy3D() {
+ assertTrue(test3DCopy(this.getContext().getCacheDir().toString()));
+ }
+
+ native boolean test1DCopyPadded(String path);
+ public void testRSAllocationCopy1DPadded() {
+ assertTrue(test1DCopyPadded(this.getContext().getCacheDir().toString()));
+ }
+
+ native boolean test2DCopyPadded(String path);
+ public void testRSAllocationCopy2DPadded() {
+ assertTrue(test2DCopyPadded(this.getContext().getCacheDir().toString()));
+ }
+
+ native boolean test3DCopyPadded(String path);
+ public void testRSAllocationCopy3DPadded() {
+ assertTrue(test3DCopyPadded(this.getContext().getCacheDir().toString()));
+ }
+
native boolean testSetElementAt(String path);
public void testRSAllocationSetElementAt() {
assertTrue(testSetElementAt(this.getContext().getCacheDir().toString()));
}
-}
\ No newline at end of file
+}
diff --git a/tests/tests/rscpp/src/android/cts/rscpp/RSCppTest.java b/tests/tests/rscpp/src/android/cts/rscpp/RSCppTest.java
index 9b09cc7..0b308cb 100644
--- a/tests/tests/rscpp/src/android/cts/rscpp/RSCppTest.java
+++ b/tests/tests/rscpp/src/android/cts/rscpp/RSCppTest.java
@@ -25,6 +25,7 @@
import android.renderscript.RenderScript;
import android.renderscript.Allocation;
import android.renderscript.Element;
+import android.renderscript.Type;
import android.util.Log;
public class RSCppTest extends AndroidTestCase {
@@ -73,6 +74,29 @@
}
};
+ protected Element makeElement(Element.DataType dt, int vecSize) {
+ Element e;
+ if (vecSize > 1) {
+ e = Element.createVector(mRS, dt, vecSize);
+ } else {
+ if (dt == Element.DataType.UNSIGNED_8) {
+ e = Element.U8(mRS);
+ } else {
+ e = Element.F32(mRS);
+ }
+ }
+ return e;
+ }
+
+ protected Allocation makeAllocation(int w, int h, Element e) {
+ Type.Builder tb = new Type.Builder(mRS, e);
+ tb.setX(w);
+ tb.setY(h);
+ Type t = tb.create();
+ Allocation a = Allocation.createTyped(mRS, t);
+ return a;
+ }
+
protected void checkForErrors() {
mRS.finish();
mVerify.invoke_checkError();
diff --git a/tests/tests/rscpp/src/android/cts/rscpp/RSResizeTest.java b/tests/tests/rscpp/src/android/cts/rscpp/RSResizeTest.java
new file mode 100644
index 0000000..b4864b5
--- /dev/null
+++ b/tests/tests/rscpp/src/android/cts/rscpp/RSResizeTest.java
@@ -0,0 +1,353 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.cts.rscpp;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.test.AndroidTestCase;
+import android.renderscript.*;
+import android.util.Log;
+import java.lang.Integer;
+
+public class RSResizeTest extends RSCppTest {
+ static {
+ System.loadLibrary("rscpptest_jni");
+ }
+
+ private final int inX = 307;
+ private final int inY = 157;
+
+ native boolean resizeTest(String path, int w, int h, float scaleX, float scaleY,
+ boolean useByte, int vecSize, byte[] inB, byte[] outB,
+ float[] inF, float[] outF);
+ private void testReszie(int w, int h, Element.DataType dt, int vecSize, float scaleX, float scaleY) {
+
+ boolean useByte = false;
+ if (dt == Element.DataType.UNSIGNED_8) {
+ useByte = true;
+ }
+
+ Element e = makeElement(dt, vecSize);
+ Allocation rsInput = makeAllocation(w, h, e);
+
+ int arrSize = w * h * (vecSize == 3 ? 4 : vecSize);
+ int[] baseAlloc = new int[arrSize];
+ byte[] byteAlloc = null;
+ float[] floatAlloc = null;
+
+ RSUtils.genRandom(0x72727272, 255, 1, -128, baseAlloc);
+ if (useByte) {
+ byteAlloc = new byte[arrSize];
+ for (int i = 0; i < arrSize; i++) {
+ byteAlloc[i] = (byte)baseAlloc[i];
+ }
+ rsInput.copyFromUnchecked(byteAlloc);
+ } else {
+ //Float case
+ floatAlloc = new float[arrSize];
+ for (int i = 0; i < arrSize; i++) {
+ floatAlloc[i] = (float)baseAlloc[i];
+ }
+ rsInput.copyFromUnchecked(floatAlloc);
+ }
+
+ int outW = (int) (w*scaleX);
+ int outH = (int) (h*scaleY);
+
+ Allocation rsOutput = makeAllocation(outW, outH, e);
+ Allocation rsCppOutput = makeAllocation(outW, outH, e);
+
+ ScriptIntrinsicResize resize = ScriptIntrinsicResize.create(mRS);
+ resize.setInput(rsInput);
+ resize.forEach_bicubic(rsOutput);
+
+ int outArrSize = outW * outH * (vecSize == 3 ? 4 : vecSize);
+ byte[] nativeByteAlloc = new byte[outArrSize];
+ float[] nativeFloatAlloc = new float[outArrSize];
+ resizeTest(this.getContext().getCacheDir().toString().toString(), w, h, scaleX, scaleY,
+ useByte, vecSize, byteAlloc, nativeByteAlloc, floatAlloc, nativeFloatAlloc);
+
+ if (useByte) {
+ rsCppOutput.copyFromUnchecked(nativeByteAlloc);
+ } else {
+ rsCppOutput.copyFromUnchecked(nativeFloatAlloc);
+ }
+ mVerify.invoke_verify(rsOutput, rsCppOutput, rsInput);
+ checkForErrors();
+ }
+
+ public void test_U8_4_SCALE10_10_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 4, 1.f, 1.f);
+ }
+ public void test_U8_3_SCALE10_10_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 3, 1.f, 1.f);
+ }
+ public void test_U8_2_SCALE10_10_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 2, 1.f, 1.f);
+ }
+ public void test_U8_1_SCALE10_10_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 1, 1.f, 1.f);
+ }
+
+ public void test_U8_4_SCALE20_20_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 4, 2.f, 2.f);
+ }
+ public void test_U8_3_SCALE20_20_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 3, 2.f, 2.f);
+ }
+ public void test_U8_2_SCALE20_20_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 2, 2.f, 2.f);
+ }
+ public void test_U8_1_SCALE20_20_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 1, 2.f, 2.f);
+ }
+
+ public void test_U8_4_SCALE05_20_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 4, 0.5f, 2.f);
+ }
+ public void test_U8_3_SCALE05_20_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 3, 0.5f, 2.f);
+ }
+ public void test_U8_2_SCALE05_20_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 2, 0.5f, 2.f);
+ }
+ public void test_U8_1_SCALE05_20_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 1, 0.5f, 2.f);
+ }
+
+ public void test_U8_4_SCALE20_05_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 4, 2.f, 0.5f);
+ }
+ public void test_U8_3_SCALE20_05_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 3, 2.f, 0.5f);
+ }
+ public void test_U8_2_SCALE20_05_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 2, 2.f, 0.5f);
+ }
+ public void test_U8_1_SCALE20_05_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 1, 2.f, 0.5f);
+ }
+
+ public void test_U8_4_SCALE05_05_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 4, 0.5f, 0.5f);
+ }
+ public void test_U8_3_SCALE05_05_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 3, 0.5f, 0.5f);
+ }
+ public void test_U8_2_SCALE05_05_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 2, 0.5f, 0.5f);
+ }
+ public void test_U8_1_SCALE05_05_inSqure() {
+ testReszie(inX, inX, Element.DataType.UNSIGNED_8, 1, 0.5f, 0.5f);
+ }
+
+ public void test_U8_4_SCALE10_10_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 4, 1.f, 1.f);
+ }
+ public void test_U8_3_SCALE10_10_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 3, 1.f, 1.f);
+ }
+ public void test_U8_2_SCALE10_10_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 2, 1.f, 1.f);
+ }
+ public void test_U8_1_SCALE10_10_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 1, 1.f, 1.f);
+ }
+
+ public void test_U8_4_SCALE20_20_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 4, 2.f, 2.f);
+ }
+ public void test_U8_3_SCALE20_20_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 3, 2.f, 2.f);
+ }
+ public void test_U8_2_SCALE20_20_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 2, 2.f, 2.f);
+ }
+ public void test_U8_1_SCALE20_20_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 1, 2.f, 2.f);
+ }
+
+ public void test_U8_4_SCALE05_20_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 4, 0.5f, 2.f);
+ }
+ public void test_U8_3_SCALE05_20_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 3, 0.5f, 2.f);
+ }
+ public void test_U8_2_SCALE05_20_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 2, 0.5f, 2.f);
+ }
+ public void test_U8_1_SCALE05_20_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 1, 0.5f, 2.f);
+ }
+
+ public void test_U8_4_SCALE20_05_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 4, 2.f, 0.5f);
+ }
+ public void test_U8_3_SCALE20_05_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 3, 2.f, 0.5f);
+ }
+ public void test_U8_2_SCALE20_05_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 2, 2.f, 0.5f);
+ }
+ public void test_U8_1_SCALE20_05_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 1, 2.f, 0.5f);
+ }
+
+ public void test_U8_4_SCALE05_05_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 4, 0.5f, 0.5f);
+ }
+ public void test_U8_3_SCALE05_05_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 3, 0.5f, 0.5f);
+ }
+ public void test_U8_2_SCALE05_05_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 2, 0.5f, 0.5f);
+ }
+ public void test_U8_1_SCALE05_05_inRectangle() {
+ testReszie(inX, inY, Element.DataType.UNSIGNED_8, 1, 0.5f, 0.5f);
+ }
+
+
+ public void test_F32_4_SCALE10_10_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 4, 1.f, 1.f);
+ }
+ public void test_F32_3_SCALE10_10_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 3, 1.f, 1.f);
+ }
+ public void test_F32_2_SCALE10_10_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 2, 1.f, 1.f);
+ }
+ public void test_F32_1_SCALE10_10_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 1, 1.f, 1.f);
+ }
+
+ public void test_F32_4_SCALE20_20_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 4, 2.f, 2.f);
+ }
+ public void test_F32_3_SCALE20_20_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 3, 2.f, 2.f);
+ }
+ public void test_F32_2_SCALE20_20_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 2, 2.f, 2.f);
+ }
+ public void test_F32_1_SCALE20_20_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 1, 2.f, 2.f);
+ }
+
+ public void test_F32_4_SCALE05_20_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 4, 0.5f, 2.f);
+ }
+ public void test_F32_3_SCALE05_20_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 3, 0.5f, 2.f);
+ }
+ public void test_F32_2_SCALE05_20_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 2, 0.5f, 2.f);
+ }
+ public void test_F32_1_SCALE05_20_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 1, 0.5f, 2.f);
+ }
+
+ public void test_F32_4_SCALE20_05_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 4, 2.f, 0.5f);
+ }
+ public void test_F32_3_SCALE20_05_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 3, 2.f, 0.5f);
+ }
+ public void test_F32_2_SCALE20_05_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 2, 2.f, 0.5f);
+ }
+ public void test_F32_1_SCALE20_05_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 1, 2.f, 0.5f);
+ }
+
+ public void test_F32_4_SCALE05_05_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 4, 0.5f, 0.5f);
+ }
+ public void test_F32_3_SCALE05_05_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 3, 0.5f, 0.5f);
+ }
+ public void test_F32_2_SCALE05_05_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 2, 0.5f, 0.5f);
+ }
+ public void test_F32_1_SCALE05_05_inSqure() {
+ testReszie(inX, inX, Element.DataType.FLOAT_32, 1, 0.5f, 0.5f);
+ }
+
+ public void test_F32_4_SCALE10_10_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 4, 1.f, 1.f);
+ }
+ public void test_F32_3_SCALE10_10_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 3, 1.f, 1.f);
+ }
+ public void test_F32_2_SCALE10_10_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 2, 1.f, 1.f);
+ }
+ public void test_F32_1_SCALE10_10_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 1, 1.f, 1.f);
+ }
+
+ public void test_F32_4_SCALE20_20_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 4, 2.f, 2.f);
+ }
+ public void test_F32_3_SCALE20_20_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 3, 2.f, 2.f);
+ }
+ public void test_F32_2_SCALE20_20_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 2, 2.f, 2.f);
+ }
+ public void test_F32_1_SCALE20_20_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 1, 2.f, 2.f);
+ }
+
+ public void test_F32_4_SCALE05_20_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 4, 0.5f, 2.f);
+ }
+ public void test_F32_3_SCALE05_20_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 3, 0.5f, 2.f);
+ }
+ public void test_F32_2_SCALE05_20_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 2, 0.5f, 2.f);
+ }
+ public void test_F32_1_SCALE05_20_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 1, 0.5f, 2.f);
+ }
+
+ public void test_F32_4_SCALE20_05_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 4, 2.f, 0.5f);
+ }
+ public void test_F32_3_SCALE20_05_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 3, 2.f, 0.5f);
+ }
+ public void test_F32_2_SCALE20_05_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 2, 2.f, 0.5f);
+ }
+ public void test_F32_1_SCALE20_05_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 1, 2.f, 0.5f);
+ }
+
+ public void test_F32_4_SCALE05_05_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 4, 0.5f, 0.5f);
+ }
+ public void test_F32_3_SCALE05_05_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 3, 0.5f, 0.5f);
+ }
+ public void test_F32_2_SCALE05_05_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 2, 0.5f, 0.5f);
+ }
+ public void test_F32_1_SCALE05_05_inRectangle() {
+ testReszie(inX, inY, Element.DataType.FLOAT_32, 1, 0.5f, 0.5f);
+ }
+}
diff --git a/tests/tests/security/src/android/security/cts/SELinuxTest.java b/tests/tests/security/src/android/security/cts/SELinuxTest.java
index c768680..3df7396 100644
--- a/tests/tests/security/src/android/security/cts/SELinuxTest.java
+++ b/tests/tests/security/src/android/security/cts/SELinuxTest.java
@@ -99,8 +99,13 @@
public void testFileContexts() throws Exception {
assertEquals(getFileContext("/"), "u:object_r:rootfs:s0");
assertEquals(getFileContext("/dev"), "u:object_r:device:s0");
+ assertEquals(getFileContext("/dev/socket"), "u:object_r:socket_device:s0");
+ assertEquals(getFileContext("/dev/binder"), "u:object_r:binder_device:s0");
assertEquals(getFileContext("/system"), "u:object_r:system_file:s0");
+ assertEquals(getFileContext("/system/bin/app_process"), "u:object_r:zygote_exec:s0");
assertEquals(getFileContext("/data"), "u:object_r:system_data_file:s0");
+ assertEquals(getFileContext("/data/app"), "u:object_r:apk_data_file:s0");
+ assertEquals(getFileContext("/data/local/tmp"), "u:object_r:shell_data_file:s0");
assertEquals(getFileContext("/cache"), "u:object_r:cache_file:s0");
assertEquals(getFileContext("/sys"), "u:object_r:sysfs:s0");
}
diff --git a/tests/tests/telephony/src/android/telephony/cts/SimRestrictedApisTest.java b/tests/tests/telephony/src/android/telephony/cts/SimRestrictedApisTest.java
index cb9d96c..68e71d1 100644
--- a/tests/tests/telephony/src/android/telephony/cts/SimRestrictedApisTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/SimRestrictedApisTest.java
@@ -221,7 +221,7 @@
public void testGetPreferredNetworkType() {
try {
if (isSimCardPresent()) {
- TelephonyManager.getDefault().getPreferredNetworkType();
+ TelephonyManager.getDefault().getPreferredNetworkType(0);
fail("Expected SecurityException. App doesn't have carrier privileges.");
}
} catch (SecurityException expected) {