Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1117)

Side by Side Diff: android_webview/javatests/src/org/chromium/android_webview/test/AndroidScrollIntegrationTest.java

Issue 98853009: Fixing Java style issues in android_webview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bo's nits Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.android_webview.test; 5 package org.chromium.android_webview.test;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.test.suitebuilder.annotation.SmallTest; 8 import android.test.suitebuilder.annotation.SmallTest;
9 import android.util.Log; 9 import android.util.Log;
10 import android.view.Gravity; 10 import android.view.Gravity;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 " background-color: blue; " + 120 " background-color: blue; " +
121 " } " + 121 " } " +
122 "</style> "; 122 "</style> ";
123 private static final String TEST_PAGE_COMMON_CONTENT = "<div>test div</div> "; 123 private static final String TEST_PAGE_COMMON_CONTENT = "<div>test div</div> ";
124 124
125 private String makeTestPage(String onscrollObserver, String firstFrameObserv er, 125 private String makeTestPage(String onscrollObserver, String firstFrameObserv er,
126 String extraContent) { 126 String extraContent) {
127 String content = TEST_PAGE_COMMON_CONTENT + extraContent; 127 String content = TEST_PAGE_COMMON_CONTENT + extraContent;
128 if (onscrollObserver != null) { 128 if (onscrollObserver != null) {
129 content += 129 content +=
130 "<script> " + 130 "<script> " +
131 " window.onscroll = function(oEvent) { " + 131 " window.onscroll = function(oEvent) { " +
132 " " + onscrollObserver + ".notifyJava(); " + 132 " " + onscrollObserver + ".notifyJava(); " +
133 " } " + 133 " } " +
134 "</script>"; 134 "</script>";
135 } 135 }
136 if (firstFrameObserver != null) { 136 if (firstFrameObserver != null) {
137 content += 137 content +=
138 "<script> " + 138 "<script> " +
139 " window.framesToIgnore = 10; " + 139 " window.framesToIgnore = 10; " +
140 " window.onAnimationFrame = function(timestamp) { " + 140 " window.onAnimationFrame = function(timestamp) { " +
141 " if (window.framesToIgnore == 0) { " + 141 " if (window.framesToIgnore == 0) { " +
142 " " + firstFrameObserver + ".notifyJava(); " + 142 " " + firstFrameObserver + ".notifyJava(); " +
143 " } else {" + 143 " } else {" +
144 " window.framesToIgnore -= 1; " + 144 " window.framesToIgnore -= 1; " +
145 " window.requestAnimationFrame(window.onAnimationFrame); " + 145 " window.requestAnimationFrame(window.onAnimationFrame ); " +
146 " } " + 146 " } " +
147 " }; " + 147 " }; " +
148 " window.requestAnimationFrame(window.onAnimationFrame); " + 148 " window.requestAnimationFrame(window.onAnimationFrame); " +
149 "</script>"; 149 "</script>";
150 } 150 }
151 return CommonResources.makeHtmlPageFrom(TEST_PAGE_COMMON_HEADERS, conten t); 151 return CommonResources.makeHtmlPageFrom(TEST_PAGE_COMMON_HEADERS, conten t);
152 } 152 }
153 153
154 private void scrollToOnMainSync(final View view, final int xPix, final int y Pix) { 154 private void scrollToOnMainSync(final View view, final int xPix, final int y Pix) {
155 getInstrumentation().runOnMainSync(new Runnable() { 155 getInstrumentation().runOnMainSync(new Runnable() {
156 @Override 156 @Override
157 public void run() { 157 public void run() {
158 view.scrollTo(xPix, yPix); 158 view.scrollTo(xPix, yPix);
159 } 159 }
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 final int scrollToCallCount = onScrollToCallbackHelper.getCallCount(); 636 final int scrollToCallCount = onScrollToCallbackHelper.getCallCount();
637 637
638 getInstrumentation().runOnMainSync(new Runnable() { 638 getInstrumentation().runOnMainSync(new Runnable() {
639 @Override 639 @Override
640 public void run() { 640 public void run() {
641 testContainerView.getAwContents().pageDown(true); 641 testContainerView.getAwContents().pageDown(true);
642 } 642 }
643 }); 643 });
644 644
645 // Wait for the animation to hit the bottom of the page. 645 // Wait for the animation to hit the bottom of the page.
646 for (int i = 1; ; ++i) { 646 for (int i = 1;; ++i) {
647 onScrollToCallbackHelper.waitForCallback(scrollToCallCount, i); 647 onScrollToCallbackHelper.waitForCallback(scrollToCallCount, i);
648 if (checkScrollOnMainSync(testContainerView, 0, maxScrollYPix)) 648 if (checkScrollOnMainSync(testContainerView, 0, maxScrollYPix))
649 break; 649 break;
650 } 650 }
651 } 651 }
652 652
653 @SmallTest 653 @SmallTest
654 @Feature({"AndroidWebView"}) 654 @Feature({"AndroidWebView"})
655 public void testPageUp() throws Throwable { 655 public void testPageUp() throws Throwable {
656 final TestAwContentsClient contentsClient = new TestAwContentsClient(); 656 final TestAwContentsClient contentsClient = new TestAwContentsClient();
(...skipping 17 matching lines...) Expand all
674 final int scrollToCallCount = onScrollToCallbackHelper.getCallCount(); 674 final int scrollToCallCount = onScrollToCallbackHelper.getCallCount();
675 675
676 getInstrumentation().runOnMainSync(new Runnable() { 676 getInstrumentation().runOnMainSync(new Runnable() {
677 @Override 677 @Override
678 public void run() { 678 public void run() {
679 testContainerView.getAwContents().pageUp(true); 679 testContainerView.getAwContents().pageUp(true);
680 } 680 }
681 }); 681 });
682 682
683 // Wait for the animation to hit the bottom of the page. 683 // Wait for the animation to hit the bottom of the page.
684 for (int i = 1; ; ++i) { 684 for (int i = 1;; ++i) {
685 onScrollToCallbackHelper.waitForCallback(scrollToCallCount, i); 685 onScrollToCallbackHelper.waitForCallback(scrollToCallCount, i);
686 if (checkScrollOnMainSync(testContainerView, 0, 0)) 686 if (checkScrollOnMainSync(testContainerView, 0, 0))
687 break; 687 break;
688 } 688 }
689 } 689 }
690 690
691 private static class TestGestureStateListener implements ContentViewCore.Ges tureStateListener { 691 private static class TestGestureStateListener implements ContentViewCore.Ges tureStateListener {
692 private CallbackHelper mOnScrollUpdateGestureConsumedHelper = new Callba ckHelper(); 692 private CallbackHelper mOnScrollUpdateGestureConsumedHelper = new Callba ckHelper();
693 693
694 public CallbackHelper getOnScrollUpdateGestureConsumedHelper() { 694 public CallbackHelper getOnScrollUpdateGestureConsumedHelper() {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 754
755 final int callCount = onScrollUpdateGestureConsumedHelper.getCallCount() ; 755 final int callCount = onScrollUpdateGestureConsumedHelper.getCallCount() ;
756 AwTestTouchUtils.dragCompleteView(testContainerView, 756 AwTestTouchUtils.dragCompleteView(testContainerView,
757 0, -targetScrollXPix, // these need to be negative as we're scro lling down. 757 0, -targetScrollXPix, // these need to be negative as we're scro lling down.
758 0, -targetScrollYPix, 758 0, -targetScrollYPix,
759 dragSteps, 759 dragSteps,
760 null /* completionLatch */); 760 null /* completionLatch */);
761 onScrollUpdateGestureConsumedHelper.waitForCallback(callCount); 761 onScrollUpdateGestureConsumedHelper.waitForCallback(callCount);
762 } 762 }
763 } 763 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698