Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_VISIBILITY_BROWSER_TEST_BASE _H_ | |
| 6 #define CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_VISIBILITY_BROWSER_TEST_BASE _H_ | |
| 7 | |
| 8 #include "content/browser/media/session/media_session.h" | |
| 9 #include "content/public/test/content_browser_test.h" | |
| 10 #include "content/public/test/test_utils.h" | |
| 11 | |
| 12 namespace base { | |
| 13 class CommandLine; | |
| 14 class TimeDelta; | |
| 15 } | |
| 16 | |
| 17 namespace content { | |
| 18 | |
| 19 class WebContents; | |
| 20 | |
| 21 // Base class of MediaSession visibility tests. The class is intended | |
| 22 // to be used to run tests under different configurations. Tests | |
| 23 // should inheret from this class, set up their own command line per | |
| 24 // their configuration, and use macro INCLUDE_TEST_FROM_BASE_CLASS to | |
| 25 // include required tests. See | |
| 26 // media_session_visibility_browsertest_instances.cc for examples. | |
| 27 class MediaSessionVisibilityBrowserTestBase | |
| 28 : public ContentBrowserTest { | |
| 29 public: | |
| 30 MediaSessionVisibilityBrowserTestBase(); | |
| 31 ~MediaSessionVisibilityBrowserTestBase() override; | |
| 32 | |
| 33 void SetUpOnMainThread() override; | |
| 34 void TearDownOnMainThread() override; | |
| 35 | |
| 36 void SetUpCommandLine(base::CommandLine* command_line) override; | |
| 37 | |
| 38 void LoadTestPage(); | |
| 39 | |
| 40 void RunScript(std::string script); | |
| 41 | |
| 42 void ClearMediaSessionStateLoopRunners(); | |
| 43 | |
| 44 void OnMediaSessionStateChanged(MediaSession::State state); | |
| 45 | |
| 46 // TODO(zqzhang): This method is shared with | |
| 47 // MediaRouterIntegrationTests. Move it into a general place. | |
| 48 void Wait(base::TimeDelta timeout); | |
| 49 | |
| 50 void WaitForMediaSessionState(MediaSession::State state); | |
| 51 | |
| 52 protected: | |
| 53 void TestSessionInactiveWhenHiddenAfterContentPause(); | |
| 54 void TestSessionInactiveWhenHiddenWhilePlaying(); | |
| 55 void TestSessionSuspendedWhenHiddenAfterContentPause(); | |
| 56 void TestSessionActiveWhenHiddenWhilePlaying(); | |
| 57 | |
| 58 WebContents* web_contents_; | |
| 59 MediaSession* media_session_; | |
| 60 // MessageLoopRunners for waiting MediaSession state to change. Note that the | |
| 61 // MessageLoopRunners can accept Quit() before calling Run(), thus the state | |
| 62 // change can still be captured before waiting. For example, the MediaSession | |
| 63 // might go active immediately after calling HTMLMediaElement.play(). A test | |
| 64 // can listen to the state change before calling play(), and then wait for the | |
| 65 // state change after play(). | |
| 66 std::map<MediaSession::State, scoped_refptr<MessageLoopRunner> > | |
| 67 media_session_state_loop_runners_; | |
| 68 scoped_ptr<base::CallbackList<void(MediaSession::State)>::Subscription> | |
| 69 media_session_state_callback_subscription_; | |
| 70 }; | |
|
DaleCurtis
2016/03/31 16:50:26
DISALLOW_COPY_AND_ASSIGN()
Zhiqiang Zhang (Slow)
2016/03/31 19:58:39
Done.
| |
| 71 | |
| 72 } // namespace content | |
| 73 | |
| 74 #define INCLUDE_TEST_FROM_BASE_CLASS(test_fixture, test_name) \ | |
|
DaleCurtis
2016/03/31 16:50:26
We generally try to avoid #define's. Can you avoid
Zhiqiang Zhang (Slow)
2016/03/31 19:58:39
Moved to .cc file
| |
| 75 IN_PROC_BROWSER_TEST_F(test_fixture, test_name) {\ | |
| 76 test_name();\ | |
| 77 } | |
| 78 | |
| 79 #endif // CONTENT_BROWSER_MEDIA_SESSION_MEDIA_SESSION_VISIBILITY_BROWSER_TEST_B ASE_H_ | |
| OLD | NEW |