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

Side by Side Diff: cc/nine_patch_layer_impl_unittest.cc

Issue 11472021: cc: Pass LayerTreeHostImpl to LayerImpl constructor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « cc/nine_patch_layer_impl.cc ('k') | cc/occlusion_tracker_unittest.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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include "cc/nine_patch_layer_impl.h" 7 #include "cc/nine_patch_layer_impl.h"
8 8
9 #include "cc/append_quads_data.h" 9 #include "cc/append_quads_data.h"
10 #include "cc/single_thread_proxy.h" 10 #include "cc/single_thread_proxy.h"
11 #include "cc/test/fake_impl_proxy.h"
12 #include "cc/test/fake_layer_tree_host_impl.h"
11 #include "cc/test/geometry_test_utils.h" 13 #include "cc/test/geometry_test_utils.h"
12 #include "cc/test/layer_test_common.h" 14 #include "cc/test/layer_test_common.h"
13 #include "cc/test/mock_quad_culler.h" 15 #include "cc/test/mock_quad_culler.h"
14 #include "cc/texture_draw_quad.h" 16 #include "cc/texture_draw_quad.h"
15 #include "ui/gfx/rect_conversions.h" 17 #include "ui/gfx/rect_conversions.h"
16 #include "ui/gfx/safe_integer_conversions.h" 18 #include "ui/gfx/safe_integer_conversions.h"
17 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
19 #include "ui/gfx/transform.h" 21 #include "ui/gfx/transform.h"
20 22
21 namespace cc { 23 namespace cc {
22 namespace { 24 namespace {
23 25
24 gfx::Rect ToRoundedIntRect(gfx::RectF rect_f) { 26 gfx::Rect ToRoundedIntRect(gfx::RectF rect_f) {
25 return gfx::Rect(gfx::ToRoundedInt(rect_f.x()), gfx::ToRoundedInt(rect_f.y() ), gfx::ToRoundedInt(rect_f.width()), gfx::ToRoundedInt(rect_f.height())); 27 return gfx::Rect(gfx::ToRoundedInt(rect_f.x()), gfx::ToRoundedInt(rect_f.y() ), gfx::ToRoundedInt(rect_f.width()), gfx::ToRoundedInt(rect_f.height()));
26 } 28 }
27 29
28 TEST(NinePatchLayerImplTest, verifyDrawQuads) 30 TEST(NinePatchLayerImplTest, verifyDrawQuads)
29 { 31 {
30 // Input is a 100x100 bitmap with a 40x50 aperture at x=20, y=30. 32 // Input is a 100x100 bitmap with a 40x50 aperture at x=20, y=30.
31 // The bounds of the layer are set to 400x400, so the draw quads 33 // The bounds of the layer are set to 400x400, so the draw quads
32 // generated should leave the border width (40) intact. 34 // generated should leave the border width (40) intact.
33 MockQuadCuller quadCuller; 35 MockQuadCuller quadCuller;
34 gfx::Size bitmapSize(100, 100); 36 gfx::Size bitmapSize(100, 100);
35 gfx::Size layerSize(400, 400); 37 gfx::Size layerSize(400, 400);
36 gfx::Rect visibleContentRect(gfx::Point(), layerSize); 38 gfx::Rect visibleContentRect(gfx::Point(), layerSize);
37 gfx::Rect apertureRect(20, 30, 40, 50); 39 gfx::Rect apertureRect(20, 30, 40, 50);
38 gfx::Rect scaledApertureNonUniform(20, 30, 340, 350); 40 gfx::Rect scaledApertureNonUniform(20, 30, 340, 350);
39 41
40 scoped_ptr<NinePatchLayerImpl> layer = NinePatchLayerImpl::create(1); 42 FakeImplProxy proxy;
43 FakeLayerTreeHostImpl hostImpl(&proxy);
44 scoped_ptr<NinePatchLayerImpl> layer = NinePatchLayerImpl::create(&hostImpl, 1);
41 layer->drawProperties().visible_content_rect = visibleContentRect; 45 layer->drawProperties().visible_content_rect = visibleContentRect;
42 layer->setBounds(layerSize); 46 layer->setBounds(layerSize);
43 layer->setContentBounds(layerSize); 47 layer->setContentBounds(layerSize);
44 layer->createRenderSurface(); 48 layer->createRenderSurface();
45 layer->drawProperties().render_target = layer.get(); 49 layer->drawProperties().render_target = layer.get();
46 layer->setLayout(bitmapSize, apertureRect); 50 layer->setLayout(bitmapSize, apertureRect);
47 layer->setResourceId(1); 51 layer->setResourceId(1);
48 52
49 // This scale should not affect the generated quad geometry, but only 53 // This scale should not affect the generated quad geometry, but only
50 // the shared draw transform. 54 // the shared draw transform.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 93
90 TEST(NinePatchLayerImplTest, verifyDrawQuadsForSqueezedLayer) 94 TEST(NinePatchLayerImplTest, verifyDrawQuadsForSqueezedLayer)
91 { 95 {
92 // Test with a layer much smaller than the bitmap. 96 // Test with a layer much smaller than the bitmap.
93 MockQuadCuller quadCuller; 97 MockQuadCuller quadCuller;
94 gfx::Size bitmapSize(101, 101); 98 gfx::Size bitmapSize(101, 101);
95 gfx::Size layerSize(51, 51); 99 gfx::Size layerSize(51, 51);
96 gfx::Rect visibleContentRect(gfx::Point(), layerSize); 100 gfx::Rect visibleContentRect(gfx::Point(), layerSize);
97 gfx::Rect apertureRect(20, 30, 40, 45); // rightWidth: 40, botHeight: 25 101 gfx::Rect apertureRect(20, 30, 40, 45); // rightWidth: 40, botHeight: 25
98 102
99 scoped_ptr<NinePatchLayerImpl> layer = NinePatchLayerImpl::create(1); 103 FakeImplProxy proxy;
104 FakeLayerTreeHostImpl hostImpl(&proxy);
105 scoped_ptr<NinePatchLayerImpl> layer = NinePatchLayerImpl::create(&hostImpl, 1);
100 layer->drawProperties().visible_content_rect = visibleContentRect; 106 layer->drawProperties().visible_content_rect = visibleContentRect;
101 layer->setBounds(layerSize); 107 layer->setBounds(layerSize);
102 layer->setContentBounds(layerSize); 108 layer->setContentBounds(layerSize);
103 layer->createRenderSurface(); 109 layer->createRenderSurface();
104 layer->drawProperties().render_target = layer.get(); 110 layer->drawProperties().render_target = layer.get();
105 layer->setLayout(bitmapSize, apertureRect); 111 layer->setLayout(bitmapSize, apertureRect);
106 layer->setResourceId(1); 112 layer->setResourceId(1);
107 113
108 AppendQuadsData data; 114 AppendQuadsData data;
109 layer->appendQuads(quadCuller, data); 115 layer->appendQuads(quadCuller, data);
(...skipping 26 matching lines...) Expand all
136 Region expectedRemainingRegion = Region(gfx::Rect(bitmapSize)); 142 Region expectedRemainingRegion = Region(gfx::Rect(bitmapSize));
137 expectedRemainingRegion.Subtract(gfx::Rect(0, 0, 17, 28)); 143 expectedRemainingRegion.Subtract(gfx::Rect(0, 0, 17, 28));
138 expectedRemainingRegion.Subtract(gfx::Rect(67, 0, 34, 28)); 144 expectedRemainingRegion.Subtract(gfx::Rect(67, 0, 34, 28));
139 expectedRemainingRegion.Subtract(gfx::Rect(0, 78, 17, 23)); 145 expectedRemainingRegion.Subtract(gfx::Rect(0, 78, 17, 23));
140 expectedRemainingRegion.Subtract(gfx::Rect(67, 78, 34, 23)); 146 expectedRemainingRegion.Subtract(gfx::Rect(67, 78, 34, 23));
141 EXPECT_EQ(expectedRemainingRegion, texRemaining); 147 EXPECT_EQ(expectedRemainingRegion, texRemaining);
142 } 148 }
143 149
144 } // namespace 150 } // namespace
145 } // namespace cc 151 } // namespace cc
OLDNEW
« no previous file with comments | « cc/nine_patch_layer_impl.cc ('k') | cc/occlusion_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698