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

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/VSyncPausedTest.java

Issue 2754493002: Expose VSync pausing through WindowAndroid and pause VSync during webVR presentation (Closed)
Patch Set: Address missed comment Created 3 years, 9 months 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 side-by-side diff with in-line comments
Download patch
Index: content/public/android/javatests/src/org/chromium/content/browser/VSyncPausedTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/VSyncPausedTest.java b/content/public/android/javatests/src/org/chromium/content/browser/VSyncPausedTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..09a8e6a9c4b7a11db2ef30829742e65eef056dff
--- /dev/null
+++ b/content/public/android/javatests/src/org/chromium/content/browser/VSyncPausedTest.java
@@ -0,0 +1,84 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.browser;
+
+import android.support.test.filters.MediumTest;
+
+import org.chromium.base.ThreadUtils;
+import org.chromium.base.test.util.CallbackHelper;
+import org.chromium.content.browser.test.util.JavaScriptUtils;
+import org.chromium.content_public.browser.WebContentsObserver;
+import org.chromium.content_shell_apk.ContentShellTestBase;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * Tests pausing the VSync loop for a WindowAndroid.
+ */
+public class VSyncPausedTest extends ContentShellTestBase {
boliu 2017/03/15 22:08:11 I think a bunch of content tests have been convert
mthiesse 2017/03/16 00:03:07 Done.
+ private static final String VSYNC_HTML = "content/test/data/android/vsync.html";
+ private static final String CALL_RAF = "window.requestAnimationFrame(onAnimationFrame);";
+
+ private CallbackHelper mOnTitleUpdatedHelper;
+ private String mTitle;
+
+ private WebContentsObserver mObserver;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ startActivityWithTestUrl(VSYNC_HTML);
+ mObserver = new WebContentsObserver(getWebContents()) {
+ @Override
+ public void titleWasSet(String title) {
+ mTitle = title;
+ mOnTitleUpdatedHelper.notifyCalled();
+ }
+ };
+ mOnTitleUpdatedHelper = new CallbackHelper();
+ }
+
+ private void fullyLoadUrl(final String url) throws Throwable {
boliu 2017/03/15 22:08:11 not used
mthiesse 2017/03/16 00:03:07 Done.
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ getActivity().getActiveShell().loadUrl(url);
+ }
+ });
+ waitForActiveShellToBeDoneLoading();
+ }
+
+ @MediumTest
+ public void testPauseVSync() throws Throwable {
+ int callCount = mOnTitleUpdatedHelper.getCallCount();
+ JavaScriptUtils.executeJavaScriptAndWaitForResult(
+ getContentViewCore().getWebContents(), CALL_RAF);
+ mOnTitleUpdatedHelper.waitForCallback(callCount);
+ assertEquals(mTitle, "1");
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ getContentViewCore().getWindowAndroid().setVSyncPaused(true);
+ }
+ });
+ callCount = mOnTitleUpdatedHelper.getCallCount();
+ JavaScriptUtils.executeJavaScriptAndWaitForResult(
+ getContentViewCore().getWebContents(), CALL_RAF);
+ try {
+ mOnTitleUpdatedHelper.waitForCallback(callCount, 1, 1, TimeUnit.SECONDS);
+ } catch (TimeoutException e) {
boliu 2017/03/15 22:08:11 add a comment timeout is expected
mthiesse 2017/03/16 00:03:07 Done.
+ }
+ assertEquals(mTitle, "1");
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ getContentViewCore().getWindowAndroid().setVSyncPaused(false);
+ }
+ });
+ mOnTitleUpdatedHelper.waitForCallback(callCount);
+ assertEquals(mTitle, "2");
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698