OLD | NEW |
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 "cc/resources/picture_layer_tiling.h" | 5 #include "cc/resources/picture_layer_tiling.h" |
6 | 6 |
7 #include "cc/test/fake_picture_layer_tiling_client.h" | 7 #include "cc/test/fake_picture_layer_tiling_client.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "ui/gfx/rect_conversions.h" | 9 #include "ui/gfx/rect_conversions.h" |
10 #include "ui/gfx/size_conversions.h" | 10 #include "ui/gfx/size_conversions.h" |
11 | 11 |
12 namespace cc { | 12 namespace cc { |
13 namespace { | 13 namespace { |
14 | 14 |
15 class PictureLayerTilingIteratorTest : public testing::Test { | 15 class PictureLayerTilingIteratorTest : public testing::Test { |
16 public: | 16 public: |
17 PictureLayerTilingIteratorTest() {} | 17 PictureLayerTilingIteratorTest() {} |
18 virtual ~PictureLayerTilingIteratorTest() {} | 18 virtual ~PictureLayerTilingIteratorTest() {} |
19 | 19 |
20 void Initialize(gfx::Size tile_size, | 20 void Initialize(gfx::Size tile_size, |
21 float contents_scale, | 21 float contents_scale, |
22 gfx::Size layer_bounds) { | 22 gfx::Size layer_bounds) { |
23 client_.SetTileSize(tile_size); | 23 client_.SetTileSize(tile_size); |
24 tiling_ = PictureLayerTiling::Create(contents_scale); | 24 tiling_ = PictureLayerTiling::Create(contents_scale, |
25 tiling_->SetClient(&client_); | 25 layer_bounds, |
26 tiling_->SetLayerBounds(layer_bounds); | 26 &client_); |
27 } | 27 } |
28 | 28 |
29 void VerifyTilesExactlyCoverRect( | 29 void VerifyTilesExactlyCoverRect( |
30 float rect_scale, | 30 float rect_scale, |
31 gfx::Rect request_rect, | 31 gfx::Rect request_rect, |
32 gfx::Rect expect_rect) { | 32 gfx::Rect expect_rect) { |
33 EXPECT_TRUE(request_rect.Contains(expect_rect)); | 33 EXPECT_TRUE(request_rect.Contains(expect_rect)); |
34 | 34 |
35 // Iterators are not valid if this ratio is too large (i.e. the | 35 // Iterators are not valid if this ratio is too large (i.e. the |
36 // tiling is too high-res for a low-res destination rect.) This is an | 36 // tiling is too high-res for a low-res destination rect.) This is an |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 gfx::Rect in(40, 50, 100, 200); | 354 gfx::Rect in(40, 50, 100, 200); |
355 gfx::Rect bounds(0, 0, 10, 10); | 355 gfx::Rect bounds(0, 0, 10, 10); |
356 int64 target_area = 400 * 400; | 356 int64 target_area = 400 * 400; |
357 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( | 357 gfx::Rect out = PictureLayerTiling::ExpandRectEquallyToAreaBoundedBy( |
358 in, target_area, bounds); | 358 in, target_area, bounds); |
359 EXPECT_TRUE(out.IsEmpty()); | 359 EXPECT_TRUE(out.IsEmpty()); |
360 } | 360 } |
361 | 361 |
362 } // namespace | 362 } // namespace |
363 } // namespace cc | 363 } // namespace cc |
OLD | NEW |