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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: cc/resources/shared_tile_bundle_unittest.cc
diff --git a/cc/resources/shared_tile_bundle_unittest.cc b/cc/resources/shared_tile_bundle_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d50284efff548ba755be1706afc9eec0ae9791e3
--- /dev/null
+++ b/cc/resources/shared_tile_bundle_unittest.cc
@@ -0,0 +1,145 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/resources/shared_tile_bundle.h"
+#include "cc/resources/tile.h"
+#include "cc/test/fake_output_surface.h"
+#include "cc/test/fake_output_surface_client.h"
+#include "cc/test/fake_picture_layer_tiling_client.h"
+#include "cc/test/fake_tile_manager.h"
+#include "cc/test/fake_tile_manager_client.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace cc {
+namespace {
+
+class SharedTileBundleTest : public testing::Test {
+ public:
+ virtual void SetUp() OVERRIDE {
+ output_surface_ = FakeOutputSurface::Create3d();
+ CHECK(output_surface_->BindToClient(&output_surface_client_));
+
+ resource_provider_ =
+ ResourceProvider::Create(output_surface_.get(), NULL, 0, false, 1);
+ tile_manager_ = make_scoped_ptr(
+ new FakeTileManager(&tile_manager_client_, resource_provider_.get()));
+
+ active_client_ = make_scoped_ptr(
+ new FakePictureLayerTilingClient(resource_provider_.get()));
+ active_client_->set_tile_manager(tile_manager_.get());
+ active_client_->MarkActive();
+ pending_client_ = make_scoped_ptr(
+ new FakePictureLayerTilingClient(resource_provider_.get()));
+ pending_client_->set_tile_manager(tile_manager_.get());
+ pending_client_->MarkPending();
+ recycled_client_ = make_scoped_ptr(
+ new FakePictureLayerTilingClient(resource_provider_.get()));
+ recycled_client_->set_tile_manager(tile_manager_.get());
+ recycled_client_->MarkRecycled();
+ }
+
+ virtual void TearDown() OVERRIDE {
+ tile_manager_.reset(NULL);
+ active_client_.reset(NULL);
+ pending_client_.reset(NULL);
+ recycled_client_.reset(NULL);
+ resource_provider_.reset(NULL);
+ }
+
+
+ protected:
+ scoped_ptr<FakeTileManager> tile_manager_;
+ FakeTileManagerClient tile_manager_client_;
+ scoped_ptr<ResourceProvider> resource_provider_;
+ FakeOutputSurfaceClient output_surface_client_;
+ scoped_ptr<FakeOutputSurface> output_surface_;
+ scoped_ptr<FakePictureLayerTilingClient> active_client_;
+ scoped_ptr<FakePictureLayerTilingClient> pending_client_;
+ scoped_ptr<FakePictureLayerTilingClient> recycled_client_;
+};
+
+TEST_F(SharedTileBundleTest, EmptyTest) {
+ base::hash_map<TileBundle::Id, TileBundle*> bundles;
+ BundleSetIterator it(&bundles);
+ EXPECT_FALSE(it);
+}
+
+TEST_F(SharedTileBundleTest, BundleWithNoTiles) {
+ base::hash_map<TileBundle::Id, TileBundle*> bundles;
+ scoped_refptr<TileBundle> bundle =
+ active_client_->CreateTileBundle(1, 1, 0, 0);
+ bundles[bundle->id()] = bundle;
+
+ BundleSetIterator it(&bundles);
+ EXPECT_FALSE(it);
+}
+
+TEST_F(SharedTileBundleTest, BundleWithOneTile) {
+ base::hash_map<TileBundle::Id, TileBundle*> bundles;
+ scoped_refptr<TileBundle> bundle =
+ active_client_->CreateTileBundle(2, 2, 0, 0);
+ bundles[bundle->id()] = bundle;
+
+ scoped_refptr<Tile> tile = active_client_->CreateTile(NULL, gfx::Rect());
+ bundle->AddTileAt(0, 0, tile);
+
+ BundleSetIterator it(&bundles);
+ EXPECT_TRUE(it);
+
+ SharedTileBundle* shared_bundle = *it;
+ SharedTileBundle::Iterator shared_it(shared_bundle);
+ EXPECT_TRUE(shared_it);
+ EXPECT_TRUE(*shared_it == tile);
+
+ ++shared_it;
+ EXPECT_FALSE(shared_it);
+
+ ++it;
+ EXPECT_FALSE(it);
+}
+
+TEST_F(SharedTileBundleTest, TwoBundlesWithOneTileEach) {
+ base::hash_map<TileBundle::Id, TileBundle*> bundles;
+ scoped_refptr<TileBundle> bundle =
+ active_client_->CreateTileBundle(2, 2, 0, 0);
+ bundles[bundle->id()] = bundle;
+ scoped_refptr<TileBundle> second_bundle =
+ active_client_->CreateTileBundle(2, 2, 2, 2);
+ bundles[second_bundle->id()] = second_bundle;
+
+ scoped_refptr<Tile> tile = active_client_->CreateTile(NULL, gfx::Rect());
+ bundle->AddTileAt(0, 0, tile);
+
+ scoped_refptr<Tile> second_tile =
+ active_client_->CreateTile(NULL, gfx::Rect());
+ second_bundle->AddTileAt(2, 2, second_tile);
+
+ BundleSetIterator it(&bundles);
+ EXPECT_TRUE(it);
+
+ SharedTileBundle* shared_bundle = *it;
+ SharedTileBundle::Iterator shared_it(shared_bundle);
+ EXPECT_TRUE(shared_it);
+ EXPECT_TRUE(*shared_it == tile);
+
+ ++shared_it;
+ EXPECT_FALSE(shared_it);
+
+ ++it;
+ EXPECT_TRUE(it);
+
+ SharedTileBundle* second_shared_bundle = *it;
+ SharedTileBundle::Iterator second_shared_it(second_shared_bundle);
+ EXPECT_TRUE(second_shared_it);
+ EXPECT_TRUE(*second_shared_it == second_tile);
+
+ ++second_shared_it;
+ EXPECT_FALSE(second_shared_it);
+
+ ++it;
+ EXPECT_FALSE(it);
+}
+
+} // namespace
+} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698