Home | History | Annotate | Download | only in frame
      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.widget.layout.frame;
     18 
     19 import android.test.ActivityInstrumentationTestCase;
     20 import android.test.suitebuilder.annotation.MediumTest;
     21 import android.test.ViewAsserts;
     22 import android.app.Activity;
     23 import android.view.View;
     24 import android.widget.layout.frame.FrameLayoutGravity;
     25 import com.android.frameworks.coretests.R;
     26 
     27 public class FrameLayoutGravityTest extends ActivityInstrumentationTestCase<FrameLayoutGravity> {
     28     private View mLeftView;
     29     private View mRightView;
     30     private View mCenterHorizontalView;
     31     private View mLeftCenterVerticalView;
     32     private View mRighCenterVerticalView;
     33     private View mCenterView;
     34     private View mLeftBottomView;
     35     private View mRightBottomView;
     36     private View mCenterHorizontalBottomView;
     37     private View mParent;
     38 
     39     public FrameLayoutGravityTest() {
     40         super("com.android.frameworks.coretests", FrameLayoutGravity.class);
     41     }
     42 
     43     @Override
     44     protected void setUp() throws Exception {
     45         super.setUp();
     46 
     47         final Activity activity = getActivity();
     48 
     49         mParent = activity.findViewById(R.id.parent);
     50 
     51         mLeftView = activity.findViewById(R.id.left);
     52         mRightView = activity.findViewById(R.id.right);
     53         mCenterHorizontalView = activity.findViewById(R.id.center_horizontal);
     54 
     55         mLeftCenterVerticalView = activity.findViewById(R.id.left_center_vertical);
     56         mRighCenterVerticalView = activity.findViewById(R.id.right_center_vertical);
     57         mCenterView = activity.findViewById(R.id.center);
     58 
     59         mLeftBottomView = activity.findViewById(R.id.left_bottom);
     60         mRightBottomView = activity.findViewById(R.id.right_bottom);
     61         mCenterHorizontalBottomView = activity.findViewById(R.id.center_horizontal_bottom);
     62     }
     63 
     64     @MediumTest
     65     public void testSetUpConditions() throws Exception {
     66         assertNotNull(mParent);
     67         assertNotNull(mLeftView);
     68         assertNotNull(mRightView);
     69         assertNotNull(mCenterHorizontalView);
     70         assertNotNull(mLeftCenterVerticalView);
     71         assertNotNull(mRighCenterVerticalView);
     72         assertNotNull(mCenterView);
     73         assertNotNull(mLeftBottomView);
     74         assertNotNull(mRightBottomView);
     75         assertNotNull(mCenterHorizontalBottomView);
     76     }
     77 
     78     @MediumTest
     79     public void testLeftTopAligned() throws Exception {
     80         ViewAsserts.assertLeftAligned(mParent, mLeftView);
     81         ViewAsserts.assertTopAligned(mParent, mLeftView);
     82     }
     83 
     84     @MediumTest
     85     public void testRightTopAligned() throws Exception {
     86         ViewAsserts.assertRightAligned(mParent, mRightView);
     87         ViewAsserts.assertTopAligned(mParent, mRightView);
     88     }
     89 
     90     @MediumTest
     91     public void testCenterHorizontalTopAligned() throws Exception {
     92         ViewAsserts.assertHorizontalCenterAligned(mParent, mCenterHorizontalView);
     93         ViewAsserts.assertTopAligned(mParent, mCenterHorizontalView);
     94     }
     95 
     96     @MediumTest
     97     public void testLeftCenterVerticalAligned() throws Exception {
     98         ViewAsserts.assertLeftAligned(mParent, mLeftCenterVerticalView);
     99         ViewAsserts.assertVerticalCenterAligned(mParent, mLeftCenterVerticalView);
    100     }
    101 
    102     @MediumTest
    103     public void testRightCenterVerticalAligned() throws Exception {
    104         ViewAsserts.assertRightAligned(mParent, mRighCenterVerticalView);
    105         ViewAsserts.assertVerticalCenterAligned(mParent, mRighCenterVerticalView);
    106     }
    107 
    108     @MediumTest
    109     public void testCenterAligned() throws Exception {
    110         ViewAsserts.assertHorizontalCenterAligned(mParent, mCenterView);
    111         ViewAsserts.assertVerticalCenterAligned(mParent, mCenterView);
    112     }
    113 
    114     @MediumTest
    115     public void testLeftBottomAligned() throws Exception {
    116         ViewAsserts.assertLeftAligned(mParent, mLeftBottomView);
    117         ViewAsserts.assertBottomAligned(mParent, mLeftBottomView);
    118     }
    119 
    120     @MediumTest
    121     public void testRightBottomAligned() throws Exception {
    122         ViewAsserts.assertRightAligned(mParent, mRightBottomView);
    123         ViewAsserts.assertBottomAligned(mParent, mRightBottomView);
    124     }
    125 
    126     @MediumTest
    127     public void testCenterHorizontalBottomAligned() throws Exception {
    128         ViewAsserts.assertHorizontalCenterAligned(mParent, mCenterHorizontalBottomView);
    129         ViewAsserts.assertBottomAligned(mParent, mCenterHorizontalBottomView);
    130     }
    131 }
    132