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.view.ViewGroup;
     25 import android.widget.layout.frame.FrameLayoutMargin;
     26 import com.android.frameworks.coretests.R;
     27 
     28 public class FrameLayoutMarginTest extends ActivityInstrumentationTestCase<FrameLayoutMargin> {
     29     private View mLeftView;
     30     private View mRightView;
     31     private View mTopView;
     32     private View mBottomView;
     33     private View mParent;
     34 
     35     public FrameLayoutMarginTest() {
     36         super("com.android.frameworks.coretests", FrameLayoutMargin.class);
     37     }
     38 
     39     @Override
     40     protected void setUp() throws Exception {
     41         super.setUp();
     42 
     43         final Activity activity = getActivity();
     44 
     45         mParent = activity.findViewById(R.id.parent);
     46 
     47         mLeftView = activity.findViewById(R.id.left);
     48         mRightView = activity.findViewById(R.id.right);
     49         mTopView = activity.findViewById(R.id.top);
     50         mBottomView = activity.findViewById(R.id.bottom);
     51     }
     52 
     53     @MediumTest
     54     public void testSetUpConditions() throws Exception {
     55         assertNotNull(mParent);
     56         assertNotNull(mLeftView);
     57         assertNotNull(mRightView);
     58         assertNotNull(mTopView);
     59         assertNotNull(mBottomView);
     60     }
     61 
     62     @MediumTest
     63     public void testLeftMarginAligned() throws Exception {
     64         ViewAsserts.assertLeftAligned(mParent, mLeftView,
     65                 ((ViewGroup.MarginLayoutParams) mLeftView.getLayoutParams()).leftMargin);
     66     }
     67 
     68     @MediumTest
     69     public void testRightMarginAligned() throws Exception {
     70         ViewAsserts.assertRightAligned(mParent, mRightView,
     71                 ((ViewGroup.MarginLayoutParams) mRightView.getLayoutParams()).rightMargin);
     72     }
     73 
     74     @MediumTest
     75     public void testTopMarginAligned() throws Exception {
     76         ViewAsserts.assertTopAligned(mParent, mTopView,
     77                 ((ViewGroup.MarginLayoutParams) mTopView.getLayoutParams()).topMargin);
     78     }
     79 
     80     @MediumTest
     81     public void testBottomMarginAligned() throws Exception {
     82         ViewAsserts.assertBottomAligned(mParent, mBottomView,
     83                 ((ViewGroup.MarginLayoutParams) mBottomView.getLayoutParams()).bottomMargin);
     84     }
     85 }
     86