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

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

Issue 2205173002: Merge to M53: Account for video rotation in OnVideoNaturalSizeChange() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 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
« no previous file with comments | « media/blink/webmediaplayer_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/message_loop/message_loop.h" 16 #include "base/message_loop/message_loop.h"
17 #include "base/run_loop.h" 17 #include "base/run_loop.h"
18 #include "base/threading/thread.h" 18 #include "base/threading/thread.h"
19 #include "base/threading/thread_task_runner_handle.h" 19 #include "base/threading/thread_task_runner_handle.h"
20 #include "media/base/media_log.h" 20 #include "media/base/media_log.h"
21 #include "media/base/test_helpers.h" 21 #include "media/base/test_helpers.h"
22 #include "media/blink/mock_webframeclient.h" 22 #include "media/blink/mock_webframeclient.h"
23 #include "media/blink/webmediaplayer_delegate.h" 23 #include "media/blink/webmediaplayer_delegate.h"
24 #include "media/blink/webmediaplayer_params.h" 24 #include "media/blink/webmediaplayer_params.h"
25 #include "media/renderers/default_renderer_factory.h" 25 #include "media/renderers/default_renderer_factory.h"
26 #include "testing/gmock/include/gmock/gmock.h" 26 #include "testing/gmock/include/gmock/gmock.h"
27 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
28 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" 28 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h"
29 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 29 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
30 #include "third_party/WebKit/public/platform/WebSize.h"
30 #include "third_party/WebKit/public/web/WebFrameClient.h" 31 #include "third_party/WebKit/public/web/WebFrameClient.h"
31 #include "third_party/WebKit/public/web/WebLocalFrame.h" 32 #include "third_party/WebKit/public/web/WebLocalFrame.h"
32 #include "third_party/WebKit/public/web/WebView.h" 33 #include "third_party/WebKit/public/web/WebView.h"
33 #include "url/gurl.h" 34 #include "url/gurl.h"
34 35
35 namespace media { 36 namespace media {
36 37
37 int64_t OnAdjustAllocatedMemory(int64_t delta) { 38 int64_t OnAdjustAllocatedMemory(int64_t delta) {
38 return 0; 39 return 0;
39 } 40 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 void SetEnded(bool is_ended) { wmpi_->ended_ = is_ended; } 135 void SetEnded(bool is_ended) { wmpi_->ended_ = is_ended; }
135 void SetFullscreen(bool is_fullscreen) { wmpi_->fullscreen_ = is_fullscreen; } 136 void SetFullscreen(bool is_fullscreen) { wmpi_->fullscreen_ = is_fullscreen; }
136 137
137 void SetMetadata(bool has_audio, bool has_video) { 138 void SetMetadata(bool has_audio, bool has_video) {
138 wmpi_->SetNetworkState(blink::WebMediaPlayer::NetworkStateLoaded); 139 wmpi_->SetNetworkState(blink::WebMediaPlayer::NetworkStateLoaded);
139 wmpi_->SetReadyState(blink::WebMediaPlayer::ReadyStateHaveMetadata); 140 wmpi_->SetReadyState(blink::WebMediaPlayer::ReadyStateHaveMetadata);
140 wmpi_->pipeline_metadata_.has_audio = has_audio; 141 wmpi_->pipeline_metadata_.has_audio = has_audio;
141 wmpi_->pipeline_metadata_.has_video = has_video; 142 wmpi_->pipeline_metadata_.has_video = has_video;
142 } 143 }
143 144
145 void OnMetadata(PipelineMetadata metadata) { wmpi_->OnMetadata(metadata); }
146
147 void OnVideoNaturalSizeChange(const gfx::Size& size) {
148 wmpi_->OnVideoNaturalSizeChange(size);
149 }
150
144 WebMediaPlayerImpl::PlayState ComputePlayState() { 151 WebMediaPlayerImpl::PlayState ComputePlayState() {
145 wmpi_->is_idle_ = false; 152 wmpi_->is_idle_ = false;
146 wmpi_->must_suspend_ = false; 153 wmpi_->must_suspend_ = false;
147 return wmpi_->UpdatePlayState_ComputePlayState(false, false, false); 154 return wmpi_->UpdatePlayState_ComputePlayState(false, false, false);
148 } 155 }
149 156
150 WebMediaPlayerImpl::PlayState ComputePlayStateSuspended() { 157 WebMediaPlayerImpl::PlayState ComputePlayStateSuspended() {
151 wmpi_->is_idle_ = false; 158 wmpi_->is_idle_ = false;
152 wmpi_->must_suspend_ = false; 159 wmpi_->must_suspend_ = false;
153 return wmpi_->UpdatePlayState_ComputePlayState(false, true, false); 160 return wmpi_->UpdatePlayState_ComputePlayState(false, true, false);
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 EXPECT_FALSE(state.is_memory_reporting_enabled); 438 EXPECT_FALSE(state.is_memory_reporting_enabled);
432 EXPECT_FALSE(state.is_suspended); 439 EXPECT_FALSE(state.is_suspended);
433 440
434 SetPaused(false); 441 SetPaused(false);
435 state = ComputePlayStateSuspended(); 442 state = ComputePlayStateSuspended();
436 EXPECT_EQ(WebMediaPlayerImpl::DelegateState::PLAYING, state.delegate_state); 443 EXPECT_EQ(WebMediaPlayerImpl::DelegateState::PLAYING, state.delegate_state);
437 EXPECT_TRUE(state.is_memory_reporting_enabled); 444 EXPECT_TRUE(state.is_memory_reporting_enabled);
438 EXPECT_FALSE(state.is_suspended); 445 EXPECT_FALSE(state.is_suspended);
439 } 446 }
440 447
448 TEST_F(WebMediaPlayerImplTest, NaturalSizeChange) {
449 PipelineMetadata metadata;
450 metadata.has_video = true;
451 metadata.natural_size = gfx::Size(320, 240);
452
453 OnMetadata(metadata);
454 ASSERT_EQ(blink::WebSize(320, 240), wmpi_->naturalSize());
455
456 // TODO(sandersd): Verify that the client is notified of the size change?
457 OnVideoNaturalSizeChange(gfx::Size(1920, 1080));
458 ASSERT_EQ(blink::WebSize(1920, 1080), wmpi_->naturalSize());
459 }
460
461 TEST_F(WebMediaPlayerImplTest, NaturalSizeChange_Rotated) {
462 PipelineMetadata metadata;
463 metadata.has_video = true;
464 metadata.natural_size = gfx::Size(320, 240);
465 metadata.video_rotation = VIDEO_ROTATION_90;
466
467 // For 90/270deg rotations, the natural size should be transposed.
468 OnMetadata(metadata);
469 ASSERT_EQ(blink::WebSize(240, 320), wmpi_->naturalSize());
470
471 OnVideoNaturalSizeChange(gfx::Size(1920, 1080));
472 ASSERT_EQ(blink::WebSize(1080, 1920), wmpi_->naturalSize());
473 }
474
441 } // namespace media 475 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698