1/* 2 * Copyright (C) 2007 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 17package android.widget.scroll; 18 19import com.android.frameworks.coretests.R; 20 21import android.test.ActivityInstrumentationTestCase; 22import android.test.ViewAsserts; 23import android.test.suitebuilder.annotation.Suppress; 24import android.view.KeyEvent; 25import android.widget.Button; 26import android.widget.ScrollView; 27import android.widget.TextView; 28 29/** 30 * This is suppressed because {@link TextView#scrollBy} isn't working. 31 */ 32@Suppress 33public class RequestRectangleVisibleWithInternalScrollTest 34 extends ActivityInstrumentationTestCase<RequestRectangleVisibleWithInternalScroll> { 35 36 private TextView mTextBlob; 37 private Button mScrollToBlob; 38 39 private ScrollView mScrollView; 40 41 42 public RequestRectangleVisibleWithInternalScrollTest() { 43 super("com.android.frameworks.coretests", 44 RequestRectangleVisibleWithInternalScroll.class); 45 } 46 47 48 @Override 49 protected void setUp() throws Exception { 50 super.setUp(); 51 mTextBlob = getActivity().getTextBlob(); 52 mScrollToBlob = getActivity().getScrollToBlob(); 53 54 mScrollView = (ScrollView) getActivity().findViewById(R.id.scrollView); 55 } 56 57 public void testPreconditions() { 58 assertNotNull(mTextBlob); 59 assertNotNull(mScrollToBlob); 60 assertEquals(getActivity().getScrollYofBlob(), mTextBlob.getScrollY()); 61 } 62 63 public void testMoveToChildWithScrollYBelow() { 64 assertTrue(mScrollToBlob.hasFocus()); 65 66 ViewAsserts.assertOffScreenBelow(mScrollView, mTextBlob); 67 68 // click 69 sendKeys(KeyEvent.KEYCODE_DPAD_CENTER); 70 getInstrumentation().waitForIdleSync(); // wait for scrolling to finish 71 72 // should be on screen, positioned at the bottom (with enough room for 73 // fading edge) 74 ViewAsserts.assertOnScreen(mScrollView, mTextBlob); 75 ViewAsserts.assertHasScreenCoordinates( 76 mScrollView, mTextBlob, 77 0, 78 mScrollView.getHeight() 79 - mTextBlob.getHeight() 80 - mScrollView.getVerticalFadingEdgeLength()); 81 82 } 83 84 85} 86