1 /* 2 * Copyright (C) 2008 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package android.text.util; 18 19 import android.test.AndroidTestCase; 20 import android.test.suitebuilder.annotation.SmallTest; 21 import android.text.method.LinkMovementMethod; 22 import android.widget.TextView; 23 24 /** 25 * LinkifyTest tests {@link Linkify}. 26 */ 27 public class LinkifyTest extends AndroidTestCase { 28 29 @SmallTest 30 public void testNothing() throws Exception { 31 TextView tv; 32 33 tv = new TextView(getContext()); 34 tv.setText("Hey, foo (at) google.com, call 415-555-1212."); 35 36 assertFalse(tv.getMovementMethod() instanceof LinkMovementMethod); 37 assertTrue(tv.getUrls().length == 0); 38 } 39 40 @SmallTest 41 public void testNormal() throws Exception { 42 TextView tv; 43 44 tv = new TextView(getContext()); 45 tv.setAutoLinkMask(Linkify.ALL); 46 tv.setText("Hey, foo (at) google.com, call 415-555-1212."); 47 48 assertTrue(tv.getMovementMethod() instanceof LinkMovementMethod); 49 assertTrue(tv.getUrls().length == 2); 50 } 51 52 @SmallTest 53 public void testUnclickable() throws Exception { 54 TextView tv; 55 56 tv = new TextView(getContext()); 57 tv.setAutoLinkMask(Linkify.ALL); 58 tv.setLinksClickable(false); 59 tv.setText("Hey, foo (at) google.com, call 415-555-1212."); 60 61 assertFalse(tv.getMovementMethod() instanceof LinkMovementMethod); 62 assertTrue(tv.getUrls().length == 2); 63 } 64 } 65