| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1357 TilingData big_border(gfx::Size(1000, 1000), gfx::Size(30, 40), 50); | 1357 TilingData big_border(gfx::Size(1000, 1000), gfx::Size(30, 40), 50); |
| 1358 TestDiff(big_border, gfx::Rect(30, 40), gfx::Rect(), 1); | 1358 TestDiff(big_border, gfx::Rect(30, 40), gfx::Rect(), 1); |
| 1359 TestDiff(big_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0); | 1359 TestDiff(big_border, gfx::Rect(5, 5, 100, 100), gfx::Rect(5, 5, 1, 1), 0); |
| 1360 } | 1360 } |
| 1361 | 1361 |
| 1362 TEST(TilingDataTest, DifferenceIteratorNoTiles) { | 1362 TEST(TilingDataTest, DifferenceIteratorNoTiles) { |
| 1363 TilingData data(gfx::Size(100, 100), gfx::Size(), false); | 1363 TilingData data(gfx::Size(100, 100), gfx::Size(), false); |
| 1364 TestDiff(data, gfx::Rect(100, 100), gfx::Rect(5, 5), 0); | 1364 TestDiff(data, gfx::Rect(100, 100), gfx::Rect(5, 5), 0); |
| 1365 } | 1365 } |
| 1366 | 1366 |
| 1367 void TestSpiralIterate(int source_line_number, | |
| 1368 const TilingData& tiling_data, | |
| 1369 const gfx::Rect& consider, | |
| 1370 const gfx::Rect& ignore, | |
| 1371 const gfx::Rect& center, | |
| 1372 const std::vector<std::pair<int, int>>& expected) { | |
| 1373 std::vector<std::pair<int, int>> actual_forward; | |
| 1374 for (TilingData::SpiralDifferenceIterator it( | |
| 1375 &tiling_data, consider, ignore, center); | |
| 1376 it; | |
| 1377 ++it) { | |
| 1378 actual_forward.push_back(it.index()); | |
| 1379 } | |
| 1380 | |
| 1381 EXPECT_EQ(expected.size(), actual_forward.size()) << "error from line " | |
| 1382 << source_line_number; | |
| 1383 for (size_t i = 0; i < std::min(expected.size(), actual_forward.size()); | |
| 1384 ++i) { | |
| 1385 EXPECT_EQ(expected[i].first, actual_forward[i].first) | |
| 1386 << "i: " << i << " error from line: " << source_line_number; | |
| 1387 EXPECT_EQ(expected[i].second, actual_forward[i].second) | |
| 1388 << "i: " << i << " error from line: " << source_line_number; | |
| 1389 } | |
| 1390 | |
| 1391 std::vector<std::pair<int, int>> actual_reverse; | |
| 1392 for (TilingData::ReverseSpiralDifferenceIterator it( | |
| 1393 &tiling_data, consider, ignore, center); | |
| 1394 it; | |
| 1395 ++it) { | |
| 1396 actual_reverse.push_back(it.index()); | |
| 1397 } | |
| 1398 | |
| 1399 std::vector<std::pair<int, int>> reversed_expected = expected; | |
| 1400 std::reverse(reversed_expected.begin(), reversed_expected.end()); | |
| 1401 EXPECT_EQ(reversed_expected.size(), actual_reverse.size()) | |
| 1402 << "error from line " << source_line_number; | |
| 1403 for (size_t i = 0; | |
| 1404 i < std::min(reversed_expected.size(), actual_reverse.size()); | |
| 1405 ++i) { | |
| 1406 EXPECT_EQ(reversed_expected[i].first, actual_reverse[i].first) | |
| 1407 << "i: " << i << " error from line: " << source_line_number; | |
| 1408 EXPECT_EQ(reversed_expected[i].second, actual_reverse[i].second) | |
| 1409 << "i: " << i << " error from line: " << source_line_number; | |
| 1410 } | |
| 1411 } | |
| 1412 | |
| 1413 TEST(TilingDataTest, SpiralDifferenceIteratorNoIgnoreFullConsider) { | |
| 1414 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(30, 30), false); | |
| 1415 gfx::Rect consider(30, 30); | |
| 1416 gfx::Rect ignore; | |
| 1417 std::vector<std::pair<int, int>> expected; | |
| 1418 | |
| 1419 // Center is in the center of the tiling. | |
| 1420 gfx::Rect center(15, 15, 1, 1); | |
| 1421 | |
| 1422 // Layout of the tiling data, and expected return order: | |
| 1423 // x 0 1 2 | |
| 1424 // y.------ | |
| 1425 // 0| 4 3 2 | |
| 1426 // 1| 5 * 1 | |
| 1427 // 2| 6 7 8 | |
| 1428 expected.push_back(std::make_pair(2, 1)); | |
| 1429 expected.push_back(std::make_pair(2, 0)); | |
| 1430 expected.push_back(std::make_pair(1, 0)); | |
| 1431 expected.push_back(std::make_pair(0, 0)); | |
| 1432 expected.push_back(std::make_pair(0, 1)); | |
| 1433 expected.push_back(std::make_pair(0, 2)); | |
| 1434 expected.push_back(std::make_pair(1, 2)); | |
| 1435 expected.push_back(std::make_pair(2, 2)); | |
| 1436 | |
| 1437 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1438 | |
| 1439 // Center is off to the right side of the tiling (and far away). | |
| 1440 center = gfx::Rect(100, 15, 1, 1); | |
| 1441 | |
| 1442 // Layout of the tiling data, and expected return order: | |
| 1443 // x 0 1 2 | |
| 1444 // y.------ | |
| 1445 // 0| 7 4 1 | |
| 1446 // 1| 8 5 2 * | |
| 1447 // 2| 9 6 3 | |
| 1448 expected.clear(); | |
| 1449 expected.push_back(std::make_pair(2, 0)); | |
| 1450 expected.push_back(std::make_pair(2, 1)); | |
| 1451 expected.push_back(std::make_pair(2, 2)); | |
| 1452 expected.push_back(std::make_pair(1, 0)); | |
| 1453 expected.push_back(std::make_pair(1, 1)); | |
| 1454 expected.push_back(std::make_pair(1, 2)); | |
| 1455 expected.push_back(std::make_pair(0, 0)); | |
| 1456 expected.push_back(std::make_pair(0, 1)); | |
| 1457 expected.push_back(std::make_pair(0, 2)); | |
| 1458 | |
| 1459 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1460 | |
| 1461 // Center is the bottom right corner of the tiling. | |
| 1462 center = gfx::Rect(25, 25, 1, 1); | |
| 1463 | |
| 1464 // Layout of the tiling data, and expected return order: | |
| 1465 // x 0 1 2 | |
| 1466 // y.------ | |
| 1467 // 0| 6 5 4 | |
| 1468 // 1| 7 2 1 | |
| 1469 // 2| 8 3 * | |
| 1470 expected.clear(); | |
| 1471 expected.push_back(std::make_pair(2, 1)); | |
| 1472 expected.push_back(std::make_pair(1, 1)); | |
| 1473 expected.push_back(std::make_pair(1, 2)); | |
| 1474 expected.push_back(std::make_pair(2, 0)); | |
| 1475 expected.push_back(std::make_pair(1, 0)); | |
| 1476 expected.push_back(std::make_pair(0, 0)); | |
| 1477 expected.push_back(std::make_pair(0, 1)); | |
| 1478 expected.push_back(std::make_pair(0, 2)); | |
| 1479 | |
| 1480 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1481 | |
| 1482 // Center is off the top left side of the tiling. | |
| 1483 center = gfx::Rect(-60, -50, 1, 1); | |
| 1484 | |
| 1485 // Layout of the tiling data, and expected return order: | |
| 1486 // * x 0 1 2 | |
| 1487 // y.------ | |
| 1488 // 0| 1 2 6 | |
| 1489 // 1| 3 4 5 | |
| 1490 // 2| 7 8 9 | |
| 1491 expected.clear(); | |
| 1492 expected.push_back(std::make_pair(0, 0)); | |
| 1493 expected.push_back(std::make_pair(1, 0)); | |
| 1494 expected.push_back(std::make_pair(0, 1)); | |
| 1495 expected.push_back(std::make_pair(1, 1)); | |
| 1496 expected.push_back(std::make_pair(2, 1)); | |
| 1497 expected.push_back(std::make_pair(2, 0)); | |
| 1498 expected.push_back(std::make_pair(0, 2)); | |
| 1499 expected.push_back(std::make_pair(1, 2)); | |
| 1500 expected.push_back(std::make_pair(2, 2)); | |
| 1501 | |
| 1502 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1503 | |
| 1504 // Two tile center. | |
| 1505 center = gfx::Rect(15, 15, 1, 10); | |
| 1506 | |
| 1507 // Layout of the tiling data, and expected return order: | |
| 1508 // x 0 1 2 | |
| 1509 // y.------ | |
| 1510 // 0| 5 4 3 | |
| 1511 // 1| 6 * 2 | |
| 1512 // 2| 7 * 1 | |
| 1513 expected.clear(); | |
| 1514 expected.push_back(std::make_pair(2, 2)); | |
| 1515 expected.push_back(std::make_pair(2, 1)); | |
| 1516 expected.push_back(std::make_pair(2, 0)); | |
| 1517 expected.push_back(std::make_pair(1, 0)); | |
| 1518 expected.push_back(std::make_pair(0, 0)); | |
| 1519 expected.push_back(std::make_pair(0, 1)); | |
| 1520 expected.push_back(std::make_pair(0, 2)); | |
| 1521 | |
| 1522 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1523 } | |
| 1524 | |
| 1525 TEST(TilingDataTest, SpiralDifferenceIteratorSmallConsider) { | |
| 1526 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false); | |
| 1527 gfx::Rect ignore; | |
| 1528 std::vector<std::pair<int, int>> expected; | |
| 1529 gfx::Rect center(15, 15, 1, 1); | |
| 1530 | |
| 1531 // Consider is one cell. | |
| 1532 gfx::Rect consider(1, 1); | |
| 1533 | |
| 1534 // Layout of the tiling data, and expected return order: | |
| 1535 // x 0 1 2 3 4 | |
| 1536 // y.---------- | |
| 1537 // 0| 1 | |
| 1538 // 1| * | |
| 1539 // 2| | |
| 1540 // 3| | |
| 1541 // 4| | |
| 1542 expected.push_back(std::make_pair(0, 0)); | |
| 1543 | |
| 1544 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1545 | |
| 1546 // Consider is bottom right corner. | |
| 1547 consider = gfx::Rect(25, 25, 10, 10); | |
| 1548 | |
| 1549 // Layout of the tiling data, and expected return order: | |
| 1550 // x 0 1 2 3 4 | |
| 1551 // y.---------- | |
| 1552 // 0| | |
| 1553 // 1| * | |
| 1554 // 2| 1 2 | |
| 1555 // 3| 3 4 | |
| 1556 // 4| | |
| 1557 expected.clear(); | |
| 1558 expected.push_back(std::make_pair(2, 2)); | |
| 1559 expected.push_back(std::make_pair(3, 2)); | |
| 1560 expected.push_back(std::make_pair(2, 3)); | |
| 1561 expected.push_back(std::make_pair(3, 3)); | |
| 1562 | |
| 1563 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1564 | |
| 1565 // Consider is one column. | |
| 1566 consider = gfx::Rect(11, 0, 1, 100); | |
| 1567 | |
| 1568 // Layout of the tiling data, and expected return order: | |
| 1569 // x 0 1 2 3 4 | |
| 1570 // y.---------- | |
| 1571 // 0| 2 | |
| 1572 // 1| * | |
| 1573 // 2| 3 | |
| 1574 // 3| 4 | |
| 1575 // 4| 5 | |
| 1576 expected.clear(); | |
| 1577 expected.push_back(std::make_pair(1, 0)); | |
| 1578 expected.push_back(std::make_pair(1, 2)); | |
| 1579 expected.push_back(std::make_pair(1, 3)); | |
| 1580 expected.push_back(std::make_pair(1, 4)); | |
| 1581 | |
| 1582 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1583 } | |
| 1584 | |
| 1585 TEST(TilingDataTest, SpiralDifferenceIteratorHasIgnore) { | |
| 1586 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false); | |
| 1587 gfx::Rect consider(50, 50); | |
| 1588 std::vector<std::pair<int, int>> expected; | |
| 1589 gfx::Rect center(15, 15, 1, 1); | |
| 1590 | |
| 1591 // Full ignore. | |
| 1592 gfx::Rect ignore(50, 50); | |
| 1593 | |
| 1594 // Layout of the tiling data, and expected return order: | |
| 1595 // x 0 1 2 3 4 | |
| 1596 // y.---------- | |
| 1597 // 0| . . . . . | |
| 1598 // 1| . * . . . | |
| 1599 // 2| . . . . . | |
| 1600 // 3| . . . . . | |
| 1601 // 4| . . . . . | |
| 1602 expected.clear(); | |
| 1603 | |
| 1604 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1605 | |
| 1606 // 3 column ignore. | |
| 1607 ignore = gfx::Rect(15, 0, 20, 100); | |
| 1608 | |
| 1609 // Layout of the tiling data, and expected return order: | |
| 1610 // x 0 1 2 3 4 | |
| 1611 // y.---------- | |
| 1612 // 0| 1 . . . 8 | |
| 1613 // 1| 2 * . . 7 | |
| 1614 // 2| 3 . . . 6 | |
| 1615 // 3| 4 . . . 5 | |
| 1616 // 4| 9 . . . 10 | |
| 1617 expected.clear(); | |
| 1618 | |
| 1619 expected.push_back(std::make_pair(0, 0)); | |
| 1620 expected.push_back(std::make_pair(0, 1)); | |
| 1621 expected.push_back(std::make_pair(0, 2)); | |
| 1622 expected.push_back(std::make_pair(0, 3)); | |
| 1623 expected.push_back(std::make_pair(4, 3)); | |
| 1624 expected.push_back(std::make_pair(4, 2)); | |
| 1625 expected.push_back(std::make_pair(4, 1)); | |
| 1626 expected.push_back(std::make_pair(4, 0)); | |
| 1627 expected.push_back(std::make_pair(0, 4)); | |
| 1628 expected.push_back(std::make_pair(4, 4)); | |
| 1629 | |
| 1630 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1631 | |
| 1632 // Ignore covers the top half. | |
| 1633 ignore = gfx::Rect(50, 25); | |
| 1634 | |
| 1635 // Layout of the tiling data, and expected return order: | |
| 1636 // x 0 1 2 3 4 | |
| 1637 // y.---------- | |
| 1638 // 0| . . . . . | |
| 1639 // 1| . * . . . | |
| 1640 // 2| . . . . . | |
| 1641 // 3| 1 2 3 4 5 | |
| 1642 // 4| 6 7 8 9 10 | |
| 1643 expected.clear(); | |
| 1644 | |
| 1645 expected.push_back(std::make_pair(0, 3)); | |
| 1646 expected.push_back(std::make_pair(1, 3)); | |
| 1647 expected.push_back(std::make_pair(2, 3)); | |
| 1648 expected.push_back(std::make_pair(3, 3)); | |
| 1649 expected.push_back(std::make_pair(4, 3)); | |
| 1650 expected.push_back(std::make_pair(0, 4)); | |
| 1651 expected.push_back(std::make_pair(1, 4)); | |
| 1652 expected.push_back(std::make_pair(2, 4)); | |
| 1653 expected.push_back(std::make_pair(3, 4)); | |
| 1654 expected.push_back(std::make_pair(4, 4)); | |
| 1655 | |
| 1656 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1657 } | |
| 1658 | |
| 1659 TEST(TilingDataTest, SpiralDifferenceIteratorRectangleCenter) { | |
| 1660 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false); | |
| 1661 gfx::Rect consider(50, 50); | |
| 1662 std::vector<std::pair<int, int>> expected; | |
| 1663 gfx::Rect ignore; | |
| 1664 | |
| 1665 // Two cell center | |
| 1666 gfx::Rect center(25, 25, 1, 10); | |
| 1667 | |
| 1668 // Layout of the tiling data, and expected return order: | |
| 1669 // x 0 1 2 3 4 | |
| 1670 // y.---------- | |
| 1671 // 0| J I H G F | |
| 1672 // 1| K 5 4 3 E | |
| 1673 // 2| L 6 * 2 D | |
| 1674 // 3| M 7 * 1 C | |
| 1675 // 4| N 8 9 A B | |
| 1676 expected.clear(); | |
| 1677 | |
| 1678 expected.push_back(std::make_pair(3, 3)); | |
| 1679 expected.push_back(std::make_pair(3, 2)); | |
| 1680 expected.push_back(std::make_pair(3, 1)); | |
| 1681 expected.push_back(std::make_pair(2, 1)); | |
| 1682 expected.push_back(std::make_pair(1, 1)); | |
| 1683 expected.push_back(std::make_pair(1, 2)); | |
| 1684 expected.push_back(std::make_pair(1, 3)); | |
| 1685 expected.push_back(std::make_pair(1, 4)); | |
| 1686 expected.push_back(std::make_pair(2, 4)); | |
| 1687 expected.push_back(std::make_pair(3, 4)); | |
| 1688 expected.push_back(std::make_pair(4, 4)); | |
| 1689 expected.push_back(std::make_pair(4, 3)); | |
| 1690 expected.push_back(std::make_pair(4, 2)); | |
| 1691 expected.push_back(std::make_pair(4, 1)); | |
| 1692 expected.push_back(std::make_pair(4, 0)); | |
| 1693 expected.push_back(std::make_pair(3, 0)); | |
| 1694 expected.push_back(std::make_pair(2, 0)); | |
| 1695 expected.push_back(std::make_pair(1, 0)); | |
| 1696 expected.push_back(std::make_pair(0, 0)); | |
| 1697 expected.push_back(std::make_pair(0, 1)); | |
| 1698 expected.push_back(std::make_pair(0, 2)); | |
| 1699 expected.push_back(std::make_pair(0, 3)); | |
| 1700 expected.push_back(std::make_pair(0, 4)); | |
| 1701 | |
| 1702 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1703 | |
| 1704 // Three by two center. | |
| 1705 center = gfx::Rect(15, 25, 20, 10); | |
| 1706 | |
| 1707 // Layout of the tiling data, and expected return order: | |
| 1708 // x 0 1 2 3 4 | |
| 1709 // y.---------- | |
| 1710 // 0| J I H G F | |
| 1711 // 1| 7 6 5 4 3 | |
| 1712 // 2| 8 * * * 2 | |
| 1713 // 3| 9 * * * 1 | |
| 1714 // 4| A B C D E | |
| 1715 expected.clear(); | |
| 1716 | |
| 1717 expected.push_back(std::make_pair(4, 3)); | |
| 1718 expected.push_back(std::make_pair(4, 2)); | |
| 1719 expected.push_back(std::make_pair(4, 1)); | |
| 1720 expected.push_back(std::make_pair(3, 1)); | |
| 1721 expected.push_back(std::make_pair(2, 1)); | |
| 1722 expected.push_back(std::make_pair(1, 1)); | |
| 1723 expected.push_back(std::make_pair(0, 1)); | |
| 1724 expected.push_back(std::make_pair(0, 2)); | |
| 1725 expected.push_back(std::make_pair(0, 3)); | |
| 1726 expected.push_back(std::make_pair(0, 4)); | |
| 1727 expected.push_back(std::make_pair(1, 4)); | |
| 1728 expected.push_back(std::make_pair(2, 4)); | |
| 1729 expected.push_back(std::make_pair(3, 4)); | |
| 1730 expected.push_back(std::make_pair(4, 4)); | |
| 1731 expected.push_back(std::make_pair(4, 0)); | |
| 1732 expected.push_back(std::make_pair(3, 0)); | |
| 1733 expected.push_back(std::make_pair(2, 0)); | |
| 1734 expected.push_back(std::make_pair(1, 0)); | |
| 1735 expected.push_back(std::make_pair(0, 0)); | |
| 1736 | |
| 1737 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1738 | |
| 1739 // Column center off the left side. | |
| 1740 center = gfx::Rect(-50, 0, 30, 50); | |
| 1741 | |
| 1742 // Layout of the tiling data, and expected return order: | |
| 1743 // x 0 1 2 3 4 | |
| 1744 // y.---------- | |
| 1745 // * 0| 5 A F K P | |
| 1746 // * 1| 4 9 E J O | |
| 1747 // * 2| 3 8 D I N | |
| 1748 // * 3| 2 7 C H M | |
| 1749 // * 4| 1 6 B G L | |
| 1750 expected.clear(); | |
| 1751 | |
| 1752 expected.push_back(std::make_pair(0, 4)); | |
| 1753 expected.push_back(std::make_pair(0, 3)); | |
| 1754 expected.push_back(std::make_pair(0, 2)); | |
| 1755 expected.push_back(std::make_pair(0, 1)); | |
| 1756 expected.push_back(std::make_pair(0, 0)); | |
| 1757 expected.push_back(std::make_pair(1, 4)); | |
| 1758 expected.push_back(std::make_pair(1, 3)); | |
| 1759 expected.push_back(std::make_pair(1, 2)); | |
| 1760 expected.push_back(std::make_pair(1, 1)); | |
| 1761 expected.push_back(std::make_pair(1, 0)); | |
| 1762 expected.push_back(std::make_pair(2, 4)); | |
| 1763 expected.push_back(std::make_pair(2, 3)); | |
| 1764 expected.push_back(std::make_pair(2, 2)); | |
| 1765 expected.push_back(std::make_pair(2, 1)); | |
| 1766 expected.push_back(std::make_pair(2, 0)); | |
| 1767 expected.push_back(std::make_pair(3, 4)); | |
| 1768 expected.push_back(std::make_pair(3, 3)); | |
| 1769 expected.push_back(std::make_pair(3, 2)); | |
| 1770 expected.push_back(std::make_pair(3, 1)); | |
| 1771 expected.push_back(std::make_pair(3, 0)); | |
| 1772 expected.push_back(std::make_pair(4, 4)); | |
| 1773 expected.push_back(std::make_pair(4, 3)); | |
| 1774 expected.push_back(std::make_pair(4, 2)); | |
| 1775 expected.push_back(std::make_pair(4, 1)); | |
| 1776 expected.push_back(std::make_pair(4, 0)); | |
| 1777 | |
| 1778 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1779 } | |
| 1780 | |
| 1781 TEST(TilingDataTest, SpiralDifferenceIteratorEdgeCases) { | |
| 1782 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(30, 30), false); | |
| 1783 std::vector<std::pair<int, int>> expected; | |
| 1784 gfx::Rect center; | |
| 1785 gfx::Rect consider; | |
| 1786 gfx::Rect ignore; | |
| 1787 | |
| 1788 // Ignore contains, but is not equal to, consider and center. | |
| 1789 ignore = gfx::Rect(15, 0, 20, 30); | |
| 1790 consider = gfx::Rect(20, 10, 10, 20); | |
| 1791 center = gfx::Rect(25, 0, 5, 5); | |
| 1792 | |
| 1793 // Layout of the tiling data, and expected return order: | |
| 1794 // x 0 1 2 | |
| 1795 // y.------ | |
| 1796 // 0| . * | |
| 1797 // 1| . . | |
| 1798 // 2| . . | |
| 1799 expected.clear(); | |
| 1800 | |
| 1801 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1802 | |
| 1803 // Center intersects with consider. | |
| 1804 ignore = gfx::Rect(); | |
| 1805 center = gfx::Rect(0, 15, 30, 15); | |
| 1806 consider = gfx::Rect(15, 30); | |
| 1807 | |
| 1808 // Layout of the tiling data, and expected return order: | |
| 1809 // x 0 1 2 | |
| 1810 // y.------ | |
| 1811 // 0| 2 1 | |
| 1812 // 1| * * * | |
| 1813 // 2| * * * | |
| 1814 expected.clear(); | |
| 1815 | |
| 1816 expected.push_back(std::make_pair(1, 0)); | |
| 1817 expected.push_back(std::make_pair(0, 0)); | |
| 1818 | |
| 1819 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1820 | |
| 1821 // Consider and ignore are non-intersecting. | |
| 1822 ignore = gfx::Rect(5, 30); | |
| 1823 consider = gfx::Rect(25, 0, 5, 30); | |
| 1824 center = gfx::Rect(15, 0, 1, 1); | |
| 1825 | |
| 1826 // Layout of the tiling data, and expected return order: | |
| 1827 // x 0 1 2 | |
| 1828 // y.------ | |
| 1829 // 0| . * 1 | |
| 1830 // 1| . 2 | |
| 1831 // 2| . 3 | |
| 1832 expected.clear(); | |
| 1833 | |
| 1834 expected.push_back(std::make_pair(2, 0)); | |
| 1835 expected.push_back(std::make_pair(2, 1)); | |
| 1836 expected.push_back(std::make_pair(2, 2)); | |
| 1837 | |
| 1838 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1839 | |
| 1840 // Center intersects with ignore. | |
| 1841 consider = gfx::Rect(30, 30); | |
| 1842 center = gfx::Rect(15, 0, 1, 30); | |
| 1843 ignore = gfx::Rect(0, 15, 30, 1); | |
| 1844 | |
| 1845 // Layout of the tiling data, and expected return order: | |
| 1846 // x 0 1 2 | |
| 1847 // y.------ | |
| 1848 // 0| 3 * 2 | |
| 1849 // 1| . * . | |
| 1850 // 2| 4 * 1 | |
| 1851 expected.clear(); | |
| 1852 | |
| 1853 expected.push_back(std::make_pair(2, 2)); | |
| 1854 expected.push_back(std::make_pair(2, 0)); | |
| 1855 expected.push_back(std::make_pair(0, 0)); | |
| 1856 expected.push_back(std::make_pair(0, 2)); | |
| 1857 | |
| 1858 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1859 | |
| 1860 // Center and ignore are the same. | |
| 1861 consider = gfx::Rect(30, 30); | |
| 1862 center = gfx::Rect(15, 0, 1, 30); | |
| 1863 ignore = center; | |
| 1864 | |
| 1865 // Layout of the tiling data, and expected return order: | |
| 1866 // x 0 1 2 | |
| 1867 // y.------ | |
| 1868 // 0| 4 * 3 | |
| 1869 // 1| 5 * 2 | |
| 1870 // 2| 6 * 1 | |
| 1871 expected.clear(); | |
| 1872 | |
| 1873 expected.push_back(std::make_pair(2, 2)); | |
| 1874 expected.push_back(std::make_pair(2, 1)); | |
| 1875 expected.push_back(std::make_pair(2, 0)); | |
| 1876 expected.push_back(std::make_pair(0, 0)); | |
| 1877 expected.push_back(std::make_pair(0, 1)); | |
| 1878 expected.push_back(std::make_pair(0, 2)); | |
| 1879 | |
| 1880 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1881 | |
| 1882 // Empty tiling data. | |
| 1883 TilingData empty_data(gfx::Size(0, 0), gfx::Size(0, 0), false); | |
| 1884 | |
| 1885 expected.clear(); | |
| 1886 TestSpiralIterate(__LINE__, empty_data, consider, ignore, center, expected); | |
| 1887 | |
| 1888 // Empty consider. | |
| 1889 ignore = gfx::Rect(); | |
| 1890 center = gfx::Rect(1, 1, 1, 1); | |
| 1891 consider = gfx::Rect(); | |
| 1892 | |
| 1893 expected.clear(); | |
| 1894 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1895 | |
| 1896 // Empty center. Note: This arbitrarily puts the center to be off the top-left | |
| 1897 // corner. | |
| 1898 consider = gfx::Rect(30, 30); | |
| 1899 ignore = gfx::Rect(); | |
| 1900 center = gfx::Rect(); | |
| 1901 | |
| 1902 // Layout of the tiling data, and expected return order: | |
| 1903 // * x 0 1 2 | |
| 1904 // y.------ | |
| 1905 // 0| 1 2 6 | |
| 1906 // 1| 3 4 5 | |
| 1907 // 2| 7 8 9 | |
| 1908 expected.clear(); | |
| 1909 | |
| 1910 expected.push_back(std::make_pair(0, 0)); | |
| 1911 expected.push_back(std::make_pair(1, 0)); | |
| 1912 expected.push_back(std::make_pair(0, 1)); | |
| 1913 expected.push_back(std::make_pair(1, 1)); | |
| 1914 expected.push_back(std::make_pair(2, 1)); | |
| 1915 expected.push_back(std::make_pair(2, 0)); | |
| 1916 expected.push_back(std::make_pair(0, 2)); | |
| 1917 expected.push_back(std::make_pair(1, 2)); | |
| 1918 expected.push_back(std::make_pair(2, 2)); | |
| 1919 | |
| 1920 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1921 | |
| 1922 // Every rect is empty. | |
| 1923 ignore = gfx::Rect(); | |
| 1924 center = gfx::Rect(); | |
| 1925 consider = gfx::Rect(); | |
| 1926 | |
| 1927 expected.clear(); | |
| 1928 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1929 | |
| 1930 // Center is just to the left of cover, and off of the tiling's left side. | |
| 1931 consider = gfx::Rect(30, 30); | |
| 1932 ignore = gfx::Rect(); | |
| 1933 center = gfx::Rect(-20, 0, 19, 30); | |
| 1934 | |
| 1935 // Layout of the tiling data, and expected return order: | |
| 1936 // x 0 1 2 | |
| 1937 // y.------ | |
| 1938 // *0| 3 6 9 | |
| 1939 // *1| 2 5 8 | |
| 1940 // *2| 1 4 7 | |
| 1941 expected.clear(); | |
| 1942 | |
| 1943 expected.push_back(std::make_pair(0, 2)); | |
| 1944 expected.push_back(std::make_pair(0, 1)); | |
| 1945 expected.push_back(std::make_pair(0, 0)); | |
| 1946 expected.push_back(std::make_pair(1, 2)); | |
| 1947 expected.push_back(std::make_pair(1, 1)); | |
| 1948 expected.push_back(std::make_pair(1, 0)); | |
| 1949 expected.push_back(std::make_pair(2, 2)); | |
| 1950 expected.push_back(std::make_pair(2, 1)); | |
| 1951 expected.push_back(std::make_pair(2, 0)); | |
| 1952 | |
| 1953 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | |
| 1954 } | |
| 1955 | |
| 1956 } // namespace | 1367 } // namespace |
| 1957 | 1368 |
| 1958 } // namespace cc | 1369 } // namespace cc |
| OLD | NEW |