Home | History | Annotate | Download | only in scroll
      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.scroll;
     18 
     19 import android.test.suitebuilder.annotation.Suppress;
     20 import android.widget.scroll.ButtonAboveTallInternalSelectionView;
     21 import android.util.InternalSelectionView;
     22 
     23 import android.test.ActivityInstrumentationTestCase;
     24 import android.test.suitebuilder.annotation.MediumTest;
     25 import android.view.KeyEvent;
     26 
     27 @Suppress // Failing.
     28 public class ButtonAboveTallInternalSelectionViewTest extends
     29         ActivityInstrumentationTestCase<ButtonAboveTallInternalSelectionView> {
     30 
     31     public ButtonAboveTallInternalSelectionViewTest() {
     32         super("com.android.frameworks.coretests", ButtonAboveTallInternalSelectionView.class);
     33     }
     34 
     35     @MediumTest
     36     public void testPreconditions() {
     37         assertTrue("expecting the top button to have focus",
     38                 getActivity().getButtonAbove().isFocused());
     39         assertEquals("scrollview scroll y",
     40                 0,
     41                 getActivity().getScrollView().getScrollY());
     42         assertTrue("internal selection view should be taller than screen",
     43                 getActivity().getIsv().getHeight() > getActivity().getScrollView().getHeight());
     44 
     45         assertTrue("top of ISV should be on screen",
     46                 getActivity().getIsv().getTop() >
     47                 getActivity().getScrollView().getScrollY());
     48 
     49     }
     50 
     51     @MediumTest
     52     public void testMovingFocusDownToItemTallerThanScreenStillOnScreen() {
     53         sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
     54         getInstrumentation().waitForIdleSync();
     55 
     56         final InternalSelectionView isv = getActivity().getIsv();
     57         assertTrue("internal selection view should have taken focus",
     58                 isv.isFocused());
     59         assertEquals("internal selection view selected row",
     60                 0, isv.getSelectedRow());
     61         assertTrue("top of ISV should still be on screen",
     62                 getActivity().getIsv().getTop() >
     63                 getActivity().getScrollView().getScrollY());
     64     }
     65 
     66 
     67 
     68 }
     69