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

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: Fix 'unused' member 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
« no previous file with comments | « content/public/android/BUILD.gn ('k') | content/test/data/android/vsync.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b7a9f5d2e21467435a1e6f3f79d4536e4b0a2719
--- /dev/null
+++ b/content/public/android/javatests/src/org/chromium/content/browser/VSyncPausedTest.java
@@ -0,0 +1,114 @@
+// 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.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.chromium.base.ThreadUtils;
+import org.chromium.base.test.BaseJUnit4ClassRunner;
+import org.chromium.base.test.util.CallbackHelper;
+import org.chromium.base.test.util.UrlUtils;
+import org.chromium.content.browser.test.util.JavaScriptUtils;
+import org.chromium.content_public.browser.WebContentsObserver;
+import org.chromium.content_shell_apk.ContentShellActivity;
+import org.chromium.content_shell_apk.ContentShellActivityTestRule;
+
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * Tests pausing the VSync loop for a WindowAndroid.
+ */
+@RunWith(BaseJUnit4ClassRunner.class)
+public class VSyncPausedTest {
+ @Rule
+ public ContentShellActivityTestRule mActivityTestRule = new ContentShellActivityTestRule();
+
+ 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;
+ private ContentShellActivity mActivity;
+
+ @Before
+ public void setUp() throws Exception {
+ mActivity = mActivityTestRule.launchContentShellWithUrl(
+ UrlUtils.getIsolatedTestFileUrl(VSYNC_HTML));
+ mActivityTestRule.waitForActiveShellToBeDoneLoading();
+ mObserver = new WebContentsObserver(mActivity.getActiveWebContents()) {
+ @Override
+ public void titleWasSet(String title) {
+ mTitle = title;
+ mOnTitleUpdatedHelper.notifyCalled();
+ }
+ };
+ mOnTitleUpdatedHelper = new CallbackHelper();
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ mObserver.destroy();
+ }
+
+ @Test
+ @MediumTest
+ public void testPauseVSync() throws Throwable {
+ int callCount = mOnTitleUpdatedHelper.getCallCount();
+ JavaScriptUtils.executeJavaScriptAndWaitForResult(
+ mActivity.getActiveWebContents(), CALL_RAF);
+ mOnTitleUpdatedHelper.waitForCallback(callCount);
+ Assert.assertEquals("1", mTitle);
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ mActivity.getActiveShell().getContentViewCore().getWindowAndroid().setVSyncPaused(
+ true);
+ }
+ });
+ callCount = mOnTitleUpdatedHelper.getCallCount();
+ JavaScriptUtils.executeJavaScriptAndWaitForResult(
+ mActivity.getActiveWebContents(), CALL_RAF);
+ try {
+ mOnTitleUpdatedHelper.waitForCallback(callCount, 1, 1, TimeUnit.SECONDS);
+ } catch (TimeoutException e) {
+ // Timeout is expected.
+ }
+ // There may be a VSync already propagating before we pause VSync, so we may receive a
+ // single extra VSync.
+ String expected = "2";
+ if (mTitle.equals("2")) {
+ expected = "3";
+ callCount = mOnTitleUpdatedHelper.getCallCount();
+ // Make sure we don't receive another extra VSync.
+ JavaScriptUtils.executeJavaScriptAndWaitForResult(
+ mActivity.getActiveWebContents(), CALL_RAF);
+ try {
+ mOnTitleUpdatedHelper.waitForCallback(callCount, 1, 1, TimeUnit.SECONDS);
+ } catch (TimeoutException e) {
+ // Timeout is expected.
+ }
+ Assert.assertEquals("2", mTitle);
+ }
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ mActivity.getActiveShell().getContentViewCore().getWindowAndroid().setVSyncPaused(
+ false);
+ }
+ });
+ mOnTitleUpdatedHelper.waitForCallback(callCount);
+ Assert.assertEquals(expected, mTitle);
+ }
+}
« no previous file with comments | « content/public/android/BUILD.gn ('k') | content/test/data/android/vsync.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698