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 com.android.unit_tests; 18 19 import android.test.AndroidTestCase; 20 import android.test.suitebuilder.annotation.MediumTest; 21 import android.test.suitebuilder.annotation.SmallTest; 22 import android.text.*; 23 import android.text.method.*; 24 import android.text.style.*; 25 import android.text.util.*; 26 import android.widget.*; 27 28 /** 29 * LinkifyTest tests {@link Linkify}. 30 */ 31 public class LinkifyTest extends AndroidTestCase { 32 33 @SmallTest testNothing()34 public void testNothing() throws Exception { 35 TextView tv; 36 37 tv = new TextView(getContext()); 38 tv.setText("Hey, foo@google.com, call 415-555-1212."); 39 40 assertFalse(tv.getMovementMethod() instanceof LinkMovementMethod); 41 assertTrue(tv.getUrls().length == 0); 42 } 43 44 @MediumTest testNormal()45 public void testNormal() throws Exception { 46 TextView tv; 47 48 tv = new TextView(getContext()); 49 tv.setAutoLinkMask(Linkify.ALL); 50 tv.setText("Hey, foo@google.com, call 415-555-1212."); 51 52 assertTrue(tv.getMovementMethod() instanceof LinkMovementMethod); 53 assertTrue(tv.getUrls().length == 2); 54 } 55 56 @SmallTest testUnclickable()57 public void testUnclickable() throws Exception { 58 TextView tv; 59 60 tv = new TextView(getContext()); 61 tv.setAutoLinkMask(Linkify.ALL); 62 tv.setLinksClickable(false); 63 tv.setText("Hey, foo@google.com, call 415-555-1212."); 64 65 assertFalse(tv.getMovementMethod() instanceof LinkMovementMethod); 66 assertTrue(tv.getUrls().length == 2); 67 } 68 } 69