Home | History | Annotate | Download | only in linear
      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.linear;
     18 
     19 import android.app.Activity;
     20 import android.test.ActivityInstrumentationTestCase;
     21 import android.test.suitebuilder.annotation.MediumTest;
     22 import android.test.ViewAsserts;
     23 import android.view.View;
     24 import android.widget.Button;
     25 
     26 import com.android.frameworks.coretests.R;
     27 import android.widget.layout.linear.BaselineAlignmentCenterGravity;
     28 
     29 public class BaselineAlignmentCenterGravityTest extends ActivityInstrumentationTestCase<BaselineAlignmentCenterGravity> {
     30     private Button mButton1;
     31     private Button mButton2;
     32     private Button mButton3;
     33 
     34     public BaselineAlignmentCenterGravityTest() {
     35         super("com.android.frameworks.coretests", BaselineAlignmentCenterGravity.class);
     36     }
     37 
     38     @Override
     39     protected void setUp() throws Exception {
     40         super.setUp();
     41 
     42         final Activity activity = getActivity();
     43         mButton1 = (Button) activity.findViewById(R.id.button1);
     44         mButton2 = (Button) activity.findViewById(R.id.button2);
     45         mButton3 = (Button) activity.findViewById(R.id.button3);
     46     }
     47 
     48     @MediumTest
     49     public void testSetUpConditions() throws Exception {
     50         assertNotNull(mButton1);
     51         assertNotNull(mButton2);
     52         assertNotNull(mButton3);
     53     }
     54 
     55     @MediumTest
     56     public void testChildrenAligned() throws Exception {
     57         final View parent = (View) mButton1.getParent();
     58         ViewAsserts.assertTopAligned(mButton1, parent);
     59         ViewAsserts.assertTopAligned(mButton2, parent);
     60         ViewAsserts.assertTopAligned(mButton3, parent);
     61         ViewAsserts.assertBottomAligned(mButton1, parent);
     62         ViewAsserts.assertBottomAligned(mButton2, parent);
     63         ViewAsserts.assertBottomAligned(mButton3, parent);
     64         ViewAsserts.assertTopAligned(mButton1, mButton2);
     65         ViewAsserts.assertTopAligned(mButton2, mButton3);
     66         ViewAsserts.assertBottomAligned(mButton1, mButton2);
     67         ViewAsserts.assertBottomAligned(mButton2, mButton3);
     68     }
     69 }
     70