Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 "cc/base/tiling_data.h" | 5 #include "cc/base/tiling_data.h" |
| 6 | 6 |
| 7 #include <algorithm> | |
| 7 #include <vector> | 8 #include <vector> |
| 8 | 9 |
| 9 #include "cc/test/geometry_test_utils.h" | 10 #include "cc/test/geometry_test_utils.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 12 |
| 12 namespace cc { | 13 namespace cc { |
| 13 namespace { | 14 namespace { |
| 14 | 15 |
| 15 int NumTiles( | 16 int NumTiles( |
| 16 const gfx::Size& max_texture_size, | 17 const gfx::Size& max_texture_size, |
| (...skipping 1143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1160 TilingData big_border(gfx::Size(1000, 1000), gfx::Size(30, 40), 50); | 1161 TilingData big_border(gfx::Size(1000, 1000), gfx::Size(30, 40), 50); |
| 1161 TestDiff(big_border, gfx::Rect(0, 0, 30, 40), gfx::Rect(), 1); | 1162 TestDiff(big_border, gfx::Rect(0, 0, 30, 40), gfx::Rect(), 1); |
| 1162 TestDiff(big_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0); | 1163 TestDiff(big_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0); |
| 1163 } | 1164 } |
| 1164 | 1165 |
| 1165 TEST(TilingDataTest, DifferenceIteratorNoTiles) { | 1166 TEST(TilingDataTest, DifferenceIteratorNoTiles) { |
| 1166 TilingData data(gfx::Size(100, 100), gfx::Size(), false); | 1167 TilingData data(gfx::Size(100, 100), gfx::Size(), false); |
| 1167 TestDiff(data, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 5, 5), 0); | 1168 TestDiff(data, gfx::Rect(0, 0, 100, 100), gfx::Rect(0, 0, 5, 5), 0); |
| 1168 } | 1169 } |
| 1169 | 1170 |
| 1171 void TestSpiralIterate(int source_line_number, | |
| 1172 const TilingData& tiling_data, | |
| 1173 const gfx::Rect& consider, | |
| 1174 const gfx::Rect& ignore, | |
| 1175 const gfx::Rect& center, | |
| 1176 const std::vector<std::pair<int, int> >& expected) { | |
| 1177 std::vector<std::pair<int, int> > actual; | |
| 1178 for (TilingData::SpiralDifferenceIterator it( | |
| 1179 &tiling_data, consider, ignore, center); | |
| 1180 it; | |
| 1181 ++it) { | |
| 1182 actual.push_back(it.index()); | |
| 1183 } | |
| 1184 | |
| 1185 EXPECT_EQ(expected.size(), actual.size()) << "error from line " | |
| 1186 << source_line_number; | |
| 1187 for (size_t i = 0; i < std::min(expected.size(), actual.size()); ++i) { | |
| 1188 EXPECT_EQ(expected[i].first, actual[i].first) | |
| 1189 << "i: " << i << " error from line: " << source_line_number; | |
| 1190 EXPECT_EQ(expected[i].second, actual[i].second) | |
| 1191 << "i: " << i << " error from line: " << source_line_number; | |
| 1192 } | |
| 1193 } | |
| 1194 | |
| 1195 TEST(TilingDataTest, SpiralDifferenceIteratorNoIgnoreFullConsider) { | |
| 1196 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(30, 30), false); | |
| 1197 gfx::Rect consider(0, 0, 30, 30); | |
| 1198 gfx::Rect ignore; | |
| 1199 std::vector<std::pair<int, int> > expected; | |
| 1200 | |
| 1201 // Center is in the center of the tiling. | |
| 1202 gfx::Rect center(15, 15, 1, 1); | |
| 1203 | |
| 1204 // Layout of the tiling data, and expected return order: | |
| 1205 // x 0 1 2 | |
| 1206 // y.------ | |
| 1207 // 0| 4 3 2 | |
| 1208 // 1| 5 * 1 | |
| 1209 // 2| 6 7 8 | |
| 1210 expected.push_back(std::make_pair(2, 1)); | |
| 1211 expected.push_back(std::make_pair(2, 0)); | |
| 1212 expected.push_back(std::make_pair(1, 0)); | |
| 1213 expected.push_back(std::make_pair(0, 0)); | |
| 1214 expected.push_back(std::make_pair(0, 1)); | |
| 1215 expected.push_back(std::make_pair(0, 2)); | |
| 1216 expected.push_back(std::make_pair(1, 2)); | |
| 1217 expected.push_back(std::make_pair(2, 2)); | |
| 1218 | |
| 1219 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1220 | |
| 1221 // Center is off to the right side of the tiling (and far away). | |
| 1222 center = gfx::Rect(100, 15, 1, 1); | |
| 1223 | |
| 1224 // Layout of the tiling data, and expected return order: | |
| 1225 // x 0 1 2 | |
| 1226 // y.------ | |
| 1227 // 0| 7 4 1 | |
| 1228 // 1| 8 5 2 * | |
| 1229 // 2| 9 6 3 | |
| 1230 expected.clear(); | |
| 1231 expected.push_back(std::make_pair(2, 0)); | |
| 1232 expected.push_back(std::make_pair(2, 1)); | |
| 1233 expected.push_back(std::make_pair(2, 2)); | |
| 1234 expected.push_back(std::make_pair(1, 0)); | |
| 1235 expected.push_back(std::make_pair(1, 1)); | |
| 1236 expected.push_back(std::make_pair(1, 2)); | |
| 1237 expected.push_back(std::make_pair(0, 0)); | |
| 1238 expected.push_back(std::make_pair(0, 1)); | |
| 1239 expected.push_back(std::make_pair(0, 2)); | |
| 1240 | |
| 1241 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1242 | |
| 1243 // Center is the bottom right corner of the tiling. | |
| 1244 center = gfx::Rect(25, 25, 1, 1); | |
| 1245 | |
| 1246 // Layout of the tiling data, and expected return order: | |
| 1247 // x 0 1 2 | |
| 1248 // y.------ | |
| 1249 // 0| 6 5 4 | |
| 1250 // 1| 7 2 1 | |
| 1251 // 2| 8 3 * | |
| 1252 expected.clear(); | |
| 1253 expected.push_back(std::make_pair(2, 1)); | |
| 1254 expected.push_back(std::make_pair(1, 1)); | |
| 1255 expected.push_back(std::make_pair(1, 2)); | |
| 1256 expected.push_back(std::make_pair(2, 0)); | |
| 1257 expected.push_back(std::make_pair(1, 0)); | |
| 1258 expected.push_back(std::make_pair(0, 0)); | |
| 1259 expected.push_back(std::make_pair(0, 1)); | |
| 1260 expected.push_back(std::make_pair(0, 2)); | |
| 1261 | |
| 1262 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1263 | |
| 1264 // Center is off the top left side of the tiling. | |
| 1265 center = gfx::Rect(-60, -50, 1, 1); | |
| 1266 | |
| 1267 // Layout of the tiling data, and expected return order: | |
| 1268 // * x 0 1 2 | |
| 1269 // y.------ | |
| 1270 // 0| 1 2 6 | |
| 1271 // 1| 3 4 5 | |
| 1272 // 2| 7 8 9 | |
| 1273 expected.clear(); | |
| 1274 expected.push_back(std::make_pair(0, 0)); | |
| 1275 expected.push_back(std::make_pair(1, 0)); | |
| 1276 expected.push_back(std::make_pair(0, 1)); | |
| 1277 expected.push_back(std::make_pair(1, 1)); | |
| 1278 expected.push_back(std::make_pair(2, 1)); | |
| 1279 expected.push_back(std::make_pair(2, 0)); | |
| 1280 expected.push_back(std::make_pair(0, 2)); | |
| 1281 expected.push_back(std::make_pair(1, 2)); | |
| 1282 expected.push_back(std::make_pair(2, 2)); | |
| 1283 | |
| 1284 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1285 | |
| 1286 // Two tile center. | |
| 1287 center = gfx::Rect(15, 15, 1, 10); | |
| 1288 | |
| 1289 // Layout of the tiling data, and expected return order: | |
| 1290 // x 0 1 2 | |
| 1291 // y.------ | |
| 1292 // 0| 5 4 3 | |
| 1293 // 1| 6 * 2 | |
| 1294 // 2| 7 * 1 | |
| 1295 expected.clear(); | |
| 1296 expected.push_back(std::make_pair(2, 2)); | |
| 1297 expected.push_back(std::make_pair(2, 1)); | |
| 1298 expected.push_back(std::make_pair(2, 0)); | |
| 1299 expected.push_back(std::make_pair(1, 0)); | |
| 1300 expected.push_back(std::make_pair(0, 0)); | |
| 1301 expected.push_back(std::make_pair(0, 1)); | |
| 1302 expected.push_back(std::make_pair(0, 2)); | |
| 1303 | |
| 1304 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1305 } | |
| 1306 | |
| 1307 TEST(TilingDataTest, SpiralDifferenceIteratorSmallConsider) { | |
| 1308 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false); | |
| 1309 gfx::Rect ignore; | |
| 1310 std::vector<std::pair<int, int> > expected; | |
| 1311 gfx::Rect center(15, 15, 1, 1); | |
| 1312 | |
| 1313 // Consider is one cell. | |
| 1314 gfx::Rect consider(0, 0, 1, 1); | |
| 1315 | |
| 1316 // Layout of the tiling data, and expected return order: | |
| 1317 // x 0 1 2 3 4 | |
| 1318 // y.---------- | |
| 1319 // 0| 1 | |
| 1320 // 1| * | |
| 1321 // 2| | |
| 1322 // 3| | |
| 1323 // 4| | |
| 1324 expected.push_back(std::make_pair(0, 0)); | |
| 1325 | |
| 1326 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1327 | |
| 1328 // Consider is bottom right corner. | |
| 1329 consider = gfx::Rect(25, 25, 10, 10); | |
| 1330 | |
| 1331 // Layout of the tiling data, and expected return order: | |
| 1332 // x 0 1 2 3 4 | |
| 1333 // y.---------- | |
| 1334 // 0| | |
| 1335 // 1| * | |
| 1336 // 2| 1 2 | |
| 1337 // 3| 3 4 | |
| 1338 // 4| | |
| 1339 expected.clear(); | |
| 1340 expected.push_back(std::make_pair(2, 2)); | |
| 1341 expected.push_back(std::make_pair(3, 2)); | |
| 1342 expected.push_back(std::make_pair(2, 3)); | |
| 1343 expected.push_back(std::make_pair(3, 3)); | |
| 1344 | |
| 1345 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1346 | |
| 1347 // Consider is one column. | |
| 1348 consider = gfx::Rect(11, 0, 1, 100); | |
| 1349 | |
| 1350 // Layout of the tiling data, and expected return order: | |
| 1351 // x 0 1 2 3 4 | |
| 1352 // y.---------- | |
| 1353 // 0| 2 | |
| 1354 // 1| * | |
| 1355 // 2| 3 | |
| 1356 // 3| 4 | |
| 1357 // 4| 5 | |
| 1358 expected.clear(); | |
| 1359 expected.push_back(std::make_pair(1, 0)); | |
| 1360 expected.push_back(std::make_pair(1, 2)); | |
| 1361 expected.push_back(std::make_pair(1, 3)); | |
| 1362 expected.push_back(std::make_pair(1, 4)); | |
| 1363 | |
| 1364 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1365 } | |
| 1366 | |
| 1367 TEST(TilingDataTest, SpiralDifferenceIteratorHasIgnore) { | |
| 1368 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false); | |
| 1369 gfx::Rect consider(0, 0, 50, 50); | |
| 1370 std::vector<std::pair<int, int> > expected; | |
| 1371 gfx::Rect center(15, 15, 1, 1); | |
| 1372 | |
| 1373 // Full ignore. | |
| 1374 gfx::Rect ignore(0, 0, 50, 50); | |
| 1375 | |
| 1376 // Layout of the tiling data, and expected return order: | |
| 1377 // x 0 1 2 3 4 | |
| 1378 // y.---------- | |
| 1379 // 0| . . . . . | |
| 1380 // 1| . * . . . | |
| 1381 // 2| . . . . . | |
| 1382 // 3| . . . . . | |
| 1383 // 4| . . . . . | |
| 1384 expected.clear(); | |
| 1385 | |
| 1386 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1387 | |
| 1388 // 3 column ignore. | |
| 1389 ignore = gfx::Rect(15, 0, 20, 100); | |
| 1390 | |
| 1391 // Layout of the tiling data, and expected return order: | |
| 1392 // x 0 1 2 3 4 | |
| 1393 // y.---------- | |
| 1394 // 0| 1 . . . 8 | |
| 1395 // 1| 2 * . . 7 | |
| 1396 // 2| 3 . . . 6 | |
| 1397 // 3| 4 . . . 5 | |
| 1398 // 4| 9 . . . 10 | |
| 1399 expected.clear(); | |
| 1400 | |
| 1401 expected.push_back(std::make_pair(0, 0)); | |
| 1402 expected.push_back(std::make_pair(0, 1)); | |
| 1403 expected.push_back(std::make_pair(0, 2)); | |
| 1404 expected.push_back(std::make_pair(0, 3)); | |
| 1405 expected.push_back(std::make_pair(4, 3)); | |
| 1406 expected.push_back(std::make_pair(4, 2)); | |
| 1407 expected.push_back(std::make_pair(4, 1)); | |
| 1408 expected.push_back(std::make_pair(4, 0)); | |
| 1409 expected.push_back(std::make_pair(0, 4)); | |
| 1410 expected.push_back(std::make_pair(4, 4)); | |
| 1411 | |
| 1412 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1413 | |
| 1414 // Ignore covers the top half. | |
| 1415 ignore = gfx::Rect(0, 0, 50, 25); | |
| 1416 | |
| 1417 // Layout of the tiling data, and expected return order: | |
| 1418 // x 0 1 2 3 4 | |
| 1419 // y.---------- | |
| 1420 // 0| . . . . . | |
| 1421 // 1| . * . . . | |
| 1422 // 2| . . . . . | |
| 1423 // 3| 1 2 3 4 5 | |
| 1424 // 4| 6 7 8 9 10 | |
| 1425 expected.clear(); | |
| 1426 | |
| 1427 expected.push_back(std::make_pair(0, 3)); | |
| 1428 expected.push_back(std::make_pair(1, 3)); | |
| 1429 expected.push_back(std::make_pair(2, 3)); | |
| 1430 expected.push_back(std::make_pair(3, 3)); | |
| 1431 expected.push_back(std::make_pair(4, 3)); | |
| 1432 expected.push_back(std::make_pair(0, 4)); | |
| 1433 expected.push_back(std::make_pair(1, 4)); | |
| 1434 expected.push_back(std::make_pair(2, 4)); | |
| 1435 expected.push_back(std::make_pair(3, 4)); | |
| 1436 expected.push_back(std::make_pair(4, 4)); | |
| 1437 | |
| 1438 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1439 } | |
| 1440 | |
| 1441 TEST(TilingDataTest, SpiralDifferenceIteratorRectangleCenter) { | |
| 1442 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false); | |
| 1443 gfx::Rect consider(0, 0, 50, 50); | |
| 1444 std::vector<std::pair<int, int> > expected; | |
| 1445 gfx::Rect ignore; | |
| 1446 | |
| 1447 // Two cell center | |
| 1448 gfx::Rect center(25, 25, 1, 10); | |
| 1449 | |
| 1450 // Layout of the tiling data, and expected return order: | |
| 1451 // x 0 1 2 3 4 | |
| 1452 // y.---------- | |
| 1453 // 0| J I H G F | |
| 1454 // 1| K 5 4 3 E | |
| 1455 // 2| L 6 * 2 D | |
| 1456 // 3| M 7 * 1 C | |
| 1457 // 4| N 8 9 A B | |
| 1458 expected.clear(); | |
| 1459 | |
| 1460 expected.push_back(std::make_pair(3, 3)); | |
| 1461 expected.push_back(std::make_pair(3, 2)); | |
| 1462 expected.push_back(std::make_pair(3, 1)); | |
| 1463 expected.push_back(std::make_pair(2, 1)); | |
| 1464 expected.push_back(std::make_pair(1, 1)); | |
| 1465 expected.push_back(std::make_pair(1, 2)); | |
| 1466 expected.push_back(std::make_pair(1, 3)); | |
| 1467 expected.push_back(std::make_pair(1, 4)); | |
| 1468 expected.push_back(std::make_pair(2, 4)); | |
| 1469 expected.push_back(std::make_pair(3, 4)); | |
| 1470 expected.push_back(std::make_pair(4, 4)); | |
| 1471 expected.push_back(std::make_pair(4, 3)); | |
| 1472 expected.push_back(std::make_pair(4, 2)); | |
| 1473 expected.push_back(std::make_pair(4, 1)); | |
| 1474 expected.push_back(std::make_pair(4, 0)); | |
| 1475 expected.push_back(std::make_pair(3, 0)); | |
| 1476 expected.push_back(std::make_pair(2, 0)); | |
| 1477 expected.push_back(std::make_pair(1, 0)); | |
| 1478 expected.push_back(std::make_pair(0, 0)); | |
| 1479 expected.push_back(std::make_pair(0, 1)); | |
| 1480 expected.push_back(std::make_pair(0, 2)); | |
| 1481 expected.push_back(std::make_pair(0, 3)); | |
| 1482 expected.push_back(std::make_pair(0, 4)); | |
| 1483 | |
| 1484 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1485 | |
| 1486 // Three by two center. | |
| 1487 center = gfx::Rect(15, 25, 20, 10); | |
| 1488 | |
| 1489 // Layout of the tiling data, and expected return order: | |
| 1490 // x 0 1 2 3 4 | |
| 1491 // y.---------- | |
| 1492 // 0| J I H G F | |
| 1493 // 1| 7 6 5 4 3 | |
| 1494 // 2| 8 * * * 2 | |
| 1495 // 3| 9 * * * 1 | |
| 1496 // 4| A B C D E | |
| 1497 expected.clear(); | |
| 1498 | |
| 1499 expected.push_back(std::make_pair(4, 3)); | |
| 1500 expected.push_back(std::make_pair(4, 2)); | |
| 1501 expected.push_back(std::make_pair(4, 1)); | |
| 1502 expected.push_back(std::make_pair(3, 1)); | |
| 1503 expected.push_back(std::make_pair(2, 1)); | |
| 1504 expected.push_back(std::make_pair(1, 1)); | |
| 1505 expected.push_back(std::make_pair(0, 1)); | |
| 1506 expected.push_back(std::make_pair(0, 2)); | |
| 1507 expected.push_back(std::make_pair(0, 3)); | |
| 1508 expected.push_back(std::make_pair(0, 4)); | |
| 1509 expected.push_back(std::make_pair(1, 4)); | |
| 1510 expected.push_back(std::make_pair(2, 4)); | |
| 1511 expected.push_back(std::make_pair(3, 4)); | |
| 1512 expected.push_back(std::make_pair(4, 4)); | |
| 1513 expected.push_back(std::make_pair(4, 0)); | |
| 1514 expected.push_back(std::make_pair(3, 0)); | |
| 1515 expected.push_back(std::make_pair(2, 0)); | |
| 1516 expected.push_back(std::make_pair(1, 0)); | |
| 1517 expected.push_back(std::make_pair(0, 0)); | |
| 1518 | |
| 1519 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1520 | |
| 1521 // Column center off the left side. | |
| 1522 center = gfx::Rect(-50, 0, 30, 50); | |
| 1523 | |
| 1524 // Layout of the tiling data, and expected return order: | |
| 1525 // x 0 1 2 3 4 | |
| 1526 // y.---------- | |
| 1527 // * 0| 5 A F K P | |
| 1528 // * 1| 4 9 E J O | |
| 1529 // * 2| 3 8 D I N | |
| 1530 // * 3| 2 7 C H M | |
| 1531 // * 4| 1 6 B G L | |
| 1532 expected.clear(); | |
| 1533 | |
| 1534 expected.push_back(std::make_pair(0, 4)); | |
| 1535 expected.push_back(std::make_pair(0, 3)); | |
| 1536 expected.push_back(std::make_pair(0, 2)); | |
| 1537 expected.push_back(std::make_pair(0, 1)); | |
| 1538 expected.push_back(std::make_pair(0, 0)); | |
| 1539 expected.push_back(std::make_pair(1, 4)); | |
| 1540 expected.push_back(std::make_pair(1, 3)); | |
| 1541 expected.push_back(std::make_pair(1, 2)); | |
| 1542 expected.push_back(std::make_pair(1, 1)); | |
| 1543 expected.push_back(std::make_pair(1, 0)); | |
| 1544 expected.push_back(std::make_pair(2, 4)); | |
| 1545 expected.push_back(std::make_pair(2, 3)); | |
| 1546 expected.push_back(std::make_pair(2, 2)); | |
| 1547 expected.push_back(std::make_pair(2, 1)); | |
| 1548 expected.push_back(std::make_pair(2, 0)); | |
| 1549 expected.push_back(std::make_pair(3, 4)); | |
| 1550 expected.push_back(std::make_pair(3, 3)); | |
| 1551 expected.push_back(std::make_pair(3, 2)); | |
| 1552 expected.push_back(std::make_pair(3, 1)); | |
| 1553 expected.push_back(std::make_pair(3, 0)); | |
| 1554 expected.push_back(std::make_pair(4, 4)); | |
| 1555 expected.push_back(std::make_pair(4, 3)); | |
| 1556 expected.push_back(std::make_pair(4, 2)); | |
| 1557 expected.push_back(std::make_pair(4, 1)); | |
| 1558 expected.push_back(std::make_pair(4, 0)); | |
| 1559 | |
| 1560 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1561 } | |
| 1562 | |
| 1563 TEST(TilingDataTest, SpiralDifferenceIteratorEdgeCases) { | |
| 1564 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(30, 30), false); | |
| 1565 std::vector<std::pair<int, int> > expected; | |
| 1566 gfx::Rect center; | |
| 1567 gfx::Rect consider; | |
| 1568 gfx::Rect ignore; | |
| 1569 | |
| 1570 // Ignore contains, but is not equal to, consider and center. | |
| 1571 ignore = gfx::Rect(15, 0, 20, 30); | |
| 1572 consider = gfx::Rect(20, 10, 10, 20); | |
| 1573 center = gfx::Rect(25, 0, 5, 5); | |
| 1574 | |
| 1575 // Layout of the tiling data, and expected return order: | |
| 1576 // x 0 1 2 | |
| 1577 // y.------ | |
| 1578 // 0| . * | |
| 1579 // 1| . . | |
| 1580 // 2| . . | |
| 1581 expected.clear(); | |
| 1582 | |
| 1583 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1584 | |
| 1585 // Center intersects with consider. | |
| 1586 ignore = gfx::Rect(); | |
| 1587 center = gfx::Rect(0, 15, 30, 15); | |
| 1588 consider = gfx::Rect(0, 0, 15, 30); | |
| 1589 | |
| 1590 // Layout of the tiling data, and expected return order: | |
| 1591 // x 0 1 2 | |
| 1592 // y.------ | |
| 1593 // 0| 2 1 | |
| 1594 // 1| * * * | |
| 1595 // 2| * * * | |
| 1596 expected.clear(); | |
| 1597 | |
| 1598 expected.push_back(std::make_pair(1, 0)); | |
| 1599 expected.push_back(std::make_pair(0, 0)); | |
| 1600 | |
| 1601 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1602 | |
| 1603 // Consider and ignore are non-intersecting. | |
| 1604 ignore = gfx::Rect(0, 0, 5, 30); | |
| 1605 consider = gfx::Rect(25, 0, 5, 30); | |
| 1606 center = gfx::Rect(15, 0, 1, 1); | |
| 1607 | |
| 1608 // Layout of the tiling data, and expected return order: | |
| 1609 // x 0 1 2 | |
| 1610 // y.------ | |
| 1611 // 0| . * 1 | |
| 1612 // 1| . 2 | |
| 1613 // 2| . 3 | |
| 1614 expected.clear(); | |
| 1615 | |
| 1616 expected.push_back(std::make_pair(2, 0)); | |
| 1617 expected.push_back(std::make_pair(2, 1)); | |
| 1618 expected.push_back(std::make_pair(2, 2)); | |
| 1619 | |
| 1620 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1621 | |
| 1622 // Center intersects with ignore. | |
| 1623 consider = gfx::Rect(0, 0, 30, 30); | |
| 1624 center = gfx::Rect(15, 0, 1, 30); | |
| 1625 ignore = gfx::Rect(0, 15, 30, 1); | |
| 1626 | |
| 1627 // Layout of the tiling data, and expected return order: | |
| 1628 // x 0 1 2 | |
| 1629 // y.------ | |
| 1630 // 0| 3 * 2 | |
| 1631 // 1| . * . | |
| 1632 // 2| 4 * 1 | |
| 1633 expected.clear(); | |
| 1634 | |
| 1635 expected.push_back(std::make_pair(2, 2)); | |
| 1636 expected.push_back(std::make_pair(2, 0)); | |
| 1637 expected.push_back(std::make_pair(0, 0)); | |
| 1638 expected.push_back(std::make_pair(0, 2)); | |
| 1639 | |
| 1640 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1641 | |
| 1642 // Center and ignore are the same. | |
| 1643 consider = gfx::Rect(0, 0, 30, 30); | |
| 1644 center = gfx::Rect(15, 0, 1, 30); | |
| 1645 ignore = center; | |
| 1646 | |
| 1647 // Layout of the tiling data, and expected return order: | |
| 1648 // x 0 1 2 | |
| 1649 // y.------ | |
| 1650 // 0| 4 * 3 | |
| 1651 // 1| 5 * 2 | |
| 1652 // 2| 6 * 1 | |
| 1653 expected.clear(); | |
| 1654 | |
| 1655 expected.push_back(std::make_pair(2, 2)); | |
| 1656 expected.push_back(std::make_pair(2, 1)); | |
| 1657 expected.push_back(std::make_pair(2, 0)); | |
| 1658 expected.push_back(std::make_pair(0, 0)); | |
| 1659 expected.push_back(std::make_pair(0, 1)); | |
| 1660 expected.push_back(std::make_pair(0, 2)); | |
| 1661 | |
| 1662 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1663 | |
| 1664 // Empty tiling data. | |
| 1665 TilingData empty_data(gfx::Size(0, 0), gfx::Size(0, 0), false); | |
| 1666 | |
| 1667 expected.clear(); | |
| 1668 TestSpiralIterate(__LINE__, empty_data, consider, ignore, center, expected); | |
| 1669 | |
| 1670 // Empty consider. | |
| 1671 ignore = gfx::Rect(); | |
| 1672 center = gfx::Rect(1, 1, 1, 1); | |
| 1673 consider = gfx::Rect(); | |
| 1674 | |
| 1675 expected.clear(); | |
| 1676 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1677 | |
| 1678 // Empty center. Note: This arbitrarily puts the center to be off the top-left | |
|
enne (OOO)
2014/03/01 00:43:45
I think I'd weakly prefer an empty center to just
vmpstr
2014/03/03 18:32:23
I kept it as is, since I believe that an empty cen
| |
| 1679 // corner. | |
| 1680 consider = gfx::Rect(0, 0, 30, 30); | |
| 1681 ignore = gfx::Rect(); | |
| 1682 center = gfx::Rect(); | |
| 1683 | |
| 1684 // Layout of the tiling data, and expected return order: | |
| 1685 // * x 0 1 2 | |
| 1686 // y.------ | |
| 1687 // 0| 1 2 6 | |
| 1688 // 1| 3 4 5 | |
| 1689 // 2| 7 8 9 | |
| 1690 expected.clear(); | |
| 1691 | |
| 1692 expected.push_back(std::make_pair(0, 0)); | |
| 1693 expected.push_back(std::make_pair(1, 0)); | |
| 1694 expected.push_back(std::make_pair(0, 1)); | |
| 1695 expected.push_back(std::make_pair(1, 1)); | |
| 1696 expected.push_back(std::make_pair(2, 1)); | |
| 1697 expected.push_back(std::make_pair(2, 0)); | |
| 1698 expected.push_back(std::make_pair(0, 2)); | |
| 1699 expected.push_back(std::make_pair(1, 2)); | |
| 1700 expected.push_back(std::make_pair(2, 2)); | |
| 1701 | |
| 1702 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1703 | |
| 1704 // Every rect is empty. | |
| 1705 ignore = gfx::Rect(); | |
| 1706 center = gfx::Rect(); | |
| 1707 consider = gfx::Rect(); | |
| 1708 | |
| 1709 expected.clear(); | |
| 1710 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1711 } | |
| 1170 } // namespace | 1712 } // namespace |
| 1171 } // namespace cc | 1713 } // namespace cc |
| OLD | NEW |