| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "cc/base/tiling_data.h" | 10 #include "cc/base/tiling_data.h" |
| 11 #include "cc/test/geometry_test_utils.h" | 11 #include "cc/test/geometry_test_utils.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace cc { | 14 namespace cc { |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 void TestSpiralIterate(int source_line_number, | 17 void TestPyramidSequenceIterate( |
| 18 const TilingData& tiling_data, | 18 int source_line_number, |
| 19 const gfx::Rect& consider, | 19 const TilingData& tiling_data, |
| 20 const gfx::Rect& ignore, | 20 const gfx::Rect& consider, |
| 21 const gfx::Rect& center, | 21 const gfx::Rect& ignore, |
| 22 const std::vector<std::pair<int, int>>& expected) { | 22 const gfx::Rect& center, |
| 23 const std::vector<std::pair<int, int>>& expected) { |
| 23 std::vector<std::pair<int, int>> actual_forward; | 24 std::vector<std::pair<int, int>> actual_forward; |
| 24 for (TilingData::SpiralDifferenceIterator it(&tiling_data, consider, ignore, | 25 for (TilingData::SpiralDifferenceIterator it(&tiling_data, consider, ignore, |
| 25 center); | 26 center, true); |
| 26 it; ++it) { | 27 it; ++it) { |
| 27 actual_forward.push_back(it.index()); | 28 actual_forward.push_back(it.index()); |
| 28 } | 29 } |
| 29 | 30 |
| 30 EXPECT_EQ(expected.size(), actual_forward.size()) << "error from line " | 31 EXPECT_EQ(expected.size(), actual_forward.size()) << "error from line " |
| 31 << source_line_number; | 32 << source_line_number; |
| 32 for (size_t i = 0; i < std::min(expected.size(), actual_forward.size()); | 33 for (size_t i = 0; i < std::min(expected.size(), actual_forward.size()); |
| 33 ++i) { | 34 ++i) { |
| 34 EXPECT_EQ(expected[i].first, actual_forward[i].first) | 35 EXPECT_EQ(expected[i].first, actual_forward[i].first) |
| 35 << "i: " << i << " error from line: " << source_line_number; | 36 << "i: " << i << " error from line: " << source_line_number; |
| 36 EXPECT_EQ(expected[i].second, actual_forward[i].second) | 37 EXPECT_EQ(expected[i].second, actual_forward[i].second) |
| 37 << "i: " << i << " error from line: " << source_line_number; | 38 << "i: " << i << " error from line: " << source_line_number; |
| 38 } | 39 } |
| 39 | 40 |
| 40 std::vector<std::pair<int, int>> actual_reverse; | 41 std::vector<std::pair<int, int>> actual_reverse; |
| 41 for (TilingData::ReverseSpiralDifferenceIterator it(&tiling_data, consider, | 42 for (TilingData::ReverseSpiralDifferenceIterator it(&tiling_data, consider, |
| 42 ignore, center); | 43 ignore, center, true); |
| 43 it; ++it) { | 44 it; ++it) { |
| 44 actual_reverse.push_back(it.index()); | 45 actual_reverse.push_back(it.index()); |
| 45 } | 46 } |
| 46 | 47 |
| 47 std::vector<std::pair<int, int>> reversed_expected = expected; | 48 std::vector<std::pair<int, int>> reversed_expected = expected; |
| 48 std::reverse(reversed_expected.begin(), reversed_expected.end()); | 49 std::reverse(reversed_expected.begin(), reversed_expected.end()); |
| 49 EXPECT_EQ(reversed_expected.size(), actual_reverse.size()) | 50 EXPECT_EQ(reversed_expected.size(), actual_reverse.size()) |
| 50 << "error from line " << source_line_number; | 51 << "error from line " << source_line_number; |
| 51 for (size_t i = 0; | 52 for (size_t i = 0; |
| 52 i < std::min(reversed_expected.size(), actual_reverse.size()); ++i) { | 53 i < std::min(reversed_expected.size(), actual_reverse.size()); ++i) { |
| 53 EXPECT_EQ(reversed_expected[i].first, actual_reverse[i].first) | 54 EXPECT_EQ(reversed_expected[i].first, actual_reverse[i].first) |
| 54 << "i: " << i << " error from line: " << source_line_number; | 55 << "i: " << i << " error from line: " << source_line_number; |
| 55 EXPECT_EQ(reversed_expected[i].second, actual_reverse[i].second) | 56 EXPECT_EQ(reversed_expected[i].second, actual_reverse[i].second) |
| 56 << "i: " << i << " error from line: " << source_line_number; | 57 << "i: " << i << " error from line: " << source_line_number; |
| 57 } | 58 } |
| 58 } | 59 } |
| 59 | 60 |
| 60 TEST(SpiralIteratorTest, NoIgnoreFullConsider) { | 61 TEST(PyramidSequenceTest, NoIgnoreFullConsider) { |
| 61 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(30, 30), false); | 62 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(30, 30), false); |
| 62 gfx::Rect consider(30, 30); | 63 gfx::Rect consider(30, 30); |
| 63 gfx::Rect ignore; | 64 gfx::Rect ignore; |
| 64 std::vector<std::pair<int, int>> expected; | 65 std::vector<std::pair<int, int>> expected; |
| 65 | 66 |
| 66 // Center is in the center of the tiling. | 67 // Center is in the center of the tiling. |
| 67 gfx::Rect center(15, 15, 1, 1); | 68 gfx::Rect center(15, 15, 1, 1); |
| 68 | 69 |
| 69 // Layout of the tiling data, and expected return order: | 70 // Layout of the tiling data, and expected return order: |
| 70 // x 0 1 2 | 71 // x 0 1 2 |
| 71 // y ┌───┬───┬───┐ | 72 // y ┌───┬───┬───┐ |
| 72 // 0 │ 4│ 3│ 2│ | 73 // 0 │ 6│ 4│ 3│ |
| 73 // ├───┼───┼───┤ | 74 // ├───┼───┼───┤ |
| 74 // 1 │ 5│ *│ 1│ | 75 // 1 │ 5│ *│ 1│ |
| 75 // ├───┼───┼───┤ | 76 // ├───┼───┼───┤ |
| 76 // 2 │ 6│ 7│ 8│ | 77 // 2 │ 7│ 8│ 2│ |
| 77 // └───┴───┴───┘ | 78 // └───┴───┴───┘ |
| 78 expected.push_back(std::make_pair(2, 1)); | 79 expected.push_back(std::make_pair(2, 1)); |
| 80 expected.push_back(std::make_pair(2, 2)); |
| 79 expected.push_back(std::make_pair(2, 0)); | 81 expected.push_back(std::make_pair(2, 0)); |
| 80 expected.push_back(std::make_pair(1, 0)); | 82 expected.push_back(std::make_pair(1, 0)); |
| 83 expected.push_back(std::make_pair(0, 1)); |
| 81 expected.push_back(std::make_pair(0, 0)); | 84 expected.push_back(std::make_pair(0, 0)); |
| 82 expected.push_back(std::make_pair(0, 1)); | |
| 83 expected.push_back(std::make_pair(0, 2)); | 85 expected.push_back(std::make_pair(0, 2)); |
| 84 expected.push_back(std::make_pair(1, 2)); | 86 expected.push_back(std::make_pair(1, 2)); |
| 85 expected.push_back(std::make_pair(2, 2)); | |
| 86 | 87 |
| 87 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 88 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 89 expected); |
| 88 | 90 |
| 89 // Center is off to the right side of the tiling (and far away). | 91 // Center is off to the right side of the tiling (and far away). |
| 90 center = gfx::Rect(100, 15, 1, 1); | 92 center = gfx::Rect(100, 15, 1, 1); |
| 91 | 93 |
| 92 // Layout of the tiling data, and expected return order: | 94 // Layout of the tiling data, and expected return order: |
| 93 // x 0 1 2 | 95 // x 0 1 2 |
| 94 // y ┌───┬───┬───┐ | 96 // y ┌───┬───┬───┐ |
| 95 // 0 │ 7│ 4│ 1│ | 97 // 0 │ 8│ 5│ 2│ |
| 96 // ├───┼───┼───┤ | 98 // ├───┼───┼───┤ |
| 97 // 1 │ 8│ 5│ 2│ * | 99 // 1 │ 7│ 4│ 1│ * |
| 98 // ├───┼───┼───┤ | 100 // ├───┼───┼───┤ |
| 99 // 2 │ 9│ 6│ 3│ | 101 // 2 │ 9│ 6│ 3│ |
| 100 // └───┴───┴───┘ | 102 // └───┴───┴───┘ |
| 101 expected.clear(); | 103 expected.clear(); |
| 104 expected.push_back(std::make_pair(2, 1)); |
| 102 expected.push_back(std::make_pair(2, 0)); | 105 expected.push_back(std::make_pair(2, 0)); |
| 103 expected.push_back(std::make_pair(2, 1)); | |
| 104 expected.push_back(std::make_pair(2, 2)); | 106 expected.push_back(std::make_pair(2, 2)); |
| 107 expected.push_back(std::make_pair(1, 1)); |
| 105 expected.push_back(std::make_pair(1, 0)); | 108 expected.push_back(std::make_pair(1, 0)); |
| 106 expected.push_back(std::make_pair(1, 1)); | |
| 107 expected.push_back(std::make_pair(1, 2)); | 109 expected.push_back(std::make_pair(1, 2)); |
| 110 expected.push_back(std::make_pair(0, 1)); |
| 108 expected.push_back(std::make_pair(0, 0)); | 111 expected.push_back(std::make_pair(0, 0)); |
| 109 expected.push_back(std::make_pair(0, 1)); | |
| 110 expected.push_back(std::make_pair(0, 2)); | 112 expected.push_back(std::make_pair(0, 2)); |
| 111 | 113 |
| 112 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 114 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 115 expected); |
| 113 | 116 |
| 114 // Center is the bottom right corner of the tiling. | 117 // Center is the bottom right corner of the tiling. |
| 115 center = gfx::Rect(25, 25, 1, 1); | 118 center = gfx::Rect(25, 25, 1, 1); |
| 116 | 119 |
| 117 // Layout of the tiling data, and expected return order: | 120 // Layout of the tiling data, and expected return order: |
| 118 // x 0 1 2 | 121 // x 0 1 2 |
| 119 // y ┌───┬───┬───┐ | 122 // y ┌───┬───┬───┐ |
| 120 // 0 │ 6│ 5│ 4│ | 123 // 0 │ 8│ 5│ 4│ |
| 121 // ├───┼───┼───┤ | 124 // ├───┼───┼───┤ |
| 122 // 1 │ 7│ 2│ 1│ | 125 // 1 │ 7│ 3│ 1│ |
| 123 // ├───┼───┼───┤ | 126 // ├───┼───┼───┤ |
| 124 // 2 │ 8│ 3│ *│ | 127 // 2 │ 6│ 2│ *│ |
| 125 // └───┴───┴───┘ | 128 // └───┴───┴───┘ |
| 126 expected.clear(); | 129 expected.clear(); |
| 127 expected.push_back(std::make_pair(2, 1)); | 130 expected.push_back(std::make_pair(2, 1)); |
| 131 expected.push_back(std::make_pair(1, 2)); |
| 128 expected.push_back(std::make_pair(1, 1)); | 132 expected.push_back(std::make_pair(1, 1)); |
| 129 expected.push_back(std::make_pair(1, 2)); | |
| 130 expected.push_back(std::make_pair(2, 0)); | 133 expected.push_back(std::make_pair(2, 0)); |
| 131 expected.push_back(std::make_pair(1, 0)); | 134 expected.push_back(std::make_pair(1, 0)); |
| 135 expected.push_back(std::make_pair(0, 2)); |
| 136 expected.push_back(std::make_pair(0, 1)); |
| 132 expected.push_back(std::make_pair(0, 0)); | 137 expected.push_back(std::make_pair(0, 0)); |
| 133 expected.push_back(std::make_pair(0, 1)); | |
| 134 expected.push_back(std::make_pair(0, 2)); | |
| 135 | 138 |
| 136 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 139 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 140 expected); |
| 137 | 141 |
| 138 // Center is off the top left side of the tiling. | 142 // Center is off the top left side of the tiling. |
| 139 center = gfx::Rect(-60, -50, 1, 1); | 143 center = gfx::Rect(-60, -50, 1, 1); |
| 140 | 144 |
| 141 // Layout of the tiling data, and expected return order: | 145 // Layout of the tiling data, and expected return order: |
| 142 // * x 0 1 2 | 146 // * x 0 1 2 |
| 143 // y ┌───┬───┬───┐ | 147 // y ┌───┬───┬───┐ |
| 144 // 0 │ 1│ 2│ 6│ | 148 // 0 │ 1│ 3│ 7│ |
| 145 // ├───┼───┼───┤ | 149 // ├───┼───┼───┤ |
| 146 // 1 │ 3│ 4│ 5│ | 150 // 1 │ 2│ 4│ 8│ |
| 147 // ├───┼───┼───┤ | 151 // ├───┼───┼───┤ |
| 148 // 2 │ 7│ 8│ 9│ | 152 // 2 │ 6│ 5│ 9│ |
| 149 // └───┴───┴───┘ | 153 // └───┴───┴───┘ |
| 150 expected.clear(); | 154 expected.clear(); |
| 151 expected.push_back(std::make_pair(0, 0)); | 155 expected.push_back(std::make_pair(0, 0)); |
| 156 expected.push_back(std::make_pair(0, 1)); |
| 152 expected.push_back(std::make_pair(1, 0)); | 157 expected.push_back(std::make_pair(1, 0)); |
| 153 expected.push_back(std::make_pair(0, 1)); | |
| 154 expected.push_back(std::make_pair(1, 1)); | 158 expected.push_back(std::make_pair(1, 1)); |
| 159 expected.push_back(std::make_pair(1, 2)); |
| 160 expected.push_back(std::make_pair(0, 2)); |
| 161 expected.push_back(std::make_pair(2, 0)); |
| 155 expected.push_back(std::make_pair(2, 1)); | 162 expected.push_back(std::make_pair(2, 1)); |
| 156 expected.push_back(std::make_pair(2, 0)); | |
| 157 expected.push_back(std::make_pair(0, 2)); | |
| 158 expected.push_back(std::make_pair(1, 2)); | |
| 159 expected.push_back(std::make_pair(2, 2)); | 163 expected.push_back(std::make_pair(2, 2)); |
| 160 | 164 |
| 161 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 165 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 166 expected); |
| 162 | 167 |
| 163 // Two tile center. | 168 // Two tile center. |
| 164 center = gfx::Rect(15, 15, 1, 10); | 169 center = gfx::Rect(15, 15, 1, 10); |
| 165 | 170 |
| 166 // Layout of the tiling data, and expected return order: | 171 // Layout of the tiling data, and expected return order: |
| 167 // x 0 1 2 | 172 // x 0 1 2 |
| 168 // y ┌───┬───┬───┐ | 173 // y ┌───┬───┬───┐ |
| 169 // 0 │ 5│ 4│ 3│ | 174 // 0 │ 7│ 4│ 3│ |
| 170 // ├───┼───┼───┤ | 175 // ├───┼───┼───┤ |
| 171 // 1 │ 6│ *│ 2│ | 176 // 1 │ 5│ *│ 2│ |
| 172 // ├───┼───┼───┤ | 177 // ├───┼───┼───┤ |
| 173 // 2 │ 7│ *│ 1│ | 178 // 2 │ 6│ *│ 1│ |
| 174 // └───┴───┴───┘ | 179 // └───┴───┴───┘ |
| 175 expected.clear(); | 180 expected.clear(); |
| 176 expected.push_back(std::make_pair(2, 2)); | 181 expected.push_back(std::make_pair(2, 2)); |
| 177 expected.push_back(std::make_pair(2, 1)); | 182 expected.push_back(std::make_pair(2, 1)); |
| 178 expected.push_back(std::make_pair(2, 0)); | 183 expected.push_back(std::make_pair(2, 0)); |
| 179 expected.push_back(std::make_pair(1, 0)); | 184 expected.push_back(std::make_pair(1, 0)); |
| 180 expected.push_back(std::make_pair(0, 0)); | |
| 181 expected.push_back(std::make_pair(0, 1)); | 185 expected.push_back(std::make_pair(0, 1)); |
| 182 expected.push_back(std::make_pair(0, 2)); | 186 expected.push_back(std::make_pair(0, 2)); |
| 187 expected.push_back(std::make_pair(0, 0)); |
| 183 | 188 |
| 184 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 189 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 190 expected); |
| 185 } | 191 } |
| 186 | 192 |
| 187 TEST(SpiralIteratorTest, SmallConsider) { | 193 TEST(PyramidSequenceTest, SmallConsider) { |
| 188 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false); | 194 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false); |
| 189 gfx::Rect ignore; | 195 gfx::Rect ignore; |
| 190 std::vector<std::pair<int, int>> expected; | 196 std::vector<std::pair<int, int>> expected; |
| 191 gfx::Rect center(15, 15, 1, 1); | 197 gfx::Rect center(15, 15, 1, 1); |
| 192 | 198 |
| 193 // Consider is one cell. | 199 // Consider is one cell. |
| 194 gfx::Rect consider(1, 1); | 200 gfx::Rect consider(1, 1); |
| 195 | 201 |
| 196 // Layout of the tiling data, and expected return order: | 202 // Layout of the tiling data, and expected return order: |
| 197 // x 0 1 2 3 4 | 203 // x 0 1 2 3 4 |
| 198 // y ┌───┬───┬───┬───┬───┐ | 204 // y ┌───┬───┬───┬───┬───┐ |
| 199 // 0 │ 1│ │ │ │ │ | 205 // 0 │ 1│ │ │ │ │ |
| 200 // ├───┼───┼───┼───┼───┤ | 206 // ├───┼───┼───┼───┼───┤ |
| 201 // 1 │ │ *│ │ │ │ | 207 // 1 │ │ *│ │ │ │ |
| 202 // ├───┼───┼───┼───┼───┤ | 208 // ├───┼───┼───┼───┼───┤ |
| 203 // 2 │ │ │ │ │ │ | 209 // 2 │ │ │ │ │ │ |
| 204 // ├───┼───┼───┼───┼───┤ | 210 // ├───┼───┼───┼───┼───┤ |
| 205 // 3 │ │ │ │ │ │ | 211 // 3 │ │ │ │ │ │ |
| 206 // ├───┼───┼───┼───┼───┤ | 212 // ├───┼───┼───┼───┼───┤ |
| 207 // 4 │ │ │ │ │ │ | 213 // 4 │ │ │ │ │ │ |
| 208 // └───┴───┴───┴───┴───┘ | 214 // └───┴───┴───┴───┴───┘ |
| 209 expected.push_back(std::make_pair(0, 0)); | 215 expected.push_back(std::make_pair(0, 0)); |
| 210 | 216 |
| 211 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 217 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 218 expected); |
| 212 | 219 |
| 213 // Consider is bottom right corner. | 220 // Consider is bottom right corner. |
| 214 consider = gfx::Rect(25, 25, 10, 10); | 221 consider = gfx::Rect(25, 25, 10, 10); |
| 215 | 222 |
| 216 // Layout of the tiling data, and expected return order: | 223 // Layout of the tiling data, and expected return order: |
| 217 // x 0 1 2 3 4 | 224 // x 0 1 2 3 4 |
| 218 // y ┌───┬───┬───┬───┬───┐ | 225 // y ┌───┬───┬───┬───┬───┐ |
| 219 // 0 │ │ │ │ │ │ | 226 // 0 │ │ │ │ │ │ |
| 220 // ├───┼───┼───┼───┼───┤ | 227 // ├───┼───┼───┼───┼───┤ |
| 221 // 1 │ │ *│ │ │ │ | 228 // 1 │ │ *│ │ │ │ |
| 222 // ├───┼───┼───┼───┼───┤ | 229 // ├───┼───┼───┼───┼───┤ |
| 223 // 2 │ │ │ 1│ 2│ │ | 230 // 2 │ │ │ 1│ 2│ │ |
| 224 // ├───┼───┼───┼───┼───┤ | 231 // ├───┼───┼───┼───┼───┤ |
| 225 // 3 │ │ │ 3│ 4│ │ | 232 // 3 │ │ │ 4│ 3│ │ |
| 226 // ├───┼───┼───┼───┼───┤ | 233 // ├───┼───┼───┼───┼───┤ |
| 227 // 4 │ │ │ │ │ │ | 234 // 4 │ │ │ │ │ │ |
| 228 // └───┴───┴───┴───┴───┘ | 235 // └───┴───┴───┴───┴───┘ |
| 229 expected.clear(); | 236 expected.clear(); |
| 230 expected.push_back(std::make_pair(2, 2)); | 237 expected.push_back(std::make_pair(2, 2)); |
| 231 expected.push_back(std::make_pair(3, 2)); | 238 expected.push_back(std::make_pair(3, 2)); |
| 239 expected.push_back(std::make_pair(3, 3)); |
| 232 expected.push_back(std::make_pair(2, 3)); | 240 expected.push_back(std::make_pair(2, 3)); |
| 233 expected.push_back(std::make_pair(3, 3)); | |
| 234 | 241 |
| 235 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 242 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 243 expected); |
| 236 | 244 |
| 237 // Consider is one column. | 245 // Consider is one column. |
| 238 consider = gfx::Rect(11, 0, 1, 100); | 246 consider = gfx::Rect(11, 0, 1, 100); |
| 239 | 247 |
| 240 // Layout of the tiling data, and expected return order: | 248 // Layout of the tiling data, and expected return order: |
| 241 // x 0 1 2 3 4 | 249 // x 0 1 2 3 4 |
| 242 // y ┌───┬───┬───┬───┬───┐ | 250 // y ┌───┬───┬───┬───┬───┐ |
| 243 // 0 │ │ 2│ │ │ │ | 251 // 0 │ │ 1│ │ │ │ |
| 244 // ├───┼───┼───┼───┼───┤ | 252 // ├───┼───┼───┼───┼───┤ |
| 245 // 1 │ │ *│ │ │ │ | 253 // 1 │ │ *│ │ │ │ |
| 246 // ├───┼───┼───┼───┼───┤ | 254 // ├───┼───┼───┼───┼───┤ |
| 247 // 2 │ │ 3│ │ │ │ | 255 // 2 │ │ 2│ │ │ │ |
| 248 // ├───┼───┼───┼───┼───┤ | 256 // ├───┼───┼───┼───┼───┤ |
| 249 // 3 │ │ 4│ │ │ │ | 257 // 3 │ │ 3│ │ │ │ |
| 250 // ├───┼───┼───┼───┼───┤ | 258 // ├───┼───┼───┼───┼───┤ |
| 251 // 4 │ │ 5│ │ │ │ | 259 // 4 │ │ 4│ │ │ │ |
| 252 // └───┴───┴───┴───┴───┘ | 260 // └───┴───┴───┴───┴───┘ |
| 253 expected.clear(); | 261 expected.clear(); |
| 254 expected.push_back(std::make_pair(1, 0)); | 262 expected.push_back(std::make_pair(1, 0)); |
| 255 expected.push_back(std::make_pair(1, 2)); | 263 expected.push_back(std::make_pair(1, 2)); |
| 256 expected.push_back(std::make_pair(1, 3)); | 264 expected.push_back(std::make_pair(1, 3)); |
| 257 expected.push_back(std::make_pair(1, 4)); | 265 expected.push_back(std::make_pair(1, 4)); |
| 258 | 266 |
| 259 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 267 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 268 expected); |
| 260 } | 269 } |
| 261 | 270 |
| 262 TEST(SpiralIteratorTest, HasIgnore) { | 271 TEST(PyramidSequenceTest, HasIgnore) { |
| 263 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false); | 272 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false); |
| 264 gfx::Rect consider(50, 50); | 273 gfx::Rect consider(50, 50); |
| 265 std::vector<std::pair<int, int>> expected; | 274 std::vector<std::pair<int, int>> expected; |
| 266 gfx::Rect center(15, 15, 1, 1); | 275 gfx::Rect center(15, 15, 1, 1); |
| 267 | 276 |
| 268 // Full ignore. | 277 // Full ignore. |
| 269 gfx::Rect ignore(50, 50); | 278 gfx::Rect ignore(50, 50); |
| 270 | 279 |
| 271 // Layout of the tiling data, and expected return order: | 280 // Layout of the tiling data, and expected return order: |
| 272 // x 0 1 2 3 4 | 281 // x 0 1 2 3 4 |
| 273 // y ┌───┬───┬───┬───┬───┐ | 282 // y ┌───┬───┬───┬───┬───┐ |
| 274 // 0 │ I│ I│ I│ I│ I│ | 283 // 0 │ I│ I│ I│ I│ I│ |
| 275 // ├───┼───┼───┼───┼───┤ | 284 // ├───┼───┼───┼───┼───┤ |
| 276 // 1 │ I│ *│ I│ I│ I│ | 285 // 1 │ I│ *│ I│ I│ I│ |
| 277 // ├───┼───┼───┼───┼───┤ | 286 // ├───┼───┼───┼───┼───┤ |
| 278 // 2 │ I│ I│ I│ I│ I│ | 287 // 2 │ I│ I│ I│ I│ I│ |
| 279 // ├───┼───┼───┼───┼───┤ | 288 // ├───┼───┼───┼───┼───┤ |
| 280 // 3 │ I│ I│ I│ I│ I│ | 289 // 3 │ I│ I│ I│ I│ I│ |
| 281 // ├───┼───┼───┼───┼───┤ | 290 // ├───┼───┼───┼───┼───┤ |
| 282 // 4 │ I│ I│ I│ I│ I│ | 291 // 4 │ I│ I│ I│ I│ I│ |
| 283 // └───┴───┴───┴───┴───┘ | 292 // └───┴───┴───┴───┴───┘ |
| 284 expected.clear(); | 293 expected.clear(); |
| 285 | 294 |
| 286 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 295 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 296 expected); |
| 287 | 297 |
| 288 // 3 column ignore. | 298 // 3 column ignore. |
| 289 ignore = gfx::Rect(15, 0, 20, 100); | 299 ignore = gfx::Rect(15, 0, 20, 100); |
| 290 | 300 |
| 291 // Layout of the tiling data, and expected return order: | 301 // Layout of the tiling data, and expected return order: |
| 292 // x 0 1 2 3 4 | 302 // x 0 1 2 3 4 |
| 293 // y ┌───┬───┬───┬───┬───┐ | 303 // y ┌───┬───┬───┬───┬───┐ |
| 294 // 0 │ 1│ I│ I│ I│ 8│ | 304 // 0 │ 2│ I│ I│ I│ 7│ |
| 295 // ├───┼───┼───┼───┼───┤ | 305 // ├───┼───┼───┼───┼───┤ |
| 296 // 1 │ 2│ *│ I│ I│ 7│ | 306 // 1 │ 1│ *│ I│ I│ 5│ |
| 297 // ├───┼───┼───┼───┼───┤ | 307 // ├───┼───┼───┼───┼───┤ |
| 298 // 2 │ 3│ I│ I│ I│ 6│ | 308 // 2 │ 3│ I│ I│ I│ 6│ |
| 299 // ├───┼───┼───┼───┼───┤ | 309 // ├───┼───┼───┼───┼───┤ |
| 300 // 3 │ 4│ I│ I│ I│ 5│ | 310 // 3 │ 4│ I│ I│ I│ 8│ |
| 301 // ├───┼───┼───┼───┼───┤ | 311 // ├───┼───┼───┼───┼───┤ |
| 302 // 4 │ 9│ I│ I│ I│ 10│ | 312 // 4 │ 10│ I│ I│ I│ 9│ |
| 303 // └───┴───┴───┴───┴───┘ | 313 // └───┴───┴───┴───┴───┘ |
| 304 expected.clear(); | 314 expected.clear(); |
| 315 expected.push_back(std::make_pair(0, 1)); |
| 305 expected.push_back(std::make_pair(0, 0)); | 316 expected.push_back(std::make_pair(0, 0)); |
| 306 expected.push_back(std::make_pair(0, 1)); | |
| 307 expected.push_back(std::make_pair(0, 2)); | 317 expected.push_back(std::make_pair(0, 2)); |
| 308 expected.push_back(std::make_pair(0, 3)); | 318 expected.push_back(std::make_pair(0, 3)); |
| 319 expected.push_back(std::make_pair(4, 1)); |
| 320 expected.push_back(std::make_pair(4, 2)); |
| 321 expected.push_back(std::make_pair(4, 0)); |
| 309 expected.push_back(std::make_pair(4, 3)); | 322 expected.push_back(std::make_pair(4, 3)); |
| 310 expected.push_back(std::make_pair(4, 2)); | 323 expected.push_back(std::make_pair(4, 4)); |
| 311 expected.push_back(std::make_pair(4, 1)); | |
| 312 expected.push_back(std::make_pair(4, 0)); | |
| 313 expected.push_back(std::make_pair(0, 4)); | 324 expected.push_back(std::make_pair(0, 4)); |
| 314 expected.push_back(std::make_pair(4, 4)); | |
| 315 | 325 |
| 316 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 326 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 327 expected); |
| 317 | 328 |
| 318 // Ignore covers the top half. | 329 // Ignore covers the top half. |
| 319 ignore = gfx::Rect(50, 25); | 330 ignore = gfx::Rect(50, 25); |
| 320 | 331 |
| 321 // Layout of the tiling data, and expected return order: | 332 // Layout of the tiling data, and expected return order: |
| 322 // x 0 1 2 3 4 | 333 // x 0 1 2 3 4 |
| 323 // y ┌───┬───┬───┬───┬───┐ | 334 // y ┌───┬───┬───┬───┬───┐ |
| 324 // 0 │ I│ I│ I│ I│ I│ | 335 // 0 │ I│ I│ I│ I│ I│ |
| 325 // ├───┼───┼───┼───┼───┤ | 336 // ├───┼───┼───┼───┼───┤ |
| 326 // 1 │ I│ *│ I│ I│ I│ | 337 // 1 │ I│ *│ I│ I│ I│ |
| 327 // ├───┼───┼───┼───┼───┤ | 338 // ├───┼───┼───┼───┼───┤ |
| 328 // 2 │ I│ I│ I│ I│ I│ | 339 // 2 │ I│ I│ I│ I│ I│ |
| 329 // ├───┼───┼───┼───┼───┤ | 340 // ├───┼───┼───┼───┼───┤ |
| 330 // 3 │ 1│ 2│ 3│ 4│ 5│ | 341 // 3 │ 3│ 2│ 4│ 1│ 5│ |
| 331 // ├───┼───┼───┼───┼───┤ | 342 // ├───┼───┼───┼───┼───┤ |
| 332 // 4 │ 6│ 7│ 8│ 9│ 10│ | 343 // 4 │ 8│ 7│ 9│ 10│ 6│ |
| 333 // └───┴───┴───┴───┴───┘ | 344 // └───┴───┴───┴───┴───┘ |
| 334 expected.clear(); | 345 expected.clear(); |
| 346 expected.push_back(std::make_pair(3, 3)); |
| 347 expected.push_back(std::make_pair(1, 3)); |
| 335 expected.push_back(std::make_pair(0, 3)); | 348 expected.push_back(std::make_pair(0, 3)); |
| 336 expected.push_back(std::make_pair(1, 3)); | |
| 337 expected.push_back(std::make_pair(2, 3)); | 349 expected.push_back(std::make_pair(2, 3)); |
| 338 expected.push_back(std::make_pair(3, 3)); | |
| 339 expected.push_back(std::make_pair(4, 3)); | 350 expected.push_back(std::make_pair(4, 3)); |
| 351 expected.push_back(std::make_pair(4, 4)); |
| 352 expected.push_back(std::make_pair(1, 4)); |
| 340 expected.push_back(std::make_pair(0, 4)); | 353 expected.push_back(std::make_pair(0, 4)); |
| 341 expected.push_back(std::make_pair(1, 4)); | |
| 342 expected.push_back(std::make_pair(2, 4)); | 354 expected.push_back(std::make_pair(2, 4)); |
| 343 expected.push_back(std::make_pair(3, 4)); | 355 expected.push_back(std::make_pair(3, 4)); |
| 344 expected.push_back(std::make_pair(4, 4)); | |
| 345 | 356 |
| 346 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 357 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 358 expected); |
| 347 } | 359 } |
| 348 | 360 |
| 349 TEST(SpiralIteratorTest, RectangleCenter) { | 361 TEST(PyramidSequenceTest, RectangleCenter) { |
| 350 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false); | 362 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false); |
| 351 gfx::Rect consider(50, 50); | 363 gfx::Rect consider(50, 50); |
| 352 std::vector<std::pair<int, int>> expected; | 364 std::vector<std::pair<int, int>> expected; |
| 353 gfx::Rect ignore; | 365 gfx::Rect ignore; |
| 354 | 366 |
| 355 // Two cell center | 367 // Two cell center |
| 356 gfx::Rect center(25, 25, 1, 10); | 368 gfx::Rect center(25, 25, 1, 10); |
| 357 | 369 |
| 358 // Layout of the tiling data, and expected return order: | 370 // Layout of the tiling data, and expected return order: |
| 359 // x 0 1 2 3 4 | 371 // x 0 1 2 3 4 |
| 360 // y ┌───┬───┬───┬───┬───┐ | 372 // y ┌───┬───┬───┬───┬───┐ |
| 361 // 0 │ 19│ 18│ 17│ 16│ 15│ | 373 // 0 │ 23│ 18│ 16│ 17│ 15│ |
| 362 // ├───┼───┼───┼───┼───┤ | 374 // ├───┼───┼───┼───┼───┤ |
| 363 // 1 │ 20│ 5│ 4│ 3│ 14│ | 375 // 1 │ 21│ 8│ 5│ 4│ 14│ |
| 364 // ├───┼───┼───┼───┼───┤ | 376 // ├───┼───┼───┼───┼───┤ |
| 365 // 2 │ 21│ 6│ *│ 2│ 13│ | 377 // 2 │ 19│ 6│ *│ 2│ 12│ |
| 366 // ├───┼───┼───┼───┼───┤ | 378 // ├───┼───┼───┼───┼───┤ |
| 367 // 3 │ 22│ 7│ *│ 1│ 12│ | 379 // 3 │ 20│ 7│ *│ 1│ 11│ |
| 368 // ├───┼───┼───┼───┼───┤ | 380 // ├───┼───┼───┼───┼───┤ |
| 369 // 4 │ 23│ 8│ 9│ 10│ 11│ | 381 // 4 │ 22│ 9│ 10│ 3│ 13│ |
| 370 // └───┴───┴───┴───┴───┘ | 382 // └───┴───┴───┴───┴───┘ |
| 371 expected.clear(); | 383 expected.clear(); |
| 372 expected.push_back(std::make_pair(3, 3)); | 384 expected.push_back(std::make_pair(3, 3)); |
| 373 expected.push_back(std::make_pair(3, 2)); | 385 expected.push_back(std::make_pair(3, 2)); |
| 386 expected.push_back(std::make_pair(3, 4)); |
| 374 expected.push_back(std::make_pair(3, 1)); | 387 expected.push_back(std::make_pair(3, 1)); |
| 375 expected.push_back(std::make_pair(2, 1)); | 388 expected.push_back(std::make_pair(2, 1)); |
| 376 expected.push_back(std::make_pair(1, 1)); | |
| 377 expected.push_back(std::make_pair(1, 2)); | 389 expected.push_back(std::make_pair(1, 2)); |
| 378 expected.push_back(std::make_pair(1, 3)); | 390 expected.push_back(std::make_pair(1, 3)); |
| 391 expected.push_back(std::make_pair(1, 1)); |
| 379 expected.push_back(std::make_pair(1, 4)); | 392 expected.push_back(std::make_pair(1, 4)); |
| 380 expected.push_back(std::make_pair(2, 4)); | 393 expected.push_back(std::make_pair(2, 4)); |
| 381 expected.push_back(std::make_pair(3, 4)); | |
| 382 expected.push_back(std::make_pair(4, 4)); | |
| 383 expected.push_back(std::make_pair(4, 3)); | 394 expected.push_back(std::make_pair(4, 3)); |
| 384 expected.push_back(std::make_pair(4, 2)); | 395 expected.push_back(std::make_pair(4, 2)); |
| 396 expected.push_back(std::make_pair(4, 4)); |
| 385 expected.push_back(std::make_pair(4, 1)); | 397 expected.push_back(std::make_pair(4, 1)); |
| 386 expected.push_back(std::make_pair(4, 0)); | 398 expected.push_back(std::make_pair(4, 0)); |
| 399 expected.push_back(std::make_pair(2, 0)); |
| 387 expected.push_back(std::make_pair(3, 0)); | 400 expected.push_back(std::make_pair(3, 0)); |
| 388 expected.push_back(std::make_pair(2, 0)); | |
| 389 expected.push_back(std::make_pair(1, 0)); | 401 expected.push_back(std::make_pair(1, 0)); |
| 390 expected.push_back(std::make_pair(0, 0)); | |
| 391 expected.push_back(std::make_pair(0, 1)); | |
| 392 expected.push_back(std::make_pair(0, 2)); | 402 expected.push_back(std::make_pair(0, 2)); |
| 393 expected.push_back(std::make_pair(0, 3)); | 403 expected.push_back(std::make_pair(0, 3)); |
| 404 expected.push_back(std::make_pair(0, 1)); |
| 394 expected.push_back(std::make_pair(0, 4)); | 405 expected.push_back(std::make_pair(0, 4)); |
| 406 expected.push_back(std::make_pair(0, 0)); |
| 395 | 407 |
| 396 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 408 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 409 expected); |
| 397 | 410 |
| 398 // Three by two center. | 411 // Three by two center. |
| 399 center = gfx::Rect(15, 25, 20, 10); | 412 center = gfx::Rect(15, 25, 20, 10); |
| 400 | 413 |
| 401 // Layout of the tiling data, and expected return order: | 414 // Layout of the tiling data, and expected return order: |
| 402 // x 0 1 2 3 4 | 415 // x 0 1 2 3 4 |
| 403 // y ┌───┬───┬───┬───┬───┐ | 416 // y ┌───┬───┬───┬───┬───┐ |
| 404 // 0 │ 19│ 18│ 17│ 16│ 15│ | 417 // 0 │ 19│ 17│ 16│ 15│ 18│ |
| 405 // ├───┼───┼───┼───┼───┤ | 418 // ├───┼───┼───┼───┼───┤ |
| 406 // 1 │ 7│ 6│ 5│ 4│ 3│ | 419 // 1 │ 10│ 7│ 6│ 5│ 4│ |
| 407 // ├───┼───┼───┼───┼───┤ | 420 // ├───┼───┼───┼───┼───┤ |
| 408 // 2 │ 8│ *│ *│ *│ 2│ | 421 // 2 │ 8│ *│ *│ *│ 2│ |
| 409 // ├───┼───┼───┼───┼───┤ | 422 // ├───┼───┼───┼───┼───┤ |
| 410 // 3 │ 9│ *│ *│ *│ 1│ | 423 // 3 │ 9│ *│ *│ *│ 1│ |
| 411 // ├───┼───┼───┼───┼───┤ | 424 // ├───┼───┼───┼───┼───┤ |
| 412 // 4 │ 10│ 11│ 12│ 13│ 14│ | 425 // 4 │ 11│ 12│ 13│ 14│ 3│ |
| 413 // └───┴───┴───┴───┴───┘ | 426 // └───┴───┴───┴───┴───┘ |
| 414 expected.clear(); | 427 expected.clear(); |
| 415 expected.push_back(std::make_pair(4, 3)); | 428 expected.push_back(std::make_pair(4, 3)); |
| 416 expected.push_back(std::make_pair(4, 2)); | 429 expected.push_back(std::make_pair(4, 2)); |
| 430 expected.push_back(std::make_pair(4, 4)); |
| 417 expected.push_back(std::make_pair(4, 1)); | 431 expected.push_back(std::make_pair(4, 1)); |
| 418 expected.push_back(std::make_pair(3, 1)); | 432 expected.push_back(std::make_pair(3, 1)); |
| 419 expected.push_back(std::make_pair(2, 1)); | 433 expected.push_back(std::make_pair(2, 1)); |
| 420 expected.push_back(std::make_pair(1, 1)); | 434 expected.push_back(std::make_pair(1, 1)); |
| 421 expected.push_back(std::make_pair(0, 1)); | |
| 422 expected.push_back(std::make_pair(0, 2)); | 435 expected.push_back(std::make_pair(0, 2)); |
| 423 expected.push_back(std::make_pair(0, 3)); | 436 expected.push_back(std::make_pair(0, 3)); |
| 437 expected.push_back(std::make_pair(0, 1)); |
| 424 expected.push_back(std::make_pair(0, 4)); | 438 expected.push_back(std::make_pair(0, 4)); |
| 425 expected.push_back(std::make_pair(1, 4)); | 439 expected.push_back(std::make_pair(1, 4)); |
| 426 expected.push_back(std::make_pair(2, 4)); | 440 expected.push_back(std::make_pair(2, 4)); |
| 427 expected.push_back(std::make_pair(3, 4)); | 441 expected.push_back(std::make_pair(3, 4)); |
| 428 expected.push_back(std::make_pair(4, 4)); | |
| 429 expected.push_back(std::make_pair(4, 0)); | |
| 430 expected.push_back(std::make_pair(3, 0)); | 442 expected.push_back(std::make_pair(3, 0)); |
| 431 expected.push_back(std::make_pair(2, 0)); | 443 expected.push_back(std::make_pair(2, 0)); |
| 432 expected.push_back(std::make_pair(1, 0)); | 444 expected.push_back(std::make_pair(1, 0)); |
| 445 expected.push_back(std::make_pair(4, 0)); |
| 433 expected.push_back(std::make_pair(0, 0)); | 446 expected.push_back(std::make_pair(0, 0)); |
| 434 | 447 |
| 435 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 448 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 449 expected); |
| 436 | 450 |
| 437 // Column center off the left side. | 451 // Column center off the left side. |
| 438 center = gfx::Rect(-50, 0, 30, 50); | 452 center = gfx::Rect(-50, 0, 30, 50); |
| 439 | 453 |
| 440 // Layout of the tiling data, and expected return order: | 454 // Layout of the tiling data, and expected return order: |
| 441 // x 0 1 2 3 4 | 455 // x 0 1 2 3 4 |
| 442 // y ┌───┬───┬───┬───┬───┐ | 456 // y ┌───┬───┬───┬───┬───┐ |
| 443 // * 0 │ 5│ 10│ 15│ 20│ 25│ | 457 // * 0 │ 5│ 10│ 15│ 20│ 25│ |
| 444 // ├───┼───┼───┼───┼───┤ | 458 // ├───┼───┼───┼───┼───┤ |
| 445 // * 1 │ 4│ 9│ 14│ 19│ 24│ | 459 // * 1 │ 4│ 9│ 14│ 19│ 24│ |
| (...skipping 24 matching lines...) Expand all Loading... |
| 470 expected.push_back(std::make_pair(3, 3)); | 484 expected.push_back(std::make_pair(3, 3)); |
| 471 expected.push_back(std::make_pair(3, 2)); | 485 expected.push_back(std::make_pair(3, 2)); |
| 472 expected.push_back(std::make_pair(3, 1)); | 486 expected.push_back(std::make_pair(3, 1)); |
| 473 expected.push_back(std::make_pair(3, 0)); | 487 expected.push_back(std::make_pair(3, 0)); |
| 474 expected.push_back(std::make_pair(4, 4)); | 488 expected.push_back(std::make_pair(4, 4)); |
| 475 expected.push_back(std::make_pair(4, 3)); | 489 expected.push_back(std::make_pair(4, 3)); |
| 476 expected.push_back(std::make_pair(4, 2)); | 490 expected.push_back(std::make_pair(4, 2)); |
| 477 expected.push_back(std::make_pair(4, 1)); | 491 expected.push_back(std::make_pair(4, 1)); |
| 478 expected.push_back(std::make_pair(4, 0)); | 492 expected.push_back(std::make_pair(4, 0)); |
| 479 | 493 |
| 480 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 494 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 495 expected); |
| 481 } | 496 } |
| 482 | 497 |
| 483 TEST(SpiralIteratorTest, EdgeCases) { | 498 TEST(PyramidSequenceTest, EdgeCases) { |
| 484 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(30, 30), false); | 499 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(30, 30), false); |
| 485 std::vector<std::pair<int, int>> expected; | 500 std::vector<std::pair<int, int>> expected; |
| 486 gfx::Rect center; | 501 gfx::Rect center; |
| 487 gfx::Rect consider; | 502 gfx::Rect consider; |
| 488 gfx::Rect ignore; | 503 gfx::Rect ignore; |
| 489 | 504 |
| 490 // Ignore contains, but is not equal to, consider and center. | 505 // Ignore contains, but is not equal to, consider and center. |
| 491 ignore = gfx::Rect(15, 0, 20, 30); | 506 ignore = gfx::Rect(15, 0, 20, 30); |
| 492 consider = gfx::Rect(20, 10, 10, 20); | 507 consider = gfx::Rect(20, 10, 10, 20); |
| 493 center = gfx::Rect(25, 0, 5, 5); | 508 center = gfx::Rect(25, 0, 5, 5); |
| 494 | 509 |
| 495 // Layout of the tiling data, and expected return order: | 510 // Layout of the tiling data, and expected return order: |
| 496 // x 0 1 2 | 511 // x 0 1 2 |
| 497 // y ┌───┬───┬───┐ | 512 // y ┌───┬───┬───┐ |
| 498 // 0 │ │ I│ *│ | 513 // 0 │ │ I│ *│ |
| 499 // ├───┼───┼───┤ | 514 // ├───┼───┼───┤ |
| 500 // 1 │ │ I│ I│ | 515 // 1 │ │ I│ I│ |
| 501 // ├───┼───┼───┤ | 516 // ├───┼───┼───┤ |
| 502 // 2 │ │ I│ I│ | 517 // 2 │ │ I│ I│ |
| 503 // └───┴───┴───┘ | 518 // └───┴───┴───┘ |
| 504 expected.clear(); | 519 expected.clear(); |
| 505 | 520 |
| 506 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 521 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 522 expected); |
| 507 | 523 |
| 508 // Center intersects with consider. | 524 // Center intersects with consider. |
| 509 ignore = gfx::Rect(); | 525 ignore = gfx::Rect(); |
| 510 center = gfx::Rect(0, 15, 30, 15); | 526 center = gfx::Rect(0, 15, 30, 15); |
| 511 consider = gfx::Rect(15, 30); | 527 consider = gfx::Rect(15, 30); |
| 512 | 528 |
| 513 // Layout of the tiling data, and expected return order: | 529 // Layout of the tiling data, and expected return order: |
| 514 // x 0 1 2 | 530 // x 0 1 2 |
| 515 // y ┌───┬───┬───┐ | 531 // y ┌───┬───┬───┐ |
| 516 // 0 │ 2│ 1│ │ | 532 // 0 │ 2│ 1│ │ |
| 517 // ├───┼───┼───┤ | 533 // ├───┼───┼───┤ |
| 518 // 1 │ *│ *│ *│ | 534 // 1 │ *│ *│ *│ |
| 519 // ├───┼───┼───┤ | 535 // ├───┼───┼───┤ |
| 520 // 2 │ *│ *│ *│ | 536 // 2 │ *│ *│ *│ |
| 521 // └───┴───┴───┘ | 537 // └───┴───┴───┘ |
| 522 expected.clear(); | 538 expected.clear(); |
| 523 expected.push_back(std::make_pair(1, 0)); | 539 expected.push_back(std::make_pair(1, 0)); |
| 524 expected.push_back(std::make_pair(0, 0)); | 540 expected.push_back(std::make_pair(0, 0)); |
| 525 | 541 |
| 526 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 542 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 543 expected); |
| 527 | 544 |
| 528 // Consider and ignore are non-intersecting. | 545 // Consider and ignore are non-intersecting. |
| 529 ignore = gfx::Rect(5, 30); | 546 ignore = gfx::Rect(5, 30); |
| 530 consider = gfx::Rect(25, 0, 5, 30); | 547 consider = gfx::Rect(25, 0, 5, 30); |
| 531 center = gfx::Rect(15, 0, 1, 1); | 548 center = gfx::Rect(15, 0, 1, 1); |
| 532 | 549 |
| 533 // Layout of the tiling data, and expected return order: | 550 // Layout of the tiling data, and expected return order: |
| 534 // x 0 1 2 | 551 // x 0 1 2 |
| 535 // y ┌───┬───┬───┐ | 552 // y ┌───┬───┬───┐ |
| 536 // 0 │ I│ *│ 1│ | 553 // 0 │ I│ *│ 1│ |
| 537 // ├───┼───┼───┤ | 554 // ├───┼───┼───┤ |
| 538 // 1 │ I│ │ 2│ | 555 // 1 │ I│ │ 2│ |
| 539 // ├───┼───┼───┤ | 556 // ├───┼───┼───┤ |
| 540 // 2 │ I│ │ 3│ | 557 // 2 │ I│ │ 3│ |
| 541 // └───┴───┴───┘ | 558 // └───┴───┴───┘ |
| 542 expected.clear(); | 559 expected.clear(); |
| 543 expected.push_back(std::make_pair(2, 0)); | 560 expected.push_back(std::make_pair(2, 0)); |
| 544 expected.push_back(std::make_pair(2, 1)); | 561 expected.push_back(std::make_pair(2, 1)); |
| 545 expected.push_back(std::make_pair(2, 2)); | 562 expected.push_back(std::make_pair(2, 2)); |
| 546 | 563 |
| 547 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 564 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 565 expected); |
| 548 | 566 |
| 549 // Center intersects with ignore. | 567 // Center intersects with ignore. |
| 550 consider = gfx::Rect(30, 30); | 568 consider = gfx::Rect(30, 30); |
| 551 center = gfx::Rect(15, 0, 1, 30); | 569 center = gfx::Rect(15, 0, 1, 30); |
| 552 ignore = gfx::Rect(0, 15, 30, 1); | 570 ignore = gfx::Rect(0, 15, 30, 1); |
| 553 | 571 |
| 554 // Layout of the tiling data, and expected return order: | 572 // Layout of the tiling data, and expected return order: |
| 555 // x 0 1 2 | 573 // x 0 1 2 |
| 556 // y ┌───┬───┬───┐ | 574 // y ┌───┬───┬───┐ |
| 557 // 0 │ 3│ *│ 2│ | 575 // 0 │ 3│ *│ 2│ |
| 558 // ├───┼───┼───┤ | 576 // ├───┼───┼───┤ |
| 559 // 1 │ I│ *│ I│ | 577 // 1 │ I│ *│ I│ |
| 560 // ├───┼───┼───┤ | 578 // ├───┼───┼───┤ |
| 561 // 2 │ 4│ *│ 1│ | 579 // 2 │ 4│ *│ 1│ |
| 562 // └───┴───┴───┘ | 580 // └───┴───┴───┘ |
| 563 expected.clear(); | 581 expected.clear(); |
| 564 expected.push_back(std::make_pair(2, 2)); | 582 expected.push_back(std::make_pair(2, 2)); |
| 565 expected.push_back(std::make_pair(2, 0)); | 583 expected.push_back(std::make_pair(2, 0)); |
| 566 expected.push_back(std::make_pair(0, 0)); | 584 expected.push_back(std::make_pair(0, 0)); |
| 567 expected.push_back(std::make_pair(0, 2)); | 585 expected.push_back(std::make_pair(0, 2)); |
| 568 | 586 |
| 569 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 587 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 588 expected); |
| 570 | 589 |
| 571 // Center and ignore are the same. | 590 // Center and ignore are the same. |
| 572 consider = gfx::Rect(30, 30); | 591 consider = gfx::Rect(30, 30); |
| 573 center = gfx::Rect(15, 0, 1, 30); | 592 center = gfx::Rect(15, 0, 1, 30); |
| 574 ignore = center; | 593 ignore = center; |
| 575 | 594 |
| 576 // Layout of the tiling data, and expected return order: | 595 // Layout of the tiling data, and expected return order: |
| 577 // x 0 1 2 | 596 // x 0 1 2 |
| 578 // y ┌───┬───┬───┐ | 597 // y ┌───┬───┬───┐ |
| 579 // 0 │ 4│ *│ 3│ | 598 // 0 │ 4│ *│ 3│ |
| 580 // ├───┼───┼───┤ | 599 // ├───┼───┼───┤ |
| 581 // 1 │ 5│ *│ 2│ | 600 // 1 │ 5│ *│ 2│ |
| 582 // ├───┼───┼───┤ | 601 // ├───┼───┼───┤ |
| 583 // 2 │ 6│ *│ 1│ | 602 // 2 │ 6│ *│ 1│ |
| 584 // └───┴───┴───┘ | 603 // └───┴───┴───┘ |
| 585 expected.clear(); | 604 expected.clear(); |
| 586 expected.push_back(std::make_pair(2, 2)); | 605 expected.push_back(std::make_pair(2, 2)); |
| 587 expected.push_back(std::make_pair(2, 1)); | 606 expected.push_back(std::make_pair(2, 1)); |
| 588 expected.push_back(std::make_pair(2, 0)); | 607 expected.push_back(std::make_pair(2, 0)); |
| 589 expected.push_back(std::make_pair(0, 0)); | 608 expected.push_back(std::make_pair(0, 0)); |
| 590 expected.push_back(std::make_pair(0, 1)); | 609 expected.push_back(std::make_pair(0, 1)); |
| 591 expected.push_back(std::make_pair(0, 2)); | 610 expected.push_back(std::make_pair(0, 2)); |
| 592 | 611 |
| 593 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 612 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 613 expected); |
| 594 | 614 |
| 595 // Empty tiling data. | 615 // Empty tiling data. |
| 596 TilingData empty_data(gfx::Size(0, 0), gfx::Size(0, 0), false); | 616 TilingData empty_data(gfx::Size(0, 0), gfx::Size(0, 0), false); |
| 597 | 617 |
| 598 expected.clear(); | 618 expected.clear(); |
| 599 | 619 |
| 600 TestSpiralIterate(__LINE__, empty_data, consider, ignore, center, expected); | 620 TestPyramidSequenceIterate(__LINE__, empty_data, consider, ignore, center, |
| 621 expected); |
| 601 | 622 |
| 602 // Empty consider. | 623 // Empty consider. |
| 603 ignore = gfx::Rect(); | 624 ignore = gfx::Rect(); |
| 604 center = gfx::Rect(1, 1, 1, 1); | 625 center = gfx::Rect(1, 1, 1, 1); |
| 605 consider = gfx::Rect(); | 626 consider = gfx::Rect(); |
| 606 | 627 |
| 607 expected.clear(); | 628 expected.clear(); |
| 608 | 629 |
| 609 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 630 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 631 expected); |
| 610 | 632 |
| 611 // Empty center. Note: This arbitrarily puts the center to be off the top-left | 633 // Empty center. Note: This arbitrarily puts the center to be off the top-left |
| 612 // corner. | 634 // corner. |
| 613 consider = gfx::Rect(30, 30); | 635 consider = gfx::Rect(30, 30); |
| 614 ignore = gfx::Rect(); | 636 ignore = gfx::Rect(); |
| 615 center = gfx::Rect(); | 637 center = gfx::Rect(); |
| 616 | 638 |
| 617 // Layout of the tiling data, and expected return order: | 639 // Layout of the tiling data, and expected return order: |
| 618 // x 0 1 2 | 640 // x 0 1 2 |
| 619 // y ┌───┬───┬───┐ | 641 // y ┌───┬───┬───┐ |
| 620 // 0 │ 1│ 2│ 6│ | 642 // 0 │ 1│ 2│ 5│ |
| 621 // ├───┼───┼───┤ | 643 // ├───┼───┼───┤ |
| 622 // 1 │ 3│ 4│ 5│ | 644 // 1 │ 4│ 3│ 6│ |
| 623 // ├───┼───┼───┤ | 645 // ├───┼───┼───┤ |
| 624 // 2 │ 7│ 8│ 9│ | 646 // 2 │ 8│ 9│ 7│ |
| 625 // └───┴───┴───┘ | 647 // └───┴───┴───┘ |
| 626 expected.clear(); | 648 expected.clear(); |
| 627 expected.push_back(std::make_pair(0, 0)); | 649 expected.push_back(std::make_pair(0, 0)); |
| 628 expected.push_back(std::make_pair(1, 0)); | 650 expected.push_back(std::make_pair(1, 0)); |
| 651 expected.push_back(std::make_pair(1, 1)); |
| 629 expected.push_back(std::make_pair(0, 1)); | 652 expected.push_back(std::make_pair(0, 1)); |
| 630 expected.push_back(std::make_pair(1, 1)); | 653 expected.push_back(std::make_pair(2, 0)); |
| 631 expected.push_back(std::make_pair(2, 1)); | 654 expected.push_back(std::make_pair(2, 1)); |
| 632 expected.push_back(std::make_pair(2, 0)); | 655 expected.push_back(std::make_pair(2, 2)); |
| 633 expected.push_back(std::make_pair(0, 2)); | 656 expected.push_back(std::make_pair(0, 2)); |
| 634 expected.push_back(std::make_pair(1, 2)); | 657 expected.push_back(std::make_pair(1, 2)); |
| 635 expected.push_back(std::make_pair(2, 2)); | |
| 636 | 658 |
| 637 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 659 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 660 expected); |
| 638 | 661 |
| 639 // Every rect is empty. | 662 // Every rect is empty. |
| 640 ignore = gfx::Rect(); | 663 ignore = gfx::Rect(); |
| 641 center = gfx::Rect(); | 664 center = gfx::Rect(); |
| 642 consider = gfx::Rect(); | 665 consider = gfx::Rect(); |
| 643 | 666 |
| 644 expected.clear(); | 667 expected.clear(); |
| 645 | 668 |
| 646 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 669 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 670 expected); |
| 647 | 671 |
| 648 // Center is just to the left of cover, and off of the tiling's left side. | 672 // Center is just to the left of cover, and off of the tiling's left side. |
| 649 consider = gfx::Rect(30, 30); | 673 consider = gfx::Rect(30, 30); |
| 650 ignore = gfx::Rect(); | 674 ignore = gfx::Rect(); |
| 651 center = gfx::Rect(-20, 0, 19, 30); | 675 center = gfx::Rect(-20, 0, 19, 30); |
| 652 | 676 |
| 653 // Layout of the tiling data, and expected return order: | 677 // Layout of the tiling data, and expected return order: |
| 654 // x 0 1 2 | 678 // x 0 1 2 |
| 655 // y ┌───┬───┬───┐ | 679 // y ┌───┬───┬───┐ |
| 656 // * 0 │ 3│ 6│ 9│ | 680 // * 0 │ 3│ 6│ 9│ |
| 657 // ├───┼───┼───┤ | 681 // ├───┼───┼───┤ |
| 658 // * 1 │ 2│ 5│ 8│ | 682 // * 1 │ 2│ 5│ 8│ |
| 659 // ├───┼───┼───┤ | 683 // ├───┼───┼───┤ |
| 660 // * 2 │ 1│ 4│ 7│ | 684 // * 2 │ 1│ 4│ 7│ |
| 661 // └───┴───┴───┘ | 685 // └───┴───┴───┘ |
| 662 expected.clear(); | 686 expected.clear(); |
| 663 expected.push_back(std::make_pair(0, 2)); | 687 expected.push_back(std::make_pair(0, 2)); |
| 664 expected.push_back(std::make_pair(0, 1)); | 688 expected.push_back(std::make_pair(0, 1)); |
| 665 expected.push_back(std::make_pair(0, 0)); | 689 expected.push_back(std::make_pair(0, 0)); |
| 666 expected.push_back(std::make_pair(1, 2)); | 690 expected.push_back(std::make_pair(1, 2)); |
| 667 expected.push_back(std::make_pair(1, 1)); | 691 expected.push_back(std::make_pair(1, 1)); |
| 668 expected.push_back(std::make_pair(1, 0)); | 692 expected.push_back(std::make_pair(1, 0)); |
| 669 expected.push_back(std::make_pair(2, 2)); | 693 expected.push_back(std::make_pair(2, 2)); |
| 670 expected.push_back(std::make_pair(2, 1)); | 694 expected.push_back(std::make_pair(2, 1)); |
| 671 expected.push_back(std::make_pair(2, 0)); | 695 expected.push_back(std::make_pair(2, 0)); |
| 672 | 696 |
| 673 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 697 TestPyramidSequenceIterate(__LINE__, tiling_data, consider, ignore, center, |
| 698 expected); |
| 674 | 699 |
| 675 // Tiling is smaller than tile size and center rect is not intersecting to | 700 // Tiling is smaller than tile size and center rect is not intersecting to |
| 676 // tiling rect. | 701 // tiling rect. |
| 677 TilingData smaller_tiling(gfx::Size(10, 10), gfx::Size(1, 1), false); | 702 TilingData smaller_tiling(gfx::Size(10, 10), gfx::Size(1, 1), false); |
| 678 consider = gfx::Rect(10, 10); | 703 consider = gfx::Rect(10, 10); |
| 679 ignore = gfx::Rect(); | 704 ignore = gfx::Rect(); |
| 680 center = gfx::Rect(2, 2, 10, 10); | 705 center = gfx::Rect(2, 2, 10, 10); |
| 681 | 706 |
| 682 // Layout of the tiling data, and expected return order: | 707 // Layout of the tiling data, and expected return order: |
| 683 // x 0 | 708 // x 0 |
| 684 // y ┌───────┐ | 709 // y ┌───────┐ |
| 685 // │ 1 │ | 710 // │ 1 │ |
| 686 // 0 │ │ | 711 // 0 │ │ |
| 687 // │ * │ | 712 // │ * │ |
| 688 // └───────┘ | 713 // └───────┘ |
| 689 expected.clear(); | 714 expected.clear(); |
| 690 expected.push_back(std::make_pair(0, 0)); | 715 expected.push_back(std::make_pair(0, 0)); |
| 691 | 716 |
| 692 TestSpiralIterate(__LINE__, smaller_tiling, consider, ignore, center, | 717 TestPyramidSequenceIterate(__LINE__, smaller_tiling, consider, ignore, center, |
| 693 expected); | 718 expected); |
| 694 } | 719 } |
| 695 | 720 |
| 696 } // namespace | 721 } // namespace |
| 697 | 722 |
| 698 } // namespace cc | 723 } // namespace cc |
| OLD | NEW |