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