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