summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/AndroidTests/Android.mk2
-rw-r--r--tests/AndroidTests/src/com/android/unit_tests/DatabaseGeneralTest.java41
-rw-r--r--tests/BrowserPowerTest/src/com/android/browserpowertest/PowerMeasurement.java21
-rw-r--r--tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java12
4 files changed, 56 insertions, 20 deletions
diff --git a/tests/AndroidTests/Android.mk b/tests/AndroidTests/Android.mk
index f5e49d7..ced796a 100644
--- a/tests/AndroidTests/Android.mk
+++ b/tests/AndroidTests/Android.mk
@@ -8,7 +8,7 @@ LOCAL_JAVA_LIBRARIES := framework-tests android.test.runner
LOCAL_STATIC_JAVA_LIBRARIES := googlelogin-client
# Resource unit tests use a private locale
-LOCAL_AAPT_FLAGS = -c xx_YY -c cs
+LOCAL_AAPT_FLAGS = -c xx_YY -c cs -c 160dpi -c 32dpi -c 240dpi
LOCAL_SRC_FILES := \
$(call all-subdir-java-files) \
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
diff --git a/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerMeasurement.java b/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerMeasurement.java
index 74ac865..861e37b 100644
--- a/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerMeasurement.java
+++ b/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerMeasurement.java
@@ -12,7 +12,8 @@ public class PowerMeasurement extends ActivityInstrumentationTestCase2<PowerTest
private static final String LOGTAG = "PowerMeasurement";
private static final String PKG_NAME = "com.android.browserpowertest";
- private static final String TESTING_URL = "http://www.espn.com";
+ private static final String TESTING_URL =
+ "http://75.17.48.204:10088/nyt/index.html";
private static final int TIME_OUT = 2 * 60 * 1000;
private static final int DELAY = 0;
@@ -46,6 +47,24 @@ public class PowerMeasurement extends ActivityInstrumentationTestCase2<PowerTest
pageErrorFlag);
Log.v(LOGTAG, "Page is loaded in " + activity.getPageLoadTime() + " ms.");
+ // Force to clean up the cache dir so that it get back to the clean
+ // state
+ Runtime fileRemoval = Runtime.getRuntime();
+ String cmdBecomeSu = "su";
+ boolean clearCacheSuccess = false;
+ try{
+ Process runsum = fileRemoval.exec(cmdBecomeSu);
+ int exitVal = runsum.waitFor();
+ String rmfile = "rm -r /data/data/com.android.browserpowertest/cache";
+ Process removal = fileRemoval.exec(rmfile);
+ exitVal = removal.waitFor();
+ if (exitVal == 0) {
+ clearCacheSuccess = true;
+ }
+ } catch ( Exception e){
+ assertTrue("Fails to clear the cahche", false);
+ }
+ assertTrue("Fails to clear the cahche", clearCacheSuccess);
activity.finish();
}
}
diff --git a/tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java b/tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java
index 7426d33..20ea4d7 100644
--- a/tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java
+++ b/tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java
@@ -257,19 +257,19 @@ public class PhoneNumberUtilsTest extends TestCase {
@SmallTest
public void testToCallerIDIndexable() throws Exception {
- assertEquals("14145", PhoneNumberUtils.toCallerIDMinMatch("17005554141"));
- assertEquals("14145", PhoneNumberUtils.toCallerIDMinMatch("1-700-555-4141"));
- assertEquals("14145", PhoneNumberUtils.toCallerIDMinMatch("1-700-555-4141,1234"));
- assertEquals("14145", PhoneNumberUtils.toCallerIDMinMatch("1-700-555-4141;1234"));
+ assertEquals("1414555", PhoneNumberUtils.toCallerIDMinMatch("17005554141"));
+ assertEquals("1414555", PhoneNumberUtils.toCallerIDMinMatch("1-700-555-4141"));
+ assertEquals("1414555", PhoneNumberUtils.toCallerIDMinMatch("1-700-555-4141,1234"));
+ assertEquals("1414555", PhoneNumberUtils.toCallerIDMinMatch("1-700-555-4141;1234"));
//this seems wrong, or at least useless
- assertEquals("NN145", PhoneNumberUtils.toCallerIDMinMatch("1-700-555-41NN"));
+ assertEquals("NN14555", PhoneNumberUtils.toCallerIDMinMatch("1-700-555-41NN"));
//<shrug> -- these are all not useful, but not terribly wrong
assertEquals("", PhoneNumberUtils.toCallerIDMinMatch(""));
assertEquals("0032", PhoneNumberUtils.toCallerIDMinMatch("2300"));
assertEquals("0032+", PhoneNumberUtils.toCallerIDMinMatch("+2300"));
- assertEquals("#130#", PhoneNumberUtils.toCallerIDMinMatch("*#031#"));
+ assertEquals("#130#*", PhoneNumberUtils.toCallerIDMinMatch("*#031#"));
}
@SmallTest