1 /* 2 * Copyright (C) 2007 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.widget.layout.table; 18 19 import android.widget.layout.table.CellSpan; 20 import com.android.frameworks.coretests.R; 21 22 import android.test.ActivityInstrumentationTestCase; 23 import android.test.suitebuilder.annotation.MediumTest; 24 import android.view.View; 25 26 /** 27 * {@link android.widget.layout.table.CellSpan} is 28 * setup to exercise tables in which cells use spanning. 29 */ 30 public class CellSpanTest extends ActivityInstrumentationTestCase<CellSpan> { 31 private View mA; 32 private View mB; 33 private View mC; 34 private View mSpanThenCell; 35 private View mCellThenSpan; 36 private View mSpan; 37 38 public CellSpanTest() { 39 super("com.android.frameworks.coretests", CellSpan.class); 40 } 41 42 @Override 43 protected void setUp() throws Exception { 44 super.setUp(); 45 46 final CellSpan activity = getActivity(); 47 mA = activity.findViewById(R.id.a); 48 mB = activity.findViewById(R.id.b); 49 mC = activity.findViewById(R.id.c); 50 mSpanThenCell = activity.findViewById(R.id.spanThenCell); 51 mCellThenSpan = activity.findViewById(R.id.cellThenSpan); 52 mSpan = activity.findViewById(R.id.span); 53 } 54 55 @MediumTest 56 public void testSetUpConditions() throws Exception { 57 assertNotNull(mA); 58 assertNotNull(mB); 59 assertNotNull(mC); 60 assertNotNull(mSpanThenCell); 61 assertNotNull(mCellThenSpan); 62 assertNotNull(mSpan); 63 } 64 65 @MediumTest 66 public void testSpanThenCell() throws Exception { 67 int spanWidth = mA.getMeasuredWidth() + mB.getMeasuredWidth(); 68 assertEquals("span followed by cell is broken", spanWidth, 69 mSpanThenCell.getMeasuredWidth()); 70 } 71 72 @MediumTest 73 public void testCellThenSpan() throws Exception { 74 int spanWidth = mB.getMeasuredWidth() + mC.getMeasuredWidth(); 75 assertEquals("cell followed by span is broken", spanWidth, 76 mCellThenSpan.getMeasuredWidth()); 77 } 78 79 @MediumTest 80 public void testSpan() throws Exception { 81 int spanWidth = mA.getMeasuredWidth() + mB.getMeasuredWidth() + 82 mC.getMeasuredWidth(); 83 assertEquals("span is broken", spanWidth, mSpan.getMeasuredWidth()); 84 } 85 } 86