diff options
author | Joe Onorato <joeo@android.com> | 2009-06-26 14:45:25 -0400 |
---|---|---|
committer | Joe Onorato <joeo@android.com> | 2009-06-26 14:45:25 -0400 |
commit | dc355a90a3d9d34f66316928a53f61ac35ab4781 (patch) | |
tree | 7b9de72bba6ed97ff81b600073cbbed46a0cf7a1 | |
parent | aae628b44518f0886a7f33b88c1131f47d853e70 (diff) | |
download | frameworks_base-dc355a90a3d9d34f66316928a53f61ac35ab4781.zip frameworks_base-dc355a90a3d9d34f66316928a53f61ac35ab4781.tar.gz frameworks_base-dc355a90a3d9d34f66316928a53f61ac35ab4781.tar.bz2 |
Add a test for SharedPreferencesBackupHelper
(which nobody had ever tested. I like it when stuff
just works the first time).
-rw-r--r-- | core/java/android/backup/SharedPreferencesBackupHelper.java | 2 | ||||
-rw-r--r-- | tests/backup/src/com/android/backuptest/BackupTestAgent.java | 2 | ||||
-rwxr-xr-x | tests/backup/test_backup.sh | 5 | ||||
-rwxr-xr-x | tests/backup/test_restore.sh | 19 |
4 files changed, 21 insertions, 7 deletions
diff --git a/core/java/android/backup/SharedPreferencesBackupHelper.java b/core/java/android/backup/SharedPreferencesBackupHelper.java index f492629..4a7b399 100644 --- a/core/java/android/backup/SharedPreferencesBackupHelper.java +++ b/core/java/android/backup/SharedPreferencesBackupHelper.java @@ -30,7 +30,7 @@ public class SharedPreferencesBackupHelper extends FileBackupHelperBase implemen private Context mContext; private String[] mPrefGroups; - public SharedPreferencesBackupHelper(Context context, String[] prefGroups) { + public SharedPreferencesBackupHelper(Context context, String... prefGroups) { super(context); mContext = context; diff --git a/tests/backup/src/com/android/backuptest/BackupTestAgent.java b/tests/backup/src/com/android/backuptest/BackupTestAgent.java index 6acd90c..8e4fd39 100644 --- a/tests/backup/src/com/android/backuptest/BackupTestAgent.java +++ b/tests/backup/src/com/android/backuptest/BackupTestAgent.java @@ -18,6 +18,7 @@ package com.android.backuptest; import android.backup.BackupHelperAgent; import android.backup.FileBackupHelper; +import android.backup.SharedPreferencesBackupHelper; public class BackupTestAgent extends BackupHelperAgent { @@ -25,6 +26,7 @@ public class BackupTestAgent extends BackupHelperAgent 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 index 6ef5dff..dbf9ed2 100755 --- a/tests/backup/test_backup.sh +++ b/tests/backup/test_backup.sh @@ -9,6 +9,8 @@ adb shell bmgr transport 1 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 ; \ @@ -20,3 +22,6 @@ 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 index f3d581e..ccf29cf 100755 --- a/tests/backup/test_restore.sh +++ b/tests/backup/test_restore.sh @@ -2,7 +2,7 @@ function check_file { - data=$(adb shell cat /data/data/com.android.backuptest/files/$1) + data=$(adb shell cat /data/data/com.android.backuptest/$1) if [ "$data" = "$2" ] ; then echo "$1 has correct value [$2]" else @@ -16,8 +16,12 @@ function check_file echo --- Previous files adb shell "ls -l /data/data/com.android.backuptest/files" adb shell "rm /data/data/com.android.backuptest/files/*" -echo --- Erased 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 @@ -32,15 +36,18 @@ echo echo # check the results -check_file file.txt "first file" -check_file another_file.txt "asdf" -check_file 3.txt "3" -check_file empty.txt "" +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 |