diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/AndroidTests/src/com/android/unit_tests/BitwiseStreamsTest.java | 33 | ||||
| -rw-r--r-- | tests/AndroidTests/src/com/android/unit_tests/CdmaSmsTest.java | 6 | ||||
| -rw-r--r-- | tests/DpiTest/AndroidManifest.xml | 2 | ||||
| -rw-r--r-- | tests/DpiTest/res/values-largeScreen/strings.xml | 19 | ||||
| -rw-r--r-- | tests/DpiTest/res/values-normalScreen/strings.xml | 19 | ||||
| -rw-r--r-- | tests/DpiTest/res/values-smallScreen/strings.xml | 19 | ||||
| -rw-r--r-- | tests/DpiTest/res/values/strings.xml | 19 | ||||
| -rw-r--r-- | tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java | 1 | ||||
| -rw-r--r-- | tests/backup/src/com/android/backuptest/BackupTestAgent.java | 4 | ||||
| -rwxr-xr-x | tests/backup/test_backup.sh | 27 | ||||
| -rwxr-xr-x | tests/backup/test_restore.sh | 53 |
11 files changed, 194 insertions, 8 deletions
diff --git a/tests/AndroidTests/src/com/android/unit_tests/BitwiseStreamsTest.java b/tests/AndroidTests/src/com/android/unit_tests/BitwiseStreamsTest.java index a935247..c5562b3 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/BitwiseStreamsTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/BitwiseStreamsTest.java @@ -25,6 +25,8 @@ import android.test.suitebuilder.annotation.SmallTest; import android.util.Log; +import java.util.Random; + public class BitwiseStreamsTest extends AndroidTestCase { private final static String LOG_TAG = "BitwiseStreamsTest"; @@ -39,7 +41,7 @@ public class BitwiseStreamsTest extends AndroidTestCase { BitwiseInputStream inStream = new BitwiseInputStream(outBuf); byte[] inBufDup = new byte[inBuf.length]; inStream.skip(offset); - for (int i = 0; i < inBufDup.length; i++) inBufDup[i] = inStream.read(8); + for (int i = 0; i < inBufDup.length; i++) inBufDup[i] = (byte)inStream.read(8); assertEquals(HexDump.toHexString(inBuf), HexDump.toHexString(inBufDup)); } @@ -53,7 +55,7 @@ public class BitwiseStreamsTest extends AndroidTestCase { BitwiseInputStream inStream = new BitwiseInputStream(outStream.toByteArray()); inStream.skip(offset); byte[] inBufDup = new byte[inBuf.length]; - for (int i = 0; i < inBufDup.length; i++) inBufDup[i] = inStream.read(8); + for (int i = 0; i < inBufDup.length; i++) inBufDup[i] = (byte)inStream.read(8); assertEquals(HexDump.toHexString(inBuf), HexDump.toHexString(inBufDup)); } @@ -67,7 +69,7 @@ public class BitwiseStreamsTest extends AndroidTestCase { BitwiseInputStream inStream = new BitwiseInputStream(outStream.toByteArray()); inStream.skip(offset); byte[] inBufDup = new byte[inBuf.length]; - for (int i = 0; i < inBufDup.length; i++) inBufDup[i] = inStream.read(8); + for (int i = 0; i < inBufDup.length; i++) inBufDup[i] = (byte)inStream.read(8); assertEquals(HexDump.toHexString(inBuf), HexDump.toHexString(inBufDup)); } @@ -84,12 +86,33 @@ public class BitwiseStreamsTest extends AndroidTestCase { BitwiseInputStream inStream = new BitwiseInputStream(outStream.toByteArray()); inStream.skip(offset); byte[] inBufDup = new byte[inBuf.length]; - for (int i = 0; i < inBufDup.length; i++) inBufDup[i] = inStream.read(8); + for (int i = 0; i < inBufDup.length; i++) inBufDup[i] = (byte)inStream.read(8); assertEquals(HexDump.toHexString(inBuf), HexDump.toHexString(inBufDup)); } @SmallTest public void testFive() throws Exception { + Random random = new Random(); + int iterations = 10000; + int[] sizeArr = new int[iterations]; + int[] valueArr = new int[iterations]; + BitwiseOutputStream outStream = new BitwiseOutputStream(iterations * 4); + for (int i = 0; i < iterations; i++) { + int x = random.nextInt(); + int size = (x & 0x07) + 1; + int value = x & (-1 >>> (32 - size)); + sizeArr[i] = size; + valueArr[i] = value; + outStream.write(size, value); + } + BitwiseInputStream inStream = new BitwiseInputStream(outStream.toByteArray()); + for (int i = 0; i < iterations; i++) { + assertEquals(valueArr[i], inStream.read(sizeArr[i])); + } + } + + @SmallTest + public void testSix() throws Exception { int num_runs = 10; long start = android.os.SystemClock.elapsedRealtime(); for (int run = 0; run < num_runs; run++) { @@ -104,7 +127,7 @@ public class BitwiseStreamsTest extends AndroidTestCase { BitwiseInputStream inStream = new BitwiseInputStream(outStream.toByteArray()); inStream.skip(offset); byte[] inBufDup = new byte[inBuf.length]; - for (int i = 0; i < inBufDup.length; i++) inBufDup[i] = inStream.read(8); + for (int i = 0; i < inBufDup.length; i++) inBufDup[i] = (byte)inStream.read(8); assertEquals(HexDump.toHexString(inBuf), HexDump.toHexString(inBufDup)); } long end = android.os.SystemClock.elapsedRealtime(); diff --git a/tests/AndroidTests/src/com/android/unit_tests/CdmaSmsTest.java b/tests/AndroidTests/src/com/android/unit_tests/CdmaSmsTest.java index b2529811..9188e04 100644 --- a/tests/AndroidTests/src/com/android/unit_tests/CdmaSmsTest.java +++ b/tests/AndroidTests/src/com/android/unit_tests/CdmaSmsTest.java @@ -171,14 +171,14 @@ public class CdmaSmsTest extends AndroidTestCase { assertEquals(bearerData.msgCenterTimeStamp.minute, 1); assertEquals(bearerData.msgCenterTimeStamp.second, 59); assertEquals(bearerData.validityPeriodAbsolute, null); - assertEquals(bearerData.validityPeriodRelative, -63); + assertEquals(bearerData.validityPeriodRelative, 193); assertEquals(bearerData.deferredDeliveryTimeAbsolute.year, 1997); assertEquals(bearerData.deferredDeliveryTimeAbsolute.month, 5); assertEquals(bearerData.deferredDeliveryTimeAbsolute.monthDay, 18); assertEquals(bearerData.deferredDeliveryTimeAbsolute.hour, 0); assertEquals(bearerData.deferredDeliveryTimeAbsolute.minute, 0); assertEquals(bearerData.deferredDeliveryTimeAbsolute.second, 0); - assertEquals(bearerData.deferredDeliveryTimeRelative, -57); + assertEquals(bearerData.deferredDeliveryTimeRelative, 199); assertEquals(bearerData.hasUserDataHeader, false); assertEquals(bearerData.userData.msgEncoding, UserData.ENCODING_7BIT_ASCII); assertEquals(bearerData.userData.numFields, 2); @@ -225,7 +225,7 @@ public class CdmaSmsTest extends AndroidTestCase { assertEquals(bearerData.deferredDeliveryTimeAbsolute.hour, 0); assertEquals(bearerData.deferredDeliveryTimeAbsolute.minute, 0); assertEquals(bearerData.deferredDeliveryTimeAbsolute.second, 0); - assertEquals(bearerData.deferredDeliveryTimeRelative, -110); + assertEquals(bearerData.deferredDeliveryTimeRelative, 146); assertEquals(bearerData.hasUserDataHeader, false); assertEquals(bearerData.userData.msgEncoding, UserData.ENCODING_7BIT_ASCII); assertEquals(bearerData.userData.numFields, 2); diff --git a/tests/DpiTest/AndroidManifest.xml b/tests/DpiTest/AndroidManifest.xml index f71cff2..64ad7be 100644 --- a/tests/DpiTest/AndroidManifest.xml +++ b/tests/DpiTest/AndroidManifest.xml @@ -16,6 +16,8 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.google.android.test.dpi"> + <uses-sdk android:minSdkVersion="3" android:targetSdkVersion="3" /> + <supports-screens android:smallScreens="true" /> <application android:label="DpiTest"> <activity android:name="DpiTestActivity" android:label="DpiTest"> <intent-filter> diff --git a/tests/DpiTest/res/values-largeScreen/strings.xml b/tests/DpiTest/res/values-largeScreen/strings.xml new file mode 100644 index 0000000..f4dd543 --- /dev/null +++ b/tests/DpiTest/res/values-largeScreen/strings.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <string name="act_title">DpiTest: Large Screen</string> +</resources> diff --git a/tests/DpiTest/res/values-normalScreen/strings.xml b/tests/DpiTest/res/values-normalScreen/strings.xml new file mode 100644 index 0000000..256d696 --- /dev/null +++ b/tests/DpiTest/res/values-normalScreen/strings.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <string name="act_title">DpiTest: Normal Screen</string> +</resources> diff --git a/tests/DpiTest/res/values-smallScreen/strings.xml b/tests/DpiTest/res/values-smallScreen/strings.xml new file mode 100644 index 0000000..cdb4ac9 --- /dev/null +++ b/tests/DpiTest/res/values-smallScreen/strings.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <string name="act_title">DpiTest: Small Screen</string> +</resources> diff --git a/tests/DpiTest/res/values/strings.xml b/tests/DpiTest/res/values/strings.xml new file mode 100644 index 0000000..ef924ac --- /dev/null +++ b/tests/DpiTest/res/values/strings.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2007 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<resources> + <string name="act_title">DpiTest: Unknown Screen</string> +</resources> diff --git a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java index 3759622..5a9f3f5 100644 --- a/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java +++ b/tests/DpiTest/src/com/google/android/test/dpi/DpiTestActivity.java @@ -34,6 +34,7 @@ public class DpiTestActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + this.setTitle(R.string.act_title); LinearLayout root = new LinearLayout(this); root.setOrientation(LinearLayout.VERTICAL); diff --git a/tests/backup/src/com/android/backuptest/BackupTestAgent.java b/tests/backup/src/com/android/backuptest/BackupTestAgent.java index c6acc66..8e4fd39 100644 --- a/tests/backup/src/com/android/backuptest/BackupTestAgent.java +++ b/tests/backup/src/com/android/backuptest/BackupTestAgent.java @@ -18,11 +18,15 @@ package com.android.backuptest; import android.backup.BackupHelperAgent; import android.backup.FileBackupHelper; +import android.backup.SharedPreferencesBackupHelper; public class BackupTestAgent extends BackupHelperAgent { public void onCreate() { addHelper("data_files", new FileBackupHelper(this, BackupTestActivity.FILE_NAME)); + addHelper("more_data_files", new FileBackupHelper(this, "another_file.txt", "3.txt", + "empty.txt")); + addHelper("shared_prefs", new SharedPreferencesBackupHelper(this, "settings", "raw")); } } diff --git a/tests/backup/test_backup.sh b/tests/backup/test_backup.sh new file mode 100755 index 0000000..dbf9ed2 --- /dev/null +++ b/tests/backup/test_backup.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +#adb kill-server + +# set the transport +adb shell bmgr transport 1 + +# load up the three files +adb shell "rm /data/data/com.android.backuptest/files/* ; \ + mkdir /data/data/com.android.backuptest ; \ + mkdir /data/data/com.android.backuptest/files ; \ + mkdir /data/data/com.android.backuptest/shared_prefs ; \ + echo -n \"<map><int name=\\\"pref\\\" value=\\\"1\\\" /></map>\" > /data/data/com.android.backuptest/shared_prefs/raw.xml ; \ + echo -n first file > /data/data/com.android.backuptest/files/file.txt ; \ + echo -n asdf > /data/data/com.android.backuptest/files/another_file.txt ; \ + echo -n 3 > /data/data/com.android.backuptest/files/3.txt ; \ + echo -n "" > /data/data/com.android.backuptest/files/empty.txt ; \ +" + +# say that the data has changed +adb shell bmgr backup com.android.backuptest + +# run the backup +adb shell bmgr run + + + diff --git a/tests/backup/test_restore.sh b/tests/backup/test_restore.sh new file mode 100755 index 0000000..ccf29cf --- /dev/null +++ b/tests/backup/test_restore.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +function check_file +{ + data=$(adb shell cat /data/data/com.android.backuptest/$1) + if [ "$data" = "$2" ] ; then + echo "$1 has correct value [$2]" + else + echo $1 is INCORRECT + echo " value: [$data]" + echo " expected: [$2]" + fi +} + +# delete the old data +echo --- Previous files +adb shell "ls -l /data/data/com.android.backuptest/files" +adb shell "rm /data/data/com.android.backuptest/files/*" +echo --- Previous shared_prefs +adb shell "ls -l /data/data/com.android.backuptest/shared_prefs" +adb shell "rm /data/data/com.android.backuptest/shared_prefs/*" +echo --- Erased files and shared_prefs +adb shell "ls -l /data/data/com.android.backuptest/files" +adb shell "ls -l /data/data/com.android.backuptest/shared_prefs" +echo --- + +echo +echo +echo + +# run the restore +adb shell bmgr restore 0 + +echo +echo +echo + +# check the results +check_file files/file.txt "first file" +check_file files/another_file.txt "asdf" +check_file files/3.txt "3" +check_file files/empty.txt "" +check_file shared_prefs/raw.xml '<map><int name="pref" value="1" /></map>' + +echo +echo +echo +echo --- Restored files +adb shell "ls -l /data/data/com.android.backuptest/files" +echo --- Restored shared_prefs +adb shell "ls -l /data/data/com.android.backuptest/shared_prefs" +echo --- +echo |
