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 17package android.widget.layout.table; 18 19import android.widget.layout.table.HorizontalGravity; 20import com.android.frameworks.coretests.R; 21 22import android.test.ActivityInstrumentationTestCase; 23import android.test.suitebuilder.annotation.MediumTest; 24import android.test.ViewAsserts; 25import android.view.View; 26 27/** 28 * {@link android.widget.layout.table.HorizontalGravity} is 29 * setup to exercise tables in which cells use horizontal gravity. 30 */ 31public class HorizontalGravityTest extends ActivityInstrumentationTestCase<HorizontalGravity> { 32 private View mReference; 33 private View mCenter; 34 private View mBottomRight; 35 private View mLeft; 36 37 public HorizontalGravityTest() { 38 super("com.android.frameworks.coretests", HorizontalGravity.class); 39 } 40 41 @Override 42 protected void setUp() throws Exception { 43 super.setUp(); 44 45 final HorizontalGravity activity = getActivity(); 46 mReference = activity.findViewById(R.id.reference); 47 mCenter = activity.findViewById(R.id.center); 48 mBottomRight = activity.findViewById(R.id.bottomRight); 49 mLeft = activity.findViewById(R.id.left); 50 } 51 52 @MediumTest 53 public void testSetUpConditions() throws Exception { 54 assertNotNull(mReference); 55 assertNotNull(mCenter); 56 assertNotNull(mBottomRight); 57 assertNotNull(mLeft); 58 } 59 60 @MediumTest 61 public void testCenterGravity() throws Exception { 62 ViewAsserts.assertHorizontalCenterAligned(mReference, mCenter); 63 } 64 65 @MediumTest 66 public void testLeftGravity() throws Exception { 67 ViewAsserts.assertLeftAligned(mReference, mLeft); 68 } 69 70 @MediumTest 71 public void testRightGravity() throws Exception { 72 ViewAsserts.assertRightAligned(mReference, mBottomRight); 73 } 74} 75