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
3 // found in the LICENSE file.
5 #include "cc/picture_layer_tiling_set.h"
7 #include "cc/test/fake_picture_layer_tiling_client.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/size_conversions.h"
13 TEST(PictureLayerTilingSetTest
, NoResources
) {
14 FakePictureLayerTilingClient client
;
15 PictureLayerTilingSet
set(&client
);
16 gfx::Size
default_tile_size(256, 256);
18 gfx::Size
layer_bounds(1000, 800);
19 set
.SetLayerBounds(layer_bounds
);
21 set
.AddTiling(1.0, default_tile_size
);
22 set
.AddTiling(1.5, default_tile_size
);
23 set
.AddTiling(2.0, default_tile_size
);
25 float contents_scale
= 2.0;
26 gfx::Size
content_bounds(
27 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds
, contents_scale
)));
28 gfx::Rect
content_rect(gfx::Point(), content_bounds
);
30 Region
remaining(content_rect
);
31 PictureLayerTilingSet::Iterator
iter(&set
, contents_scale
, content_rect
);
32 for (; iter
; ++iter
) {
33 gfx::Rect geometry_rect
= iter
.geometry_rect();
34 EXPECT_TRUE(content_rect
.Contains(geometry_rect
));
35 ASSERT_TRUE(remaining
.Contains(geometry_rect
));
36 remaining
.Subtract(geometry_rect
);
38 // No tiles have resources, so no iter represents a real tile.
41 EXPECT_TRUE(remaining
.IsEmpty());