| 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 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1436 | 1436 |
| 1437 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1437 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1438 | 1438 |
| 1439 // Center is off to the right side of the tiling (and far away). | 1439 // Center is off to the right side of the tiling (and far away). |
| 1440 center = gfx::Rect(100, 15, 1, 1); | 1440 center = gfx::Rect(100, 15, 1, 1); |
| 1441 | 1441 |
| 1442 // Layout of the tiling data, and expected return order: | 1442 // Layout of the tiling data, and expected return order: |
| 1443 // x 0 1 2 | 1443 // x 0 1 2 |
| 1444 // y.------ | 1444 // y.------ |
| 1445 // 0| 7 4 1 | 1445 // 0| 7 4 1 |
| 1446 // 1| 8 5 2 * | 1446 // 1| 8 5 2 * |
| 1447 // 2| 9 6 3 | 1447 // 2| 9 6 3 |
| 1448 expected.clear(); | 1448 expected.clear(); |
| 1449 expected.push_back(std::make_pair(2, 0)); | 1449 expected.push_back(std::make_pair(2, 0)); |
| 1450 expected.push_back(std::make_pair(2, 1)); | 1450 expected.push_back(std::make_pair(2, 1)); |
| 1451 expected.push_back(std::make_pair(2, 2)); | 1451 expected.push_back(std::make_pair(2, 2)); |
| 1452 expected.push_back(std::make_pair(1, 0)); | 1452 expected.push_back(std::make_pair(1, 0)); |
| 1453 expected.push_back(std::make_pair(1, 1)); | 1453 expected.push_back(std::make_pair(1, 1)); |
| 1454 expected.push_back(std::make_pair(1, 2)); | 1454 expected.push_back(std::make_pair(1, 2)); |
| 1455 expected.push_back(std::make_pair(0, 0)); | 1455 expected.push_back(std::make_pair(0, 0)); |
| 1456 expected.push_back(std::make_pair(0, 1)); | 1456 expected.push_back(std::make_pair(0, 1)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1478 expected.push_back(std::make_pair(0, 2)); | 1478 expected.push_back(std::make_pair(0, 2)); |
| 1479 | 1479 |
| 1480 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1480 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1481 | 1481 |
| 1482 // Center is off the top left side of the tiling. | 1482 // Center is off the top left side of the tiling. |
| 1483 center = gfx::Rect(-60, -50, 1, 1); | 1483 center = gfx::Rect(-60, -50, 1, 1); |
| 1484 | 1484 |
| 1485 // Layout of the tiling data, and expected return order: | 1485 // Layout of the tiling data, and expected return order: |
| 1486 // * x 0 1 2 | 1486 // * x 0 1 2 |
| 1487 // y.------ | 1487 // y.------ |
| 1488 // 0| 1 2 6 | 1488 // 0| 1 4 9 |
| 1489 // 1| 3 4 5 | 1489 // 1| 2 3 8 |
| 1490 // 2| 7 8 9 | 1490 // 2| 5 6 7 |
| 1491 expected.clear(); | 1491 expected.clear(); |
| 1492 expected.push_back(std::make_pair(0, 0)); | 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)); | 1493 expected.push_back(std::make_pair(0, 1)); |
| 1495 expected.push_back(std::make_pair(1, 1)); | 1494 expected.push_back(std::make_pair(1, 1)); |
| 1496 expected.push_back(std::make_pair(2, 1)); | 1495 expected.push_back(std::make_pair(1, 0)); |
| 1497 expected.push_back(std::make_pair(2, 0)); | |
| 1498 expected.push_back(std::make_pair(0, 2)); | 1496 expected.push_back(std::make_pair(0, 2)); |
| 1499 expected.push_back(std::make_pair(1, 2)); | 1497 expected.push_back(std::make_pair(1, 2)); |
| 1500 expected.push_back(std::make_pair(2, 2)); | 1498 expected.push_back(std::make_pair(2, 2)); |
| 1499 expected.push_back(std::make_pair(2, 1)); |
| 1500 expected.push_back(std::make_pair(2, 0)); |
| 1501 | 1501 |
| 1502 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1502 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1503 | 1503 |
| 1504 // Two tile center. | 1504 // Two tile center. |
| 1505 center = gfx::Rect(15, 15, 1, 10); | 1505 center = gfx::Rect(15, 15, 1, 10); |
| 1506 | 1506 |
| 1507 // Layout of the tiling data, and expected return order: | 1507 // Layout of the tiling data, and expected return order: |
| 1508 // x 0 1 2 | 1508 // x 0 1 2 |
| 1509 // y.------ | 1509 // y.------ |
| 1510 // 0| 5 4 3 | 1510 // 0| 5 4 3 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 expected.push_back(std::make_pair(3, 3)); | 1561 expected.push_back(std::make_pair(3, 3)); |
| 1562 | 1562 |
| 1563 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1563 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1564 | 1564 |
| 1565 // Consider is one column. | 1565 // Consider is one column. |
| 1566 consider = gfx::Rect(11, 0, 1, 100); | 1566 consider = gfx::Rect(11, 0, 1, 100); |
| 1567 | 1567 |
| 1568 // Layout of the tiling data, and expected return order: | 1568 // Layout of the tiling data, and expected return order: |
| 1569 // x 0 1 2 3 4 | 1569 // x 0 1 2 3 4 |
| 1570 // y.---------- | 1570 // y.---------- |
| 1571 // 0| 2 | 1571 // 0| 1 |
| 1572 // 1| * | 1572 // 1| * |
| 1573 // 2| 3 | 1573 // 2| 2 |
| 1574 // 3| 4 | 1574 // 3| 3 |
| 1575 // 4| 5 | 1575 // 4| 4 |
| 1576 expected.clear(); | 1576 expected.clear(); |
| 1577 expected.push_back(std::make_pair(1, 0)); | 1577 expected.push_back(std::make_pair(1, 0)); |
| 1578 expected.push_back(std::make_pair(1, 2)); | 1578 expected.push_back(std::make_pair(1, 2)); |
| 1579 expected.push_back(std::make_pair(1, 3)); | 1579 expected.push_back(std::make_pair(1, 3)); |
| 1580 expected.push_back(std::make_pair(1, 4)); | 1580 expected.push_back(std::make_pair(1, 4)); |
| 1581 | 1581 |
| 1582 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1582 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1583 } | 1583 } |
| 1584 | 1584 |
| 1585 TEST(TilingDataTest, SpiralDifferenceIteratorHasIgnore) { | 1585 TEST(TilingDataTest, SpiralDifferenceIteratorHasIgnore) { |
| 1586 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false); | 1586 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false); |
| 1587 gfx::Rect consider(50, 50); | 1587 gfx::Rect consider(50, 50); |
| 1588 std::vector<std::pair<int, int>> expected; | 1588 std::vector<std::pair<int, int>> expected; |
| 1589 gfx::Rect center(15, 15, 1, 1); | 1589 gfx::Rect center(15, 15, 1, 1); |
| 1590 | 1590 |
| 1591 // Full ignore. | 1591 // Full ignore. |
| 1592 gfx::Rect ignore(50, 50); | 1592 gfx::Rect ignore(50, 50); |
| 1593 | 1593 |
| 1594 // Layout of the tiling data, and expected return order: | 1594 // Layout of the tiling data, and expected return order: |
| 1595 // x 0 1 2 3 4 | 1595 // x 0 1 2 3 4 |
| 1596 // y.---------- | 1596 // y.--------------- |
| 1597 // 0| . . . . . | 1597 // 0| I I I I I |
| 1598 // 1| . * . . . | 1598 // 1| I * I I I |
| 1599 // 2| . . . . . | 1599 // 2| I I I I I |
| 1600 // 3| . . . . . | 1600 // 3| I I I I I |
| 1601 // 4| . . . . . | 1601 // 4| I I I I I |
| 1602 expected.clear(); | 1602 expected.clear(); |
| 1603 | 1603 |
| 1604 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1604 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1605 | 1605 |
| 1606 // 3 column ignore. | 1606 // 3 column ignore. |
| 1607 ignore = gfx::Rect(15, 0, 20, 100); | 1607 ignore = gfx::Rect(15, 0, 20, 100); |
| 1608 | 1608 |
| 1609 // Layout of the tiling data, and expected return order: | 1609 // Layout of the tiling data, and expected return order: |
| 1610 // x 0 1 2 3 4 | 1610 // x 0 1 2 3 4 |
| 1611 // y.---------- | 1611 // y.--------------- |
| 1612 // 0| 1 . . . 8 | 1612 // 0| 1 I I I 8 |
| 1613 // 1| 2 * . . 7 | 1613 // 1| 2 * I I 7 |
| 1614 // 2| 3 . . . 6 | 1614 // 2| 3 I I I 6 |
| 1615 // 3| 4 . . . 5 | 1615 // 3| 4 I I I 5 |
| 1616 // 4| 9 . . . 10 | 1616 // 4| 9 I I I 10 |
| 1617 expected.clear(); | 1617 expected.clear(); |
| 1618 | |
| 1619 expected.push_back(std::make_pair(0, 0)); | 1618 expected.push_back(std::make_pair(0, 0)); |
| 1620 expected.push_back(std::make_pair(0, 1)); | 1619 expected.push_back(std::make_pair(0, 1)); |
| 1621 expected.push_back(std::make_pair(0, 2)); | 1620 expected.push_back(std::make_pair(0, 2)); |
| 1622 expected.push_back(std::make_pair(0, 3)); | 1621 expected.push_back(std::make_pair(0, 3)); |
| 1623 expected.push_back(std::make_pair(4, 3)); | 1622 expected.push_back(std::make_pair(4, 3)); |
| 1624 expected.push_back(std::make_pair(4, 2)); | 1623 expected.push_back(std::make_pair(4, 2)); |
| 1625 expected.push_back(std::make_pair(4, 1)); | 1624 expected.push_back(std::make_pair(4, 1)); |
| 1626 expected.push_back(std::make_pair(4, 0)); | 1625 expected.push_back(std::make_pair(4, 0)); |
| 1627 expected.push_back(std::make_pair(0, 4)); | 1626 expected.push_back(std::make_pair(0, 4)); |
| 1628 expected.push_back(std::make_pair(4, 4)); | 1627 expected.push_back(std::make_pair(4, 4)); |
| 1629 | 1628 |
| 1630 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1629 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1631 | 1630 |
| 1632 // Ignore covers the top half. | 1631 // Ignore covers the top half. |
| 1633 ignore = gfx::Rect(50, 25); | 1632 ignore = gfx::Rect(50, 25); |
| 1634 | 1633 |
| 1635 // Layout of the tiling data, and expected return order: | 1634 // Layout of the tiling data, and expected return order: |
| 1636 // x 0 1 2 3 4 | 1635 // x 0 1 2 3 4 |
| 1637 // y.---------- | 1636 // y.--------------- |
| 1638 // 0| . . . . . | 1637 // 0| I I I I I |
| 1639 // 1| . * . . . | 1638 // 1| I * I I I |
| 1640 // 2| . . . . . | 1639 // 2| I I I I I |
| 1641 // 3| 1 2 3 4 5 | 1640 // 3| 1 2 3 4 5 |
| 1642 // 4| 6 7 8 9 10 | 1641 // 4| 6 7 8 9 10 |
| 1643 expected.clear(); | 1642 expected.clear(); |
| 1644 | |
| 1645 expected.push_back(std::make_pair(0, 3)); | 1643 expected.push_back(std::make_pair(0, 3)); |
| 1646 expected.push_back(std::make_pair(1, 3)); | 1644 expected.push_back(std::make_pair(1, 3)); |
| 1647 expected.push_back(std::make_pair(2, 3)); | 1645 expected.push_back(std::make_pair(2, 3)); |
| 1648 expected.push_back(std::make_pair(3, 3)); | 1646 expected.push_back(std::make_pair(3, 3)); |
| 1649 expected.push_back(std::make_pair(4, 3)); | 1647 expected.push_back(std::make_pair(4, 3)); |
| 1650 expected.push_back(std::make_pair(0, 4)); | 1648 expected.push_back(std::make_pair(0, 4)); |
| 1651 expected.push_back(std::make_pair(1, 4)); | 1649 expected.push_back(std::make_pair(1, 4)); |
| 1652 expected.push_back(std::make_pair(2, 4)); | 1650 expected.push_back(std::make_pair(2, 4)); |
| 1653 expected.push_back(std::make_pair(3, 4)); | 1651 expected.push_back(std::make_pair(3, 4)); |
| 1654 expected.push_back(std::make_pair(4, 4)); | 1652 expected.push_back(std::make_pair(4, 4)); |
| 1655 | 1653 |
| 1656 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1654 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1657 } | 1655 } |
| 1658 | 1656 |
| 1659 TEST(TilingDataTest, SpiralDifferenceIteratorRectangleCenter) { | 1657 TEST(TilingDataTest, SpiralDifferenceIteratorRectangleCenter) { |
| 1660 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false); | 1658 TilingData tiling_data(gfx::Size(10, 10), gfx::Size(50, 50), false); |
| 1661 gfx::Rect consider(50, 50); | 1659 gfx::Rect consider(50, 50); |
| 1662 std::vector<std::pair<int, int>> expected; | 1660 std::vector<std::pair<int, int>> expected; |
| 1663 gfx::Rect ignore; | 1661 gfx::Rect ignore; |
| 1664 | 1662 |
| 1665 // Two cell center | 1663 // Two cell center |
| 1666 gfx::Rect center(25, 25, 1, 10); | 1664 gfx::Rect center(25, 25, 1, 10); |
| 1667 | 1665 |
| 1668 // Layout of the tiling data, and expected return order: | 1666 // Layout of the tiling data, and expected return order: |
| 1669 // x 0 1 2 3 4 | 1667 // x 0 1 2 3 4 |
| 1670 // y.---------- | 1668 // y.--------------- |
| 1671 // 0| J I H G F | 1669 // 0| 19 18 17 16 15 |
| 1672 // 1| K 5 4 3 E | 1670 // 1| 20 5 4 3 14 |
| 1673 // 2| L 6 * 2 D | 1671 // 2| 21 6 * 2 13 |
| 1674 // 3| M 7 * 1 C | 1672 // 3| 22 7 * 1 12 |
| 1675 // 4| N 8 9 A B | 1673 // 4| 23 8 9 10 11 |
| 1676 expected.clear(); | 1674 expected.clear(); |
| 1677 | |
| 1678 expected.push_back(std::make_pair(3, 3)); | 1675 expected.push_back(std::make_pair(3, 3)); |
| 1679 expected.push_back(std::make_pair(3, 2)); | 1676 expected.push_back(std::make_pair(3, 2)); |
| 1680 expected.push_back(std::make_pair(3, 1)); | 1677 expected.push_back(std::make_pair(3, 1)); |
| 1681 expected.push_back(std::make_pair(2, 1)); | 1678 expected.push_back(std::make_pair(2, 1)); |
| 1682 expected.push_back(std::make_pair(1, 1)); | 1679 expected.push_back(std::make_pair(1, 1)); |
| 1683 expected.push_back(std::make_pair(1, 2)); | 1680 expected.push_back(std::make_pair(1, 2)); |
| 1684 expected.push_back(std::make_pair(1, 3)); | 1681 expected.push_back(std::make_pair(1, 3)); |
| 1685 expected.push_back(std::make_pair(1, 4)); | 1682 expected.push_back(std::make_pair(1, 4)); |
| 1686 expected.push_back(std::make_pair(2, 4)); | 1683 expected.push_back(std::make_pair(2, 4)); |
| 1687 expected.push_back(std::make_pair(3, 4)); | 1684 expected.push_back(std::make_pair(3, 4)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1698 expected.push_back(std::make_pair(0, 2)); | 1695 expected.push_back(std::make_pair(0, 2)); |
| 1699 expected.push_back(std::make_pair(0, 3)); | 1696 expected.push_back(std::make_pair(0, 3)); |
| 1700 expected.push_back(std::make_pair(0, 4)); | 1697 expected.push_back(std::make_pair(0, 4)); |
| 1701 | 1698 |
| 1702 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1699 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1703 | 1700 |
| 1704 // Three by two center. | 1701 // Three by two center. |
| 1705 center = gfx::Rect(15, 25, 20, 10); | 1702 center = gfx::Rect(15, 25, 20, 10); |
| 1706 | 1703 |
| 1707 // Layout of the tiling data, and expected return order: | 1704 // Layout of the tiling data, and expected return order: |
| 1708 // x 0 1 2 3 4 | 1705 // x 0 1 2 3 4 |
| 1709 // y.---------- | 1706 // y.--------------- |
| 1710 // 0| J I H G F | 1707 // 0| 19 18 17 16 15 |
| 1711 // 1| 7 6 5 4 3 | 1708 // 1| 7 6 5 4 3 |
| 1712 // 2| 8 * * * 2 | 1709 // 2| 8 * * * 2 |
| 1713 // 3| 9 * * * 1 | 1710 // 3| 9 * * * 1 |
| 1714 // 4| A B C D E | 1711 // 4| 10 11 12 13 14 |
| 1715 expected.clear(); | 1712 expected.clear(); |
| 1716 | |
| 1717 expected.push_back(std::make_pair(4, 3)); | 1713 expected.push_back(std::make_pair(4, 3)); |
| 1718 expected.push_back(std::make_pair(4, 2)); | 1714 expected.push_back(std::make_pair(4, 2)); |
| 1719 expected.push_back(std::make_pair(4, 1)); | 1715 expected.push_back(std::make_pair(4, 1)); |
| 1720 expected.push_back(std::make_pair(3, 1)); | 1716 expected.push_back(std::make_pair(3, 1)); |
| 1721 expected.push_back(std::make_pair(2, 1)); | 1717 expected.push_back(std::make_pair(2, 1)); |
| 1722 expected.push_back(std::make_pair(1, 1)); | 1718 expected.push_back(std::make_pair(1, 1)); |
| 1723 expected.push_back(std::make_pair(0, 1)); | 1719 expected.push_back(std::make_pair(0, 1)); |
| 1724 expected.push_back(std::make_pair(0, 2)); | 1720 expected.push_back(std::make_pair(0, 2)); |
| 1725 expected.push_back(std::make_pair(0, 3)); | 1721 expected.push_back(std::make_pair(0, 3)); |
| 1726 expected.push_back(std::make_pair(0, 4)); | 1722 expected.push_back(std::make_pair(0, 4)); |
| 1727 expected.push_back(std::make_pair(1, 4)); | 1723 expected.push_back(std::make_pair(1, 4)); |
| 1728 expected.push_back(std::make_pair(2, 4)); | 1724 expected.push_back(std::make_pair(2, 4)); |
| 1729 expected.push_back(std::make_pair(3, 4)); | 1725 expected.push_back(std::make_pair(3, 4)); |
| 1730 expected.push_back(std::make_pair(4, 4)); | 1726 expected.push_back(std::make_pair(4, 4)); |
| 1731 expected.push_back(std::make_pair(4, 0)); | 1727 expected.push_back(std::make_pair(4, 0)); |
| 1732 expected.push_back(std::make_pair(3, 0)); | 1728 expected.push_back(std::make_pair(3, 0)); |
| 1733 expected.push_back(std::make_pair(2, 0)); | 1729 expected.push_back(std::make_pair(2, 0)); |
| 1734 expected.push_back(std::make_pair(1, 0)); | 1730 expected.push_back(std::make_pair(1, 0)); |
| 1735 expected.push_back(std::make_pair(0, 0)); | 1731 expected.push_back(std::make_pair(0, 0)); |
| 1736 | 1732 |
| 1737 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1733 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1738 | 1734 |
| 1739 // Column center off the left side. | 1735 // Column center off the left side. |
| 1740 center = gfx::Rect(-50, 0, 30, 50); | 1736 center = gfx::Rect(-50, 0, 30, 50); |
| 1741 | 1737 |
| 1742 // Layout of the tiling data, and expected return order: | 1738 // Layout of the tiling data, and expected return order: |
| 1743 // x 0 1 2 3 4 | 1739 // x 0 1 2 3 4 |
| 1744 // y.---------- | 1740 // y.--------------- |
| 1745 // * 0| 5 A F K P | 1741 // * 0| 5 10 15 20 25 |
| 1746 // * 1| 4 9 E J O | 1742 // * 1| 4 9 14 19 24 |
| 1747 // * 2| 3 8 D I N | 1743 // * 2| 3 8 13 18 23 |
| 1748 // * 3| 2 7 C H M | 1744 // * 3| 2 7 12 17 22 |
| 1749 // * 4| 1 6 B G L | 1745 // * 4| 1 6 11 16 21 |
| 1750 expected.clear(); | 1746 expected.clear(); |
| 1751 | |
| 1752 expected.push_back(std::make_pair(0, 4)); | 1747 expected.push_back(std::make_pair(0, 4)); |
| 1753 expected.push_back(std::make_pair(0, 3)); | 1748 expected.push_back(std::make_pair(0, 3)); |
| 1754 expected.push_back(std::make_pair(0, 2)); | 1749 expected.push_back(std::make_pair(0, 2)); |
| 1755 expected.push_back(std::make_pair(0, 1)); | 1750 expected.push_back(std::make_pair(0, 1)); |
| 1756 expected.push_back(std::make_pair(0, 0)); | 1751 expected.push_back(std::make_pair(0, 0)); |
| 1757 expected.push_back(std::make_pair(1, 4)); | 1752 expected.push_back(std::make_pair(1, 4)); |
| 1758 expected.push_back(std::make_pair(1, 3)); | 1753 expected.push_back(std::make_pair(1, 3)); |
| 1759 expected.push_back(std::make_pair(1, 2)); | 1754 expected.push_back(std::make_pair(1, 2)); |
| 1760 expected.push_back(std::make_pair(1, 1)); | 1755 expected.push_back(std::make_pair(1, 1)); |
| 1761 expected.push_back(std::make_pair(1, 0)); | 1756 expected.push_back(std::make_pair(1, 0)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1786 gfx::Rect ignore; | 1781 gfx::Rect ignore; |
| 1787 | 1782 |
| 1788 // Ignore contains, but is not equal to, consider and center. | 1783 // Ignore contains, but is not equal to, consider and center. |
| 1789 ignore = gfx::Rect(15, 0, 20, 30); | 1784 ignore = gfx::Rect(15, 0, 20, 30); |
| 1790 consider = gfx::Rect(20, 10, 10, 20); | 1785 consider = gfx::Rect(20, 10, 10, 20); |
| 1791 center = gfx::Rect(25, 0, 5, 5); | 1786 center = gfx::Rect(25, 0, 5, 5); |
| 1792 | 1787 |
| 1793 // Layout of the tiling data, and expected return order: | 1788 // Layout of the tiling data, and expected return order: |
| 1794 // x 0 1 2 | 1789 // x 0 1 2 |
| 1795 // y.------ | 1790 // y.------ |
| 1796 // 0| . * | 1791 // 0| I * |
| 1797 // 1| . . | 1792 // 1| I I |
| 1798 // 2| . . | 1793 // 2| I I |
| 1799 expected.clear(); | 1794 expected.clear(); |
| 1800 | 1795 |
| 1801 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1796 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1802 | 1797 |
| 1803 // Center intersects with consider. | 1798 // Center intersects with consider. |
| 1804 ignore = gfx::Rect(); | 1799 ignore = gfx::Rect(); |
| 1805 center = gfx::Rect(0, 15, 30, 15); | 1800 center = gfx::Rect(0, 15, 30, 15); |
| 1806 consider = gfx::Rect(15, 30); | 1801 consider = gfx::Rect(15, 30); |
| 1807 | 1802 |
| 1808 // Layout of the tiling data, and expected return order: | 1803 // Layout of the tiling data, and expected return order: |
| 1809 // x 0 1 2 | 1804 // x 0 1 2 |
| 1810 // y.------ | 1805 // y.------ |
| 1811 // 0| 2 1 | 1806 // 0| 2 1 |
| 1812 // 1| * * * | 1807 // 1| * * * |
| 1813 // 2| * * * | 1808 // 2| * * * |
| 1814 expected.clear(); | 1809 expected.clear(); |
| 1815 | |
| 1816 expected.push_back(std::make_pair(1, 0)); | 1810 expected.push_back(std::make_pair(1, 0)); |
| 1817 expected.push_back(std::make_pair(0, 0)); | 1811 expected.push_back(std::make_pair(0, 0)); |
| 1818 | 1812 |
| 1819 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1813 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1820 | 1814 |
| 1821 // Consider and ignore are non-intersecting. | 1815 // Consider and ignore are non-intersecting. |
| 1822 ignore = gfx::Rect(5, 30); | 1816 ignore = gfx::Rect(5, 30); |
| 1823 consider = gfx::Rect(25, 0, 5, 30); | 1817 consider = gfx::Rect(25, 0, 5, 30); |
| 1824 center = gfx::Rect(15, 0, 1, 1); | 1818 center = gfx::Rect(15, 0, 1, 1); |
| 1825 | 1819 |
| 1826 // Layout of the tiling data, and expected return order: | 1820 // Layout of the tiling data, and expected return order: |
| 1827 // x 0 1 2 | 1821 // x 0 1 2 |
| 1828 // y.------ | 1822 // y.------ |
| 1829 // 0| . * 1 | 1823 // 0| I * 1 |
| 1830 // 1| . 2 | 1824 // 1| I 2 |
| 1831 // 2| . 3 | 1825 // 2| I 3 |
| 1832 expected.clear(); | 1826 expected.clear(); |
| 1833 | |
| 1834 expected.push_back(std::make_pair(2, 0)); | 1827 expected.push_back(std::make_pair(2, 0)); |
| 1835 expected.push_back(std::make_pair(2, 1)); | 1828 expected.push_back(std::make_pair(2, 1)); |
| 1836 expected.push_back(std::make_pair(2, 2)); | 1829 expected.push_back(std::make_pair(2, 2)); |
| 1837 | 1830 |
| 1838 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1831 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1839 | 1832 |
| 1840 // Center intersects with ignore. | 1833 // Center intersects with ignore. |
| 1841 consider = gfx::Rect(30, 30); | 1834 consider = gfx::Rect(30, 30); |
| 1842 center = gfx::Rect(15, 0, 1, 30); | 1835 center = gfx::Rect(15, 0, 1, 30); |
| 1843 ignore = gfx::Rect(0, 15, 30, 1); | 1836 ignore = gfx::Rect(0, 15, 30, 1); |
| 1844 | 1837 |
| 1845 // Layout of the tiling data, and expected return order: | 1838 // Layout of the tiling data, and expected return order: |
| 1846 // x 0 1 2 | 1839 // x 0 1 2 |
| 1847 // y.------ | 1840 // y.------ |
| 1848 // 0| 3 * 2 | 1841 // 0| 3 * 2 |
| 1849 // 1| . * . | 1842 // 1| I * I |
| 1850 // 2| 4 * 1 | 1843 // 2| 4 * 1 |
| 1851 expected.clear(); | 1844 expected.clear(); |
| 1852 | |
| 1853 expected.push_back(std::make_pair(2, 2)); | 1845 expected.push_back(std::make_pair(2, 2)); |
| 1854 expected.push_back(std::make_pair(2, 0)); | 1846 expected.push_back(std::make_pair(2, 0)); |
| 1855 expected.push_back(std::make_pair(0, 0)); | 1847 expected.push_back(std::make_pair(0, 0)); |
| 1856 expected.push_back(std::make_pair(0, 2)); | 1848 expected.push_back(std::make_pair(0, 2)); |
| 1857 | 1849 |
| 1858 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1850 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1859 | 1851 |
| 1860 // Center and ignore are the same. | 1852 // Center and ignore are the same. |
| 1861 consider = gfx::Rect(30, 30); | 1853 consider = gfx::Rect(30, 30); |
| 1862 center = gfx::Rect(15, 0, 1, 30); | 1854 center = gfx::Rect(15, 0, 1, 30); |
| 1863 ignore = center; | 1855 ignore = center; |
| 1864 | 1856 |
| 1865 // Layout of the tiling data, and expected return order: | 1857 // Layout of the tiling data, and expected return order: |
| 1866 // x 0 1 2 | 1858 // x 0 1 2 |
| 1867 // y.------ | 1859 // y.------ |
| 1868 // 0| 4 * 3 | 1860 // 0| 4 * 3 |
| 1869 // 1| 5 * 2 | 1861 // 1| 5 * 2 |
| 1870 // 2| 6 * 1 | 1862 // 2| 6 * 1 |
| 1871 expected.clear(); | 1863 expected.clear(); |
| 1872 | |
| 1873 expected.push_back(std::make_pair(2, 2)); | 1864 expected.push_back(std::make_pair(2, 2)); |
| 1874 expected.push_back(std::make_pair(2, 1)); | 1865 expected.push_back(std::make_pair(2, 1)); |
| 1875 expected.push_back(std::make_pair(2, 0)); | 1866 expected.push_back(std::make_pair(2, 0)); |
| 1876 expected.push_back(std::make_pair(0, 0)); | 1867 expected.push_back(std::make_pair(0, 0)); |
| 1877 expected.push_back(std::make_pair(0, 1)); | 1868 expected.push_back(std::make_pair(0, 1)); |
| 1878 expected.push_back(std::make_pair(0, 2)); | 1869 expected.push_back(std::make_pair(0, 2)); |
| 1879 | 1870 |
| 1880 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1871 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1881 | 1872 |
| 1882 // Empty tiling data. | 1873 // Empty tiling data. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1899 ignore = gfx::Rect(); | 1890 ignore = gfx::Rect(); |
| 1900 center = gfx::Rect(); | 1891 center = gfx::Rect(); |
| 1901 | 1892 |
| 1902 // Layout of the tiling data, and expected return order: | 1893 // Layout of the tiling data, and expected return order: |
| 1903 // * x 0 1 2 | 1894 // * x 0 1 2 |
| 1904 // y.------ | 1895 // y.------ |
| 1905 // 0| 1 2 6 | 1896 // 0| 1 2 6 |
| 1906 // 1| 3 4 5 | 1897 // 1| 3 4 5 |
| 1907 // 2| 7 8 9 | 1898 // 2| 7 8 9 |
| 1908 expected.clear(); | 1899 expected.clear(); |
| 1909 | |
| 1910 expected.push_back(std::make_pair(0, 0)); | 1900 expected.push_back(std::make_pair(0, 0)); |
| 1911 expected.push_back(std::make_pair(1, 0)); | 1901 expected.push_back(std::make_pair(1, 0)); |
| 1912 expected.push_back(std::make_pair(0, 1)); | 1902 expected.push_back(std::make_pair(0, 1)); |
| 1913 expected.push_back(std::make_pair(1, 1)); | 1903 expected.push_back(std::make_pair(1, 1)); |
| 1914 expected.push_back(std::make_pair(2, 1)); | 1904 expected.push_back(std::make_pair(2, 1)); |
| 1915 expected.push_back(std::make_pair(2, 0)); | 1905 expected.push_back(std::make_pair(2, 0)); |
| 1916 expected.push_back(std::make_pair(0, 2)); | 1906 expected.push_back(std::make_pair(0, 2)); |
| 1917 expected.push_back(std::make_pair(1, 2)); | 1907 expected.push_back(std::make_pair(1, 2)); |
| 1918 expected.push_back(std::make_pair(2, 2)); | 1908 expected.push_back(std::make_pair(2, 2)); |
| 1919 | 1909 |
| 1920 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1910 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1921 | 1911 |
| 1922 // Every rect is empty. | 1912 // Every rect is empty. |
| 1923 ignore = gfx::Rect(); | 1913 ignore = gfx::Rect(); |
| 1924 center = gfx::Rect(); | 1914 center = gfx::Rect(); |
| 1925 consider = gfx::Rect(); | 1915 consider = gfx::Rect(); |
| 1926 | 1916 |
| 1927 expected.clear(); | 1917 expected.clear(); |
| 1918 |
| 1928 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1919 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1929 | 1920 |
| 1930 // Center is just to the left of cover, and off of the tiling's left side. | 1921 // Center is just to the left of cover, and off of the tiling's left side. |
| 1931 consider = gfx::Rect(30, 30); | 1922 consider = gfx::Rect(30, 30); |
| 1932 ignore = gfx::Rect(); | 1923 ignore = gfx::Rect(); |
| 1933 center = gfx::Rect(-20, 0, 19, 30); | 1924 center = gfx::Rect(-20, 0, 19, 30); |
| 1934 | 1925 |
| 1935 // Layout of the tiling data, and expected return order: | 1926 // Layout of the tiling data, and expected return order: |
| 1936 // x 0 1 2 | 1927 // x 0 1 2 |
| 1937 // y.------ | 1928 // y.------ |
| 1938 // *0| 3 6 9 | 1929 // * 0| 3 6 9 |
| 1939 // *1| 2 5 8 | 1930 // * 1| 2 5 8 |
| 1940 // *2| 1 4 7 | 1931 // * 2| 1 4 7 |
| 1941 expected.clear(); | 1932 expected.clear(); |
| 1942 | |
| 1943 expected.push_back(std::make_pair(0, 2)); | 1933 expected.push_back(std::make_pair(0, 2)); |
| 1944 expected.push_back(std::make_pair(0, 1)); | 1934 expected.push_back(std::make_pair(0, 1)); |
| 1945 expected.push_back(std::make_pair(0, 0)); | 1935 expected.push_back(std::make_pair(0, 0)); |
| 1946 expected.push_back(std::make_pair(1, 2)); | 1936 expected.push_back(std::make_pair(1, 2)); |
| 1947 expected.push_back(std::make_pair(1, 1)); | 1937 expected.push_back(std::make_pair(1, 1)); |
| 1948 expected.push_back(std::make_pair(1, 0)); | 1938 expected.push_back(std::make_pair(1, 0)); |
| 1949 expected.push_back(std::make_pair(2, 2)); | 1939 expected.push_back(std::make_pair(2, 2)); |
| 1950 expected.push_back(std::make_pair(2, 1)); | 1940 expected.push_back(std::make_pair(2, 1)); |
| 1951 expected.push_back(std::make_pair(2, 0)); | 1941 expected.push_back(std::make_pair(2, 0)); |
| 1952 | 1942 |
| 1953 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); | 1943 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 1944 |
| 1945 // Tiling is smaller than tile size and center rect is not intersecting to |
| 1946 // tiling rect. |
| 1947 TilingData smaller_tiling(gfx::Size(10, 10), gfx::Size(1, 1), false); |
| 1948 consider = gfx::Rect(10, 10); |
| 1949 ignore = gfx::Rect(); |
| 1950 center = gfx::Rect(2, 2, 10, 10); |
| 1951 |
| 1952 // Layout of the tiling data, and expected return order: |
| 1953 // x 0 |
| 1954 // y.--- |
| 1955 // 0| 1 |
| 1956 // | * |
| 1957 expected.clear(); |
| 1958 expected.push_back(std::make_pair(0, 0)); |
| 1959 |
| 1960 TestSpiralIterate(__LINE__, smaller_tiling, consider, ignore, center, |
| 1961 expected); |
| 1954 } | 1962 } |
| 1955 | 1963 |
| 1964 TEST(TilingDataTest, SpiralDifferenceIteratorWideTilesNoIgnoreFullConsider) { |
| 1965 TilingData tiling_data(gfx::Size(20, 10), gfx::Size(100, 50), false); |
| 1966 gfx::Rect consider(100, 50); |
| 1967 gfx::Rect ignore; |
| 1968 std::vector<std::pair<int, int>> expected; |
| 1969 |
| 1970 // Center is in the center of the tiling. |
| 1971 gfx::Rect center(50, 25, 1, 1); |
| 1972 |
| 1973 // Layout of the tiling data, and expected return order: |
| 1974 // x 0 1 2 3 4 |
| 1975 // y.--------------- |
| 1976 // 0| 19 11 10 9 18 |
| 1977 // 1| 20 4 3 2 17 |
| 1978 // 2| 21 5 * 1 16 |
| 1979 // 3| 22 6 7 8 15 |
| 1980 // 4| 23 12 13 14 24 |
| 1981 expected.push_back(std::make_pair(3, 2)); |
| 1982 expected.push_back(std::make_pair(3, 1)); |
| 1983 expected.push_back(std::make_pair(2, 1)); |
| 1984 expected.push_back(std::make_pair(1, 1)); |
| 1985 expected.push_back(std::make_pair(1, 2)); |
| 1986 expected.push_back(std::make_pair(1, 3)); |
| 1987 expected.push_back(std::make_pair(2, 3)); |
| 1988 expected.push_back(std::make_pair(3, 3)); |
| 1989 expected.push_back(std::make_pair(3, 0)); |
| 1990 expected.push_back(std::make_pair(2, 0)); |
| 1991 expected.push_back(std::make_pair(1, 0)); |
| 1992 expected.push_back(std::make_pair(1, 4)); |
| 1993 expected.push_back(std::make_pair(2, 4)); |
| 1994 expected.push_back(std::make_pair(3, 4)); |
| 1995 expected.push_back(std::make_pair(4, 3)); |
| 1996 expected.push_back(std::make_pair(4, 2)); |
| 1997 expected.push_back(std::make_pair(4, 1)); |
| 1998 expected.push_back(std::make_pair(4, 0)); |
| 1999 expected.push_back(std::make_pair(0, 0)); |
| 2000 expected.push_back(std::make_pair(0, 1)); |
| 2001 expected.push_back(std::make_pair(0, 2)); |
| 2002 expected.push_back(std::make_pair(0, 3)); |
| 2003 expected.push_back(std::make_pair(0, 4)); |
| 2004 expected.push_back(std::make_pair(4, 4)); |
| 2005 |
| 2006 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2007 |
| 2008 // Center is off to the right side of the tiling (and far away). |
| 2009 center = gfx::Rect(200, 25, 1, 1); |
| 2010 |
| 2011 // Layout of the tiling data, and expected return order: |
| 2012 // x 0 1 2 3 4 |
| 2013 // y.--------------- |
| 2014 // 0| 21 16 11 6 1 |
| 2015 // 1| 22 17 12 7 2 |
| 2016 // 2| 23 18 13 8 3 * |
| 2017 // 3| 24 19 14 9 4 |
| 2018 // 4| 25 20 15 10 5 |
| 2019 expected.clear(); |
| 2020 expected.push_back(std::make_pair(4, 0)); |
| 2021 expected.push_back(std::make_pair(4, 1)); |
| 2022 expected.push_back(std::make_pair(4, 2)); |
| 2023 expected.push_back(std::make_pair(4, 3)); |
| 2024 expected.push_back(std::make_pair(4, 4)); |
| 2025 expected.push_back(std::make_pair(3, 0)); |
| 2026 expected.push_back(std::make_pair(3, 1)); |
| 2027 expected.push_back(std::make_pair(3, 2)); |
| 2028 expected.push_back(std::make_pair(3, 3)); |
| 2029 expected.push_back(std::make_pair(3, 4)); |
| 2030 expected.push_back(std::make_pair(2, 0)); |
| 2031 expected.push_back(std::make_pair(2, 1)); |
| 2032 expected.push_back(std::make_pair(2, 2)); |
| 2033 expected.push_back(std::make_pair(2, 3)); |
| 2034 expected.push_back(std::make_pair(2, 4)); |
| 2035 expected.push_back(std::make_pair(1, 0)); |
| 2036 expected.push_back(std::make_pair(1, 1)); |
| 2037 expected.push_back(std::make_pair(1, 2)); |
| 2038 expected.push_back(std::make_pair(1, 3)); |
| 2039 expected.push_back(std::make_pair(1, 4)); |
| 2040 expected.push_back(std::make_pair(0, 0)); |
| 2041 expected.push_back(std::make_pair(0, 1)); |
| 2042 expected.push_back(std::make_pair(0, 2)); |
| 2043 expected.push_back(std::make_pair(0, 3)); |
| 2044 expected.push_back(std::make_pair(0, 4)); |
| 2045 |
| 2046 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2047 |
| 2048 // Center is the bottom right corner of the tiling. |
| 2049 center = gfx::Rect(90, 45, 1, 1); |
| 2050 |
| 2051 // Layout of the tiling data, and expected return order: |
| 2052 // x 0 1 2 3 4 |
| 2053 // y.--------------- |
| 2054 // 0| 20 15 14 13 12 |
| 2055 // 1| 21 16 8 7 6 |
| 2056 // 2| 22 17 9 5 4 |
| 2057 // 3| 23 18 10 2 1 |
| 2058 // 4| 24 19 11 3 * |
| 2059 expected.clear(); |
| 2060 expected.push_back(std::make_pair(4, 3)); |
| 2061 expected.push_back(std::make_pair(3, 3)); |
| 2062 expected.push_back(std::make_pair(3, 4)); |
| 2063 expected.push_back(std::make_pair(4, 2)); |
| 2064 expected.push_back(std::make_pair(3, 2)); |
| 2065 expected.push_back(std::make_pair(4, 1)); |
| 2066 expected.push_back(std::make_pair(3, 1)); |
| 2067 expected.push_back(std::make_pair(2, 1)); |
| 2068 expected.push_back(std::make_pair(2, 2)); |
| 2069 expected.push_back(std::make_pair(2, 3)); |
| 2070 expected.push_back(std::make_pair(2, 4)); |
| 2071 expected.push_back(std::make_pair(4, 0)); |
| 2072 expected.push_back(std::make_pair(3, 0)); |
| 2073 expected.push_back(std::make_pair(2, 0)); |
| 2074 expected.push_back(std::make_pair(1, 0)); |
| 2075 expected.push_back(std::make_pair(1, 1)); |
| 2076 expected.push_back(std::make_pair(1, 2)); |
| 2077 expected.push_back(std::make_pair(1, 3)); |
| 2078 expected.push_back(std::make_pair(1, 4)); |
| 2079 expected.push_back(std::make_pair(0, 0)); |
| 2080 expected.push_back(std::make_pair(0, 1)); |
| 2081 expected.push_back(std::make_pair(0, 2)); |
| 2082 expected.push_back(std::make_pair(0, 3)); |
| 2083 expected.push_back(std::make_pair(0, 4)); |
| 2084 |
| 2085 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2086 |
| 2087 // Center is off the top left side of the tiling. |
| 2088 center = gfx::Rect(-60, -50, 1, 1); |
| 2089 |
| 2090 // Layout of the tiling data, and expected return order: |
| 2091 // Layout of the tiling data, and expected return order: |
| 2092 // * |
| 2093 // |
| 2094 // |
| 2095 // |
| 2096 // |
| 2097 // x 0 1 2 3 4 |
| 2098 // y.--------------- |
| 2099 // 0| 1 2 20 21 24 |
| 2100 // 1| 3 4 5 22 23 |
| 2101 // 2| 6 7 8 9 25 |
| 2102 // 3| 10 11 12 13 14 |
| 2103 // 4| 15 16 17 18 19 |
| 2104 expected.clear(); |
| 2105 expected.push_back(std::make_pair(0, 0)); |
| 2106 expected.push_back(std::make_pair(1, 0)); |
| 2107 expected.push_back(std::make_pair(0, 1)); |
| 2108 expected.push_back(std::make_pair(1, 1)); |
| 2109 expected.push_back(std::make_pair(2, 1)); |
| 2110 expected.push_back(std::make_pair(0, 2)); |
| 2111 expected.push_back(std::make_pair(1, 2)); |
| 2112 expected.push_back(std::make_pair(2, 2)); |
| 2113 expected.push_back(std::make_pair(3, 2)); |
| 2114 expected.push_back(std::make_pair(0, 3)); |
| 2115 expected.push_back(std::make_pair(1, 3)); |
| 2116 expected.push_back(std::make_pair(2, 3)); |
| 2117 expected.push_back(std::make_pair(3, 3)); |
| 2118 expected.push_back(std::make_pair(4, 3)); |
| 2119 expected.push_back(std::make_pair(0, 4)); |
| 2120 expected.push_back(std::make_pair(1, 4)); |
| 2121 expected.push_back(std::make_pair(2, 4)); |
| 2122 expected.push_back(std::make_pair(3, 4)); |
| 2123 expected.push_back(std::make_pair(4, 4)); |
| 2124 expected.push_back(std::make_pair(2, 0)); |
| 2125 expected.push_back(std::make_pair(3, 0)); |
| 2126 expected.push_back(std::make_pair(3, 1)); |
| 2127 expected.push_back(std::make_pair(4, 1)); |
| 2128 expected.push_back(std::make_pair(4, 0)); |
| 2129 expected.push_back(std::make_pair(4, 2)); |
| 2130 |
| 2131 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2132 |
| 2133 // Two tile center. |
| 2134 center = gfx::Rect(50, 15, 1, 10); |
| 2135 |
| 2136 // Layout of the tiling data, and expected return order: |
| 2137 // x 0 1 2 3 4 |
| 2138 // y.--------------- |
| 2139 // 0| 18 5 4 3 17 |
| 2140 // 1| 19 6 * 2 16 |
| 2141 // 2| 20 7 * 1 15 |
| 2142 // 3| 21 8 9 10 14 |
| 2143 // 4| 22 11 12 13 23 |
| 2144 expected.clear(); |
| 2145 expected.push_back(std::make_pair(3, 2)); |
| 2146 expected.push_back(std::make_pair(3, 1)); |
| 2147 expected.push_back(std::make_pair(3, 0)); |
| 2148 expected.push_back(std::make_pair(2, 0)); |
| 2149 expected.push_back(std::make_pair(1, 0)); |
| 2150 expected.push_back(std::make_pair(1, 1)); |
| 2151 expected.push_back(std::make_pair(1, 2)); |
| 2152 expected.push_back(std::make_pair(1, 3)); |
| 2153 expected.push_back(std::make_pair(2, 3)); |
| 2154 expected.push_back(std::make_pair(3, 3)); |
| 2155 expected.push_back(std::make_pair(1, 4)); |
| 2156 expected.push_back(std::make_pair(2, 4)); |
| 2157 expected.push_back(std::make_pair(3, 4)); |
| 2158 expected.push_back(std::make_pair(4, 3)); |
| 2159 expected.push_back(std::make_pair(4, 2)); |
| 2160 expected.push_back(std::make_pair(4, 1)); |
| 2161 expected.push_back(std::make_pair(4, 0)); |
| 2162 expected.push_back(std::make_pair(0, 0)); |
| 2163 expected.push_back(std::make_pair(0, 1)); |
| 2164 expected.push_back(std::make_pair(0, 2)); |
| 2165 expected.push_back(std::make_pair(0, 3)); |
| 2166 expected.push_back(std::make_pair(0, 4)); |
| 2167 expected.push_back(std::make_pair(4, 4)); |
| 2168 |
| 2169 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2170 } |
| 2171 |
| 2172 TEST(TilingDataTest, SpiralDifferenceIteratorWideTilesSmallConsider) { |
| 2173 TilingData tiling_data(gfx::Size(20, 10), gfx::Size(100, 50), false); |
| 2174 gfx::Rect ignore; |
| 2175 std::vector<std::pair<int, int>> expected; |
| 2176 gfx::Rect center(30, 15, 1, 1); |
| 2177 |
| 2178 // Consider is one cell. |
| 2179 gfx::Rect consider(1, 1); |
| 2180 |
| 2181 // Layout of the tiling data, and expected return order: |
| 2182 // x 0 1 2 3 4 |
| 2183 // y.--------------- |
| 2184 // 0| 1 |
| 2185 // 1| * |
| 2186 // 2| |
| 2187 // 3| |
| 2188 // 4| |
| 2189 expected.push_back(std::make_pair(0, 0)); |
| 2190 |
| 2191 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2192 |
| 2193 // Consider is bottom right corner. |
| 2194 consider = gfx::Rect(70, 35, 20, 10); |
| 2195 |
| 2196 // Layout of the tiling data, and expected return order: |
| 2197 // x 0 1 2 3 4 |
| 2198 // y.--------------- |
| 2199 // 0| |
| 2200 // 1| * |
| 2201 // 2| |
| 2202 // 3| 2 3 |
| 2203 // 4| 1 4 |
| 2204 expected.clear(); |
| 2205 expected.push_back(std::make_pair(3, 4)); |
| 2206 expected.push_back(std::make_pair(3, 3)); |
| 2207 expected.push_back(std::make_pair(4, 3)); |
| 2208 expected.push_back(std::make_pair(4, 4)); |
| 2209 |
| 2210 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2211 |
| 2212 // Consider is one column. |
| 2213 consider = gfx::Rect(21, 0, 1, 100); |
| 2214 |
| 2215 // Layout of the tiling data, and expected return order: |
| 2216 // x 0 1 2 3 4 |
| 2217 // y.--------------- |
| 2218 // 0| 1 |
| 2219 // 1| * |
| 2220 // 2| 2 |
| 2221 // 3| 3 |
| 2222 // 4| 4 |
| 2223 expected.clear(); |
| 2224 expected.push_back(std::make_pair(1, 0)); |
| 2225 expected.push_back(std::make_pair(1, 2)); |
| 2226 expected.push_back(std::make_pair(1, 3)); |
| 2227 expected.push_back(std::make_pair(1, 4)); |
| 2228 |
| 2229 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2230 |
| 2231 // Consider is four columns. |
| 2232 consider = gfx::Rect(80, 50); |
| 2233 |
| 2234 // Layout of the tiling data, and expected return order: |
| 2235 // x 0 1 2 3 4 |
| 2236 // y.--------------- |
| 2237 // 0| 4 3 2 14 |
| 2238 // 1| 5 * 1 13 |
| 2239 // 2| 6 7 8 12 |
| 2240 // 3| 9 10 11 19 |
| 2241 // 4| 15 16 17 18 |
| 2242 expected.clear(); |
| 2243 expected.push_back(std::make_pair(2, 1)); |
| 2244 expected.push_back(std::make_pair(2, 0)); |
| 2245 expected.push_back(std::make_pair(1, 0)); |
| 2246 expected.push_back(std::make_pair(0, 0)); |
| 2247 expected.push_back(std::make_pair(0, 1)); |
| 2248 expected.push_back(std::make_pair(0, 2)); |
| 2249 expected.push_back(std::make_pair(1, 2)); |
| 2250 expected.push_back(std::make_pair(2, 2)); |
| 2251 expected.push_back(std::make_pair(0, 3)); |
| 2252 expected.push_back(std::make_pair(1, 3)); |
| 2253 expected.push_back(std::make_pair(2, 3)); |
| 2254 expected.push_back(std::make_pair(3, 2)); |
| 2255 expected.push_back(std::make_pair(3, 1)); |
| 2256 expected.push_back(std::make_pair(3, 0)); |
| 2257 expected.push_back(std::make_pair(0, 4)); |
| 2258 expected.push_back(std::make_pair(1, 4)); |
| 2259 expected.push_back(std::make_pair(2, 4)); |
| 2260 expected.push_back(std::make_pair(3, 4)); |
| 2261 expected.push_back(std::make_pair(3, 3)); |
| 2262 |
| 2263 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2264 } |
| 2265 |
| 2266 TEST(TilingDataTest, SpiralDifferenceIteratorWideTilesHasIgnore) { |
| 2267 TilingData tiling_data(gfx::Size(20, 10), gfx::Size(100, 50), false); |
| 2268 gfx::Rect consider(100, 50); |
| 2269 std::vector<std::pair<int, int>> expected; |
| 2270 gfx::Rect center(30, 15, 1, 1); |
| 2271 |
| 2272 // Full ignore. |
| 2273 gfx::Rect ignore(100, 50); |
| 2274 |
| 2275 // Layout of the tiling data, and expected return order: |
| 2276 // x 0 1 2 3 4 |
| 2277 // y.--------------- |
| 2278 // 0| I I I I I |
| 2279 // 1| I * I I I |
| 2280 // 2| I I I I I |
| 2281 // 3| I I I I I |
| 2282 // 4| I I I I I |
| 2283 expected.clear(); |
| 2284 |
| 2285 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2286 |
| 2287 // 3 column ignore. |
| 2288 ignore = gfx::Rect(30, 0, 40, 100); |
| 2289 |
| 2290 // Layout of the tiling data, and expected return order: |
| 2291 // x 0 1 2 3 4 |
| 2292 // y.--------------- |
| 2293 // 0| 1 I I I 9 |
| 2294 // 1| 2 * I I 8 |
| 2295 // 2| 3 I I I 7 |
| 2296 // 3| 4 I I I 6 |
| 2297 // 4| 5 I I I 10 |
| 2298 expected.clear(); |
| 2299 expected.push_back(std::make_pair(0, 0)); |
| 2300 expected.push_back(std::make_pair(0, 1)); |
| 2301 expected.push_back(std::make_pair(0, 2)); |
| 2302 expected.push_back(std::make_pair(0, 3)); |
| 2303 expected.push_back(std::make_pair(0, 4)); |
| 2304 expected.push_back(std::make_pair(4, 3)); |
| 2305 expected.push_back(std::make_pair(4, 2)); |
| 2306 expected.push_back(std::make_pair(4, 1)); |
| 2307 expected.push_back(std::make_pair(4, 0)); |
| 2308 expected.push_back(std::make_pair(4, 4)); |
| 2309 |
| 2310 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2311 |
| 2312 // Ignore covers the top half. |
| 2313 ignore = gfx::Rect(100, 25); |
| 2314 |
| 2315 // Layout of the tiling data, and expected return order: |
| 2316 // x 0 1 2 3 4 |
| 2317 // y.--------------- |
| 2318 // 0| I I I I I |
| 2319 // 1| I * I I I |
| 2320 // 2| I I I I I |
| 2321 // 3| 1 2 3 8 9 |
| 2322 // 4| 4 5 6 7 10 |
| 2323 expected.clear(); |
| 2324 expected.push_back(std::make_pair(0, 3)); |
| 2325 expected.push_back(std::make_pair(1, 3)); |
| 2326 expected.push_back(std::make_pair(2, 3)); |
| 2327 expected.push_back(std::make_pair(0, 4)); |
| 2328 expected.push_back(std::make_pair(1, 4)); |
| 2329 expected.push_back(std::make_pair(2, 4)); |
| 2330 expected.push_back(std::make_pair(3, 4)); |
| 2331 expected.push_back(std::make_pair(3, 3)); |
| 2332 expected.push_back(std::make_pair(4, 3)); |
| 2333 expected.push_back(std::make_pair(4, 4)); |
| 2334 |
| 2335 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2336 } |
| 2337 |
| 2338 TEST(TilingDataTest, SpiralDifferenceIteratorWideTilesRectangleCenter) { |
| 2339 TilingData tiling_data(gfx::Size(20, 10), gfx::Size(100, 50), false); |
| 2340 gfx::Rect consider(100, 50); |
| 2341 std::vector<std::pair<int, int>> expected; |
| 2342 gfx::Rect ignore; |
| 2343 |
| 2344 // Two cell center |
| 2345 gfx::Rect center(50, 25, 1, 10); |
| 2346 |
| 2347 // Layout of the tiling data, and expected return order: |
| 2348 // x 0 1 2 3 4 |
| 2349 // y.--------------- |
| 2350 // 0| 19 13 12 11 18 |
| 2351 // 1| 20 5 4 3 17 |
| 2352 // 2| 21 6 * 2 16 |
| 2353 // 3| 22 7 * 1 15 |
| 2354 // 4| 23 8 9 10 14 |
| 2355 expected.clear(); |
| 2356 expected.push_back(std::make_pair(3, 3)); |
| 2357 expected.push_back(std::make_pair(3, 2)); |
| 2358 expected.push_back(std::make_pair(3, 1)); |
| 2359 expected.push_back(std::make_pair(2, 1)); |
| 2360 expected.push_back(std::make_pair(1, 1)); |
| 2361 expected.push_back(std::make_pair(1, 2)); |
| 2362 expected.push_back(std::make_pair(1, 3)); |
| 2363 expected.push_back(std::make_pair(1, 4)); |
| 2364 expected.push_back(std::make_pair(2, 4)); |
| 2365 expected.push_back(std::make_pair(3, 4)); |
| 2366 expected.push_back(std::make_pair(3, 0)); |
| 2367 expected.push_back(std::make_pair(2, 0)); |
| 2368 expected.push_back(std::make_pair(1, 0)); |
| 2369 expected.push_back(std::make_pair(4, 4)); |
| 2370 expected.push_back(std::make_pair(4, 3)); |
| 2371 expected.push_back(std::make_pair(4, 2)); |
| 2372 expected.push_back(std::make_pair(4, 1)); |
| 2373 expected.push_back(std::make_pair(4, 0)); |
| 2374 expected.push_back(std::make_pair(0, 0)); |
| 2375 expected.push_back(std::make_pair(0, 1)); |
| 2376 expected.push_back(std::make_pair(0, 2)); |
| 2377 expected.push_back(std::make_pair(0, 3)); |
| 2378 expected.push_back(std::make_pair(0, 4)); |
| 2379 |
| 2380 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2381 |
| 2382 // Three by two center. |
| 2383 center = gfx::Rect(30, 25, 40, 10); |
| 2384 |
| 2385 // Layout of the tiling data, and expected return order: |
| 2386 // x 0 1 2 3 4 |
| 2387 // y.--------------- |
| 2388 // 0| 19 18 17 16 15 |
| 2389 // 1| 7 6 5 4 3 |
| 2390 // 2| 8 * * * 2 |
| 2391 // 3| 9 * * * 1 |
| 2392 // 4| 10 11 12 13 14 |
| 2393 expected.clear(); |
| 2394 expected.push_back(std::make_pair(4, 3)); |
| 2395 expected.push_back(std::make_pair(4, 2)); |
| 2396 expected.push_back(std::make_pair(4, 1)); |
| 2397 expected.push_back(std::make_pair(3, 1)); |
| 2398 expected.push_back(std::make_pair(2, 1)); |
| 2399 expected.push_back(std::make_pair(1, 1)); |
| 2400 expected.push_back(std::make_pair(0, 1)); |
| 2401 expected.push_back(std::make_pair(0, 2)); |
| 2402 expected.push_back(std::make_pair(0, 3)); |
| 2403 expected.push_back(std::make_pair(0, 4)); |
| 2404 expected.push_back(std::make_pair(1, 4)); |
| 2405 expected.push_back(std::make_pair(2, 4)); |
| 2406 expected.push_back(std::make_pair(3, 4)); |
| 2407 expected.push_back(std::make_pair(4, 4)); |
| 2408 expected.push_back(std::make_pair(4, 0)); |
| 2409 expected.push_back(std::make_pair(3, 0)); |
| 2410 expected.push_back(std::make_pair(2, 0)); |
| 2411 expected.push_back(std::make_pair(1, 0)); |
| 2412 expected.push_back(std::make_pair(0, 0)); |
| 2413 |
| 2414 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2415 |
| 2416 // Column center off the left side. |
| 2417 center = gfx::Rect(-100, 0, 60, 50); |
| 2418 |
| 2419 // Layout of the tiling data, and expected return order: |
| 2420 // x 0 1 2 3 4 |
| 2421 // y.--------------- |
| 2422 // * 0| 5 10 15 20 25 |
| 2423 // * 1| 4 9 14 19 24 |
| 2424 // * 2| 3 8 13 18 23 |
| 2425 // * 3| 2 7 12 17 22 |
| 2426 // * 4| 1 6 11 16 21 |
| 2427 expected.clear(); |
| 2428 expected.push_back(std::make_pair(0, 4)); |
| 2429 expected.push_back(std::make_pair(0, 3)); |
| 2430 expected.push_back(std::make_pair(0, 2)); |
| 2431 expected.push_back(std::make_pair(0, 1)); |
| 2432 expected.push_back(std::make_pair(0, 0)); |
| 2433 expected.push_back(std::make_pair(1, 4)); |
| 2434 expected.push_back(std::make_pair(1, 3)); |
| 2435 expected.push_back(std::make_pair(1, 2)); |
| 2436 expected.push_back(std::make_pair(1, 1)); |
| 2437 expected.push_back(std::make_pair(1, 0)); |
| 2438 expected.push_back(std::make_pair(2, 4)); |
| 2439 expected.push_back(std::make_pair(2, 3)); |
| 2440 expected.push_back(std::make_pair(2, 2)); |
| 2441 expected.push_back(std::make_pair(2, 1)); |
| 2442 expected.push_back(std::make_pair(2, 0)); |
| 2443 expected.push_back(std::make_pair(3, 4)); |
| 2444 expected.push_back(std::make_pair(3, 3)); |
| 2445 expected.push_back(std::make_pair(3, 2)); |
| 2446 expected.push_back(std::make_pair(3, 1)); |
| 2447 expected.push_back(std::make_pair(3, 0)); |
| 2448 expected.push_back(std::make_pair(4, 4)); |
| 2449 expected.push_back(std::make_pair(4, 3)); |
| 2450 expected.push_back(std::make_pair(4, 2)); |
| 2451 expected.push_back(std::make_pair(4, 1)); |
| 2452 expected.push_back(std::make_pair(4, 0)); |
| 2453 |
| 2454 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2455 } |
| 2456 |
| 2457 TEST(TilingDataTest, SpiralDifferenceIteratorWideTilesEdgeCases) { |
| 2458 TilingData tiling_data(gfx::Size(20, 10), gfx::Size(100, 50), false); |
| 2459 std::vector<std::pair<int, int>> expected; |
| 2460 gfx::Rect center; |
| 2461 gfx::Rect consider; |
| 2462 gfx::Rect ignore; |
| 2463 |
| 2464 // Ignore contains, but is not equal to, consider and center. |
| 2465 ignore = gfx::Rect(70, 0, 40, 50); |
| 2466 consider = gfx::Rect(80, 20, 20, 30); |
| 2467 center = gfx::Rect(90, 0, 5, 5); |
| 2468 |
| 2469 // Layout of the tiling data, and expected return order: |
| 2470 // x 0 1 2 3 4 |
| 2471 // y.--------------- |
| 2472 // 0| I * |
| 2473 // 1| I I |
| 2474 // 2| I I |
| 2475 // 3| I I |
| 2476 // 4| I I |
| 2477 expected.clear(); |
| 2478 |
| 2479 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2480 |
| 2481 // Center intersects with consider. |
| 2482 ignore = gfx::Rect(); |
| 2483 center = gfx::Rect(0, 30, 100, 20); |
| 2484 consider = gfx::Rect(40, 50); |
| 2485 |
| 2486 // Layout of the tiling data, and expected return order: |
| 2487 // x 0 1 2 3 4 |
| 2488 // y.--------------- |
| 2489 // 0| 6 5 |
| 2490 // 1| 4 3 |
| 2491 // 2| 2 1 |
| 2492 // 3| * * * * * |
| 2493 // 4| * * * * * |
| 2494 expected.clear(); |
| 2495 expected.push_back(std::make_pair(1, 2)); |
| 2496 expected.push_back(std::make_pair(0, 2)); |
| 2497 expected.push_back(std::make_pair(1, 1)); |
| 2498 expected.push_back(std::make_pair(0, 1)); |
| 2499 expected.push_back(std::make_pair(1, 0)); |
| 2500 expected.push_back(std::make_pair(0, 0)); |
| 2501 |
| 2502 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2503 |
| 2504 // Consider and ignore are non-intersecting. |
| 2505 ignore = gfx::Rect(30, 50); |
| 2506 consider = gfx::Rect(60, 0, 30, 50); |
| 2507 center = gfx::Rect(50, 0, 1, 1); |
| 2508 |
| 2509 // Layout of the tiling data, and expected return order: |
| 2510 // x 0 1 2 3 4 |
| 2511 // y.--------------- |
| 2512 // 0| I I * 1 5 |
| 2513 // 1| I I 2 4 |
| 2514 // 2| I I 3 8 |
| 2515 // 3| I I 6 7 |
| 2516 // 4| I I 9 10 |
| 2517 expected.clear(); |
| 2518 expected.push_back(std::make_pair(3, 0)); |
| 2519 expected.push_back(std::make_pair(3, 1)); |
| 2520 expected.push_back(std::make_pair(3, 2)); |
| 2521 expected.push_back(std::make_pair(4, 1)); |
| 2522 expected.push_back(std::make_pair(4, 0)); |
| 2523 expected.push_back(std::make_pair(3, 3)); |
| 2524 expected.push_back(std::make_pair(4, 3)); |
| 2525 expected.push_back(std::make_pair(4, 2)); |
| 2526 expected.push_back(std::make_pair(3, 4)); |
| 2527 expected.push_back(std::make_pair(4, 4)); |
| 2528 |
| 2529 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2530 |
| 2531 // Center intersects with ignore. |
| 2532 consider = gfx::Rect(100, 50); |
| 2533 center = gfx::Rect(50, 0, 1, 50); |
| 2534 ignore = gfx::Rect(0, 25, 100, 1); |
| 2535 |
| 2536 // Layout of the tiling data, and expected return order: |
| 2537 // x 0 1 2 3 4 |
| 2538 // y.--------------- |
| 2539 // 0| 13 5 * 4 12 |
| 2540 // 1| 14 6 * 3 11 |
| 2541 // 2| I I * I I |
| 2542 // 3| 15 7 * 2 10 |
| 2543 // 4| 16 8 * 1 9 |
| 2544 expected.clear(); |
| 2545 expected.push_back(std::make_pair(3, 4)); |
| 2546 expected.push_back(std::make_pair(3, 3)); |
| 2547 expected.push_back(std::make_pair(3, 1)); |
| 2548 expected.push_back(std::make_pair(3, 0)); |
| 2549 expected.push_back(std::make_pair(1, 0)); |
| 2550 expected.push_back(std::make_pair(1, 1)); |
| 2551 expected.push_back(std::make_pair(1, 3)); |
| 2552 expected.push_back(std::make_pair(1, 4)); |
| 2553 expected.push_back(std::make_pair(4, 4)); |
| 2554 expected.push_back(std::make_pair(4, 3)); |
| 2555 expected.push_back(std::make_pair(4, 1)); |
| 2556 expected.push_back(std::make_pair(4, 0)); |
| 2557 expected.push_back(std::make_pair(0, 0)); |
| 2558 expected.push_back(std::make_pair(0, 1)); |
| 2559 expected.push_back(std::make_pair(0, 3)); |
| 2560 expected.push_back(std::make_pair(0, 4)); |
| 2561 |
| 2562 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2563 |
| 2564 // Center and ignore are the same. |
| 2565 consider = gfx::Rect(100, 50); |
| 2566 center = gfx::Rect(50, 0, 1, 50); |
| 2567 ignore = center; |
| 2568 |
| 2569 // Layout of the tiling data, and expected return order: |
| 2570 // x 0 1 2 3 4 |
| 2571 // y.--------------- |
| 2572 // 0| 16 6 * 5 15 |
| 2573 // 1| 17 7 * 4 14 |
| 2574 // 2| 18 8 * 3 13 |
| 2575 // 3| 19 9 * 2 12 |
| 2576 // 4| 20 10 * 1 11 |
| 2577 expected.clear(); |
| 2578 expected.push_back(std::make_pair(3, 4)); |
| 2579 expected.push_back(std::make_pair(3, 3)); |
| 2580 expected.push_back(std::make_pair(3, 2)); |
| 2581 expected.push_back(std::make_pair(3, 1)); |
| 2582 expected.push_back(std::make_pair(3, 0)); |
| 2583 expected.push_back(std::make_pair(1, 0)); |
| 2584 expected.push_back(std::make_pair(1, 1)); |
| 2585 expected.push_back(std::make_pair(1, 2)); |
| 2586 expected.push_back(std::make_pair(1, 3)); |
| 2587 expected.push_back(std::make_pair(1, 4)); |
| 2588 expected.push_back(std::make_pair(4, 4)); |
| 2589 expected.push_back(std::make_pair(4, 3)); |
| 2590 expected.push_back(std::make_pair(4, 2)); |
| 2591 expected.push_back(std::make_pair(4, 1)); |
| 2592 expected.push_back(std::make_pair(4, 0)); |
| 2593 expected.push_back(std::make_pair(0, 0)); |
| 2594 expected.push_back(std::make_pair(0, 1)); |
| 2595 expected.push_back(std::make_pair(0, 2)); |
| 2596 expected.push_back(std::make_pair(0, 3)); |
| 2597 expected.push_back(std::make_pair(0, 4)); |
| 2598 |
| 2599 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2600 |
| 2601 // Empty tiling data. |
| 2602 TilingData empty_data(gfx::Size(0, 0), gfx::Size(0, 0), false); |
| 2603 |
| 2604 expected.clear(); |
| 2605 |
| 2606 TestSpiralIterate(__LINE__, empty_data, consider, ignore, center, expected); |
| 2607 |
| 2608 // Empty consider. |
| 2609 ignore = gfx::Rect(); |
| 2610 center = gfx::Rect(1, 1, 1, 1); |
| 2611 consider = gfx::Rect(); |
| 2612 |
| 2613 expected.clear(); |
| 2614 |
| 2615 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2616 |
| 2617 // Empty center. Note: This arbitrarily puts the center to be off the top-left |
| 2618 // corner. |
| 2619 consider = gfx::Rect(100, 50); |
| 2620 ignore = gfx::Rect(); |
| 2621 center = gfx::Rect(); |
| 2622 |
| 2623 // Layout of the tiling data, and expected return order: |
| 2624 // x 0 1 2 3 4 |
| 2625 // y.--------------- |
| 2626 // 0| 1 3 11 19 24 |
| 2627 // 1| 2 6 10 18 23 |
| 2628 // 2| 4 5 16 17 22 |
| 2629 // 3| 7 8 9 20 21 |
| 2630 // 4| 12 13 14 15 25 |
| 2631 expected.clear(); |
| 2632 expected.push_back(std::make_pair(0, 0)); |
| 2633 expected.push_back(std::make_pair(0, 1)); |
| 2634 expected.push_back(std::make_pair(1, 0)); |
| 2635 expected.push_back(std::make_pair(0, 2)); |
| 2636 expected.push_back(std::make_pair(1, 2)); |
| 2637 expected.push_back(std::make_pair(1, 1)); |
| 2638 expected.push_back(std::make_pair(0, 3)); |
| 2639 expected.push_back(std::make_pair(1, 3)); |
| 2640 expected.push_back(std::make_pair(2, 3)); |
| 2641 expected.push_back(std::make_pair(2, 1)); |
| 2642 expected.push_back(std::make_pair(2, 0)); |
| 2643 expected.push_back(std::make_pair(0, 4)); |
| 2644 expected.push_back(std::make_pair(1, 4)); |
| 2645 expected.push_back(std::make_pair(2, 4)); |
| 2646 expected.push_back(std::make_pair(3, 4)); |
| 2647 expected.push_back(std::make_pair(2, 2)); |
| 2648 expected.push_back(std::make_pair(3, 2)); |
| 2649 expected.push_back(std::make_pair(3, 1)); |
| 2650 expected.push_back(std::make_pair(3, 0)); |
| 2651 expected.push_back(std::make_pair(3, 3)); |
| 2652 expected.push_back(std::make_pair(4, 3)); |
| 2653 expected.push_back(std::make_pair(4, 2)); |
| 2654 expected.push_back(std::make_pair(4, 1)); |
| 2655 expected.push_back(std::make_pair(4, 0)); |
| 2656 expected.push_back(std::make_pair(4, 4)); |
| 2657 |
| 2658 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2659 |
| 2660 // Every rect is empty. |
| 2661 ignore = gfx::Rect(); |
| 2662 center = gfx::Rect(); |
| 2663 consider = gfx::Rect(); |
| 2664 |
| 2665 expected.clear(); |
| 2666 |
| 2667 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2668 |
| 2669 // Center is just to the left of cover, and off of the tiling's left side. |
| 2670 consider = gfx::Rect(100, 50); |
| 2671 ignore = gfx::Rect(); |
| 2672 center = gfx::Rect(-40, 0, 39, 50); |
| 2673 |
| 2674 // Layout of the tiling data, and expected return order: |
| 2675 // x 0 1 2 3 4 |
| 2676 // y.--------------- |
| 2677 // * 0| 5 10 15 20 25 |
| 2678 // * 1| 4 9 14 19 24 |
| 2679 // * 2| 3 8 13 18 23 |
| 2680 // * 3| 2 7 12 17 22 |
| 2681 // * 4| 1 6 11 16 21 |
| 2682 expected.clear(); |
| 2683 expected.push_back(std::make_pair(0, 4)); |
| 2684 expected.push_back(std::make_pair(0, 3)); |
| 2685 expected.push_back(std::make_pair(0, 2)); |
| 2686 expected.push_back(std::make_pair(0, 1)); |
| 2687 expected.push_back(std::make_pair(0, 0)); |
| 2688 expected.push_back(std::make_pair(1, 4)); |
| 2689 expected.push_back(std::make_pair(1, 3)); |
| 2690 expected.push_back(std::make_pair(1, 2)); |
| 2691 expected.push_back(std::make_pair(1, 1)); |
| 2692 expected.push_back(std::make_pair(1, 0)); |
| 2693 expected.push_back(std::make_pair(2, 4)); |
| 2694 expected.push_back(std::make_pair(2, 3)); |
| 2695 expected.push_back(std::make_pair(2, 2)); |
| 2696 expected.push_back(std::make_pair(2, 1)); |
| 2697 expected.push_back(std::make_pair(2, 0)); |
| 2698 expected.push_back(std::make_pair(3, 4)); |
| 2699 expected.push_back(std::make_pair(3, 3)); |
| 2700 expected.push_back(std::make_pair(3, 2)); |
| 2701 expected.push_back(std::make_pair(3, 1)); |
| 2702 expected.push_back(std::make_pair(3, 0)); |
| 2703 expected.push_back(std::make_pair(4, 4)); |
| 2704 expected.push_back(std::make_pair(4, 3)); |
| 2705 expected.push_back(std::make_pair(4, 2)); |
| 2706 expected.push_back(std::make_pair(4, 1)); |
| 2707 expected.push_back(std::make_pair(4, 0)); |
| 2708 |
| 2709 TestSpiralIterate(__LINE__, tiling_data, consider, ignore, center, expected); |
| 2710 |
| 2711 // Tiling is smaller than tile size and center rect is not intersecting to |
| 2712 // tiling rect. |
| 2713 TilingData smaller_tiling(gfx::Size(20, 10), gfx::Size(1, 1), false); |
| 2714 consider = gfx::Rect(20, 10); |
| 2715 ignore = gfx::Rect(); |
| 2716 center = gfx::Rect(2, 2, 20, 10); |
| 2717 |
| 2718 // Layout of the tiling data, and expected return order: |
| 2719 // x 0 |
| 2720 // y.--- |
| 2721 // 0| 1 |
| 2722 // | * |
| 2723 expected.clear(); |
| 2724 expected.push_back(std::make_pair(0, 0)); |
| 2725 |
| 2726 TestSpiralIterate(__LINE__, smaller_tiling, consider, ignore, center, |
| 2727 expected); |
| 2728 } |
| 2729 |
| 1956 } // namespace | 2730 } // namespace |
| 1957 | 2731 |
| 1958 } // namespace cc | 2732 } // namespace cc |
| OLD | NEW |