Add CTS tests for PhoneNumberUtils
Add CTS tests for newly exposed PhoneNumberUtils APIs
isUriNumber
getUsernameFromUriNumber
convertAndStrip
Bug: 6948882
Change-Id: Ie3e0d3cb0c573648e96c420c2987cf1a63269b11
diff --git a/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java b/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java
index 3fc5b28..d96743c 100644
--- a/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/PhoneNumberUtilsTest.java
@@ -301,4 +301,29 @@
assertTrue(PhoneNumberUtils.isWellFormedSmsAddress("+17005554141"));
assertFalse(PhoneNumberUtils.isWellFormedSmsAddress("android"));
}
+
+ public void testIsUriNumber() {
+ assertTrue(PhoneNumberUtils.isUriNumber("foo@google.com"));
+ assertTrue(PhoneNumberUtils.isUriNumber("xyz@zzz.org"));
+ assertFalse(PhoneNumberUtils.isUriNumber("+15103331245"));
+ assertFalse(PhoneNumberUtils.isUriNumber("+659231235"));
+ }
+
+ public void testGetUsernameFromUriNumber() {
+ assertEquals("john", PhoneNumberUtils.getUsernameFromUriNumber("john@myorg.com"));
+ assertEquals("tim_123", PhoneNumberUtils.getUsernameFromUriNumber("tim_123@zzz.org"));
+ assertEquals("5103331245", PhoneNumberUtils.getUsernameFromUriNumber("5103331245"));
+ }
+
+ public void testConvertAndStrip() {
+ // Untouched number.
+ assertEquals("123456789", PhoneNumberUtils.convertAndStrip("123456789"));
+ // Dashes should be stripped, legal separators (i.e. wild character remain untouched)
+ assertEquals("+15103331245*123", PhoneNumberUtils.convertAndStrip("+1-510-333-1245*123"));
+ // Arabic digits should be converted
+ assertEquals("5567861616", PhoneNumberUtils.convertAndStrip("٥٥٦٧٨٦١٦١٦"));
+ // Arabic digits converted and spaces stripped
+ assertEquals("5567861616", PhoneNumberUtils.convertAndStrip("٥ ٥٦ ٧ ٨ ٦ ١ ٦ ١ ٦"));
+
+ }
}