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

Side by Side Diff: media/blink/webmediaplayer_impl_unittest.cc

Issue 2369613003: Require WebLocalFrame to be created with a non-null client (Closed)
Patch Set: oops Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "media/blink/webmediaplayer_impl.h" 5 #include "media/blink/webmediaplayer_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
16 #include "base/memory/weak_ptr.h" 16 #include "base/memory/weak_ptr.h"
17 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
18 #include "base/run_loop.h" 18 #include "base/run_loop.h"
19 #include "base/threading/thread.h" 19 #include "base/threading/thread.h"
20 #include "base/threading/thread_task_runner_handle.h" 20 #include "base/threading/thread_task_runner_handle.h"
21 #include "media/base/media_log.h" 21 #include "media/base/media_log.h"
22 #include "media/base/media_switches.h" 22 #include "media/base/media_switches.h"
23 #include "media/base/test_helpers.h" 23 #include "media/base/test_helpers.h"
24 #include "media/blink/mock_webframeclient.h"
25 #include "media/blink/webmediaplayer_delegate.h" 24 #include "media/blink/webmediaplayer_delegate.h"
26 #include "media/blink/webmediaplayer_params.h" 25 #include "media/blink/webmediaplayer_params.h"
27 #include "media/renderers/default_renderer_factory.h" 26 #include "media/renderers/default_renderer_factory.h"
28 #include "testing/gmock/include/gmock/gmock.h" 27 #include "testing/gmock/include/gmock/gmock.h"
29 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
30 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" 29 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h"
31 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 30 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
32 #include "third_party/WebKit/public/platform/WebSize.h" 31 #include "third_party/WebKit/public/platform/WebSize.h"
33 #include "third_party/WebKit/public/web/WebFrameClient.h" 32 #include "third_party/WebKit/public/web/WebFrameClient.h"
34 #include "third_party/WebKit/public/web/WebLocalFrame.h" 33 #include "third_party/WebKit/public/web/WebLocalFrame.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 ~WebMediaPlayerImplTest() override { 144 ~WebMediaPlayerImplTest() override {
146 // Destruct WebMediaPlayerImpl and pump the message loop to ensure that 145 // Destruct WebMediaPlayerImpl and pump the message loop to ensure that
147 // objects passed to the message loop for destruction are released. 146 // objects passed to the message loop for destruction are released.
148 // 147 //
149 // NOTE: This should be done before any other member variables are 148 // NOTE: This should be done before any other member variables are
150 // destructed since WMPI may reference them during destruction. 149 // destructed since WMPI may reference them during destruction.
151 wmpi_.reset(); 150 wmpi_.reset();
152 base::RunLoop().RunUntilIdle(); 151 base::RunLoop().RunUntilIdle();
153 152
154 web_view_->close(); 153 web_view_->close();
155 web_local_frame_->close();
156 } 154 }
157 155
158 protected: 156 protected:
159 void SetReadyState(blink::WebMediaPlayer::ReadyState state) { 157 void SetReadyState(blink::WebMediaPlayer::ReadyState state) {
160 wmpi_->SetReadyState(state); 158 wmpi_->SetReadyState(state);
161 } 159 }
162 160
163 void SetPaused(bool is_paused) { wmpi_->paused_ = is_paused; } 161 void SetPaused(bool is_paused) { wmpi_->paused_ = is_paused; }
164 void SetSeeking(bool is_seeking) { wmpi_->seeking_ = is_seeking; } 162 void SetSeeking(bool is_seeking) { wmpi_->seeking_ = is_seeking; }
165 void SetEnded(bool is_ended) { wmpi_->ended_ = is_ended; } 163 void SetEnded(bool is_ended) { wmpi_->ended_ = is_ended; }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 234 }
237 235
238 // "Renderer" thread. 236 // "Renderer" thread.
239 base::MessageLoop message_loop_; 237 base::MessageLoop message_loop_;
240 238
241 // "Media" thread. This is necessary because WMPI destruction waits on a 239 // "Media" thread. This is necessary because WMPI destruction waits on a
242 // WaitableEvent. 240 // WaitableEvent.
243 base::Thread media_thread_; 241 base::Thread media_thread_;
244 242
245 // Blink state. 243 // Blink state.
246 MockWebFrameClient web_frame_client_; 244 blink::WebFrameClient web_frame_client_;
247 blink::WebView* web_view_; 245 blink::WebView* web_view_;
248 blink::WebLocalFrame* web_local_frame_; 246 blink::WebLocalFrame* web_local_frame_;
249 247
250 scoped_refptr<MediaLog> media_log_; 248 scoped_refptr<MediaLog> media_log_;
251 linked_ptr<media::UrlIndex> url_index_; 249 linked_ptr<media::UrlIndex> url_index_;
252 250
253 // Audio hardware configuration. 251 // Audio hardware configuration.
254 AudioParameters audio_parameters_; 252 AudioParameters audio_parameters_;
255 253
256 // The client interface used by |wmpi_|. Just a dummy for now, but later we 254 // The client interface used by |wmpi_|. Just a dummy for now, but later we
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 EXPECT_CALL(delegate_, IsPlayingBackgroundVideo()).WillOnce(Return(false)); 647 EXPECT_CALL(delegate_, IsPlayingBackgroundVideo()).WillOnce(Return(false));
650 EXPECT_CALL(delegate_, IsHidden()).WillRepeatedly(Return(true)); 648 EXPECT_CALL(delegate_, IsHidden()).WillRepeatedly(Return(true));
651 649
652 state = ComputeBackgroundedPlayState(); 650 state = ComputeBackgroundedPlayState();
653 EXPECT_EQ(WebMediaPlayerImpl::DelegateState::PAUSED, state.delegate_state); 651 EXPECT_EQ(WebMediaPlayerImpl::DelegateState::PAUSED, state.delegate_state);
654 EXPECT_FALSE(state.is_memory_reporting_enabled); 652 EXPECT_FALSE(state.is_memory_reporting_enabled);
655 EXPECT_TRUE(state.is_suspended); 653 EXPECT_TRUE(state.is_suspended);
656 } 654 }
657 655
658 } // namespace media 656 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698