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

Unified Diff: content/browser/media/session/media_session_visibility_browsertest_base.h

Issue 1819113002: [MediaSession, Android] Adding visibility tests for MediaSession (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixing tests Created 4 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/browser/media/session/media_session_visibility_browsertest_base.h
diff --git a/content/browser/media/session/media_session_visibility_browsertest_base.h b/content/browser/media/session/media_session_visibility_browsertest_base.h
new file mode 100644
index 0000000000000000000000000000000000000000..9c3337a1d39e3ff00d0d8a20966e82ba7f1a6a34
--- /dev/null
+++ b/content/browser/media/session/media_session_visibility_browsertest_base.h
@@ -0,0 +1,76 @@
+// Copyright 2016 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.
+
+#ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_VISIBILITY_BROWSER_TEST_BASE_H_
+#define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_VISIBILITY_BROWSER_TEST_BASE_H_
+
+#include "content/public/test/content_browser_test.h"
+
+namespace base {
+class CommandLine;
+class TimeDelta;
+}
+
+namespace content {
+
+class WebContents;
+class MediaSession;
+
+// Base class of MediaSession visibility tests. The class is intended
+// to be used to run tests under different configurations. Tests
+// should inheret from this class, set up their own command line per
+// their configuration, and use macro INCLUDE_TEST_FROM_BASE_CLASS to
+// include required tests. See
+// media_session_visibility_browsertest_instances.cc for examples.
+class MediaSessionVisibilityBrowserTestBase
+ : public ContentBrowserTest {
+ public:
+ MediaSessionVisibilityBrowserTestBase() = default;
+
+ void SetUpOnMainThread() override;
+
+ void SetUpCommandLine(base::CommandLine* command_line) override;
+
+ void LoadTestPage();
+
+ void RunScript(std::string script);
+
+ // TODO(zqzhang): This method is shared with
+ // MediaRouterIntegrationTests. Move it into a general place.
+ bool ConditionalWait(base::TimeDelta timeout,
+ base::TimeDelta interval,
+ const base::Callback<bool(void)>& callback);
+
+ // TODO(zqzhang): This method is shared with
+ // MediaRouterIntegrationTests. Move it into a general place.
+ void Wait(base::TimeDelta timeout);
+
+ // Check the MediaSession state.
+ bool IsMediaSessionActive();
+ bool IsMediaSessionSuspended();
+ bool IsMediaSessionInactive();
+
+ // Wait for the MediaSession state to change.
+ bool WaitForMediaSessionActive();
+ bool WaitForMediaSessionSuspended();
+ bool WaitForMediaSessionInactive();
+
+ protected:
+ void TestSessionInactiveWhenHiddenAfterContentPause();
+ void TestSessionInactiveWhenHiddenWhilePlaying();
+ void TestSessionSuspendedWhenHiddenAfterContentPause();
+ void TestSessionActiveWhenHiddenWhilePlaying();
+
+ WebContents* web_contents_;
+ MediaSession* media_session_;
+};
+
+} // namespace content
+
+#define INCLUDE_TEST_FROM_BASE_CLASS(test_fixture, test_name) \
+ IN_PROC_BROWSER_TEST_F(test_fixture, test_name) {\
+ test_name();\
+ }
+
+#endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_VISIBILITY_BROWSER_TEST_BASE_H_

Powered by Google App Engine
This is Rietveld 408576698