 Chromium Code Reviews
 Chromium Code Reviews Issue 1370453002:
  Introduce WebMediaSession  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1370453002:
  Introduce WebMediaSession  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 // Copyright 2015 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 #include "config.h" | |
| 6 #include "modules/mediasession/MediaSession.h" | |
| 7 | |
| 8 #include "core/dom/Document.h" | |
| 9 #include "core/testing/DummyPageHolder.h" | |
| 10 #include "public/platform/modules/mediasession/WebMediaSession.h" | |
| 11 #include <gmock/gmock.h> | |
| 12 #include <gtest/gtest.h> | |
| 13 | |
| 14 using testing::_; | |
| 15 | |
| 16 namespace blink { | |
| 17 namespace { | |
| 18 | |
| 19 class MockWebMediaSession : public WebMediaSession { | |
| 20 public: | |
| 21 MOCK_METHOD1(activate, void(WebMediaSessionCommandCallback*)); | |
| 22 MOCK_METHOD1(deactivate, void(WebMediaSessionCommandCallback*)); | |
| 23 }; | |
| 24 | |
| 25 class MediaSessionTest : public ::testing::Test { | |
| 26 protected: | |
| 27 MediaSessionTest() | |
| 28 : m_page(DummyPageHolder::create(IntSize(1, 1))) | |
| 29 {} | |
| 30 | |
| 31 MediaSession* createMediaSession(WebMediaSession* webMediaSession) | |
| 32 { | |
| 33 // The MediaSession takes ownership of the WebMediaSession, and the | |
| 34 // caller must take care to not end up with a stale pointer. | |
| 35 return MediaSession::createForTesting(adoptPtr(webMediaSession)); | |
| 
mlamouri (slow - plz ping)
2015/10/09 13:01:28
I would still prefer to have MediaSessionTest a fr
 
davve
2015/10/19 13:12:42
WFM. Thanks.
 | |
| 36 } | |
| 37 | |
| 38 Document& document() { return m_page->document(); } | |
| 39 ScriptState* mainScriptState() { return ScriptState::forMainWorld(document() .frame()); } | |
| 40 private: | |
| 41 OwnPtr<DummyPageHolder> m_page; | |
| 42 }; | |
| 43 | |
| 44 TEST_F(MediaSessionTest, Activate) | |
| 45 { | |
| 46 MockWebMediaSession* mockWebMediaSession = new MockWebMediaSession; | |
| 47 MediaSession* mediaSession = createMediaSession(mockWebMediaSession); | |
| 48 | |
| 49 EXPECT_CALL(*mockWebMediaSession, activate(_)); | |
| 50 mediaSession->activate(mainScriptState()); | |
| 51 } | |
| 52 | |
| 53 TEST_F(MediaSessionTest, Deactivate) | |
| 54 { | |
| 55 MockWebMediaSession* mockWebMediaSession = new MockWebMediaSession; | |
| 56 MediaSession* mediaSession = createMediaSession(mockWebMediaSession); | |
| 57 | |
| 58 EXPECT_CALL(*mockWebMediaSession, deactivate(_)); | |
| 59 mediaSession->deactivate(mainScriptState()); | |
| 60 } | |
| 61 | |
| 62 } // namespace | |
| 63 } // namespace blink | |
| OLD | NEW |