summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-09-21 13:52:02 -0400
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-09-21 13:52:02 -0400
commita13ccc908ee54d6c606b5a73b3a57e4dda13e44a (patch)
treec7e850670e7d3848a11b92c9fb1ef02670e89019
parent8451c25b919ecef694d293d6bbd84d08d5fb60be (diff)
parent6a857d957e7998d99d664fbf88fb1590b9decf77 (diff)
downloadframeworks_base-a13ccc908ee54d6c606b5a73b3a57e4dda13e44a.zip
frameworks_base-a13ccc908ee54d6c606b5a73b3a57e4dda13e44a.tar.gz
frameworks_base-a13ccc908ee54d6c606b5a73b3a57e4dda13e44a.tar.bz2
Merge change 26175 into eclair
* changes: Fix test for phone number comparation. Now that there are two algorithms, we should consider them in Java layer. Uguu.
-rw-r--r--tests/AndroidTests/src/com/android/unit_tests/DatabaseGeneralTest.java41
1 files changed, 29 insertions, 12 deletions
diff --git a/tests/AndroidTests/src/com/android/unit_tests/DatabaseGeneralTest.java b/tests/AndroidTests/src/com/android/unit_tests/DatabaseGeneralTest.java
index 0991e8c..853f10a 100644
--- a/tests/AndroidTests/src/com/android/unit_tests/DatabaseGeneralTest.java
+++ b/tests/AndroidTests/src/com/android/unit_tests/DatabaseGeneralTest.java
@@ -204,16 +204,18 @@ public class DatabaseGeneralTest extends TestCase implements PerformanceTestCase
assertEquals("+" + PHONE_NUMBER, number);
c.close();
}
-
-
- private void phoneNumberCompare(String phone1, String phone2, boolean equal)
- throws Exception {
+
+ private void phoneNumberCompare(String phone1, String phone2, boolean equal,
+ boolean useStrictComparation) {
String[] temporalPhoneNumbers = new String[2];
temporalPhoneNumbers[0] = phone1;
temporalPhoneNumbers[1] = phone2;
Cursor cursor = mDatabase.rawQuery(
- "SELECT CASE WHEN PHONE_NUMBERS_EQUAL(?, ?) THEN 'equal' ELSE 'not equal' END",
+ String.format(
+ "SELECT CASE WHEN PHONE_NUMBERS_EQUAL(?, ?, %d) " +
+ "THEN 'equal' ELSE 'not equal' END",
+ (useStrictComparation ? 1 : 0)),
temporalPhoneNumbers);
try {
assertNotNull(cursor);
@@ -233,11 +235,23 @@ public class DatabaseGeneralTest extends TestCase implements PerformanceTestCase
}
private void assertPhoneNumberEqual(String phone1, String phone2) throws Exception {
- phoneNumberCompare(phone1, phone2, true);
+ assertPhoneNumberEqual(phone1, phone2, true);
+ assertPhoneNumberEqual(phone1, phone2, false);
+ }
+
+ private void assertPhoneNumberEqual(String phone1, String phone2, boolean useStrict)
+ throws Exception {
+ phoneNumberCompare(phone1, phone2, true, useStrict);
}
private void assertPhoneNumberNotEqual(String phone1, String phone2) throws Exception {
- phoneNumberCompare(phone1, phone2, false);
+ assertPhoneNumberNotEqual(phone1, phone2, true);
+ assertPhoneNumberNotEqual(phone1, phone2, false);
+ }
+
+ private void assertPhoneNumberNotEqual(String phone1, String phone2, boolean useStrict)
+ throws Exception {
+ phoneNumberCompare(phone1, phone2, false, useStrict);
}
/**
@@ -252,7 +266,8 @@ public class DatabaseGeneralTest extends TestCase implements PerformanceTestCase
assertPhoneNumberNotEqual("123123", "923123");
assertPhoneNumberNotEqual("123123", "123129");
assertPhoneNumberNotEqual("123123", "1231234");
- assertPhoneNumberNotEqual("123123", "0123123");
+ assertPhoneNumberEqual("123123", "0123123", false);
+ assertPhoneNumberNotEqual("123123", "0123123", true);
assertPhoneNumberEqual("650-253-0000", "6502530000");
assertPhoneNumberEqual("650-253-0000", "650 253 0000");
assertPhoneNumberEqual("650 253 0000", "6502530000");
@@ -291,11 +306,13 @@ public class DatabaseGeneralTest extends TestCase implements PerformanceTestCase
assertPhoneNumberEqual("+593-2-1234-123", "21234123");
// Two continuous 0 at the beginning of the phone string should not be
- // treated as trunk prefix.
- assertPhoneNumberNotEqual("008001231234", "8001231234");
+ // treated as trunk prefix in the strict comparation.
+ assertPhoneNumberEqual("008001231234", "8001231234", false);
+ assertPhoneNumberNotEqual("008001231234", "8001231234", true);
- // Confirm that the bug found before does not re-appear.
- assertPhoneNumberNotEqual("080-1234-5678", "+819012345678");
+ // Confirm that the bug found before does not re-appear in the strict compalation
+ assertPhoneNumberEqual("080-1234-5678", "+819012345678", false);
+ assertPhoneNumberNotEqual("080-1234-5678", "+819012345678", true);
}
@MediumTest