| 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 "cc/layers/video_frame_provider_client_impl.h" | 5 #include "cc/layers/video_frame_provider_client_impl.h" |
| 6 #include "cc/layers/video_layer_impl.h" | 6 #include "cc/layers/video_layer_impl.h" |
| 7 #include "cc/output/begin_frame_args.h" | 7 #include "cc/output/begin_frame_args.h" |
| 8 #include "cc/test/fake_video_frame_provider.h" | 8 #include "cc/test/fake_video_frame_provider.h" |
| 9 #include "cc/test/layer_test_common.h" | 9 #include "cc/test/layer_test_common.h" |
| 10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 using testing::_; | 14 using testing::_; |
| 15 | 15 |
| 16 namespace cc { | 16 namespace cc { |
| 17 | 17 |
| 18 // NOTE: We cannot use DebugScopedSetImplThreadAndMainThreadBlocked in these | 18 // NOTE: We cannot use DebugScopedSetImplThreadAndMainThreadBlocked in these |
| 19 // tests because it gets destroyed before the VideoLayerImpl is destroyed. This | 19 // tests because it gets destroyed before the VideoLayerImpl is destroyed. This |
| 20 // causes a DCHECK in VideoLayerImpl's destructor to fail. | 20 // causes a DCHECK in VideoLayerImpl's destructor to fail. |
| 21 static void DebugSetImplThreadAndMainThreadBlocked(Proxy* proxy) { | 21 static void DebugSetImplThreadAndMainThreadBlocked( |
| 22 TaskRunnerProvider* task_runner_provider) { |
| 22 #if DCHECK_IS_ON() | 23 #if DCHECK_IS_ON() |
| 23 proxy->SetCurrentThreadIsImplThread(true); | 24 task_runner_provider->SetCurrentThreadIsImplThread(true); |
| 24 proxy->SetMainThreadBlocked(true); | 25 task_runner_provider->SetMainThreadBlocked(true); |
| 25 #endif | 26 #endif |
| 26 } | 27 } |
| 27 | 28 |
| 28 class VideoFrameProviderClientImplTest : public testing::Test, | 29 class VideoFrameProviderClientImplTest : public testing::Test, |
| 29 public VideoFrameControllerClient { | 30 public VideoFrameControllerClient { |
| 30 public: | 31 public: |
| 31 VideoFrameProviderClientImplTest() | 32 VideoFrameProviderClientImplTest() |
| 32 : client_impl_(VideoFrameProviderClientImpl::Create(&provider_, this)), | 33 : client_impl_(VideoFrameProviderClientImpl::Create(&provider_, this)), |
| 33 video_layer_impl_(nullptr), | 34 video_layer_impl_(nullptr), |
| 34 test_frame_(media::VideoFrame::CreateFrame(media::PIXEL_FORMAT_YV12, | 35 test_frame_(media::VideoFrame::CreateFrame(media::PIXEL_FORMAT_YV12, |
| 35 gfx::Size(10, 10), | 36 gfx::Size(10, 10), |
| 36 gfx::Rect(10, 10), | 37 gfx::Rect(10, 10), |
| 37 gfx::Size(10, 10), | 38 gfx::Size(10, 10), |
| 38 base::TimeDelta())) { | 39 base::TimeDelta())) { |
| 39 DebugSetImplThreadAndMainThreadBlocked(impl_.proxy()); | 40 DebugSetImplThreadAndMainThreadBlocked(impl_.task_runner_provider()); |
| 40 } | 41 } |
| 41 | 42 |
| 42 ~VideoFrameProviderClientImplTest() { | 43 ~VideoFrameProviderClientImplTest() { |
| 43 if (!client_impl_->Stopped()) { | 44 if (!client_impl_->Stopped()) { |
| 44 client_impl_->Stop(); | 45 client_impl_->Stop(); |
| 45 DCHECK(client_impl_->Stopped()); | 46 DCHECK(client_impl_->Stopped()); |
| 46 DCHECK(!client_impl_->ActiveVideoLayer()); | 47 DCHECK(!client_impl_->ActiveVideoLayer()); |
| 47 } | 48 } |
| 48 | 49 |
| 49 provider_.SetVideoFrameProviderClient(nullptr); | 50 provider_.SetVideoFrameProviderClient(nullptr); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 0.0, | 158 0.0, |
| 158 1.0, | 159 1.0, |
| 159 }; | 160 }; |
| 160 | 161 |
| 161 EXPECT_FALSE(client_impl_->StreamTextureMatrix().IsIdentity()); | 162 EXPECT_FALSE(client_impl_->StreamTextureMatrix().IsIdentity()); |
| 162 client_impl_->DidUpdateMatrix(kIdentityMatrix); | 163 client_impl_->DidUpdateMatrix(kIdentityMatrix); |
| 163 EXPECT_TRUE(client_impl_->StreamTextureMatrix().IsIdentity()); | 164 EXPECT_TRUE(client_impl_->StreamTextureMatrix().IsIdentity()); |
| 164 } | 165 } |
| 165 | 166 |
| 166 } // namespace cc | 167 } // namespace cc |
| OLD | NEW |