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

Unified Diff: cc/layers/video_layer_impl_unittest.cc

Issue 1033563002: cc: Various code safety improvements in video compositing code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: cc/layers/video_layer_impl_unittest.cc
diff --git a/cc/layers/video_layer_impl_unittest.cc b/cc/layers/video_layer_impl_unittest.cc
index 2fde4957c267d1a9a4dee67f982210f81b7e9f71..6abb1ccf6b2296b4526d3c087c441b9cffa5fd68 100644
--- a/cc/layers/video_layer_impl_unittest.cc
+++ b/cc/layers/video_layer_impl_unittest.cc
@@ -17,12 +17,26 @@
namespace cc {
namespace {
-TEST(VideoLayerImplTest, Occlusion) {
- gfx::Size layer_size(1000, 1000);
- gfx::Size viewport_size(1000, 1000);
+// We can't use DebugScopedSetImplThreadAndMainThreadBlocked for these tests
danakj 2015/03/24 17:38:01 What if you SetRootLayer(nullptr) before exiting t
sunnyps 2015/03/24 19:43:38 I didn't use SetRootLayer(nullptr) but changed thi
+// because it gets destroyed before the layer tree. VideoLayerImpl triggers a
+// DCHECK in it's destructor that checks if we're on impl thread and main thread
+// is blocked.
+class VideoLayerImplTest : public testing::Test {
+ public:
+ VideoLayerImplTest() {
+#if DCHECK_IS_ON()
+ impl.proxy()->SetCurrentThreadIsImplThread(true);
+ impl.proxy()->SetMainThreadBlocked(true);
+#endif
+ }
+ protected:
LayerTestCommon::LayerImplTest impl;
- DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
+};
+
+TEST_F(VideoLayerImplTest, Occlusion) {
+ gfx::Size layer_size(1000, 1000);
+ gfx::Size viewport_size(1000, 1000);
scoped_refptr<media::VideoFrame> video_frame =
media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
@@ -74,10 +88,7 @@ TEST(VideoLayerImplTest, Occlusion) {
}
}
-TEST(VideoLayerImplTest, DidBecomeActiveShouldSetActiveVideoLayer) {
- LayerTestCommon::LayerImplTest impl;
- DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
-
+TEST_F(VideoLayerImplTest, DidBecomeActiveShouldStartProviderClient) {
FakeVideoFrameProvider provider;
VideoLayerImpl* video_layer_impl =
impl.AddChildToRoot<VideoLayerImpl>(&provider, media::VIDEO_ROTATION_0);
@@ -85,19 +96,16 @@ TEST(VideoLayerImplTest, DidBecomeActiveShouldSetActiveVideoLayer) {
VideoFrameProviderClientImpl* client =
static_cast<VideoFrameProviderClientImpl*>(provider.client());
ASSERT_TRUE(client);
- EXPECT_FALSE(client->active_video_layer());
+ EXPECT_FALSE(client->Started());
video_layer_impl->DidBecomeActive();
- EXPECT_EQ(video_layer_impl, client->active_video_layer());
+ EXPECT_TRUE(client->Started());
}
-TEST(VideoLayerImplTest, Rotated0) {
+TEST_F(VideoLayerImplTest, Rotated0) {
gfx::Size layer_size(100, 50);
gfx::Size viewport_size(1000, 500);
- LayerTestCommon::LayerImplTest impl;
- DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
-
scoped_refptr<media::VideoFrame> video_frame =
media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
gfx::Size(20, 10),
@@ -127,13 +135,10 @@ TEST(VideoLayerImplTest, Rotated0) {
EXPECT_EQ(gfx::Point3F(100, 0, 0), p2);
}
-TEST(VideoLayerImplTest, Rotated90) {
+TEST_F(VideoLayerImplTest, Rotated90) {
gfx::Size layer_size(100, 50);
gfx::Size viewport_size(1000, 500);
- LayerTestCommon::LayerImplTest impl;
- DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
-
scoped_refptr<media::VideoFrame> video_frame =
media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
gfx::Size(20, 10),
@@ -163,13 +168,10 @@ TEST(VideoLayerImplTest, Rotated90) {
EXPECT_EQ(gfx::Point3F(100, 50, 0), p2);
}
-TEST(VideoLayerImplTest, Rotated180) {
+TEST_F(VideoLayerImplTest, Rotated180) {
gfx::Size layer_size(100, 50);
gfx::Size viewport_size(1000, 500);
- LayerTestCommon::LayerImplTest impl;
- DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
-
scoped_refptr<media::VideoFrame> video_frame =
media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
gfx::Size(20, 10),
@@ -199,13 +201,10 @@ TEST(VideoLayerImplTest, Rotated180) {
EXPECT_EQ(gfx::Point3F(0, 50, 0), p2);
}
-TEST(VideoLayerImplTest, Rotated270) {
+TEST_F(VideoLayerImplTest, Rotated270) {
gfx::Size layer_size(100, 50);
gfx::Size viewport_size(1000, 500);
- LayerTestCommon::LayerImplTest impl;
- DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
-
scoped_refptr<media::VideoFrame> video_frame =
media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
gfx::Size(20, 10),

Powered by Google App Engine
This is Rietveld 408576698