diff options
author | mkosiba@chromium.org <mkosiba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-14 21:19:59 +0000 |
---|---|---|
committer | mkosiba@chromium.org <mkosiba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-14 21:19:59 +0000 |
commit | 02fa8f66a28c54ab81a415017f8f97659d05e9bc (patch) | |
tree | d66d3127091996770c0aa49acdc59716d8034efe /android_webview | |
parent | f3d3b3843becc02b010ebbcf4087850c215f3ebc (diff) | |
download | chromium_src-02fa8f66a28c54ab81a415017f8f97659d05e9bc.zip chromium_src-02fa8f66a28c54ab81a415017f8f97659d05e9bc.tar.gz chromium_src-02fa8f66a28c54ab81a415017f8f97659d05e9bc.tar.bz2 |
[android_webview] Increase the scroll distance in one of the tests.
The testNoSpuriousOverScrolls test was failing on the N5 because
of what seems to be a difference in the touch slop region size.
Increasing the number of pixels we scroll by in the test fixes
the issue but also caused a fling animation which is the reason
for the custom AwScrollOffsetManager.
BUG=351476
Review URL: https://codereview.chromium.org/198013003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257204 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'android_webview')
4 files changed, 43 insertions, 16 deletions
diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java index 4303bd4..02453f4 100644 --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java @@ -64,6 +64,7 @@ import java.util.HashMap; import java.util.List; import java.util.concurrent.Callable; + /** * Exposes the native AwContents class, and together these classes wrap the ContentViewCore * and Browser components that are required to implement Android WebView API. This is the @@ -147,6 +148,21 @@ public class AwContents { public boolean executeHardwareAction(Runnable action); } + /** + * Class to facilitate dependency injection. Subclasses by test code to provide mock versions of + * certain AwContents dependencies. + */ + public static class DependencyFactory { + public AwLayoutSizer createLayoutSizer() { + return new AwLayoutSizer(); + } + + public AwScrollOffsetManager createScrollOffsetManager( + AwScrollOffsetManager.Delegate delegate, OverScroller overScroller) { + return new AwScrollOffsetManager(delegate, overScroller); + } + } + private long mNativeAwContents; private final AwBrowserContext mBrowserContext; private final ViewGroup mContainerView; @@ -468,24 +484,25 @@ public class AwContents { InternalAccessDelegate internalAccessAdapter, AwContentsClient contentsClient, AwSettings awSettings) { this(browserContext, containerView, internalAccessAdapter, contentsClient, awSettings, - new AwLayoutSizer()); + new DependencyFactory()); } /** - * @param layoutSizer the AwLayoutSizer instance implementing the sizing policy for the view. + * @param dependencyFactory an instance of the DependencyFactory used to provide instances of + * classes that this class depends on. * * This version of the constructor is used in test code to inject test versions of the above * documented classes. */ public AwContents(AwBrowserContext browserContext, ViewGroup containerView, InternalAccessDelegate internalAccessAdapter, AwContentsClient contentsClient, - AwSettings settings, AwLayoutSizer layoutSizer) { + AwSettings settings, DependencyFactory dependencyFactory) { mBrowserContext = browserContext; mContainerView = containerView; mInternalAccessAdapter = internalAccessAdapter; mContentsClient = contentsClient; mContentViewClient = new AwContentViewClient(contentsClient, settings); - mLayoutSizer = layoutSizer; + mLayoutSizer = dependencyFactory.createLayoutSizer(); mSettings = settings; mDIPScale = DeviceDisplayInfo.create(mContainerView.getContext()).getDIPScale(); mLayoutSizer.setDelegate(new AwLayoutSizerDelegate()); @@ -511,8 +528,8 @@ public class AwContents { mSettings.setDefaultVideoPosterURL( mDefaultVideoPosterRequestHandler.getDefaultVideoPosterURL()); mSettings.setDIPScale(mDIPScale); - mScrollOffsetManager = new AwScrollOffsetManager(new AwScrollOffsetManagerDelegate(), - new OverScroller(mContainerView.getContext())); + mScrollOffsetManager = dependencyFactory.createScrollOffsetManager( + new AwScrollOffsetManagerDelegate(), new OverScroller(mContainerView.getContext())); mScrollAccessibilityHelper = new ScrollAccessibilityHelper(mContainerView); setOverScrollMode(mContainerView.getOverScrollMode()); diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AndroidScrollIntegrationTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AndroidScrollIntegrationTest.java index 9c05181..a222023 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/AndroidScrollIntegrationTest.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AndroidScrollIntegrationTest.java @@ -7,8 +7,10 @@ package org.chromium.android_webview.test; import android.content.Context; import android.test.suitebuilder.annotation.SmallTest; import android.view.View; +import android.widget.OverScroller; import org.chromium.android_webview.AwContents; +import org.chromium.android_webview.AwScrollOffsetManager; import org.chromium.android_webview.test.util.AwTestTouchUtils; import org.chromium.android_webview.test.util.CommonResources; import org.chromium.android_webview.test.util.JavascriptEventObserver; @@ -98,6 +100,19 @@ public class AndroidScrollIntegrationTest extends AwTestBase { protected TestDependencyFactory createTestDependencyFactory() { return new TestDependencyFactory() { @Override + public AwScrollOffsetManager createScrollOffsetManager( + AwScrollOffsetManager.Delegate delegate, OverScroller overScroller) { + return new AwScrollOffsetManager(delegate, overScroller) { + @Override + public void onUnhandledFlingStartEvent(int velocityX, int velocityY) { + // Intentional no-op. The synthetic scroll gestures this test creates all + // happen at the same time which triggers the fling detection logic. + // NOTE: this simply disables handling the gesture, flinging the AwContents + // via the flingScroll API is still possible. + } + }; + } + @Override public AwTestContainerView createAwTestContainerView(AwTestRunnerActivity activity) { return new ScrollTestContainerView(activity); } @@ -129,7 +144,7 @@ public class AndroidScrollIntegrationTest extends AwTestBase { if (firstFrameObserver != null) { content += "<script> " + - " window.framesToIgnore = 10; " + + " window.framesToIgnore = 20; " + " window.onAnimationFrame = function(timestamp) { " + " if (window.framesToIgnore == 0) { " + " " + firstFrameObserver + ".notifyJava(); " + @@ -398,7 +413,7 @@ public class AndroidScrollIntegrationTest extends AwTestBase { enableJavaScriptOnUiThread(testContainerView.getAwContents()); final int dragSteps = 1; - final int targetScrollYPix = 24; + final int targetScrollYPix = 40; setMaxScrollOnMainSync(testContainerView, 0, 0); diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java index b078c1c..f362c37 100644 --- a/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java +++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwTestBase.java @@ -15,7 +15,6 @@ import org.chromium.android_webview.AwBrowserContext; import org.chromium.android_webview.AwBrowserProcess; import org.chromium.android_webview.AwContents; import org.chromium.android_webview.AwContentsClient; -import org.chromium.android_webview.AwLayoutSizer; import org.chromium.android_webview.AwSettings; import org.chromium.android_webview.test.util.JSUtils; import org.chromium.base.test.util.InMemorySharedPreferences; @@ -257,10 +256,7 @@ public class AwTestBase * Test cases can provide subclass instances to the createAwTest* methods in order to create an * AwContents instance with injected test dependencies. */ - public static class TestDependencyFactory { - public AwLayoutSizer createLayoutSizer() { - return new AwLayoutSizer(); - } + public static class TestDependencyFactory extends AwContents.DependencyFactory { public AwTestContainerView createAwTestContainerView(AwTestRunnerActivity activity) { return new AwTestContainerView(activity); } @@ -305,7 +301,7 @@ public class AwTestBase supportsLegacyQuirks); testContainerView.initialize(new AwContents( mBrowserContext, testContainerView, testContainerView.getInternalAccessDelegate(), - awContentsClient, awSettings, testDependencyFactory.createLayoutSizer())); + awContentsClient, awSettings, testDependencyFactory)); return testContainerView; } diff --git a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java index e8215cc..b2f79e3 100644 --- a/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java +++ b/android_webview/test/shell/src/org/chromium/android_webview/shell/AwShellActivity.java @@ -28,7 +28,6 @@ import org.chromium.android_webview.AwBrowserProcess; import org.chromium.android_webview.AwContents; import org.chromium.android_webview.AwContentsClient; import org.chromium.android_webview.AwDevToolsServer; -import org.chromium.android_webview.AwLayoutSizer; import org.chromium.android_webview.AwSettings; import org.chromium.android_webview.test.AwTestContainerView; import org.chromium.android_webview.test.NullContentsClient; @@ -94,7 +93,7 @@ public class AwShellActivity extends Activity { false /*isAccessFromFileURLsGrantedByDefault*/, true /*supportsLegacyQuirks*/); testContainerView.initialize(new AwContents(mBrowserContext, testContainerView, testContainerView.getInternalAccessDelegate(), - awContentsClient, awSettings, new AwLayoutSizer())); + awContentsClient, awSettings)); testContainerView.getAwContents().getSettings().setJavaScriptEnabled(true); if (mDevToolsServer == null) { mDevToolsServer = new AwDevToolsServer(); |