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.method.cts; 18 19 import static org.junit.Assert.assertArrayEquals; 20 import static org.junit.Assert.assertNotNull; 21 import static org.junit.Assert.assertSame; 22 23 import android.support.test.filters.SmallTest; 24 import android.support.test.runner.AndroidJUnit4; 25 import android.text.method.HideReturnsTransformationMethod; 26 27 import org.junit.Test; 28 import org.junit.runner.RunWith; 29 30 /** 31 * Test {@link HideReturnsTransformationMethod}. 32 */ 33 @SmallTest 34 @RunWith(AndroidJUnit4.class) 35 public class HideReturnsTransformationMethodTest { 36 @Test 37 public void testConstructor() { 38 new HideReturnsTransformationMethod(); 39 } 40 41 @Test 42 public void testGetOriginal() { 43 MyHideReturnsTranformationMethod method = new MyHideReturnsTranformationMethod(); 44 assertArrayEquals(new char[] { '\r' }, method.getOriginal()); 45 } 46 47 @Test 48 public void testGetInstance() { 49 HideReturnsTransformationMethod method0 = HideReturnsTransformationMethod.getInstance(); 50 assertNotNull(method0); 51 52 HideReturnsTransformationMethod method1 = HideReturnsTransformationMethod.getInstance(); 53 assertSame(method0, method1); 54 } 55 56 @Test 57 public void testGetReplacement() { 58 MyHideReturnsTranformationMethod method = new MyHideReturnsTranformationMethod(); 59 assertArrayEquals(new char[] { '\uFEFF' }, method.getReplacement()); 60 } 61 62 private static class MyHideReturnsTranformationMethod extends HideReturnsTransformationMethod { 63 @Override 64 protected char[] getOriginal() { 65 return super.getOriginal(); 66 } 67 68 @Override 69 protected char[] getReplacement() { 70 return super.getReplacement(); 71 } 72 } 73 } 74