Re-enable ExtensionCrxInstallerTest.InstallToSharedLocation
[chromium-blink-merge.git] / cc / test / fake_picture_pile.cc
blob80a584ba944d23ded15e70dd62bae79ad536f1de
1 // Copyright 2014 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/test/fake_picture_pile.h"
7 #include <utility>
9 #include "cc/test/fake_picture_pile_impl.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 namespace cc {
14 namespace {
16 scoped_ptr<FakePicturePile> CreatePile(const gfx::Size& tile_size,
17 const gfx::Size& layer_bounds,
18 bool is_filled) {
19 scoped_ptr<FakePicturePile> pile(
20 new FakePicturePile(ImplSidePaintingSettings().minimum_contents_scale,
21 ImplSidePaintingSettings().default_tile_grid_size));
22 pile->tiling().SetBorderTexels(0);
23 pile->tiling().SetTilingSize(layer_bounds);
24 pile->tiling().SetMaxTextureSize(tile_size);
25 pile->SetRecordedViewport(is_filled ? gfx::Rect(layer_bounds) : gfx::Rect());
26 pile->SetHasAnyRecordings(is_filled);
27 if (is_filled) {
28 for (int x = 0; x < pile->tiling().num_tiles_x(); ++x) {
29 for (int y = 0; y < pile->tiling().num_tiles_y(); ++y)
30 pile->AddRecordingAt(x, y);
33 return pile;
36 } // namespace
38 scoped_ptr<FakePicturePile> FakePicturePile::CreateFilledPile(
39 const gfx::Size& tile_size,
40 const gfx::Size& layer_bounds) {
41 bool is_filled = true;
42 return CreatePile(tile_size, layer_bounds, is_filled);
45 scoped_ptr<FakePicturePile> FakePicturePile::CreateEmptyPile(
46 const gfx::Size& tile_size,
47 const gfx::Size& layer_bounds) {
48 bool is_filled = false;
49 return CreatePile(tile_size, layer_bounds, is_filled);
52 scoped_refptr<RasterSource> FakePicturePile::CreateRasterSource(
53 bool can_use_lcd_text) const {
54 return FakePicturePileImpl::CreateFromPile(this, playback_allowed_event_);
57 void FakePicturePile::AddRecordingAt(int x, int y) {
58 EXPECT_GE(x, 0);
59 EXPECT_GE(y, 0);
60 EXPECT_LT(x, tiling_.num_tiles_x());
61 EXPECT_LT(y, tiling_.num_tiles_y());
63 if (HasRecordingAt(x, y))
64 return;
65 gfx::Rect bounds(tiling().TileBounds(x, y));
66 bounds.Inset(-buffer_pixels(), -buffer_pixels());
68 scoped_refptr<Picture> picture(
69 Picture::Create(bounds, &client_, tile_grid_size_, gather_pixel_refs_,
70 RecordingSource::RECORD_NORMALLY));
71 picture_map_[std::pair<int, int>(x, y)] = picture;
72 EXPECT_TRUE(HasRecordingAt(x, y));
74 has_any_recordings_ = true;
77 void FakePicturePile::RemoveRecordingAt(int x, int y) {
78 EXPECT_GE(x, 0);
79 EXPECT_GE(y, 0);
80 EXPECT_LT(x, tiling_.num_tiles_x());
81 EXPECT_LT(y, tiling_.num_tiles_y());
83 if (!HasRecordingAt(x, y))
84 return;
85 picture_map_.erase(std::pair<int, int>(x, y));
86 EXPECT_FALSE(HasRecordingAt(x, y));
89 bool FakePicturePile::HasRecordingAt(int x, int y) const {
90 PictureMap::const_iterator found = picture_map_.find(PictureMapKey(x, y));
91 return found != picture_map_.end();
94 void FakePicturePile::Rerecord() {
95 for (int y = 0; y < num_tiles_y(); ++y) {
96 for (int x = 0; x < num_tiles_x(); ++x) {
97 RemoveRecordingAt(x, y);
98 AddRecordingAt(x, y);
103 } // namespace cc