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

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

Issue 1370453002: Introduce WebMediaSession (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add virtual default destructor Created 5 years, 2 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: third_party/WebKit/Source/modules/mediasession/MediaSessionTest.cpp
diff --git a/third_party/WebKit/Source/modules/mediasession/MediaSessionTest.cpp b/third_party/WebKit/Source/modules/mediasession/MediaSessionTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..215dadbd7affa8bd64f5f37f56192f9b4d61b7ec
--- /dev/null
+++ b/third_party/WebKit/Source/modules/mediasession/MediaSessionTest.cpp
@@ -0,0 +1,66 @@
+// 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 {
+
+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 new MediaSession(adoptPtr(webMediaSession));
+ }
+
+ Document& document() { return m_page->document(); }
+ ScriptState* mainScriptState() { return ScriptState::forMainWorld(document().frame()); }
+private:
+ OwnPtr<DummyPageHolder> m_page;
+};
+
+namespace {
+
+class MockWebMediaSession : public WebMediaSession {
+public:
+ MOCK_METHOD1(activate, void(WebMediaSessionActivateCallback*));
+ MOCK_METHOD1(deactivate, void(WebMediaSessionDeactivateCallback*));
+};
+
+TEST_F(MediaSessionTest, Activate)
+{
+ ScriptState::Scope scope(mainScriptState());
+ MockWebMediaSession* mockWebMediaSession = new MockWebMediaSession;
+ MediaSession* mediaSession = createMediaSession(mockWebMediaSession);
+
+ EXPECT_CALL(*mockWebMediaSession, activate(_));
+ mediaSession->activate(mainScriptState());
+}
+
+TEST_F(MediaSessionTest, Deactivate)
+{
+ ScriptState::Scope scope(mainScriptState());
+ MockWebMediaSession* mockWebMediaSession = new MockWebMediaSession;
+ MediaSession* mediaSession = createMediaSession(mockWebMediaSession);
+
+ EXPECT_CALL(*mockWebMediaSession, deactivate(_));
+ mediaSession->deactivate(mainScriptState());
+}
+
+} // namespace
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/mediasession/MediaSessionError.cpp ('k') | third_party/WebKit/Source/modules/modules.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698