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

Side by Side Diff: cc/layers/ui_resource_layer_impl_unittest.cc

Issue 1062043003: cc: Add ResourceId validation checks at the time of AppendQuads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resource-validate: fixtests Created 5 years, 8 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 | « cc/layers/ui_resource_layer_impl.cc ('k') | cc/layers/video_layer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/append_quads_data.h" 5 #include "cc/layers/append_quads_data.h"
6 #include "cc/layers/ui_resource_layer_impl.h" 6 #include "cc/layers/ui_resource_layer_impl.h"
7 #include "cc/quads/draw_quad.h" 7 #include "cc/quads/draw_quad.h"
8 #include "cc/resources/ui_resource_bitmap.h" 8 #include "cc/resources/ui_resource_bitmap.h"
9 #include "cc/resources/ui_resource_client.h" 9 #include "cc/resources/ui_resource_client.h"
10 #include "cc/test/fake_impl_proxy.h" 10 #include "cc/test/fake_impl_proxy.h"
11 #include "cc/test/fake_layer_tree_host_impl.h" 11 #include "cc/test/fake_layer_tree_host_impl.h"
12 #include "cc/test/fake_output_surface.h"
12 #include "cc/test/fake_ui_resource_layer_tree_host_impl.h" 13 #include "cc/test/fake_ui_resource_layer_tree_host_impl.h"
13 #include "cc/test/layer_test_common.h" 14 #include "cc/test/layer_test_common.h"
14 #include "cc/test/test_shared_bitmap_manager.h" 15 #include "cc/test/test_shared_bitmap_manager.h"
15 #include "cc/trees/single_thread_proxy.h" 16 #include "cc/trees/single_thread_proxy.h"
16 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "ui/gfx/transform.h" 19 #include "ui/gfx/transform.h"
19 20
20 namespace cc { 21 namespace cc {
21 namespace { 22 namespace {
(...skipping 30 matching lines...) Expand all
52 53
53 // Verify quad rects 54 // Verify quad rects
54 const QuadList& quads = render_pass->quad_list; 55 const QuadList& quads = render_pass->quad_list;
55 EXPECT_EQ(expected_quad_size, quads.size()); 56 EXPECT_EQ(expected_quad_size, quads.size());
56 } 57 }
57 58
58 TEST(UIResourceLayerImplTest, VerifyDrawQuads) { 59 TEST(UIResourceLayerImplTest, VerifyDrawQuads) {
59 FakeImplProxy proxy; 60 FakeImplProxy proxy;
60 TestSharedBitmapManager shared_bitmap_manager; 61 TestSharedBitmapManager shared_bitmap_manager;
61 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); 62 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
63 host_impl.InitializeRenderer(FakeOutputSurface::Create3d());
64
62 // Make sure we're appending quads when there are valid values. 65 // Make sure we're appending quads when there are valid values.
63 gfx::Size bitmap_size(100, 100); 66 gfx::Size bitmap_size(100, 100);
64 gfx::Size layer_size(100, 100);; 67 gfx::Size layer_size(100, 100);;
65 size_t expected_quad_size = 1; 68 size_t expected_quad_size = 1;
66 bool opaque = true; 69 bool opaque = true;
67 UIResourceId uid = 1; 70 UIResourceId uid = 1;
68 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer(&host_impl, 71 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer(&host_impl,
69 bitmap_size, 72 bitmap_size,
70 layer_size, 73 layer_size,
71 opaque, 74 opaque,
(...skipping 22 matching lines...) Expand all
94 const QuadList& quads = render_pass->quad_list; 97 const QuadList& quads = render_pass->quad_list;
95 EXPECT_GE(quads.size(), (size_t)0); 98 EXPECT_GE(quads.size(), (size_t)0);
96 gfx::Rect opaque_rect = quads.front()->opaque_rect; 99 gfx::Rect opaque_rect = quads.front()->opaque_rect;
97 EXPECT_EQ(expected_opaque_bounds, opaque_rect); 100 EXPECT_EQ(expected_opaque_bounds, opaque_rect);
98 } 101 }
99 102
100 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnSkBitmap) { 103 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnSkBitmap) {
101 FakeImplProxy proxy; 104 FakeImplProxy proxy;
102 TestSharedBitmapManager shared_bitmap_manager; 105 TestSharedBitmapManager shared_bitmap_manager;
103 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); 106 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
107 host_impl.InitializeRenderer(FakeOutputSurface::Create3d());
104 108
105 gfx::Size bitmap_size(100, 100); 109 gfx::Size bitmap_size(100, 100);
106 gfx::Size layer_size(100, 100);; 110 gfx::Size layer_size(100, 100);;
107 bool opaque = false; 111 bool opaque = false;
108 UIResourceId uid = 1; 112 UIResourceId uid = 1;
109 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer(&host_impl, 113 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer(&host_impl,
110 bitmap_size, 114 bitmap_size,
111 layer_size, 115 layer_size,
112 opaque, 116 opaque,
113 uid); 117 uid);
114 gfx::Rect expected_opaque_bounds; 118 gfx::Rect expected_opaque_bounds;
115 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); 119 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds);
116 120
117 opaque = true; 121 opaque = true;
118 layer = GenerateUIResourceLayer(&host_impl, 122 layer = GenerateUIResourceLayer(&host_impl,
119 bitmap_size, 123 bitmap_size,
120 layer_size, 124 layer_size,
121 opaque, 125 opaque,
122 uid); 126 uid);
123 expected_opaque_bounds = gfx::Rect(layer->bounds()); 127 expected_opaque_bounds = gfx::Rect(layer->bounds());
124 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); 128 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds);
125 } 129 }
126 130
127 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnLayer) { 131 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnLayer) {
128 FakeImplProxy proxy; 132 FakeImplProxy proxy;
129 TestSharedBitmapManager shared_bitmap_manager; 133 TestSharedBitmapManager shared_bitmap_manager;
130 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); 134 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
135 host_impl.InitializeRenderer(FakeOutputSurface::Create3d());
131 136
132 gfx::Size bitmap_size(100, 100); 137 gfx::Size bitmap_size(100, 100);
133 gfx::Size layer_size(100, 100); 138 gfx::Size layer_size(100, 100);
134 bool skbitmap_opaque = false; 139 bool skbitmap_opaque = false;
135 UIResourceId uid = 1; 140 UIResourceId uid = 1;
136 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer( 141 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer(
137 &host_impl, bitmap_size, layer_size, skbitmap_opaque, uid); 142 &host_impl, bitmap_size, layer_size, skbitmap_opaque, uid);
138 layer->SetContentsOpaque(false); 143 layer->SetContentsOpaque(false);
139 gfx::Rect expected_opaque_bounds; 144 gfx::Rect expected_opaque_bounds;
140 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); 145 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 LayerTestCommon::VerifyQuadsAreOccluded( 201 LayerTestCommon::VerifyQuadsAreOccluded(
197 impl.quad_list(), occluded, &partially_occluded_count); 202 impl.quad_list(), occluded, &partially_occluded_count);
198 // The layer outputs one quad, which is partially occluded. 203 // The layer outputs one quad, which is partially occluded.
199 EXPECT_EQ(1u, impl.quad_list().size()); 204 EXPECT_EQ(1u, impl.quad_list().size());
200 EXPECT_EQ(1u, partially_occluded_count); 205 EXPECT_EQ(1u, partially_occluded_count);
201 } 206 }
202 } 207 }
203 208
204 } // namespace 209 } // namespace
205 } // namespace cc 210 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/ui_resource_layer_impl.cc ('k') | cc/layers/video_layer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698