Home | History | Annotate | Download | only in arrowscroll
      1 /*
      2  * Copyright (C) 2008 Google Inc.
      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.listview.arrowscroll;
     18 
     19 import android.widget.listview.ListWithFirstScreenUnSelectable;
     20 import android.test.ActivityInstrumentationTestCase2;
     21 import android.view.KeyEvent;
     22 import android.widget.ListView;
     23 import android.widget.AdapterView;
     24 
     25 public class ListWithFirstScreenUnSelectableTest
     26         extends ActivityInstrumentationTestCase2<ListWithFirstScreenUnSelectable> {
     27     private ListView mListView;
     28 
     29     public ListWithFirstScreenUnSelectableTest() {
     30         super("com.android.frameworks.coretests", ListWithFirstScreenUnSelectable.class);
     31     }
     32 
     33     protected void setUp() throws Exception {
     34         super.setUp();
     35 
     36         setActivityInitialTouchMode(true);
     37 
     38         mListView = getActivity().getListView();
     39     }
     40 
     41     public void testPreconditions() {
     42         assertTrue(mListView.isInTouchMode());
     43         assertEquals(1, mListView.getChildCount());
     44         assertFalse(mListView.getAdapter().isEnabled(0));
     45         assertEquals(AdapterView.INVALID_POSITION, mListView.getSelectedItemPosition());
     46     }
     47 
     48     public void testRessurectSelection() {
     49         sendKeys(KeyEvent.KEYCODE_SPACE);
     50         assertEquals(AdapterView.INVALID_POSITION, mListView.getSelectedItemPosition());
     51     }
     52 
     53     public void testScrollUpDoesNothing() {
     54         sendKeys(KeyEvent.KEYCODE_DPAD_UP);
     55         assertEquals(AdapterView.INVALID_POSITION, mListView.getSelectedItemPosition());
     56         assertEquals(1, mListView.getChildCount());
     57         assertEquals(0, mListView.getFirstVisiblePosition());
     58     }
     59 
     60     public void testScrollDownPansNextItemOn() {
     61         sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
     62         assertEquals(2, mListView.getChildCount());
     63     }
     64 }
     65