MediaCodecPlayer implementation - stage 6 (respect audio permission)
[chromium-blink-merge.git] / cc / playback / picture_pile_impl_unittest.cc
blob3931f8dd4239b6f80f73e79a41ee15282914714c
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
3 // found in the LICENSE file.
5 #include "base/memory/scoped_ptr.h"
6 #include "cc/test/fake_picture_pile_impl.h"
7 #include "cc/test/skia_common.h"
8 #include "skia/ext/refptr.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/skia/include/core/SkPixelRef.h"
11 #include "third_party/skia/include/core/SkShader.h"
12 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/geometry/size_conversions.h"
15 namespace cc {
16 namespace {
18 TEST(PicturePileImplTest, AnalyzeIsSolidUnscaled) {
19 gfx::Size tile_size(100, 100);
20 gfx::Size layer_bounds(400, 400);
22 scoped_ptr<FakePicturePile> recording_source =
23 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
25 SkPaint solid_paint;
26 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34);
27 solid_paint.setColor(solid_color);
29 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67);
30 SkPaint non_solid_paint;
31 non_solid_paint.setColor(non_solid_color);
33 recording_source->add_draw_rect_with_paint(gfx::Rect(400, 400), solid_paint);
34 recording_source->Rerecord();
36 scoped_refptr<FakePicturePileImpl> pile =
37 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
39 // Ensure everything is solid.
40 for (int y = 0; y <= 300; y += 100) {
41 for (int x = 0; x <= 300; x += 100) {
42 RasterSource::SolidColorAnalysis analysis;
43 gfx::Rect rect(x, y, 100, 100);
44 pile->PerformSolidColorAnalysis(rect, 1.0, &analysis);
45 EXPECT_TRUE(analysis.is_solid_color) << rect.ToString();
46 EXPECT_EQ(analysis.solid_color, solid_color) << rect.ToString();
50 // Add one non-solid pixel and recreate the raster source.
51 recording_source->add_draw_rect_with_paint(gfx::Rect(50, 50, 1, 1),
52 non_solid_paint);
53 recording_source->Rerecord();
54 pile = FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
56 RasterSource::SolidColorAnalysis analysis;
57 pile->PerformSolidColorAnalysis(gfx::Rect(0, 0, 100, 100), 1.0, &analysis);
58 EXPECT_FALSE(analysis.is_solid_color);
60 pile->PerformSolidColorAnalysis(gfx::Rect(100, 0, 100, 100), 1.0, &analysis);
61 EXPECT_TRUE(analysis.is_solid_color);
62 EXPECT_EQ(analysis.solid_color, solid_color);
64 // Boundaries should be clipped.
65 analysis.is_solid_color = false;
66 pile->PerformSolidColorAnalysis(gfx::Rect(350, 0, 100, 100), 1.0, &analysis);
67 EXPECT_TRUE(analysis.is_solid_color);
68 EXPECT_EQ(analysis.solid_color, solid_color);
70 analysis.is_solid_color = false;
71 pile->PerformSolidColorAnalysis(gfx::Rect(0, 350, 100, 100), 1.0, &analysis);
72 EXPECT_TRUE(analysis.is_solid_color);
73 EXPECT_EQ(analysis.solid_color, solid_color);
75 analysis.is_solid_color = false;
76 pile->PerformSolidColorAnalysis(gfx::Rect(350, 350, 100, 100), 1.0,
77 &analysis);
78 EXPECT_TRUE(analysis.is_solid_color);
79 EXPECT_EQ(analysis.solid_color, solid_color);
82 TEST(PicturePileImplTest, AnalyzeIsSolidScaled) {
83 gfx::Size tile_size(100, 100);
84 gfx::Size layer_bounds(400, 400);
86 scoped_ptr<FakePicturePile> recording_source =
87 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
89 SkColor solid_color = SkColorSetARGB(255, 12, 23, 34);
90 SkPaint solid_paint;
91 solid_paint.setColor(solid_color);
93 SkColor non_solid_color = SkColorSetARGB(128, 45, 56, 67);
94 SkPaint non_solid_paint;
95 non_solid_paint.setColor(non_solid_color);
97 recording_source->add_draw_rect_with_paint(gfx::Rect(400, 400), solid_paint);
98 recording_source->Rerecord();
100 scoped_refptr<FakePicturePileImpl> pile =
101 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
103 // Ensure everything is solid.
104 for (int y = 0; y <= 30; y += 10) {
105 for (int x = 0; x <= 30; x += 10) {
106 RasterSource::SolidColorAnalysis analysis;
107 gfx::Rect rect(x, y, 10, 10);
108 pile->PerformSolidColorAnalysis(rect, 0.1f, &analysis);
109 EXPECT_TRUE(analysis.is_solid_color) << rect.ToString();
110 EXPECT_EQ(analysis.solid_color, solid_color) << rect.ToString();
114 // Add one non-solid pixel and recreate the raster source.
115 recording_source->add_draw_rect_with_paint(gfx::Rect(50, 50, 1, 1),
116 non_solid_paint);
117 recording_source->Rerecord();
118 pile = FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
120 RasterSource::SolidColorAnalysis analysis;
121 pile->PerformSolidColorAnalysis(gfx::Rect(0, 0, 10, 10), 0.1f, &analysis);
122 EXPECT_FALSE(analysis.is_solid_color);
124 pile->PerformSolidColorAnalysis(gfx::Rect(10, 0, 10, 10), 0.1f, &analysis);
125 EXPECT_TRUE(analysis.is_solid_color);
126 EXPECT_EQ(analysis.solid_color, solid_color);
128 // Boundaries should be clipped.
129 analysis.is_solid_color = false;
130 pile->PerformSolidColorAnalysis(gfx::Rect(35, 0, 10, 10), 0.1f, &analysis);
131 EXPECT_TRUE(analysis.is_solid_color);
132 EXPECT_EQ(analysis.solid_color, solid_color);
134 analysis.is_solid_color = false;
135 pile->PerformSolidColorAnalysis(gfx::Rect(0, 35, 10, 10), 0.1f, &analysis);
136 EXPECT_TRUE(analysis.is_solid_color);
137 EXPECT_EQ(analysis.solid_color, solid_color);
139 analysis.is_solid_color = false;
140 pile->PerformSolidColorAnalysis(gfx::Rect(35, 35, 10, 10), 0.1f, &analysis);
141 EXPECT_TRUE(analysis.is_solid_color);
142 EXPECT_EQ(analysis.solid_color, solid_color);
145 TEST(PicturePileImplTest, AnalyzeIsSolidEmpty) {
146 gfx::Size tile_size(100, 100);
147 gfx::Size layer_bounds(400, 400);
149 scoped_refptr<FakePicturePileImpl> pile =
150 FakePicturePileImpl::CreateFilledPile(tile_size, layer_bounds);
151 RasterSource::SolidColorAnalysis analysis;
152 EXPECT_FALSE(analysis.is_solid_color);
154 pile->PerformSolidColorAnalysis(gfx::Rect(0, 0, 400, 400), 1.f, &analysis);
156 EXPECT_TRUE(analysis.is_solid_color);
157 EXPECT_EQ(analysis.solid_color, SkColorSetARGB(0, 0, 0, 0));
160 TEST(PicturePileImplTest, ImageIteratorDiscardableImagesOneTile) {
161 gfx::Size tile_size(256, 256);
162 gfx::Size layer_bounds(512, 512);
164 scoped_ptr<FakePicturePile> recording_source =
165 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
167 skia::RefPtr<SkImage> discardable_image[2][2];
168 discardable_image[0][0] = CreateDiscardableImage(gfx::Size(32, 32));
169 discardable_image[0][1] = CreateDiscardableImage(gfx::Size(32, 32));
170 discardable_image[1][1] = CreateDiscardableImage(gfx::Size(32, 32));
172 // Discardable pixel refs are found in the following cells:
173 // |---|---|
174 // | x | x |
175 // |---|---|
176 // | | x |
177 // |---|---|
178 recording_source->add_draw_image(discardable_image[0][0].get(),
179 gfx::Point(0, 0));
180 recording_source->add_draw_image(discardable_image[0][1].get(),
181 gfx::Point(260, 0));
182 recording_source->add_draw_image(discardable_image[1][1].get(),
183 gfx::Point(260, 260));
184 recording_source->SetGatherDiscardableImages(true);
185 recording_source->Rerecord();
187 scoped_refptr<FakePicturePileImpl> pile =
188 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
190 // Tile sized iterators. These should find only one pixel ref.
192 PicturePileImpl::ImageIterator iterator(gfx::Rect(0, 0, 256, 256),
193 pile.get());
194 EXPECT_TRUE(iterator);
195 EXPECT_TRUE(iterator->image == discardable_image[0][0].get());
196 EXPECT_EQ(gfx::SkRectToRectF(iterator->image_rect).ToString(),
197 gfx::RectF(32, 32).ToString());
198 EXPECT_FALSE(++iterator);
200 // Shifted tile sized iterators. These should find only one pixel ref.
202 PicturePileImpl::ImageIterator iterator(gfx::Rect(260, 260, 256, 256),
203 pile.get());
204 EXPECT_TRUE(iterator);
205 EXPECT_TRUE(iterator->image == discardable_image[1][1].get());
206 EXPECT_EQ(gfx::SkRectToRectF(iterator->image_rect).ToString(),
207 gfx::RectF(260, 260, 32, 32).ToString());
208 EXPECT_FALSE(++iterator);
210 // Ensure there's no discardable pixel refs in the empty cell
212 PicturePileImpl::ImageIterator iterator(gfx::Rect(0, 256, 256, 256),
213 pile.get());
214 EXPECT_FALSE(iterator);
216 // Layer sized iterators. These should find three pixel ref.
218 PicturePileImpl::ImageIterator iterator(gfx::Rect(0, 0, 512, 512),
219 pile.get());
220 EXPECT_TRUE(iterator);
221 EXPECT_TRUE(iterator->image == discardable_image[0][0].get());
222 EXPECT_EQ(gfx::SkRectToRectF(iterator->image_rect).ToString(),
223 gfx::RectF(32, 32).ToString());
224 EXPECT_TRUE(++iterator);
225 EXPECT_TRUE(iterator->image == discardable_image[0][1].get());
226 EXPECT_EQ(gfx::SkRectToRectF(iterator->image_rect).ToString(),
227 gfx::RectF(260, 0, 32, 32).ToString());
228 EXPECT_TRUE(++iterator);
229 EXPECT_TRUE(iterator->image == discardable_image[1][1].get());
230 EXPECT_EQ(gfx::SkRectToRectF(iterator->image_rect).ToString(),
231 gfx::RectF(260, 260, 32, 32).ToString());
232 EXPECT_FALSE(++iterator);
236 // Copy test.
237 PicturePileImpl::ImageIterator iterator(gfx::Rect(0, 0, 512, 512),
238 pile.get());
239 EXPECT_TRUE(iterator);
240 EXPECT_TRUE(iterator->image == discardable_image[0][0].get());
241 EXPECT_EQ(gfx::RectF(32, 32).ToString(),
242 gfx::SkRectToRectF(iterator->image_rect).ToString());
243 EXPECT_TRUE(++iterator);
244 EXPECT_TRUE(iterator->image == discardable_image[0][1].get());
245 EXPECT_EQ(gfx::RectF(260, 0, 32, 32).ToString(),
246 gfx::SkRectToRectF(iterator->image_rect).ToString());
248 // copy now points to the same spot as iterator,
249 // but both can be incremented independently.
250 PicturePileImpl::ImageIterator copy = iterator;
251 EXPECT_TRUE(++iterator);
252 EXPECT_TRUE(iterator->image == discardable_image[1][1].get());
253 EXPECT_EQ(gfx::RectF(260, 260, 32, 32).ToString(),
254 gfx::SkRectToRectF(iterator->image_rect).ToString());
255 EXPECT_FALSE(++iterator);
257 EXPECT_TRUE(copy);
258 EXPECT_TRUE(copy->image == discardable_image[0][1].get());
259 EXPECT_EQ(gfx::RectF(260, 0, 32, 32).ToString(),
260 gfx::SkRectToRectF(copy->image_rect).ToString());
261 EXPECT_TRUE(++copy);
262 EXPECT_TRUE(copy->image == discardable_image[1][1].get());
263 EXPECT_EQ(gfx::RectF(260, 260, 32, 32).ToString(),
264 gfx::SkRectToRectF(copy->image_rect).ToString());
265 EXPECT_FALSE(++copy);
269 TEST(PicturePileImplTest, RasterFullContents) {
270 gfx::Size tile_size(1000, 1000);
271 gfx::Size layer_bounds(3, 5);
272 float contents_scale = 1.5f;
273 float raster_divisions = 2.f;
275 scoped_ptr<FakePicturePile> recording_source =
276 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
277 recording_source->SetBackgroundColor(SK_ColorBLACK);
278 recording_source->SetIsSolidColor(false);
279 recording_source->SetRequiresClear(false);
280 recording_source->SetClearCanvasWithDebugColor(false);
282 // Because the caller sets content opaque, it also promises that it
283 // has at least filled in layer_bounds opaquely.
284 SkPaint white_paint;
285 white_paint.setColor(SK_ColorWHITE);
286 recording_source->add_draw_rect_with_paint(gfx::Rect(layer_bounds),
287 white_paint);
289 recording_source->SetMinContentsScale(contents_scale);
290 recording_source->Rerecord();
292 scoped_refptr<FakePicturePileImpl> pile =
293 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
295 gfx::Size content_bounds(
296 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)));
298 // Simulate drawing into different tiles at different offsets.
299 int step_x = std::ceil(content_bounds.width() / raster_divisions);
300 int step_y = std::ceil(content_bounds.height() / raster_divisions);
301 for (int offset_x = 0; offset_x < content_bounds.width();
302 offset_x += step_x) {
303 for (int offset_y = 0; offset_y < content_bounds.height();
304 offset_y += step_y) {
305 gfx::Rect content_rect(offset_x, offset_y, step_x, step_y);
306 content_rect.Intersect(gfx::Rect(content_bounds));
308 // Simulate a canvas rect larger than the content rect. Every pixel
309 // up to one pixel outside the content rect is guaranteed to be opaque.
310 // Outside of that is undefined.
311 gfx::Rect canvas_rect(content_rect);
312 canvas_rect.Inset(0, 0, -1, -1);
314 SkBitmap bitmap;
315 bitmap.allocN32Pixels(canvas_rect.width(), canvas_rect.height());
316 SkCanvas canvas(bitmap);
317 canvas.clear(SK_ColorTRANSPARENT);
319 pile->PlaybackToCanvas(&canvas, canvas_rect, canvas_rect, contents_scale);
321 SkColor* pixels = reinterpret_cast<SkColor*>(bitmap.getPixels());
322 int num_pixels = bitmap.width() * bitmap.height();
323 bool all_white = true;
324 for (int i = 0; i < num_pixels; ++i) {
325 EXPECT_EQ(SkColorGetA(pixels[i]), 255u);
326 all_white &= (SkColorGetR(pixels[i]) == 255);
327 all_white &= (SkColorGetG(pixels[i]) == 255);
328 all_white &= (SkColorGetB(pixels[i]) == 255);
331 // If the canvas doesn't extend past the edge of the content,
332 // it should be entirely white. Otherwise, the edge of the content
333 // will be non-white.
334 EXPECT_EQ(all_white, gfx::Rect(content_bounds).Contains(canvas_rect));
339 TEST(PicturePileImpl, RasterContentsTransparent) {
340 gfx::Size tile_size(1000, 1000);
341 gfx::Size layer_bounds(5, 3);
342 float contents_scale = 0.5f;
344 scoped_ptr<FakePicturePile> recording_source =
345 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
346 recording_source->SetBackgroundColor(SK_ColorTRANSPARENT);
347 recording_source->SetRequiresClear(true);
348 recording_source->SetMinContentsScale(contents_scale);
349 recording_source->SetClearCanvasWithDebugColor(false);
350 recording_source->Rerecord();
352 scoped_refptr<FakePicturePileImpl> pile =
353 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
354 gfx::Size content_bounds(
355 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)));
357 gfx::Rect canvas_rect(content_bounds);
358 canvas_rect.Inset(0, 0, -1, -1);
360 SkBitmap bitmap;
361 bitmap.allocN32Pixels(canvas_rect.width(), canvas_rect.height());
362 SkCanvas canvas(bitmap);
364 pile->PlaybackToCanvas(&canvas, canvas_rect, canvas_rect, contents_scale);
366 SkColor* pixels = reinterpret_cast<SkColor*>(bitmap.getPixels());
367 int num_pixels = bitmap.width() * bitmap.height();
368 for (int i = 0; i < num_pixels; ++i) {
369 EXPECT_EQ(SkColorGetA(pixels[i]), 0u);
373 class OverlapTest : public ::testing::TestWithParam<float> {
374 public:
375 static float MinContentsScale() { return 1.f / 4.f; }
378 TEST_P(OverlapTest, NoOverlap) {
379 gfx::Size tile_size(10, 10);
380 gfx::Size layer_bounds(30, 30);
381 gfx::Size bigger_than_layer_bounds(300, 300);
382 float contents_scale = GetParam();
383 // Pick an opaque color to not have to deal with premultiplication off-by-one.
384 SkColor test_color = SkColorSetARGB(255, 45, 56, 67);
386 scoped_ptr<FakePicturePile> recording_source =
387 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
388 recording_source->SetBackgroundColor(SK_ColorTRANSPARENT);
389 recording_source->SetRequiresClear(true);
390 recording_source->SetMinContentsScale(MinContentsScale());
391 recording_source->SetClearCanvasWithDebugColor(true);
393 SkPaint color_paint;
394 color_paint.setColor(test_color);
395 // Additive paint, so that if two paints overlap, the color will change.
396 color_paint.setXfermodeMode(SkXfermode::kPlus_Mode);
397 // Paint outside the layer to make sure that blending works.
398 recording_source->add_draw_rect_with_paint(
399 gfx::Rect(bigger_than_layer_bounds), color_paint);
400 recording_source->Rerecord();
402 scoped_refptr<FakePicturePileImpl> pile =
403 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
404 gfx::Size content_bounds(
405 gfx::ToCeiledSize(gfx::ScaleSize(layer_bounds, contents_scale)));
407 SkBitmap bitmap;
408 bitmap.allocN32Pixels(content_bounds.width(), content_bounds.height());
409 SkCanvas canvas(bitmap);
411 pile->PlaybackToCanvas(&canvas, gfx::Rect(content_bounds),
412 gfx::Rect(content_bounds), contents_scale);
414 for (int y = 0; y < bitmap.height(); y++) {
415 for (int x = 0; x < bitmap.width(); x++) {
416 SkColor color = bitmap.getColor(x, y);
417 EXPECT_EQ(SkColorGetR(test_color), SkColorGetR(color)) << "x: " << x
418 << ", y: " << y;
419 EXPECT_EQ(SkColorGetG(test_color), SkColorGetG(color)) << "x: " << x
420 << ", y: " << y;
421 EXPECT_EQ(SkColorGetB(test_color), SkColorGetB(color)) << "x: " << x
422 << ", y: " << y;
423 EXPECT_EQ(SkColorGetA(test_color), SkColorGetA(color)) << "x: " << x
424 << ", y: " << y;
425 if (test_color != color)
426 break;
431 INSTANTIATE_TEST_CASE_P(PicturePileImpl,
432 OverlapTest,
433 ::testing::Values(1.f, 0.873f, 1.f / 4.f, 4.f));
435 TEST(PicturePileImplTest, ImageIteratorBorders) {
436 // 3 tile width / 1 tile height pile
437 gfx::Size tile_size(128, 128);
438 gfx::Size layer_bounds(320, 128);
440 // Fake picture pile uses a tile grid the size of the tile. So,
441 // any iteration that intersects with a tile will return all pixel refs
442 // inside of it.
443 scoped_ptr<FakePicturePile> recording_source =
444 FakePicturePile::CreateFilledPile(tile_size, layer_bounds);
445 recording_source->SetMinContentsScale(0.5f);
447 // Bitmaps 0-2 are exactly on tiles 0-2, so that they overlap the borders
448 // of adjacent tiles.
449 gfx::Rect bitmap_rects[] = {
450 recording_source->tiling().TileBounds(0, 0),
451 recording_source->tiling().TileBounds(1, 0),
452 recording_source->tiling().TileBounds(2, 0),
454 gfx::RectF expected_rects[] = {
455 gfx::RectF(recording_source->tiling().TileBounds(0, 0)),
456 gfx::RectF(recording_source->tiling().TileBounds(1, 0)),
457 gfx::RectF(recording_source->tiling().TileBounds(2, 0)),
459 skia::RefPtr<SkImage> discardable_image[arraysize(bitmap_rects)];
461 for (size_t i = 0; i < arraysize(bitmap_rects); ++i) {
462 discardable_image[i] = CreateDiscardableImage(bitmap_rects[i].size());
463 recording_source->add_draw_image(discardable_image[i].get(),
464 bitmap_rects[i].origin());
467 recording_source->SetGatherDiscardableImages(true);
468 recording_source->Rerecord();
470 scoped_refptr<FakePicturePileImpl> pile =
471 FakePicturePileImpl::CreateFromPile(recording_source.get(), nullptr);
473 // Sanity check that bitmaps 0-2 intersect the borders of their adjacent
474 // tiles, but not the actual tiles.
475 EXPECT_TRUE(
476 bitmap_rects[0].Intersects(pile->tiling().TileBoundsWithBorder(1, 0)));
477 EXPECT_FALSE(bitmap_rects[0].Intersects(pile->tiling().TileBounds(1, 0)));
478 EXPECT_TRUE(
479 bitmap_rects[1].Intersects(pile->tiling().TileBoundsWithBorder(0, 0)));
480 EXPECT_FALSE(bitmap_rects[1].Intersects(pile->tiling().TileBounds(0, 0)));
481 EXPECT_TRUE(
482 bitmap_rects[1].Intersects(pile->tiling().TileBoundsWithBorder(2, 0)));
483 EXPECT_FALSE(bitmap_rects[1].Intersects(pile->tiling().TileBounds(2, 0)));
484 EXPECT_TRUE(
485 bitmap_rects[2].Intersects(pile->tiling().TileBoundsWithBorder(1, 0)));
486 EXPECT_FALSE(bitmap_rects[2].Intersects(pile->tiling().TileBounds(1, 0)));
488 // Tile-sized iterators.
490 // Because tile 0's borders extend onto tile 1, it will include both
491 // image 0 and 1. However, it should *not* include image 2.
492 PicturePileImpl::ImageIterator iterator(pile->tiling().TileBounds(0, 0),
493 pile.get());
494 EXPECT_TRUE(iterator);
495 EXPECT_TRUE(iterator->image == discardable_image[0].get());
496 EXPECT_EQ(expected_rects[0].ToString(),
497 gfx::SkRectToRectF(iterator->image_rect).ToString());
498 EXPECT_TRUE(++iterator);
499 EXPECT_TRUE(iterator->image == discardable_image[1].get());
500 EXPECT_EQ(expected_rects[1].ToString(),
501 gfx::SkRectToRectF(iterator->image_rect).ToString());
502 EXPECT_FALSE(++iterator);
505 // Tile 1 + borders hits all images.
506 PicturePileImpl::ImageIterator iterator(pile->tiling().TileBounds(1, 0),
507 pile.get());
508 EXPECT_TRUE(iterator);
509 EXPECT_TRUE(iterator->image == discardable_image[0].get());
510 EXPECT_EQ(expected_rects[0].ToString(),
511 gfx::SkRectToRectF(iterator->image_rect).ToString());
512 EXPECT_TRUE(++iterator);
513 EXPECT_TRUE(iterator->image == discardable_image[1].get());
514 EXPECT_EQ(expected_rects[1].ToString(),
515 gfx::SkRectToRectF(iterator->image_rect).ToString());
516 EXPECT_TRUE(++iterator);
517 EXPECT_TRUE(iterator->image == discardable_image[2].get());
518 EXPECT_EQ(expected_rects[2].ToString(),
519 gfx::SkRectToRectF(iterator->image_rect).ToString());
520 EXPECT_FALSE(++iterator);
523 // Tile 2 should not include image 0, which is only on tile 0 and the
524 // borders of tile 1.
525 PicturePileImpl::ImageIterator iterator(pile->tiling().TileBounds(2, 0),
526 pile.get());
527 EXPECT_TRUE(iterator);
528 EXPECT_TRUE(iterator->image == discardable_image[1].get());
529 EXPECT_EQ(expected_rects[1].ToString(),
530 gfx::SkRectToRectF(iterator->image_rect).ToString());
531 EXPECT_TRUE(++iterator);
532 EXPECT_TRUE(iterator->image == discardable_image[2].get());
533 EXPECT_EQ(expected_rects[2].ToString(),
534 gfx::SkRectToRectF(iterator->image_rect).ToString());
535 EXPECT_FALSE(++iterator);
539 } // namespace
540 } // namespace cc