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