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

Unified Diff: content/renderer/media/android/webmediasession_android_unittest.cc

Issue 1436243002: Add render-side manager for MediaSession (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moar tests Created 5 years, 1 month 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 | « content/renderer/media/android/webmediasession_android.cc ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/android/webmediasession_android_unittest.cc
diff --git a/content/renderer/media/android/webmediasession_android_unittest.cc b/content/renderer/media/android/webmediasession_android_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fb153f761d9cc4f5e82bc06cc5638c06a4727413
--- /dev/null
+++ b/content/renderer/media/android/webmediasession_android_unittest.cc
@@ -0,0 +1,86 @@
+// Copyright 2013 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 "content/renderer/media/android/webmediasession_android.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "content/renderer/media/android/renderer_media_session_manager.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace content {
+
+class WebMediaSessionTest : public testing::Test {
+ public:
+ bool SessionManagerHasSession(RendererMediaSessionManager* session_manager,
+ WebMediaSessionAndroid* session) {
+ for (auto& iter : session_manager->sessions_) {
+ if (iter.second == session)
+ return true;
+ }
+ return false;
+ }
+
+ bool IsSessionManagerEmpty(RendererMediaSessionManager* session_manager) {
+ return session_manager->sessions_.empty();
+ }
+};
+
+TEST_F(WebMediaSessionTest, TestRegistration) {
+ scoped_ptr<RendererMediaSessionManager> session_manager(
+ new RendererMediaSessionManager(nullptr));
+ EXPECT_TRUE(IsSessionManagerEmpty(session_manager.get()));
+ {
+ scoped_ptr<WebMediaSessionAndroid> session(
+ new WebMediaSessionAndroid(session_manager.get()));
+ EXPECT_TRUE(SessionManagerHasSession(session_manager.get(), session.get()));
+ }
+ EXPECT_TRUE(IsSessionManagerEmpty(session_manager.get()));
+}
+
+TEST_F(WebMediaSessionTest, TestMultipleRegistration) {
+ scoped_ptr<RendererMediaSessionManager> session_manager(
+ new RendererMediaSessionManager(nullptr));
+ EXPECT_TRUE(IsSessionManagerEmpty(session_manager.get()));
+
+ {
+ scoped_ptr<WebMediaSessionAndroid> session1(
+ new WebMediaSessionAndroid(session_manager.get()));
+ EXPECT_TRUE(
+ SessionManagerHasSession(session_manager.get(), session1.get()));
+
+ {
+ scoped_ptr<WebMediaSessionAndroid> session2(
+ new WebMediaSessionAndroid(session_manager.get()));
+ EXPECT_TRUE(
+ SessionManagerHasSession(session_manager.get(), session2.get()));
+ }
+
+ EXPECT_TRUE(
+ SessionManagerHasSession(session_manager.get(), session1.get()));
+ }
+
+ EXPECT_TRUE(IsSessionManagerEmpty(session_manager.get()));
+}
+
+TEST_F(WebMediaSessionTest, TestMultipleRegistrationOutOfOrder) {
+ scoped_ptr<RendererMediaSessionManager> session_manager(
+ new RendererMediaSessionManager(nullptr));
+ EXPECT_TRUE(IsSessionManagerEmpty(session_manager.get()));
+
+ WebMediaSessionAndroid* session1 =
+ new WebMediaSessionAndroid(session_manager.get());
+ EXPECT_TRUE(SessionManagerHasSession(session_manager.get(), session1));
+
+ WebMediaSessionAndroid* session2 =
+ new WebMediaSessionAndroid(session_manager.get());
+ EXPECT_TRUE(SessionManagerHasSession(session_manager.get(), session2));
+
+ delete session1;
+ EXPECT_TRUE(SessionManagerHasSession(session_manager.get(), session2));
+
+ delete session2;
+ EXPECT_TRUE(IsSessionManagerEmpty(session_manager.get()));
+}
+
+} // namespace content
« no previous file with comments | « content/renderer/media/android/webmediasession_android.cc ('k') | content/renderer/render_frame_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698