OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/mediasession/MediaSession.h" | 5 #include "modules/mediasession/MediaSession.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/testing/DummyPageHolder.h" | 8 #include "core/testing/DummyPageHolder.h" |
9 #include "modules/mediasession/MediaMetadata.h" | 9 #include "modules/mediasession/MediaMetadata.h" |
10 #include "modules/mediasession/MediaMetadataInit.h" | 10 #include "modules/mediasession/MediaMetadataInit.h" |
11 #include "public/platform/modules/mediasession/WebMediaSession.h" | 11 #include "public/platform/modules/mediasession/WebMediaSession.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "wtf/PtrUtil.h" |
| 15 #include <memory> |
14 | 16 |
15 using ::testing::_; | 17 using ::testing::_; |
16 using ::testing::Invoke; | 18 using ::testing::Invoke; |
17 | 19 |
18 namespace blink { | 20 namespace blink { |
19 | 21 |
20 class MediaSessionTest : public ::testing::Test { | 22 class MediaSessionTest : public ::testing::Test { |
21 protected: | 23 protected: |
22 MediaSessionTest() | 24 MediaSessionTest() |
23 : m_page(DummyPageHolder::create(IntSize(1, 1))) | 25 : m_page(DummyPageHolder::create(IntSize(1, 1))) |
24 {} | 26 {} |
25 | 27 |
26 MediaSession* createMediaSession(WebMediaSession* webMediaSession) | 28 MediaSession* createMediaSession(WebMediaSession* webMediaSession) |
27 { | 29 { |
28 // The MediaSession takes ownership of the WebMediaSession, and the | 30 // The MediaSession takes ownership of the WebMediaSession, and the |
29 // caller must take care to not end up with a stale pointer. | 31 // caller must take care to not end up with a stale pointer. |
30 return new MediaSession(adoptPtr(webMediaSession)); | 32 return new MediaSession(wrapUnique(webMediaSession)); |
31 } | 33 } |
32 | 34 |
33 Document& document() { return m_page->document(); } | 35 Document& document() { return m_page->document(); } |
34 ScriptState* mainScriptState() { return ScriptState::forMainWorld(document()
.frame()); } | 36 ScriptState* mainScriptState() { return ScriptState::forMainWorld(document()
.frame()); } |
35 private: | 37 private: |
36 OwnPtr<DummyPageHolder> m_page; | 38 std::unique_ptr<DummyPageHolder> m_page; |
37 }; | 39 }; |
38 | 40 |
39 namespace { | 41 namespace { |
40 | 42 |
41 class MockWebMediaSession : public WebMediaSession { | 43 class MockWebMediaSession : public WebMediaSession { |
42 public: | 44 public: |
43 MOCK_METHOD1(activate, void(WebMediaSessionActivateCallback*)); | 45 MOCK_METHOD1(activate, void(WebMediaSessionActivateCallback*)); |
44 MOCK_METHOD1(deactivate, void(WebMediaSessionDeactivateCallback*)); | 46 MOCK_METHOD1(deactivate, void(WebMediaSessionDeactivateCallback*)); |
45 MOCK_METHOD1(setMetadata, void(const WebMediaMetadata*)); | 47 MOCK_METHOD1(setMetadata, void(const WebMediaMetadata*)); |
46 }; | 48 }; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 MediaSession* mediaSession = createMediaSession(mockWebMediaSession); | 92 MediaSession* mediaSession = createMediaSession(mockWebMediaSession); |
91 | 93 |
92 EXPECT_CALL(*mockWebMediaSession, setMetadata(testing::NotNull())); | 94 EXPECT_CALL(*mockWebMediaSession, setMetadata(testing::NotNull())); |
93 mediaSession->setMetadata(MediaMetadata::create(&document(), MediaMetadataIn
it())); | 95 mediaSession->setMetadata(MediaMetadata::create(&document(), MediaMetadataIn
it())); |
94 | 96 |
95 EXPECT_NE(nullptr, mediaSession->metadata()); | 97 EXPECT_NE(nullptr, mediaSession->metadata()); |
96 } | 98 } |
97 | 99 |
98 } // namespace | 100 } // namespace |
99 } // namespace blink | 101 } // namespace blink |
OLD | NEW |