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

Unified Diff: cc/resources/tile_bundle_unittest.cc

Issue 98113005: Revert "cc: Added tile bundles" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
« no previous file with comments | « cc/resources/tile_bundle.cc ('k') | cc/resources/tile_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/tile_bundle_unittest.cc
diff --git a/cc/resources/tile_bundle_unittest.cc b/cc/resources/tile_bundle_unittest.cc
deleted file mode 100644
index 268bdc4c143125c3d06d665551a65c382b438c70..0000000000000000000000000000000000000000
--- a/cc/resources/tile_bundle_unittest.cc
+++ /dev/null
@@ -1,257 +0,0 @@
-// 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/tile_bundle.h"
-
-#include <set>
-
-#include "cc/test/fake_picture_pile_impl.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 {
-
-TEST(TileBundle, AddRemoveTile) {
- FakeTileManagerClient tile_manager_client;
- FakeTileManager tile_manager(&tile_manager_client);
- scoped_refptr<PicturePileImpl> picture_pile =
- FakePicturePileImpl::CreatePile();
-
- scoped_refptr<Tile> tile = tile_manager.CreateTile(picture_pile.get(),
- gfx::Size(256, 256),
- gfx::Rect(),
- gfx::Rect(),
- 1.0,
- 0,
- 0,
- true);
- scoped_refptr<TileBundle> bundle = tile_manager.CreateTileBundle(0, 0, 2, 2);
-
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 0, 0));
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 1, 0));
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 0, 1));
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 1, 1));
- EXPECT_TRUE(bundle->IsEmpty());
-
- bundle->AddTileAt(ACTIVE_TREE, 0, 1, tile);
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 0, 0));
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 1, 0));
- EXPECT_TRUE(bundle->TileAt(ACTIVE_TREE, 0, 1));
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 1, 1));
- EXPECT_FALSE(bundle->IsEmpty());
-
- bundle->AddTileAt(ACTIVE_TREE, 1, 1, tile);
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 0, 0));
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 1, 0));
- EXPECT_TRUE(bundle->TileAt(ACTIVE_TREE, 0, 1));
- EXPECT_TRUE(bundle->TileAt(ACTIVE_TREE, 1, 1));
- EXPECT_FALSE(bundle->IsEmpty());
-
- bundle->RemoveTileAt(ACTIVE_TREE, 0, 1);
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 0, 0));
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 1, 0));
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 0, 1));
- EXPECT_TRUE(bundle->TileAt(ACTIVE_TREE, 1, 1));
- EXPECT_FALSE(bundle->IsEmpty());
-
- bundle->RemoveTileAt(ACTIVE_TREE, 0, 1);
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 0, 0));
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 1, 0));
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 0, 1));
- EXPECT_TRUE(bundle->TileAt(ACTIVE_TREE, 1, 1));
- EXPECT_FALSE(bundle->IsEmpty());
-
- bundle->RemoveTileAt(ACTIVE_TREE, 1, 1);
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 0, 0));
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 1, 0));
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 0, 1));
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 1, 1));
- EXPECT_TRUE(bundle->IsEmpty());
-}
-
-TEST(TileBundle, DidBecomeActiveSwapsTiles) {
- FakeTileManagerClient tile_manager_client;
- FakeTileManager tile_manager(&tile_manager_client);
- scoped_refptr<PicturePileImpl> picture_pile =
- FakePicturePileImpl::CreatePile();
-
- scoped_refptr<Tile> tile = tile_manager.CreateTile(picture_pile.get(),
- gfx::Size(256, 256),
- gfx::Rect(),
- gfx::Rect(),
- 1.0,
- 0,
- 0,
- true);
- scoped_refptr<Tile> other_tile = tile_manager.CreateTile(picture_pile.get(),
- gfx::Size(256, 256),
- gfx::Rect(),
- gfx::Rect(),
- 1.0,
- 0,
- 0,
- true);
-
- scoped_refptr<TileBundle> bundle = tile_manager.CreateTileBundle(0, 0, 2, 2);
- bundle->AddTileAt(ACTIVE_TREE, 0, 0, tile);
- bundle->AddTileAt(PENDING_TREE, 1, 1, other_tile);
-
- EXPECT_EQ(bundle->TileAt(ACTIVE_TREE, 0, 0), tile.get());
- EXPECT_EQ(bundle->TileAt(PENDING_TREE, 1, 1), other_tile.get());
-
- bundle->DidBecomeActive();
-
- EXPECT_EQ(bundle->TileAt(PENDING_TREE, 0, 0), tile.get());
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 0, 0));
- EXPECT_EQ(bundle->TileAt(ACTIVE_TREE, 1, 1), other_tile.get());
- EXPECT_FALSE(bundle->TileAt(PENDING_TREE, 1, 1));
-
- bundle->SwapTilesIfRequired();
-
- EXPECT_EQ(bundle->TileAt(PENDING_TREE, 0, 0), tile.get());
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 0, 0));
- EXPECT_EQ(bundle->TileAt(ACTIVE_TREE, 1, 1), other_tile.get());
- EXPECT_FALSE(bundle->TileAt(PENDING_TREE, 1, 1));
-}
-
-TEST(TileBundle, DidBecomeRecycledMarksTilesForSwap) {
- FakeTileManagerClient tile_manager_client;
- FakeTileManager tile_manager(&tile_manager_client);
- scoped_refptr<PicturePileImpl> picture_pile =
- FakePicturePileImpl::CreatePile();
-
- scoped_refptr<Tile> tile = tile_manager.CreateTile(picture_pile.get(),
- gfx::Size(256, 256),
- gfx::Rect(),
- gfx::Rect(),
- 1.0,
- 0,
- 0,
- true);
- scoped_refptr<Tile> other_tile = tile_manager.CreateTile(picture_pile.get(),
- gfx::Size(256, 256),
- gfx::Rect(),
- gfx::Rect(),
- 1.0,
- 0,
- 0,
- true);
-
- scoped_refptr<TileBundle> bundle = tile_manager.CreateTileBundle(0, 0, 2, 2);
- bundle->AddTileAt(ACTIVE_TREE, 0, 0, tile);
- bundle->AddTileAt(PENDING_TREE, 1, 1, other_tile);
-
- EXPECT_EQ(bundle->TileAt(ACTIVE_TREE, 0, 0), tile.get());
- EXPECT_EQ(bundle->TileAt(PENDING_TREE, 1, 1), other_tile.get());
-
- bundle->DidBecomeRecycled();
- bundle->DidBecomeRecycled();
-
- EXPECT_EQ(bundle->TileAt(ACTIVE_TREE, 0, 0), tile.get());
- EXPECT_FALSE(bundle->TileAt(PENDING_TREE, 0, 0));
- EXPECT_EQ(bundle->TileAt(PENDING_TREE, 1, 1), other_tile.get());
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 1, 1));
-
- bundle->DidBecomeRecycled();
- bundle->SwapTilesIfRequired();
-
- EXPECT_EQ(bundle->TileAt(PENDING_TREE, 0, 0), tile.get());
- EXPECT_FALSE(bundle->TileAt(ACTIVE_TREE, 0, 0));
- EXPECT_EQ(bundle->TileAt(ACTIVE_TREE, 1, 1), other_tile.get());
- EXPECT_FALSE(bundle->TileAt(PENDING_TREE, 1, 1));
-}
-
-TEST(TileBundle, EmptyIterator) {
- FakeTileManagerClient tile_manager_client;
- FakeTileManager tile_manager(&tile_manager_client);
- scoped_refptr<TileBundle> bundle = tile_manager.CreateTileBundle(0, 0, 2, 2);
-
- TileBundle::Iterator it(bundle.get());
- EXPECT_FALSE(it);
-
- TileBundle::Iterator active_it(bundle.get(), ACTIVE_TREE);
- EXPECT_FALSE(active_it);
-
- TileBundle::Iterator pending_it(bundle.get(), PENDING_TREE);
- EXPECT_FALSE(pending_it);
-}
-
-TEST(TileBundle, NonEmptyIterator) {
- FakeTileManagerClient tile_manager_client;
- FakeTileManager tile_manager(&tile_manager_client);
- scoped_refptr<PicturePileImpl> picture_pile =
- FakePicturePileImpl::CreatePile();
- scoped_refptr<TileBundle> bundle = tile_manager.CreateTileBundle(0, 0, 2, 2);
-
- scoped_refptr<Tile> tile = tile_manager.CreateTile(picture_pile.get(),
- gfx::Size(256, 256),
- gfx::Rect(),
- gfx::Rect(),
- 1.0,
- 0,
- 0,
- true);
- scoped_refptr<Tile> other_tile = tile_manager.CreateTile(picture_pile.get(),
- gfx::Size(256, 256),
- gfx::Rect(),
- gfx::Rect(),
- 1.0,
- 0,
- 0,
- true);
- scoped_refptr<Tile> third_tile = tile_manager.CreateTile(picture_pile.get(),
- gfx::Size(256, 256),
- gfx::Rect(),
- gfx::Rect(),
- 1.0,
- 0,
- 0,
- true);
-
- bundle->AddTileAt(ACTIVE_TREE, 0, 0, tile);
- bundle->AddTileAt(PENDING_TREE, 1, 1, other_tile);
- bundle->AddTileAt(ACTIVE_TREE, 1, 1, third_tile);
-
- TileBundle::Iterator it(bundle.get());
- EXPECT_TRUE(it);
- std::set<Tile*> tiles;
- size_t count = 0;
- while (it) {
- tiles.insert(*it);
- ++it;
- ++count;
- }
-
- EXPECT_EQ(count, tiles.size());
- EXPECT_TRUE(tiles.count(tile.get()));
- EXPECT_TRUE(tiles.count(other_tile.get()));
- EXPECT_TRUE(tiles.count(third_tile.get()));
-
- TileBundle::Iterator active_it(bundle.get(), ACTIVE_TREE);
- EXPECT_TRUE(active_it);
- count = 0;
- tiles.clear();
- while (active_it) {
- tiles.insert(*active_it);
- ++active_it;
- ++count;
- }
-
- EXPECT_EQ(count, tiles.size());
- EXPECT_TRUE(tiles.count(tile.get()));
- EXPECT_FALSE(tiles.count(other_tile.get()));
- EXPECT_TRUE(tiles.count(third_tile.get()));
-
- TileBundle::Iterator pending_it(bundle.get(), PENDING_TREE);
- EXPECT_TRUE(pending_it);
- EXPECT_EQ(*pending_it, other_tile.get());
- ++pending_it;
- EXPECT_FALSE(pending_it);
-}
-
-
-} // namespace
-} // namespace cc
« no previous file with comments | « cc/resources/tile_bundle.cc ('k') | cc/resources/tile_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698