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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/video/FullscreenVideoTest.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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: chrome/android/javatests/src/org/chromium/chrome/browser/video/FullscreenVideoTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/video/FullscreenVideoTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/video/FullscreenVideoTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..c706d13533eb795a570746f63c674bb35e3191e9
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/video/FullscreenVideoTest.java
@@ -0,0 +1,94 @@
+// Copyright 2015 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.chrome.browser.video;
+
+import android.test.FlakyTest;
+import android.view.KeyEvent;
+
+import org.chromium.base.ThreadUtils;
+import org.chromium.chrome.browser.ChromeActivity;
+import org.chromium.chrome.browser.EmptyTabObserver;
+import org.chromium.chrome.browser.Tab;
+import org.chromium.chrome.test.ChromeActivityTestCaseBase;
+import org.chromium.chrome.test.util.TestHttpServerClient;
+import org.chromium.content.browser.test.util.Criteria;
+import org.chromium.content.browser.test.util.CriteriaHelper;
+import org.chromium.content.browser.test.util.TestTouchUtils;
+
+/**
+ * Test suite for fullscreen video implementation.
+ */
+public class FullscreenVideoTest extends ChromeActivityTestCaseBase<ChromeActivity> {
+ private static final int TEST_TIMEOUT = 3000;
+ private boolean mIsTabFullscreen = false;
+
+ private class FullscreenTabObserver extends EmptyTabObserver {
+ @Override
+ public void onToggleFullscreenMode(Tab tab, boolean enable) {
+ mIsTabFullscreen = enable;
+ }
+ }
+
+ public FullscreenVideoTest() {
+ super(ChromeActivity.class);
+ }
+
+ @Override
+ public void startMainActivity() throws InterruptedException {
+ startMainActivityOnBlankPage();
+ }
+
+ /**
+ * Test that when playing a fullscreen video, hitting the back button will let the tab
+ * exit fullscreen mode without changing its URL.
+ *
+ * @MediumTest
+ * crbug.com/458368.
+ */
+ @FlakyTest
+ public void testExitFullscreenNotifiesTabObservers() throws InterruptedException {
+ String url = TestHttpServerClient.getUrl(
+ "chrome/test/data/android/media/video-fullscreen.html");
+ loadUrl(url);
+ Tab tab = getActivity().getActivityTab();
+ FullscreenTabObserver observer = new FullscreenTabObserver();
+ tab.addObserver(observer);
+
+ TestTouchUtils.singleClickView(getInstrumentation(), tab.getView(), 500, 500);
+ waitForVideoToEnterFullscreen();
+ // Key events have to be dispached on UI thread.
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ getActivity().dispatchKeyEvent(
+ new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK));
+ getActivity().dispatchKeyEvent(
+ new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK));
+ }
+ });
+
+ waitForTabToExitFullscreen();
+ assertEquals("URL mismatch after exiting fullscreen video",
+ url, getActivity().getActivityTab().getUrl());
+ }
+
+ void waitForVideoToEnterFullscreen() throws InterruptedException {
+ assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ return mIsTabFullscreen;
+ }
+ }, TEST_TIMEOUT, CriteriaHelper.DEFAULT_POLLING_INTERVAL));
+ }
+
+ void waitForTabToExitFullscreen() throws InterruptedException {
+ assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ return !mIsTabFullscreen;
+ }
+ }, TEST_TIMEOUT, CriteriaHelper.DEFAULT_POLLING_INTERVAL));
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698