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

Side by Side Diff: cc/resources/shared_tile_bundle_unittest.cc

Issue 62283012: cc: Added tile bundles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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
OLDNEW
(Empty)
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.
4
5 #include "cc/resources/shared_tile_bundle.h"
6 #include "cc/resources/tile.h"
7 #include "cc/test/fake_output_surface.h"
8 #include "cc/test/fake_output_surface_client.h"
9 #include "cc/test/fake_picture_layer_tiling_client.h"
10 #include "cc/test/fake_tile_manager.h"
11 #include "cc/test/fake_tile_manager_client.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace cc {
15 namespace {
16
17 class SharedTileBundleTest : public testing::Test {
18 public:
19 virtual void SetUp() OVERRIDE {
20 output_surface_ = FakeOutputSurface::Create3d();
21 CHECK(output_surface_->BindToClient(&output_surface_client_));
22
23 resource_provider_ =
24 ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1);
25 tile_manager_ = make_scoped_ptr(
26 new FakeTileManager(&tile_manager_client_, resource_provider_.get()));
27
28 active_client_ = make_scoped_ptr(
29 new FakePictureLayerTilingClient(resource_provider_.get()));
30 active_client_->set_tile_manager(tile_manager_.get());
31 active_client_->MarkActive();
32 pending_client_ = make_scoped_ptr(
33 new FakePictureLayerTilingClient(resource_provider_.get()));
34 pending_client_->set_tile_manager(tile_manager_.get());
35 pending_client_->MarkPending();
36 recycled_client_ = make_scoped_ptr(
37 new FakePictureLayerTilingClient(resource_provider_.get()));
38 recycled_client_->set_tile_manager(tile_manager_.get());
39 recycled_client_->MarkRecycled();
40 }
41
42 virtual void TearDown() OVERRIDE {
43 tile_manager_.reset(NULL);
44 active_client_.reset(NULL);
45 pending_client_.reset(NULL);
46 recycled_client_.reset(NULL);
47 resource_provider_.reset(NULL);
48 }
49
50
51 protected:
52 scoped_ptr<FakeTileManager> tile_manager_;
53 FakeTileManagerClient tile_manager_client_;
54 scoped_ptr<ResourceProvider> resource_provider_;
55 FakeOutputSurfaceClient output_surface_client_;
56 scoped_ptr<FakeOutputSurface> output_surface_;
57 scoped_ptr<FakePictureLayerTilingClient> active_client_;
58 scoped_ptr<FakePictureLayerTilingClient> pending_client_;
59 scoped_ptr<FakePictureLayerTilingClient> recycled_client_;
60 };
61
62 TEST_F(SharedTileBundleTest, EmptyTest) {
63 base::hash_map<TileBundle::Id, TileBundle*> bundles;
64 BundleSetIterator it(&bundles);
65 EXPECT_FALSE(it);
66 }
67
68 TEST_F(SharedTileBundleTest, BundleWithNoTiles) {
69 base::hash_map<TileBundle::Id, TileBundle*> bundles;
70 scoped_refptr<TileBundle> bundle =
71 active_client_->CreateTileBundle(1, 1, 0, 0);
72 bundles[bundle->id()] = bundle;
73
74 BundleSetIterator it(&bundles);
75 EXPECT_FALSE(it);
76 }
77
78 TEST_F(SharedTileBundleTest, BundleWithOneTile) {
79 base::hash_map<TileBundle::Id, TileBundle*> bundles;
80 scoped_refptr<TileBundle> bundle =
81 active_client_->CreateTileBundle(2, 2, 0, 0);
82 bundles[bundle->id()] = bundle;
83
84 scoped_refptr<Tile> tile = active_client_->CreateTile(NULL, gfx::Rect());
85 bundle->AddTileAt(0, 0, tile);
86
87 BundleSetIterator it(&bundles);
88 EXPECT_TRUE(it);
89
90 SharedTileBundle* shared_bundle = *it;
91 SharedTileBundle::Iterator shared_it(shared_bundle);
92 EXPECT_TRUE(shared_it);
93 EXPECT_TRUE(*shared_it == tile);
94
95 ++shared_it;
96 EXPECT_FALSE(shared_it);
97
98 ++it;
99 EXPECT_FALSE(it);
100 }
101
102 TEST_F(SharedTileBundleTest, TwoBundlesWithOneTileEach) {
103 base::hash_map<TileBundle::Id, TileBundle*> bundles;
104 scoped_refptr<TileBundle> bundle =
105 active_client_->CreateTileBundle(2, 2, 0, 0);
106 bundles[bundle->id()] = bundle;
107 scoped_refptr<TileBundle> second_bundle =
108 active_client_->CreateTileBundle(2, 2, 2, 2);
109 bundles[second_bundle->id()] = second_bundle;
110
111 scoped_refptr<Tile> tile = active_client_->CreateTile(NULL, gfx::Rect());
112 bundle->AddTileAt(0, 0, tile);
113
114 scoped_refptr<Tile> second_tile =
115 active_client_->CreateTile(NULL, gfx::Rect());
116 second_bundle->AddTileAt(2, 2, second_tile);
117
118 BundleSetIterator it(&bundles);
119 EXPECT_TRUE(it);
120
121 SharedTileBundle* shared_bundle = *it;
122 SharedTileBundle::Iterator shared_it(shared_bundle);
123 EXPECT_TRUE(shared_it);
124 EXPECT_TRUE(*shared_it == tile);
125
126 ++shared_it;
127 EXPECT_FALSE(shared_it);
128
129 ++it;
130 EXPECT_TRUE(it);
131
132 SharedTileBundle* second_shared_bundle = *it;
133 SharedTileBundle::Iterator second_shared_it(second_shared_bundle);
134 EXPECT_TRUE(second_shared_it);
135 EXPECT_TRUE(*second_shared_it == second_tile);
136
137 ++second_shared_it;
138 EXPECT_FALSE(second_shared_it);
139
140 ++it;
141 EXPECT_FALSE(it);
142 }
143
144 } // namespace
145 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698