Abstract GoogleURLTracker & google_util Profile dependencies
[chromium-blink-merge.git] / cc / layers / video_layer_impl_unittest.cc
blob68a2b2ee217b24150d4643ca74f6c011ca602973
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/layers/video_layer_impl.h"
7 #include "cc/layers/video_frame_provider_client_impl.h"
8 #include "cc/output/context_provider.h"
9 #include "cc/output/output_surface.h"
10 #include "cc/test/fake_video_frame_provider.h"
11 #include "cc/test/layer_test_common.h"
12 #include "cc/trees/single_thread_proxy.h"
13 #include "media/base/video_frame.h"
14 #include "testing/gtest/include/gtest/gtest.h"
16 namespace cc {
17 namespace {
19 TEST(VideoLayerImplTest, Occlusion) {
20 gfx::Size layer_size(1000, 1000);
21 gfx::Size viewport_size(1000, 1000);
23 LayerTestCommon::LayerImplTest impl;
24 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
26 scoped_refptr<media::VideoFrame> video_frame =
27 media::VideoFrame::CreateFrame(media::VideoFrame::YV12,
28 gfx::Size(10, 10),
29 gfx::Rect(10, 10),
30 gfx::Size(10, 10),
31 base::TimeDelta());
32 FakeVideoFrameProvider provider;
33 provider.set_frame(video_frame);
35 VideoLayerImpl* video_layer_impl =
36 impl.AddChildToRoot<VideoLayerImpl>(&provider);
37 video_layer_impl->SetAnchorPoint(gfx::PointF());
38 video_layer_impl->SetBounds(layer_size);
39 video_layer_impl->SetContentBounds(layer_size);
40 video_layer_impl->SetDrawsContent(true);
42 impl.CalcDrawProps(viewport_size);
45 SCOPED_TRACE("No occlusion");
46 gfx::Rect occluded;
47 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded);
49 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(),
50 gfx::Rect(layer_size));
51 EXPECT_EQ(1u, impl.quad_list().size());
55 SCOPED_TRACE("Full occlusion");
56 gfx::Rect occluded(video_layer_impl->visible_content_rect());
57 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded);
59 LayerTestCommon::VerifyQuadsExactlyCoverRect(impl.quad_list(), gfx::Rect());
60 EXPECT_EQ(impl.quad_list().size(), 0u);
64 SCOPED_TRACE("Partial occlusion");
65 gfx::Rect occluded(200, 0, 800, 1000);
66 impl.AppendQuadsWithOcclusion(video_layer_impl, occluded);
68 size_t partially_occluded_count = 0;
69 LayerTestCommon::VerifyQuadsCoverRectWithOcclusion(
70 impl.quad_list(),
71 gfx::Rect(layer_size),
72 occluded,
73 &partially_occluded_count);
74 // The layer outputs one quad, which is partially occluded.
75 EXPECT_EQ(1u, impl.quad_list().size());
76 EXPECT_EQ(1u, partially_occluded_count);
80 TEST(VideoLayerImplTest, DidBecomeActiveShouldSetActiveVideoLayer) {
81 LayerTestCommon::LayerImplTest impl;
82 DebugScopedSetImplThreadAndMainThreadBlocked thread(impl.proxy());
84 FakeVideoFrameProvider provider;
85 VideoLayerImpl* video_layer_impl =
86 impl.AddChildToRoot<VideoLayerImpl>(&provider);
88 VideoFrameProviderClientImpl* client =
89 static_cast<VideoFrameProviderClientImpl*>(provider.client());
90 ASSERT_TRUE(client);
91 EXPECT_FALSE(client->active_video_layer());
93 video_layer_impl->DidBecomeActive();
94 EXPECT_EQ(video_layer_impl, client->active_video_layer());
97 } // namespace
98 } // namespace cc