diff options
author | Brett Chabot <brettchabot@android.com> | 2010-04-01 18:21:38 -0700 |
---|---|---|
committer | Brett Chabot <brettchabot@android.com> | 2010-04-01 18:31:11 -0700 |
commit | 0dc59e78e18493aecd37427531d093e800846c3e (patch) | |
tree | f78a49ef7fdeb85648a93444850f06b4243a9555 /tests/AndroidTests/src/com/android/unit_tests/PatternsTest.java | |
parent | 2d8234b73d11fdc2178232cabad3ffaa23723405 (diff) | |
download | frameworks_base-0dc59e78e18493aecd37427531d093e800846c3e.zip frameworks_base-0dc59e78e18493aecd37427531d093e800846c3e.tar.gz frameworks_base-0dc59e78e18493aecd37427531d093e800846c3e.tar.bz2 |
More framework tests cleanup.
Move all tests for android.* classes from tests/AndroidTests and
tests/CoreTests into framework/base/<core|graphics>/tests.
Consolidate all tests for java.* classes to tests/CoreTests.
Eventually hopefully these will be moved to dalvik/ somewhere.
Remove tests/AndroidTests entirely.
Change-Id: I86584d086ab7bd045bb38a10b699907805298a95
Diffstat (limited to 'tests/AndroidTests/src/com/android/unit_tests/PatternsTest.java')
-rw-r--r-- | tests/AndroidTests/src/com/android/unit_tests/PatternsTest.java | 162 |
1 files changed, 0 insertions, 162 deletions
diff --git a/tests/AndroidTests/src/com/android/unit_tests/PatternsTest.java b/tests/AndroidTests/src/com/android/unit_tests/PatternsTest.java deleted file mode 100644 index 0edcd6d..0000000 --- a/tests/AndroidTests/src/com/android/unit_tests/PatternsTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.android.unit_tests; - -import android.test.suitebuilder.annotation.SmallTest; -import android.util.Patterns; - -import java.util.regex.Matcher; - -import junit.framework.TestCase; - -public class PatternsTest extends TestCase { - - @SmallTest - public void testTldPattern() throws Exception { - boolean t; - - t = Patterns.TOP_LEVEL_DOMAIN.matcher("com").matches(); - assertTrue("Missed valid TLD", t); - - // One of the new top level domain. - t = Patterns.TOP_LEVEL_DOMAIN.matcher("me").matches(); - assertTrue("Missed valid TLD", t); - - // One of the new top level test domain. - t = Patterns.TOP_LEVEL_DOMAIN.matcher("xn--0zwm56d").matches(); - assertTrue("Missed valid TLD", t); - - t = Patterns.TOP_LEVEL_DOMAIN.matcher("mem").matches(); - assertFalse("Matched invalid TLD!", t); - - t = Patterns.TOP_LEVEL_DOMAIN.matcher("xn").matches(); - assertFalse("Matched invalid TLD!", t); - - t = Patterns.TOP_LEVEL_DOMAIN.matcher("xer").matches(); - assertFalse("Matched invalid TLD!", t); - } - - @SmallTest - public void testUrlPattern() throws Exception { - boolean t; - - t = Patterns.WEB_URL.matcher("http://www.google.com").matches(); - assertTrue("Valid URL", t); - - // Google in one of the new top level domain. - t = Patterns.WEB_URL.matcher("http://www.google.me").matches(); - assertTrue("Valid URL", t); - t = Patterns.WEB_URL.matcher("google.me").matches(); - assertTrue("Valid URL", t); - - // Test url in Chinese: http://xn--fsqu00a.xn--0zwm56d - t = Patterns.WEB_URL.matcher("http://xn--fsqu00a.xn--0zwm56d").matches(); - assertTrue("Valid URL", t); - t = Patterns.WEB_URL.matcher("xn--fsqu00a.xn--0zwm56d").matches(); - assertTrue("Valid URL", t); - - // Internationalized URL. - t = Patterns.WEB_URL.matcher("http://\uD604\uAE08\uC601\uC218\uC99D.kr").matches(); - assertTrue("Valid URL", t); - t = Patterns.WEB_URL.matcher("\uD604\uAE08\uC601\uC218\uC99D.kr").matches(); - assertTrue("Valid URL", t); - - t = Patterns.WEB_URL.matcher("ftp://www.example.com").matches(); - assertFalse("Matched invalid protocol", t); - - t = Patterns.WEB_URL.matcher("http://www.example.com:8080").matches(); - assertTrue("Didn't match valid URL with port", t); - - t = Patterns.WEB_URL.matcher("http://www.example.com:8080/?foo=bar").matches(); - assertTrue("Didn't match valid URL with port and query args", t); - - t = Patterns.WEB_URL.matcher("http://www.example.com:8080/~user/?foo=bar").matches(); - assertTrue("Didn't match valid URL with ~", t); - } - - @SmallTest - public void testIpPattern() throws Exception { - boolean t; - - t = Patterns.IP_ADDRESS.matcher("172.29.86.3").matches(); - assertTrue("Valid IP", t); - - t = Patterns.IP_ADDRESS.matcher("1234.4321.9.9").matches(); - assertFalse("Invalid IP", t); - } - - @SmallTest - public void testDomainPattern() throws Exception { - boolean t; - - t = Patterns.DOMAIN_NAME.matcher("mail.example.com").matches(); - assertTrue("Valid domain", t); - - t = Patterns.WEB_URL.matcher("google.me").matches(); - assertTrue("Valid domain", t); - - // Internationalized domains. - t = Patterns.DOMAIN_NAME.matcher("\uD604\uAE08\uC601\uC218\uC99D.kr").matches(); - assertTrue("Valid domain", t); - - t = Patterns.DOMAIN_NAME.matcher("__+&42.xer").matches(); - assertFalse("Invalid domain", t); - } - - @SmallTest - public void testPhonePattern() throws Exception { - boolean t; - - t = Patterns.PHONE.matcher("(919) 555-1212").matches(); - assertTrue("Valid phone", t); - - t = Patterns.PHONE.matcher("2334 9323/54321").matches(); - assertFalse("Invalid phone", t); - - String[] tests = { - "Me: 16505551212 this\n", - "Me: 6505551212 this\n", - "Me: 5551212 this\n", - - "Me: 1-650-555-1212 this\n", - "Me: (650) 555-1212 this\n", - "Me: +1 (650) 555-1212 this\n", - "Me: +1-650-555-1212 this\n", - "Me: 650-555-1212 this\n", - "Me: 555-1212 this\n", - - "Me: 1.650.555.1212 this\n", - "Me: (650) 555.1212 this\n", - "Me: +1 (650) 555.1212 this\n", - "Me: +1.650.555.1212 this\n", - "Me: 650.555.1212 this\n", - "Me: 555.1212 this\n", - - "Me: 1 650 555 1212 this\n", - "Me: (650) 555 1212 this\n", - "Me: +1 (650) 555 1212 this\n", - "Me: +1 650 555 1212 this\n", - "Me: 650 555 1212 this\n", - "Me: 555 1212 this\n", - }; - - for (String test : tests) { - Matcher m = Patterns.PHONE.matcher(test); - - assertTrue("Valid phone " + test, m.find()); - } - } -} |