| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.content.res.Configuration; | 7 import android.content.res.Configuration; |
| 8 import android.graphics.Canvas; | 8 import android.graphics.Canvas; |
| 9 import android.os.SystemClock; | 9 import android.os.SystemClock; |
| 10 import android.test.suitebuilder.annotation.SmallTest; | 10 import android.test.suitebuilder.annotation.SmallTest; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 private void scrollTo(final int x, final int y) throws Throwable { | 130 private void scrollTo(final int x, final int y) throws Throwable { |
| 131 runTestOnUiThread(new Runnable() { | 131 runTestOnUiThread(new Runnable() { |
| 132 @Override | 132 @Override |
| 133 public void run() { | 133 public void run() { |
| 134 getContentViewCore().getContainerView().scrollTo(x, y); | 134 getContentViewCore().getContainerView().scrollTo(x, y); |
| 135 } | 135 } |
| 136 }); | 136 }); |
| 137 } | 137 } |
| 138 | 138 |
| 139 private void scrollBy(final int dx, final int dy) throws Throwable { |
| 140 runTestOnUiThread(new Runnable() { |
| 141 @Override |
| 142 public void run() { |
| 143 getContentViewCore().getContainerView().scrollBy(dx, dy); |
| 144 } |
| 145 }); |
| 146 } |
| 147 |
| 139 @Override | 148 @Override |
| 140 protected void setUp() throws Exception { | 149 protected void setUp() throws Exception { |
| 141 super.setUp(); | 150 super.setUp(); |
| 142 | 151 |
| 143 launchContentShellWithUrl(LARGE_PAGE); | 152 launchContentShellWithUrl(LARGE_PAGE); |
| 144 assertTrue("Page failed to load", waitForActiveShellToBeDoneLoading()); | 153 assertTrue("Page failed to load", waitForActiveShellToBeDoneLoading()); |
| 145 assertWaitForPageScaleFactorMatch(2.0f); | 154 assertWaitForPageScaleFactorMatch(2.0f); |
| 146 | 155 |
| 147 assertEquals(0, getContentViewCore().getNativeScrollXForTest()); | 156 assertEquals(0, getContentViewCore().getNativeScrollXForTest()); |
| 148 assertEquals(0, getContentViewCore().getNativeScrollYForTest()); | 157 assertEquals(0, getContentViewCore().getNativeScrollYForTest()); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 174 assertWaitForScroll(true, true); | 183 assertWaitForScroll(true, true); |
| 175 | 184 |
| 176 // Diagonal fling to bottom-right. | 185 // Diagonal fling to bottom-right. |
| 177 fling(-velocity, -velocity); | 186 fling(-velocity, -velocity); |
| 178 assertWaitForScroll(false, false); | 187 assertWaitForScroll(false, false); |
| 179 } | 188 } |
| 180 | 189 |
| 181 @SmallTest | 190 @SmallTest |
| 182 @RerunWithUpdatedContainerView | 191 @RerunWithUpdatedContainerView |
| 183 @Feature({"Main"}) | 192 @Feature({"Main"}) |
| 184 public void testScroll() throws Throwable { | 193 public void testScrollTo() throws Throwable { |
| 185 // Vertical scroll to lower-left. | 194 // Vertical scroll to lower-left. |
| 186 scrollTo(0, 2500); | 195 scrollTo(0, 2500); |
| 187 assertWaitForScroll(true, false); | 196 assertWaitForScroll(true, false); |
| 188 | 197 |
| 189 // Horizontal scroll to lower-right. | 198 // Horizontal scroll to lower-right. |
| 190 scrollTo(2500, 2500); | 199 scrollTo(2500, 2500); |
| 191 assertWaitForScroll(false, false); | 200 assertWaitForScroll(false, false); |
| 192 | 201 |
| 193 // Vertical scroll to upper-right. | 202 // Vertical scroll to upper-right. |
| 194 scrollTo(2500, 0); | 203 scrollTo(2500, 0); |
| 195 assertWaitForScroll(false, true); | 204 assertWaitForScroll(false, true); |
| 196 | 205 |
| 197 // Horizontal scroll to top-left. | 206 // Horizontal scroll to top-left. |
| 198 scrollTo(0, 0); | 207 scrollTo(0, 0); |
| 199 assertWaitForScroll(true, true); | 208 assertWaitForScroll(true, true); |
| 200 | 209 |
| 201 // Diagonal scroll to bottom-right. | 210 // Diagonal scroll to bottom-right. |
| 202 scrollTo(2500, 2500); | 211 scrollTo(2500, 2500); |
| 203 assertWaitForScroll(false, false); | 212 assertWaitForScroll(false, false); |
| 204 } | 213 } |
| 205 | 214 |
| 215 @SmallTest |
| 216 @RerunWithUpdatedContainerView |
| 217 @Feature({"Main"}) |
| 218 public void testScrollBy() throws Throwable { |
| 219 scrollTo(0, 0); |
| 220 assertWaitForScroll(true, true); |
| 221 |
| 222 // No scroll |
| 223 scrollBy(0, 0); |
| 224 assertWaitForScroll(true, true); |
| 225 |
| 226 // Vertical scroll to lower-left. |
| 227 scrollBy(0, 2500); |
| 228 assertWaitForScroll(true, false); |
| 229 |
| 230 // Horizontal scroll to lower-right. |
| 231 scrollBy(2500, 0); |
| 232 assertWaitForScroll(false, false); |
| 233 |
| 234 // Vertical scroll to upper-right. |
| 235 scrollBy(0, -2500); |
| 236 assertWaitForScroll(false, true); |
| 237 |
| 238 // Horizontal scroll to top-left. |
| 239 scrollBy(-2500, 0); |
| 240 assertWaitForScroll(true, true); |
| 241 |
| 242 // Diagonal scroll to bottom-right. |
| 243 scrollBy(2500, 2500); |
| 244 assertWaitForScroll(false, false); |
| 245 } |
| 246 |
| 206 /** | 247 /** |
| 207 * To ensure the device properly responds to bounds-exceeding scrolls, e.g.,
overscroll | 248 * To ensure the device properly responds to bounds-exceeding scrolls, e.g.,
overscroll |
| 208 * effects are properly initialized. | 249 * effects are properly initialized. |
| 209 */ | 250 */ |
| 210 @SmallTest | 251 @SmallTest |
| 211 @RerunWithUpdatedContainerView | 252 @RerunWithUpdatedContainerView |
| 212 @Feature({"Main"}) | 253 @Feature({"Main"}) |
| 213 public void testOverScroll() throws Throwable { | 254 public void testOverScroll() throws Throwable { |
| 214 // Overscroll lower-left. | 255 // Overscroll lower-left. |
| 215 scrollTo(-10000, 10000); | 256 scrollTo(-10000, 10000); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 scrollTo(scrollToX, scrollToY); | 293 scrollTo(scrollToX, scrollToY); |
| 253 assertWaitForScroll(false, false); | 294 assertWaitForScroll(false, false); |
| 254 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { | 295 assertTrue(CriteriaHelper.pollForCriteria(new Criteria() { |
| 255 @Override | 296 @Override |
| 256 public boolean isSatisfied() { | 297 public boolean isSatisfied() { |
| 257 return containerViewInternals.isScrollChanged(); | 298 return containerViewInternals.isScrollChanged(); |
| 258 } | 299 } |
| 259 })); | 300 })); |
| 260 } | 301 } |
| 261 } | 302 } |
| OLD | NEW |