From 9e534153264138cfee383c626db92b934fafc1af Mon Sep 17 00:00:00 2001 From: Tammo Spalink Date: Mon, 19 Oct 2009 14:10:47 +0800 Subject: Let PLUS occur once anywhere in dial-str network portion. Create a new extractNetworkPortion() function, since the old one is public, that does effectively the same thing but is more flexible as just mentioned. Addresses issue: http://buganizer/issue?id=2013998 Change-Id: Ie5df08ef9c871881e8728a44abf0385908000823 --- .../internal/telephony/PhoneNumberUtilsTest.java | 64 +++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java b/tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java index 20ea4d7..a4e253e 100644 --- a/tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java +++ b/tests/CoreTests/com/android/internal/telephony/PhoneNumberUtilsTest.java @@ -25,7 +25,7 @@ import junit.framework.TestCase; public class PhoneNumberUtilsTest extends TestCase { @SmallTest - public void testA() throws Exception { + public void testExtractNetworkPortion() throws Exception { assertEquals( "+17005554141", PhoneNumberUtils.extractNetworkPortion("+17005554141") @@ -181,6 +181,68 @@ public class PhoneNumberUtilsTest extends TestCase { } @SmallTest + public void testExtractNetworkPortionAlt() throws Exception { + assertEquals( + "+17005554141", + PhoneNumberUtils.extractNetworkPortionAlt("+17005554141") + ); + + assertEquals( + "+17005554141", + PhoneNumberUtils.extractNetworkPortionAlt("+1 (700).555-4141") + ); + + assertEquals( + "17005554141", + PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-4141") + ); + + // This may seem wrong, but it's probably ok + assertEquals( + "17005554141*#", + PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-4141*#") + ); + + assertEquals( + "170055541NN", + PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-41NN") + ); + + assertEquals( + "170055541NN", + PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-41NN,1234") + ); + + assertEquals( + "170055541NN", + PhoneNumberUtils.extractNetworkPortionAlt("1 (700).555-41NN;1234") + ); + + // An MMI string is unperterbed, even though it contains a + // (valid in this case) embedded + + assertEquals( + "**21**+17005554141#", + PhoneNumberUtils.extractNetworkPortionAlt("**21**+17005554141#") + ); + + assertEquals( + "*31#+447966164208", + PhoneNumberUtils.extractNetworkPortionAlt("*31#+447966164208") + ); + + assertEquals( + "*31#+447966164208", + PhoneNumberUtils.extractNetworkPortionAlt("*31# (+44) 79 6616 4208") + ); + + assertEquals("", PhoneNumberUtils.extractNetworkPortionAlt("")); + + assertEquals("", PhoneNumberUtils.extractNetworkPortionAlt(",1234")); + + assertNull(PhoneNumberUtils.extractNetworkPortionAlt(null)); + } + + @SmallTest public void testB() throws Exception { assertEquals("", PhoneNumberUtils.extractPostDialPortion("+17005554141")); assertEquals("", PhoneNumberUtils.extractPostDialPortion("+1 (700).555-4141")); -- cgit v1.1