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

Unified Diff: Source/modules/mediasession/MediaSessionTest.cpp

Issue 1325493002: NOT FOR LANDING Introduce and use WebMediaSession (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add missing files Created 5 years, 3 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 | « Source/modules/mediasession/MediaSessionError.cpp ('k') | Source/modules/modules.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/mediasession/MediaSessionTest.cpp
diff --git a/Source/modules/mediasession/MediaSessionTest.cpp b/Source/modules/mediasession/MediaSessionTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b2d4d814feaf8c6ae2ee46485bbd4ba0be7fded0
--- /dev/null
+++ b/Source/modules/mediasession/MediaSessionTest.cpp
@@ -0,0 +1,62 @@
+// 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.
+
+#include "config.h"
+#include "modules/mediasession/MediaSession.h"
+
+#include "core/dom/Document.h"
+#include "core/testing/DummyPageHolder.h"
+#include "public/platform/modules/mediasession/WebMediaSession.h"
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+using testing::_;
+
+namespace blink {
+namespace {
+
+class MockWebMediaSession : public WebMediaSession {
+public:
+ MOCK_METHOD1(activate, void(WebMediaSessionCommandCallback*));
+ MOCK_METHOD1(deactivate, void(WebMediaSessionCommandCallback*));
+};
+
+class MediaSessionTest : public ::testing::Test {
+protected:
+ MediaSessionTest()
+ : m_page(DummyPageHolder::create(IntSize(1, 1)))
+ {}
+
+ MediaSession* createMediaSession(WebMediaSession* webMediaSession)
+ {
+ // The MediaSession takes ownership of the WebMediaSession, and the
+ // caller must take care to not end up with a stale pointer.
+ return MediaSession::createForTesting(adoptPtr(webMediaSession));
+ }
+
+ Document& document() { return m_page->document(); }
+ ScriptState* mainScriptState() { return ScriptState::forMainWorld(document().frame()); }
+private:
+ OwnPtr<DummyPageHolder> m_page;
+};
+
+TEST_F(MediaSessionTest, Activate)
+{
+ MockWebMediaSession* mockWebMediaSession = new MockWebMediaSession;
+ MediaSession* mediaSession = createMediaSession(mockWebMediaSession);
+ EXPECT_CALL(*mockWebMediaSession, activate(_));
+
+ mediaSession->activate(mainScriptState());
+}
+
+TEST_F(MediaSessionTest, Deactivate)
+{
+ MockWebMediaSession* mockWebMediaSession = new MockWebMediaSession;
+ MediaSession* mediaSession = createMediaSession(mockWebMediaSession);
+ EXPECT_CALL(*mockWebMediaSession, deactivate(_));
+ mediaSession->deactivate(mainScriptState());
+}
+
+} // namespace
+} // namespace blink
« no previous file with comments | « Source/modules/mediasession/MediaSessionError.cpp ('k') | Source/modules/modules.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698