blob: 1a221ff63863e36871ffdd9d630816247ece5718 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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 Nguyen1d3165f2010-01-12 13:26:10 -080017package android.widget.scroll;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080018
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080019import android.test.ActivityInstrumentationTestCase;
20import android.test.ViewAsserts;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.view.KeyEvent;
22import android.widget.Button;
23import android.widget.ScrollView;
24import android.widget.TextView;
25
Tadashi G. Takaokab4470f22019-01-15 18:29:15 +090026import androidx.test.filters.Suppress;
27
28import com.android.frameworks.coretests.R;
29
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030/**
31 * This is suppressed because {@link TextView#scrollBy} isn't working.
32 */
33@Suppress
34public 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 Nguyen1d3165f2010-01-12 13:26:10 -080044 super("com.android.frameworks.coretests",
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045 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}