1925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su/* 2925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su * Copyright (C) 2008 The Android Open Source Project 3925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su * 4925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su * Licensed under the Apache License, Version 2.0 (the "License"); 5925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su * you may not use this file except in compliance with the License. 6925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su * You may obtain a copy of the License at 7925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su * 8925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su * http://www.apache.org/licenses/LICENSE-2.0 9925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su * 10925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su * Unless required by applicable law or agreed to in writing, software 11925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su * distributed under the License is distributed on an "AS IS" BASIS, 12925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su * See the License for the specific language governing permissions and 14925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su * limitations under the License. 15925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su */ 16925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su 17925e92cb0de3281be5de7b6b42566e6d4cab809bScott Supackage android.text.style.cts; 18925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su 19925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su 20925e92cb0de3281be5de7b6b42566e6d4cab809bScott Suimport android.os.Parcel; 21925e92cb0de3281be5de7b6b42566e6d4cab809bScott Suimport android.text.style.LeadingMarginSpan; 22925e92cb0de3281be5de7b6b42566e6d4cab809bScott Suimport android.text.style.LeadingMarginSpan.Standard; 23925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su 24925e92cb0de3281be5de7b6b42566e6d4cab809bScott Suimport junit.framework.TestCase; 25925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su 26925e92cb0de3281be5de7b6b42566e6d4cab809bScott Supublic class LeadingMarginSpan_StandardTest extends TestCase { 27925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su public void testConstructor() { 28925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su new Standard(1, 2); 29925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su new Standard(3); 30925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su new Standard(-1, -2); 31925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su new Standard(-3); 32925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su 33925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su Standard standard = new Standard(10, 20); 34925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su final Parcel p = Parcel.obtain(); 3530a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot try { 3630a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot standard.writeToParcel(p, 0); 3730a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot p.setDataPosition(0); 3830a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot new Standard(p); 3930a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot } finally { 4030a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot p.recycle(); 4130a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot } 42925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su } 43925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su 44925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su public void testGetLeadingMargin() { 45925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su int first = 4; 46925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su int rest = 5; 47925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su 48925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su Standard standard = new LeadingMarginSpan.Standard(first, rest); 49925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su assertEquals(first, standard.getLeadingMargin(true)); 50925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su assertEquals(rest, standard.getLeadingMargin(false)); 51925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su 52925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su standard = new LeadingMarginSpan.Standard(-1); 53925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su assertEquals(-1, standard.getLeadingMargin(true)); 54925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su assertEquals(-1, standard.getLeadingMargin(false)); 55925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su } 56925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su 57925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su public void testDrawLeadingMargin() { 58925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su Standard standard = new LeadingMarginSpan.Standard(10); 59925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su standard.drawLeadingMargin(null, null, 0, 0, 0, 0, 0, null, 0, 0, false, null); 60925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su } 61925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su 62925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su public void testDescribeContents() { 63925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su Standard standard = new Standard(1); 64925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su standard.describeContents(); 65925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su } 66925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su 67925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su public void testGetSpanTypeId() { 68925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su Standard standard = new Standard(1); 69925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su standard.getSpanTypeId(); 70925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su } 71925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su 72925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su public void testWriteToParcel() { 73925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su Parcel p = Parcel.obtain(); 7430a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot try { 7530a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot Standard s = new Standard(10, 20); 7630a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot s.writeToParcel(p, 0); 7730a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot p.setDataPosition(0); 7830a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot Standard standard = new Standard(p); 7930a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot assertEquals(10, standard.getLeadingMargin(true)); 8030a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot assertEquals(20, standard.getLeadingMargin(false)); 8130a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot } finally { 8230a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot p.recycle(); 8330a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot } 84925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su 8530a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot p = Parcel.obtain(); 8630a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot try { 8730a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot Standard s = new Standard(3); 8830a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot s.writeToParcel(p, 0); 8930a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot p.setDataPosition(0); 9030a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot Standard standard = new Standard(p); 9130a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot assertEquals(3, standard.getLeadingMargin(true)); 9230a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot assertEquals(3, standard.getLeadingMargin(false)); 9330a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot } finally { 9430a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot p.recycle(); 9530a5c5d2b1caa999829a7924ff24ab33efed5c5bBrett Chabot } 96925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su } 97925e92cb0de3281be5de7b6b42566e6d4cab809bScott Su} 98