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

Unified Diff: cc/base/tiling_data_unittest.cc

Issue 505913003: cc: Remove and Create the correct tiles when resizing live tiles rect (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: livetiles: removeparamfromdifference Created 6 years, 4 months 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/base/tiling_data_unittest.cc
diff --git a/cc/base/tiling_data_unittest.cc b/cc/base/tiling_data_unittest.cc
index 60e5a21e89f7311c69d4c79bbb1d4a2ced456009..b91904c2faff9b88e240056a207e10ab7204aec4 100644
--- a/cc/base/tiling_data_unittest.cc
+++ b/cc/base/tiling_data_unittest.cc
@@ -1086,11 +1086,11 @@ void TestIterate(const TilingData& data,
}
// Make sure this also works with a difference iterator and an empty ignore.
- // The difference iterator always includes borders, so ignore it otherwise.
- if (include_borders) {
+ // The difference iterator never includes borders, so ignore it otherwise.
+ if (!include_borders) {
std::vector<std::pair<int, int> > expected = original_expected;
- for (TilingData::DifferenceIterator iter(&data, rect, gfx::Rect());
- iter; ++iter) {
+ for (TilingData::DifferenceIterator iter(&data, rect, gfx::Rect()); iter;
+ ++iter) {
bool found = false;
for (size_t i = 0; i < expected.size(); ++i) {
if (expected[i] == iter.index()) {
@@ -1250,16 +1250,14 @@ TEST(TilingDataTest, IteratorNoTiles) {
TestIterateAll(data, gfx::Rect(100, 100), 0, 0, -1, -1);
}
-void TestDiff(
- const TilingData& data,
- gfx::Rect consider,
- gfx::Rect ignore,
- size_t num_tiles) {
-
+void TestDiff(const TilingData& data,
+ gfx::Rect consider,
+ gfx::Rect ignore,
+ size_t num_tiles) {
std::vector<std::pair<int, int> > expected;
for (int y = 0; y < data.num_tiles_y(); ++y) {
for (int x = 0; x < data.num_tiles_x(); ++x) {
- gfx::Rect bounds = data.TileBoundsWithBorder(x, y);
+ gfx::Rect bounds = data.TileBounds(x, y);
if (bounds.Intersects(consider) && !bounds.Intersects(ignore))
expected.push_back(std::make_pair(x, y));
}
@@ -1268,8 +1266,8 @@ void TestDiff(
// Sanity check the test.
EXPECT_EQ(num_tiles, expected.size());
- for (TilingData::DifferenceIterator iter(&data, consider, ignore);
- iter; ++iter) {
+ for (TilingData::DifferenceIterator iter(&data, consider, ignore); iter;
+ ++iter) {
bool found = false;
for (size_t i = 0; i < expected.size(); ++i) {
if (expected[i] == iter.index()) {
@@ -1339,16 +1337,26 @@ TEST(TilingDataTest, DifferenceIteratorIgnoreGeometry) {
TEST(TilingDataTest, DifferenceIteratorManyBorderTexels) {
// X border index by src coord: [0-50), [10-60), [20-65)
// Y border index by src coord: [0-60), [20-80), [40-100), [60-110)
+ // X tile bounds by src coord: [0-30), [30-40), [40-65)
+ // Y tile bounds by src coord: [0-40), [40-60), [60-80), [80-110)
TilingData data(gfx::Size(50, 60), gfx::Size(65, 110), 20);
- // Ignore one column, three rows
- TestDiff(data, gfx::Rect(0, 30, 55, 80), gfx::Rect(5, 30, 5, 15), 9);
+ // Knock out two rows, but not the left column.
+ TestDiff(data, gfx::Rect(10, 30, 55, 80), gfx::Rect(30, 59, 20, 2), 8);
- // Knock out three columns, leaving only one.
- TestDiff(data, gfx::Rect(10, 30, 55, 80), gfx::Rect(30, 59, 20, 1), 3);
+ // Knock out one row.
+ TestDiff(data, gfx::Rect(10, 30, 55, 80), gfx::Rect(29, 59, 20, 1), 9);
// Overlap all tiles with ignore rect.
- TestDiff(data, gfx::Rect(65, 110), gfx::Rect(30, 59, 1, 2), 0);
+ TestDiff(data, gfx::Rect(65, 110), gfx::Rect(29, 39, 12, 42), 0);
+
+ gfx::Rect tile = data.TileBounds(1, 1);
+
+ // Ignore one tile.
+ TestDiff(data, gfx::Rect(20, 30, 45, 80), tile, 11);
+
+ // Include one tile.
+ TestDiff(data, tile, gfx::Rect(), 1);
}
TEST(TilingDataTest, DifferenceIteratorOneTile) {

Powered by Google App Engine
This is Rietveld 408576698