summaryrefslogtreecommitdiffstats
path: root/basicsuite/shared
diff options
context:
space:
mode:
authorJuho Annunen <juho.annunen@qt.io>2018-08-29 12:45:14 +0300
committerJuho Annunen <juho.annunen@qt.io>2018-08-29 10:55:16 +0000
commitf730907fcfeb2548554f291025f2991598df8fda (patch)
tree50f59437747535d9260df654eb893917d76922f4 /basicsuite/shared
parent09aa32dd522176a9b9762e4d85b3e8c66d4d6be2 (diff)
Fix mediaplayer default video path
Task-number: QTBUG-70198 Change-Id: If07b7e618e109893ab19cf1c7147c98e5ae8f17f Reviewed-by: Mikko Gronoff <mikko.gronoff@qt.io> Reviewed-by: Teemu Holappa <teemu.holappa@qt.io>
Diffstat (limited to 'basicsuite/shared')
-rw-r--r--basicsuite/shared/main.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/basicsuite/shared/main.cpp b/basicsuite/shared/main.cpp
index d22ea8a..e07e09c 100644
--- a/basicsuite/shared/main.cpp
+++ b/basicsuite/shared/main.cpp
@@ -135,10 +135,6 @@ int main(int argc, char **argv)
QGuiApplication::setFont(font);
}
- QString videosPath = QStringLiteral("file://");
- QString defaultVideoUrl = QStringLiteral("file:///data/videos/Qt_video_720p.webm");
- videosPath.append("/data/videos");
-
QSettings styleSettings;
QString style = styleSettings.value("style").toString();
if (style.isEmpty() || style == "Default")
@@ -153,17 +149,17 @@ int main(int argc, char **argv)
applicationengine.rootContext()->setContextProperty("appFont", appFont);
applicationengine.rootContext()->setContextProperty("availableStyles", QQuickStyle::availableStyles());
- applicationengine.rootContext()->setContextProperty("VideosLocation", videosPath);
- applicationengine.rootContext()->setContextProperty("DefaultVideoUrl", defaultVideoUrl);
+ QSettings demoSettings("Boot2Qt-demos", "demoSettings");
- QSettings themeColorSettings("QtLauncher", "colorSettings");
+ applicationengine.rootContext()->setContextProperty("_backgroundColor", demoSettings.value("backgroundColor", "#09102b"));
+ applicationengine.rootContext()->setContextProperty("_primaryGreen", demoSettings.value("primaryGreen", "#41cd52"));
+ applicationengine.rootContext()->setContextProperty("_mediumGreen", demoSettings.value("mediumGreen", "#21be2b"));
+ applicationengine.rootContext()->setContextProperty("_darkGreen", demoSettings.value("darkGreen", "#17a81a"));
+ applicationengine.rootContext()->setContextProperty("_primaryGrey", demoSettings.value("primaryGrey", "#9d9faa"));
+ applicationengine.rootContext()->setContextProperty("_secondaryGrey", demoSettings.value("secondaryGrey", "#3a4055"));
- applicationengine.rootContext()->setContextProperty("_backgroundColor", themeColorSettings.value("backgroundColor", "#09102b"));
- applicationengine.rootContext()->setContextProperty("_primaryGreen", themeColorSettings.value("primaryGreen", "#41cd52"));
- applicationengine.rootContext()->setContextProperty("_mediumGreen", themeColorSettings.value("mediumGreen", "#21be2b"));
- applicationengine.rootContext()->setContextProperty("_darkGreen", themeColorSettings.value("darkGreen", "#17a81a"));
- applicationengine.rootContext()->setContextProperty("_primaryGrey", themeColorSettings.value("primaryGrey", "#9d9faa"));
- applicationengine.rootContext()->setContextProperty("_secondaryGrey", themeColorSettings.value("secondaryGrey", "#3a4055"));
+ applicationengine.rootContext()->setContextProperty("VideosLocation", demoSettings.value("videosLocation", "file:///data/videos"));
+ applicationengine.rootContext()->setContextProperty("DefaultVideoUrl", demoSettings.value("defaultVideoUrl", "file:///data/videos/Qt+for+Designers+and+Developers.mp4"));
applicationengine.load(QUrl::fromLocalFile(path + "/SharedMain.qml"));
'#n210'>210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

//TESTED_COMPONENT=src/location

#include <QtTest/QtTest>
#include <QtPositioning/QGeoCoordinate>
#include <QtPositioning/QGeoCircle>
#include <QtPositioning/QGeoRectangle>

QT_USE_NAMESPACE

class tst_QGeoRectangle : public QObject
{
    Q_OBJECT

private slots:
    void default_constructor();
    void center_constructor();
    void corner_constructor();
    void list_constructor();
    void copy_constructor();
    void assignment();
    void destructor();

    void equality();
    void equality_data();

    void isValid();
    void isValid_data();

    void isEmpty();
    void isEmpty_data();

    void corners();
    void corners_data();

    void setCorners();

    void width();
    void width_data();

    void height();
    void height_data();

    void center();
    void center_data();

    void boundingGeoRectangle();
    void boundingGeoRectangle_data();

    void containsCoord();
    void containsCoord_data();

    void containsBoxAndIntersects();
    void containsBoxAndIntersects_data();

    void translate();
    void translate_data();

    void unite();
    void unite_data();

    void extendRectangle();
    void extendRectangle_data();

    void areaComparison();
    void areaComparison_data();

    void circleComparison();
    void circleComparison_data();

    void hashing();
};

void tst_QGeoRectangle::default_constructor()
{
    QGeoRectangle box;
    QCOMPARE(box.topLeft().isValid(), false);
    QCOMPARE(box.bottomRight().isValid(), false);
}

void tst_QGeoRectangle::center_constructor()
{
    QGeoRectangle b1 = QGeoRectangle(QGeoCoordinate(5.0, 5.0), 10.0, 10.0);

    QCOMPARE(b1.topLeft(), QGeoCoordinate(10.0, 0.0));
    QCOMPARE(b1.bottomRight(), QGeoCoordinate(0.0, 10.0));
}

void tst_QGeoRectangle::corner_constructor()
{
    QGeoRectangle b1 = QGeoRectangle(QGeoCoordinate(10.0, 0.0),
                                         QGeoCoordinate(0.0, 10.0));

    QCOMPARE(b1.topLeft(), QGeoCoordinate(10.0, 0.0));
    QCOMPARE(b1.bottomRight(), QGeoCoordinate(0.0, 10.0));
}

void tst_QGeoRectangle::list_constructor()
{
    QList<QGeoCoordinate> coordinates;
    QGeoRectangle b1 = QGeoRectangle(coordinates);
    QCOMPARE(b1.isValid(), false);

    coordinates << QGeoCoordinate(10.0, 0.0);
    b1 = QGeoRectangle(coordinates);
    QCOMPARE(b1.isValid(), true);
    QCOMPARE(b1.isEmpty(), true);

    coordinates << QGeoCoordinate(0.0, 10.0) << QGeoCoordinate(0.0, 5.0);
    b1 = QGeoRectangle(coordinates);
    QCOMPARE(b1.topLeft(), QGeoCoordinate(10.0,0.0));
    QCOMPARE(b1.bottomRight(), QGeoCoordinate(0.0, 10.0));
}

void tst_QGeoRectangle::copy_constructor()
{
    QGeoRectangle b1 = QGeoRectangle(QGeoCoordinate(10.0, 0.0),
                                         QGeoCoordinate(0.0, 10.0));
    QGeoRectangle b2 = QGeoRectangle(b1);

    QCOMPARE(b2.topLeft(), QGeoCoordinate(10.0, 0.0));
    QCOMPARE(b2.bottomRight(), QGeoCoordinate(0.0, 10.0));

    b2.setTopLeft(QGeoCoordinate(30.0, 0.0));
    b2.setBottomRight(QGeoCoordinate(0.0, 30.0));
    QCOMPARE(b1.topLeft(), QGeoCoordinate(10.0, 0.0));
    QCOMPARE(b1.bottomRight(), QGeoCoordinate(0.0, 10.0));

    QGeoShape area;
    QGeoRectangle areaBox(area);
    QVERIFY(!areaBox.isValid());
    QVERIFY(areaBox.isEmpty());

    QGeoCircle circle;
    QGeoRectangle circleBox(circle);
    QVERIFY(!circleBox.isValid());
    QVERIFY(circleBox.isEmpty());
}

void tst_QGeoRectangle::destructor()
{
    QGeoRectangle *box = new QGeoRectangle();
    delete box;
    // checking for a crash
}

void tst_QGeoRectangle::assignment()
{
    QGeoRectangle b1 = QGeoRectangle(QGeoCoordinate(10.0, 0.0),
                                         QGeoCoordinate(0.0, 10.0));
    QGeoRectangle b2 = QGeoRectangle(QGeoCoordinate(20.0, 0.0),
                                         QGeoCoordinate(0.0, 20.0));

    QVERIFY(b1 != b2);

    b2 = b1;
    QCOMPARE(b2.topLeft(), QGeoCoordinate(10.0, 0.0));
    QCOMPARE(b2.bottomRight(), QGeoCoordinate(0.0, 10.0));
    QCOMPARE(b1, b2);

    b2.setTopLeft(QGeoCoordinate(30.0, 0.0));
    b2.setBottomRight(QGeoCoordinate(0.0, 30.0));
    QCOMPARE(b1.topLeft(), QGeoCoordinate(10.0, 0.0));
    QCOMPARE(b1.bottomRight(), QGeoCoordinate(0.0, 10.0));

    // Assign b1 to an area
    QGeoShape area = b1;
    QCOMPARE(area.type(), b1.type());
    QVERIFY(area == b1);

    // Assign the area back to a bounding box
    QGeoRectangle ba = area;
    QCOMPARE(ba.topLeft(), b1.topLeft());
    QCOMPARE(ba.bottomRight(), b1.bottomRight());

    // Check that the copy is not modified when modifying the original.
    b1.setTopLeft(QGeoCoordinate(80, 30));
    QVERIFY(ba.topLeft() != b1.topLeft());
    QVERIFY(ba != b1);
}

void tst_QGeoRectangle::equality()
{
    QFETCH(QGeoRectangle, box1);
    QFETCH(QGeoRectangle, box2);
    QFETCH(QGeoShape, area1);
    QFETCH(QGeoShape, area2);
    QFETCH(bool, equal);

    // compare boxes
    QCOMPARE((box1 == box2), equal);
    QCOMPARE((box1 != box2), !equal);

    // compare areas
    QCOMPARE((area1 == area2), equal);
    QCOMPARE((area1 != area2), !equal);

    // compare area to box
    QCOMPARE((area1 == box2), equal);
    QCOMPARE((area1 != box2), !equal);

    // compare box to area
    QCOMPARE((box1 == area2), equal);
    QCOMPARE((box1 != area2), !equal);
}

void tst_QGeoRectangle::equality_data()
{
    QTest::addColumn<QGeoRectangle>("box1");
    QTest::addColumn<QGeoRectangle>("box2");
    QTest::addColumn<QGeoShape>("area1");
    QTest::addColumn<QGeoShape>("area2");
    QTest::addColumn<bool>("equal");

    QGeoCoordinate c1(10, 5);
    QGeoCoordinate c2(5, 10);
    QGeoCoordinate c3(20, 15);
    QGeoCoordinate c4(15, 20);

    QGeoRectangle b1(c1, c2);
    QGeoRectangle b2(c3, c4);
    QGeoRectangle b3(c3, c2);
    QGeoRectangle b4(c1, c3);
    QGeoRectangle b5(c1, c2);

    QGeoShape a1(b1);
    QGeoShape a2(b2);
    QGeoShape a3(b3);
    QGeoShape a4(b4);
    QGeoShape a5(b5);

    QTest::newRow("all unequal")
            << b1 << b2 << a1 << a2 << false;
    QTest::newRow("top left unequal")
            << b1 << b3 << a1 << a3 << false;
    QTest::newRow("bottom right unequal")
            << b1 << b4 << a1 << a4 << false;
    QTest::newRow("equal")
            << b1 << b5 << a1 << a5 << true;
}

void tst_QGeoRectangle::isValid()
{
    QFETCH(QGeoRectangle, input);
    QFETCH(bool, valid);

    QCOMPARE(input.isValid(), valid);

    QGeoShape area = input;
    QCOMPARE(area.isValid(), valid);
}

void tst_QGeoRectangle::isValid_data()
{
    QTest::addColumn<QGeoRectangle>("input");
    QTest::addColumn<bool>("valid");

    QGeoCoordinate c0;
    QGeoCoordinate c1(10, 5);
    QGeoCoordinate c2(5, 10);

    QTest::newRow("both corners invalid")
        << QGeoRectangle(c0, c0) << false;
    QTest::newRow("top left corner invalid")
        << QGeoRectangle(c0, c2) << false;
    QTest::newRow("bottom right corner invalid")
        << QGeoRectangle(c1, c0) << false;
    QTest::newRow("height in wrong order")
        << QGeoRectangle(c2, c1) << false;
    QTest::newRow("both corners valid")
        << QGeoRectangle(c1, c2) << true;
}

void tst_QGeoRectangle::isEmpty()
{
    QFETCH(QGeoRectangle, input);
    QFETCH(bool, empty);

    QCOMPARE(input.isEmpty(), empty);

    QGeoShape area = input;
    QCOMPARE(area.isEmpty(), empty);
}

void tst_QGeoRectangle::isEmpty_data()
{
    QTest::addColumn<QGeoRectangle>("input");
    QTest::addColumn<bool>("empty");

    QGeoCoordinate c0;
    QGeoCoordinate c1(10, 5);
    QGeoCoordinate c2(5, 10);
    QGeoCoordinate c3(10, 10);

    QTest::newRow("both corners invalid")
        << QGeoRectangle(c0, c0) << true;
    QTest::newRow("top left corner invalid")
        << QGeoRectangle(c0, c2) << true;
    QTest::newRow("bottom right corner invalid")
        << QGeoRectangle(c1, c0) << true;
    QTest::newRow("zero width")
            << QGeoRectangle(c1, c3) << true;
    QTest::newRow("zero height")
            << QGeoRectangle(c3, c2) << true;
    QTest::newRow("zero width and height")
            << QGeoRectangle(c1, c1) << true;
    QTest::newRow("non-zero width and height")
            << QGeoRectangle(c1, c2) << false;
}

void tst_QGeoRectangle::corners()
{
    QFETCH(QGeoRectangle, box);
    QFETCH(QGeoCoordinate, topLeft);
    QFETCH(QGeoCoordinate, topRight);
    QFETCH(QGeoCoordinate, bottomLeft);
    QFETCH(QGeoCoordinate, bottomRight);

    QCOMPARE(box.topLeft(), topLeft);
    QCOMPARE(box.topRight(), topRight);
    QCOMPARE(box.bottomLeft(), bottomLeft);
    QCOMPARE(box.bottomRight(), bottomRight);
}

void tst_QGeoRectangle::corners_data()
{
    QTest::addColumn<QGeoRectangle>("box");
    QTest::addColumn<QGeoCoordinate>("topLeft");
    QTest::addColumn<QGeoCoordinate>("topRight");
    QTest::addColumn<QGeoCoordinate>("bottomLeft");
    QTest::addColumn<QGeoCoordinate>("bottomRight");

    QGeoCoordinate c0;
    QGeoCoordinate tl(10, 5);
    QGeoCoordinate br(5, 10);
    QGeoCoordinate tr(10, 10);
    QGeoCoordinate bl(5, 5);

    QTest::newRow("both invalid")
            << QGeoRectangle(c0, c0)
            << c0
            << c0
            << c0
            << c0;
    QTest::newRow("top left invalid")
            << QGeoRectangle(c0, br)
            << c0
            << c0
            << c0
            << br;
    QTest::newRow("bottom right invalid")
            << QGeoRectangle(tl, c0)
            << tl
            << c0
            << c0
            << c0;
    QTest::newRow("both valid")
            << QGeoRectangle(tl, br)
            << tl
            << tr
            << bl
            << br;
}

void tst_QGeoRectangle::setCorners()
{
    QGeoRectangle box(QGeoCoordinate(10.0, 0.0),
                        QGeoCoordinate(0.0, 10.0));

    box.setTopLeft(QGeoCoordinate(20.0, -10.0));

    QCOMPARE(box.topLeft(), QGeoCoordinate(20.0, -10.0));
    QCOMPARE(box.topRight(), QGeoCoordinate(20.0, 10.0));
    QCOMPARE(box.bottomLeft(), QGeoCoordinate(0.0, -10.0));
    QCOMPARE(box.bottomRight(), QGeoCoordinate(0.0, 10.0));

    box.setTopRight(QGeoCoordinate(30.0, 20.0));

    QCOMPARE(box.topLeft(), QGeoCoordinate(30.0, -10.0));
    QCOMPARE(box.topRight(), QGeoCoordinate(30.0, 20.0));
    QCOMPARE(box.bottomLeft(), QGeoCoordinate(0.0, -10.0));
    QCOMPARE(box.bottomRight(), QGeoCoordinate(0.0, 20.0));

    box.setBottomRight(QGeoCoordinate(-10.0, 30.0));

    QCOMPARE(box.topLeft(), QGeoCoordinate(30.0, -10.0));
    QCOMPARE(box.topRight(), QGeoCoordinate(30.0, 30.0));
    QCOMPARE(box.bottomLeft(), QGeoCoordinate(-10.0, -10.0));
    QCOMPARE(box.bottomRight(), QGeoCoordinate(-10.0, 30.0));

    box.setBottomLeft(QGeoCoordinate(-20.0, -20.0));

    QCOMPARE(box.topLeft(), QGeoCoordinate(30.0, -20.0));
    QCOMPARE(box.topRight(), QGeoCoordinate(30.0, 30.0));
    QCOMPARE(box.bottomLeft(), QGeoCoordinate(-20.0, -20.0));
    QCOMPARE(box.bottomRight(), QGeoCoordinate(-20.0, 30.0));


}

void tst_QGeoRectangle::width()
{
    QFETCH(QGeoRectangle, box);
    QFETCH(double, oldWidth);
    QFETCH(double, newWidth);
    QFETCH(QGeoRectangle, newBox);

    if (qIsNaN(oldWidth))
        QVERIFY(qIsNaN(box.width()));
    else
        QCOMPARE(box.width(), oldWidth);

    box.setWidth(newWidth);

    QCOMPARE(box, newBox);
}

void tst_QGeoRectangle::width_data()
{
    QTest::addColumn<QGeoRectangle>("box");
    QTest::addColumn<double>("oldWidth");
    QTest::addColumn<double>("newWidth");
    QTest::addColumn<QGeoRectangle>("newBox");

    QTest::newRow("invalid box")
            << QGeoRectangle()
            << qQNaN()
            << 100.0
            << QGeoRectangle();

     QTest::newRow("0 width -> negative width")
             << QGeoRectangle(QGeoCoordinate(10.0, 90.0),
                                QGeoCoordinate(5.0, 90.0))
             << 0.0
             << -1.0
             << QGeoRectangle(QGeoCoordinate(10.0, 90.0),
                                QGeoCoordinate(5.0, 90.0));

     QTest::newRow("0 width -> 0 width")
             << QGeoRectangle(QGeoCoordinate(10.0, 90.0),
                                QGeoCoordinate(5.0, 90.0))
             << 0.0
             << 0.0
             << QGeoRectangle(QGeoCoordinate(10.0, 90.0),
                                QGeoCoordinate(5.0, 90.0));

     QTest::newRow("0 width -> non wrapping width")
             << QGeoRectangle(QGeoCoordinate(10.0, 90.0),
                                QGeoCoordinate(5.0, 90.0))
             << 0.0
             << 10.0
             << QGeoRectangle(QGeoCoordinate(10.0, 85.0),
                                QGeoCoordinate(5.0, 95.0));

     QTest::newRow("0 width -> wrapping width positive")
             << QGeoRectangle(QGeoCoordinate(10.0, 90.0),
                                QGeoCoordinate(5.0, 90.0))
             << 0.0
             << 190.0
             << QGeoRectangle(QGeoCoordinate(10.0, -5.0),
                                QGeoCoordinate(5.0, -175.0));

     QTest::newRow("0 width -> wrapping width negative")
             << QGeoRectangle(QGeoCoordinate(10.0, -90.0),
                                QGeoCoordinate(5.0, -90.0))
             << 0.0
             << 190.0
             << QGeoRectangle(QGeoCoordinate(10.0, 175.0),
                                QGeoCoordinate(5.0, 5.0));

     QTest::newRow("0 width -> 360 width")
             << QGeoRectangle(QGeoCoordinate(10.0, 90.0),
                                QGeoCoordinate(5.0, 90.0))
             << 0.0
             << 360.0
             << QGeoRectangle(QGeoCoordinate(10.0, -180.0),
                                QGeoCoordinate(5.0, 180.0));

     QTest::newRow("0 width -> 360+ width")
             << QGeoRectangle(QGeoCoordinate(10.0, 90.0),
                                QGeoCoordinate(5.0, 90.0))
             << 0.0
             << 370.0
             << QGeoRectangle(QGeoCoordinate(10.0, -180.0),
                                QGeoCoordinate(5.0, 180.0));

     QTest::newRow("non wrapping width -> negative width")
             << QGeoRectangle(QGeoCoordinate(10.0, 85.0),
                                QGeoCoordinate(5.0, 95.0))
             << 10.0
             << -1.0
             << QGeoRectangle(QGeoCoordinate(10.0, 85.0),
                                QGeoCoordinate(5.0, 95.0));

     QTest::newRow("non wrapping width -> 0 width")
             << QGeoRectangle(QGeoCoordinate(10.0, 85.0),
                                QGeoCoordinate(5.0, 95.0))
             << 10.0
             << 0.0
             << QGeoRectangle(QGeoCoordinate(10.0, 90.0),
                                QGeoCoordinate(5.0, 90.0));

     QTest::newRow("non wrapping width -> non wrapping width")
             << QGeoRectangle(QGeoCoordinate(10.0, 85.0),
                                QGeoCoordinate(5.0, 95.0))
             << 10.0
             << 20.0
             << QGeoRectangle(QGeoCoordinate(10.0, 80.0),
                                QGeoCoordinate(5.0, 100.0));

     QTest::newRow("non wrapping width -> wrapping width positive")
             << QGeoRectangle(QGeoCoordinate(10.0, 85.0),
                                QGeoCoordinate(5.0, 95.0))
             << 10.0
             << 190.0
             << QGeoRectangle(QGeoCoordinate(10.0, -5.0),
                                QGeoCoordinate(5.0, -175.0));

     QTest::newRow("non wrapping width -> wrapping width negative")
             << QGeoRectangle(QGeoCoordinate(10.0, -95.0),
                                QGeoCoordinate(5.0, -85.0))
             << 10.0
             << 190.0
             << QGeoRectangle(QGeoCoordinate(10.0, 175.0),
                                QGeoCoordinate(5.0, 5.0));

     QTest::newRow("non wrapping width -> 360 width")
             << QGeoRectangle(QGeoCoordinate(10.0, 85.0),
                                QGeoCoordinate(5.0, 95.0))
             << 10.0
             << 360.0
             << QGeoRectangle(QGeoCoordinate(10.0, -180.0),
                                QGeoCoordinate(5.0, 180.0));

     QTest::newRow("non wrapping width width -> 360+ width")
             << QGeoRectangle(QGeoCoordinate(10.0, 85.0),
                                QGeoCoordinate(5.0, 95.0))
             << 10.0
             << 370.0
             << QGeoRectangle(QGeoCoordinate(10.0, -180.0),
                                QGeoCoordinate(5.0, 180.0));

     QTest::newRow("wrapping width -> negative width")
             << QGeoRectangle(QGeoCoordinate(10.0, 175.0),
                                QGeoCoordinate(5.0, -85.0))
             << 100.0
             << -1.0
             << QGeoRectangle(QGeoCoordinate(10.0, 175.0),
                                QGeoCoordinate(5.0, -85.0));

     QTest::newRow("wrapping width -> 0 width")
             << QGeoRectangle(QGeoCoordinate(10.0, 175.0),
                                QGeoCoordinate(5.0, -85.0))
             << 100.0
             << 0.0
             << QGeoRectangle(QGeoCoordinate(10.0, -135.0),
                                QGeoCoordinate(5.0, -135.0));

     QTest::newRow("wrapping width -> non wrapping width")
             << QGeoRectangle(QGeoCoordinate(10.0, 175.0),
                                QGeoCoordinate(5.0, -85.0))
             << 100.0
             << 80.0
             << QGeoRectangle(QGeoCoordinate(10.0, -175.0),
                                QGeoCoordinate(5.0, -95.0));

     QTest::newRow("wrapping width -> wrapping width")
             << QGeoRectangle(QGeoCoordinate(10.0, 175.0),
                                QGeoCoordinate(5.0, -85.0))
             << 100.0
             << 120.0
             << QGeoRectangle(QGeoCoordinate(10.0, 165.0),
                                QGeoCoordinate(5.0, -75.0));

     QTest::newRow("wrapping width -> 360 width")
             << QGeoRectangle(QGeoCoordinate(10.0, 175.0),
                                QGeoCoordinate(5.0, -85.0))
             << 100.0
             << 360.0
             << QGeoRectangle(QGeoCoordinate(10.0, -180.0),
                                QGeoCoordinate(5.0, 180.0));

     QTest::newRow("wrapping width width -> 360+ width")
             << QGeoRectangle(QGeoCoordinate(10.0, 175.0),
                                QGeoCoordinate(5.0, -85.0))
             << 100.0
             << 370.0
             << QGeoRectangle(QGeoCoordinate(10.0, -180.0),
                                QGeoCoordinate(5.0, 180.0));
}

void tst_QGeoRectangle::height()
{
    QFETCH(QGeoRectangle, box);
    QFETCH(double, oldHeight);
    QFETCH(double, newHeight);
    QFETCH(QGeoRectangle, newBox);

    if (qIsNaN(oldHeight))
        QVERIFY(qIsNaN(box.height()));
    else
        QCOMPARE(box.height(), oldHeight);

    box.setHeight(newHeight);
    QCOMPARE(box, newBox);
}

void tst_QGeoRectangle::height_data()
{
    QTest::addColumn<QGeoRectangle>("box");
    QTest::addColumn<double>("oldHeight");
    QTest::addColumn<double>("newHeight");
    QTest::addColumn<QGeoRectangle>("newBox");

    QTest::newRow("invalid box")
            << QGeoRectangle()
            << qQNaN()
            << 100.0
            << QGeoRectangle();

     QTest::newRow("0 height -> negative height")
             << QGeoRectangle(QGeoCoordinate(10.0, 5.0),
                                QGeoCoordinate(10.0, 10.0))
             << 0.0
             << -1.0
             << QGeoRectangle(QGeoCoordinate(10.0, 5.0),
                                QGeoCoordinate(10.0, 10.0));

     QTest::newRow("0 height -> 0 height")
             << QGeoRectangle(QGeoCoordinate(10.0, 5.0),
                                QGeoCoordinate(10.0, 10.0))
             << 0.0
             << 0.0
             << QGeoRectangle(QGeoCoordinate(10.0, 5.0),
                                QGeoCoordinate(10.0, 10.0));

     QTest::newRow("0 height -> non zero height")
             << QGeoRectangle(QGeoCoordinate(10.0, 5.0),
                                QGeoCoordinate(10.0, 10.0))
             << 0.0
             << 20.0
             << QGeoRectangle(QGeoCoordinate(20.0, 5.0),
                                QGeoCoordinate(0.0, 10.0));

     QTest::newRow("0 height -> squash top")
             << QGeoRectangle(QGeoCoordinate(70.0, 30.0),
                                QGeoCoordinate(70.0, 70.0))
             << 0.0
             << 60.0
             << QGeoRectangle(QGeoCoordinate(90.0, 30.0),
                                QGeoCoordinate(50.0, 70.0));

     QTest::newRow("0 height -> squash bottom")
             << QGeoRectangle(QGeoCoordinate(-70.0, 30.0),
                                QGeoCoordinate(-70.0, 70.0))
             << 0.0
             << 60.0
             << QGeoRectangle(QGeoCoordinate(-50.0, 30.0),
                                QGeoCoordinate(-90.0, 70.0));

     QTest::newRow("0 height -> 180")
             << QGeoRectangle(QGeoCoordinate(0.0, 5.0),
                                QGeoCoordinate(0.0, 10.0))
             << 0.0
             << 180.0
             << QGeoRectangle(QGeoCoordinate(90.0, 5.0),
                                QGeoCoordinate(-90.0, 10.0));

     QTest::newRow("0 height -> 180 squash top")
             << QGeoRectangle(QGeoCoordinate(20.0, 5.0),
                                QGeoCoordinate(20.0, 10.0))
             << 0.0
             << 180.0
             << QGeoRectangle(QGeoCoordinate(90.0, 5.0),
                                QGeoCoordinate(-50.0, 10.0));

     QTest::newRow("0 height -> 180 squash bottom")
             << QGeoRectangle(QGeoCoordinate(-20.0, 5.0),
                                QGeoCoordinate(-20.0, 10.0))
             << 0.0
             << 180.0
             << QGeoRectangle(QGeoCoordinate(50.0, 5.0),
                                QGeoCoordinate(-90.0, 10.0));

     QTest::newRow("0 height -> 180+")
             << QGeoRectangle(QGeoCoordinate(0.0, 5.0),
                                QGeoCoordinate(0.0, 10.0))
             << 0.0
             << 190.0
             << QGeoRectangle(QGeoCoordinate(90.0, 5.0),
                                QGeoCoordinate(-90.0, 10.0));

     QTest::newRow("0 height -> 180+ squash top")
             << QGeoRectangle(QGeoCoordinate(20.0, 5.0),
                                QGeoCoordinate(20.0, 10.0))
             << 0.0
             << 190.0
             << QGeoRectangle(QGeoCoordinate(90.0, 5.0),
                                QGeoCoordinate(-50.0, 10.0));

     QTest::newRow("0 height -> 180+ squash bottom")
             << QGeoRectangle(QGeoCoordinate(-20.0, 5.0),
                                QGeoCoordinate(-20.0, 10.0))
             << 0.0
             << 190.0
             << QGeoRectangle(QGeoCoordinate(50.0, 5.0),
                                QGeoCoordinate(-90.0, 10.0));

     QTest::newRow("non zero height -> negative height")
             << QGeoRectangle(QGeoCoordinate(70.0, 30.0),
                                QGeoCoordinate(30.0, 70.0))
             << 40.0
             << -1.0
             << QGeoRectangle(QGeoCoordinate(70.0, 30.0),
                                QGeoCoordinate(30.0, 70.0));

     QTest::newRow("non zero height -> 0 height")
             << QGeoRectangle(QGeoCoordinate(70.0, 30.0),
                                QGeoCoordinate(30.0, 70.0))
             << 40.0
             << 0.0
             << QGeoRectangle(QGeoCoordinate(50.0, 30.0),
                                QGeoCoordinate(50.0, 70.0));

     QTest::newRow("non zero height -> non zero height")
             << QGeoRectangle(QGeoCoordinate(70.0, 30.0),
                                QGeoCoordinate(30.0, 70.0))
             << 40.0
             << 20.0
             << QGeoRectangle(QGeoCoordinate(60.0, 30.0),
                                QGeoCoordinate(40.0, 70.0));

     QTest::newRow("non zero height -> squash top")
             << QGeoRectangle(QGeoCoordinate(70.0, 30.0),
                                QGeoCoordinate(30.0, 70.0))
             << 40.0
             << 100.0
             << QGeoRectangle(QGeoCoordinate(90.0, 30.0),
                                QGeoCoordinate(10.0, 70.0));

     QTest::newRow("non zero height -> squash bottom")
             << QGeoRectangle(QGeoCoordinate(-30.0, 30.0),
                                QGeoCoordinate(-70.0, 70.0))
             << 40.0
             << 100.0
             << QGeoRectangle(QGeoCoordinate(-10.0, 30.0),
                                QGeoCoordinate(-90.0, 70.0));

     QTest::newRow("non zero height -> 180")
             << QGeoRectangle(QGeoCoordinate(20.0, 30.0),
                                QGeoCoordinate(-20.0, 70.0))
             << 40.0
             << 180.0
             << QGeoRectangle(QGeoCoordinate(90.0, 30.0),
                                QGeoCoordinate(-90.0, 70.0));

     QTest::newRow("non zero height -> 180 squash top")
             << QGeoRectangle(QGeoCoordinate(70.0, 30.0),
                                QGeoCoordinate(30.0, 70.0))
             << 40.0
             << 180.0
             << QGeoRectangle(QGeoCoordinate(90.0, 30.0),
                                QGeoCoordinate(10.0, 70.0));

     QTest::newRow("non zero height -> 180 squash bottom")
             << QGeoRectangle(QGeoCoordinate(-30.0, 30.0),
                                QGeoCoordinate(-70.0, 70.0))
             << 40.0
             << 180.0
             << QGeoRectangle(QGeoCoordinate(-10.0, 30.0),
                                QGeoCoordinate(-90.0, 70.0));

     QTest::newRow("non zero height -> 180+")
             << QGeoRectangle(QGeoCoordinate(20.0, 30.0),
                                QGeoCoordinate(-20.0, 70.0))
             << 40.0
             << 190.0
             << QGeoRectangle(QGeoCoordinate(90.0, 30.0),
                                QGeoCoordinate(-90.0, 70.0));

     QTest::newRow("non zero height -> 180+ squash top")
             << QGeoRectangle(QGeoCoordinate(70.0, 30.0),
                                QGeoCoordinate(30.0, 70.0))
             << 40.0
             << 190.0
             << QGeoRectangle(QGeoCoordinate(90.0, 30.0),
                                QGeoCoordinate(10.0, 70.0));

     QTest::newRow("non zero height -> 180+ squash bottom")
             << QGeoRectangle(QGeoCoordinate(-30.0, 30.0),
                                QGeoCoordinate(-70.0, 70.0))
             << 40.0
             << 190.0
             << QGeoRectangle(QGeoCoordinate(-10.0, 30.0),
                                QGeoCoordinate(-90.0, 70.0));
}

void tst_QGeoRectangle::center()
{
    QFETCH(QGeoRectangle, box);
    QFETCH(QGeoCoordinate, oldCenter);
    QFETCH(QGeoCoordinate, newCenter);
    QFETCH(QGeoRectangle, newBox);

    QGeoShape shape = box;
    QCOMPARE(box.center(), oldCenter);
    QCOMPARE(shape.center(), oldCenter);
    box.setCenter(newCenter);
    QCOMPARE(box, newBox);
}

void tst_QGeoRectangle::center_data()
{
    QTest::addColumn<QGeoRectangle>("box");
    QTest::addColumn<QGeoCoordinate>("oldCenter");
    QTest::addColumn<QGeoCoordinate>("newCenter");
    QTest::addColumn<QGeoRectangle>("newBox");

     QTest::newRow("invalid")
          << QGeoRectangle()
          << QGeoCoordinate()
          << QGeoCoordinate(0.0, 0.0)
          << QGeoRectangle(QGeoCoordinate(0.0, 0.0), 0.0, 0.0);

     QTest::newRow("zero width")
             << QGeoRectangle(QGeoCoordinate(10.0, 5.0),
                                QGeoCoordinate(5.0, 5.0))
          << QGeoCoordinate(7.5, 5.0)
          << QGeoCoordinate(20.0, 20.0)
          << QGeoRectangle(QGeoCoordinate(22.5, 20.0),
                             QGeoCoordinate(17.5, 20.0));

     QTest::newRow("360 width")
             << QGeoRectangle(QGeoCoordinate(10.0, -180.0),
                                QGeoCoordinate(5.0, 180.0))
          << QGeoCoordinate(7.5, 0.0)
          << QGeoCoordinate(20.0, 20.0)
          << QGeoRectangle(QGeoCoordinate(22.5, -180.0),
                             QGeoCoordinate(17.5, 180.0));

     QTest::newRow("zero height")
             << QGeoRectangle(QGeoCoordinate(5.0, 5.0),
                                QGeoCoordinate(5.0, 10.0))
          << QGeoCoordinate(5.0, 7.5)
          << QGeoCoordinate(20.0, 20.0)
          << QGeoRectangle(QGeoCoordinate(20.0, 17.5),
                             QGeoCoordinate(20.0, 22.5));

     QTest::newRow("180 height -> move")
             << QGeoRectangle(QGeoCoordinate(90.0, 5.0),
                                QGeoCoordinate(-90.0, 10.0))
          << QGeoCoordinate(0.0, 7.5)
          << QGeoCoordinate(0.0, 20.0)
          << QGeoRectangle(QGeoCoordinate(90.0, 17.5),
                             QGeoCoordinate(-90.0, 22.5));

     QTest::newRow("180 height -> squash top")
             << QGeoRectangle(QGeoCoordinate(90.0, 5.0),
                                QGeoCoordinate(-90.0, 10.0))
          << QGeoCoordinate(0.0, 7.5)
          << QGeoCoordinate(-20.0, 20.0)
          << QGeoRectangle(QGeoCoordinate(50.0, 17.5),
                             QGeoCoordinate(-90.0, 22.5));

     QTest::newRow("180 height -> squash bottom")
             << QGeoRectangle(QGeoCoordinate(90.0, 5.0),
                                QGeoCoordinate(-90.0, 10.0))
          << QGeoCoordinate(0.0, 7.5)
          << QGeoCoordinate(20.0, 20.0)
          << QGeoRectangle(QGeoCoordinate(90.0, 17.5),
                             QGeoCoordinate(-50.0, 22.5));

     QTest::newRow("non wrapping -> non wrapping")
             << QGeoRectangle(QGeoCoordinate(70.0, 30.0),
                                QGeoCoordinate(30.0, 70.0))
             << QGeoCoordinate(50.0, 50.0)
             << QGeoCoordinate(10.0, 10.0)
             << QGeoRectangle(QGeoCoordinate(30.0, -10.0),
                                QGeoCoordinate(-10.0, 30.0));

     QTest::newRow("non wrapping -> wrapping")
             << QGeoRectangle(QGeoCoordinate(70.0, 30.0),
                                QGeoCoordinate(30.0, 70.0))
             << QGeoCoordinate(50.0, 50.0)
             << QGeoCoordinate(10.0, 170.0)
             << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                                QGeoCoordinate(-10.0, -170.0));

     QTest::newRow("non wrapping -> squash top")
             << QGeoRectangle(QGeoCoordinate(70.0, 30.0),
                                QGeoCoordinate(30.0, 70.0))
             << QGeoCoordinate(50.0, 50.0)
             << QGeoCoordinate(80.0, 50.0)
             << QGeoRectangle(QGeoCoordinate(90.0, 30.0),
                                QGeoCoordinate(70.0, 70.0));

     QTest::newRow("non wrapping -> squash bottom")
             << QGeoRectangle(QGeoCoordinate(70.0, 30.0),
                                QGeoCoordinate(30.0, 70.0))
             << QGeoCoordinate(50.0, 50.0)
             << QGeoCoordinate(-80.0, 50.0)
             << QGeoRectangle(QGeoCoordinate(-70.0, 30.0),
                                QGeoCoordinate(-90.0, 70.0));

     QTest::newRow("wrapping -> non wrapping")
             << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                                QGeoCoordinate(-10.0, -170.0))
             << QGeoCoordinate(10.0, 170.0)
             << QGeoCoordinate(50.0, 50.0)
             << QGeoRectangle(QGeoCoordinate(70.0, 30.0),
                                QGeoCoordinate(30.0, 70.0));

     QTest::newRow("wrapping -> wrapping")
             << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                                QGeoCoordinate(-10.0, -170.0))
             << QGeoCoordinate(10.0, 170.0)
             << QGeoCoordinate(10.0, -170.0)
             << QGeoRectangle(QGeoCoordinate(30.0, 170.0),
                                QGeoCoordinate(-10.0, -150.0));

     QTest::newRow("wrapping -> squash top")
             << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                                QGeoCoordinate(-10.0, -170.0))
             << QGeoCoordinate(10.0, 170.0)
             << QGeoCoordinate(80.0, 170.0)
             << QGeoRectangle(QGeoCoordinate(90.0, 150.0),
                                QGeoCoordinate(70.0, -170.0));

     QTest::newRow("wrapping -> squash bottom")
             << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                                QGeoCoordinate(-10.0, -170.0))
             << QGeoCoordinate(10.0, 170.0)
             << QGeoCoordinate(-80.0, 170.0)
             << QGeoRectangle(QGeoCoordinate(-70.0, 150.0),
                                QGeoCoordinate(-90.0, -170.0));
}

void tst_QGeoRectangle::boundingGeoRectangle_data()
{
    QTest::addColumn<QGeoRectangle>("rectangle");

    QGeoRectangle b1(QGeoCoordinate(70, 30), QGeoCoordinate(30, 70));
    QGeoRectangle b2(QGeoCoordinate(70, 150), QGeoCoordinate(30, -170));
    QGeoRectangle b3(QGeoCoordinate(90, 30), QGeoCoordinate(50, 70));
    QGeoRectangle b4(QGeoCoordinate(-50, 30), QGeoCoordinate(-90, 70));

    QTest::newRow("Box 1") << b1;
    QTest::newRow("Box 2") << b2;
    QTest::newRow("Box 3") << b3;
    QTest::newRow("Box 4") << b4;
}

void tst_QGeoRectangle::boundingGeoRectangle()
{
    QFETCH(QGeoRectangle, rectangle);

    QGeoRectangle box = rectangle.boundingGeoRectangle();
    QCOMPARE(box, rectangle);
}

void tst_QGeoRectangle::containsCoord()
{
    QFETCH(QGeoRectangle, box);
    QFETCH(QGeoCoordinate, coord);
    QFETCH(bool, contains);

    QCOMPARE(box.contains(coord), contains);

    QGeoShape area = box;
    QCOMPARE(area.contains(coord), contains);
}

void tst_QGeoRectangle::containsCoord_data()
{
    QTest::addColumn<QGeoRectangle>("box");
    QTest::addColumn<QGeoCoordinate>("coord");
    QTest::addColumn<bool>("contains");

    QGeoRectangle b1(QGeoCoordinate(70, 30), QGeoCoordinate(30, 70));

    double lonLO1 = 20.0;
    double lonL1 = 30.0;
    double lonLI1 = 40.0;
    double lonC1 = 50.0;
    double lonRI1 = 60.0;
    double lonR1 = 70.0;
    double lonRO1 = 80.0;

    double latTO1 = 80.0;
    double latT1 = 70.0;
    double latTI1 = 60.0;
    double latC1 = 50.0;
    double latBI1 = 40.0;
    double latB1 = 30.0;
    double latBO1 = 20.0;

    QTest::newRow("non wrapped - in center")
            << b1 << QGeoCoordinate(latC1, lonC1) << true;
    QTest::newRow("non wrapped - left edge - inside")
            << b1 << QGeoCoordinate(latC1, lonLI1) << true;
    QTest::newRow("non wrapped - left edge")
            << b1 << QGeoCoordinate(latC1, lonL1) << true;
    QTest::newRow("non wrapped - left edge - outside")
            << b1 << QGeoCoordinate(latC1, lonLO1) << false;
    QTest::newRow("non wrapped - right edge - inside")
            << b1 << QGeoCoordinate(latC1, lonRI1) << true;
    QTest::newRow("non wrapped - right edge")
            << b1 << QGeoCoordinate(latC1, lonR1) << true;
    QTest::newRow("non wrapped - right edge - outside")
            << b1 << QGeoCoordinate(latC1, lonRO1) << false;
    QTest::newRow("non wrapped - top edge - inside")
            << b1 << QGeoCoordinate(latTI1, lonC1) << true;
    QTest::newRow("non wrapped - top edge")
            << b1 << QGeoCoordinate(latT1, lonC1) << true;
    QTest::newRow("non wrapped - top edge - outside")
            << b1 << QGeoCoordinate(latTO1, lonC1) << false;
    QTest::newRow("non wrapped - bottom edge - inside")
            << b1 << QGeoCoordinate(latBI1, lonC1) << true;
    QTest::newRow("non wrapped - bottom edge")
            << b1 << QGeoCoordinate(latB1, lonC1) << true;
    QTest::newRow("non wrapped - bottom edge - outside")
            << b1 << QGeoCoordinate(latBO1, lonC1) << false;
    QTest::newRow("non wrapped - top left - inside")
            << b1 << QGeoCoordinate(latTI1, lonLI1) << true;
    QTest::newRow("non wrapped - top left")
            << b1 << QGeoCoordinate(latT1, lonL1) << true;
    QTest::newRow("non wrapped - top left - outside")
            << b1 << QGeoCoordinate(latTO1, lonLO1) << false;
    QTest::newRow("non wrapped - top right - inside")
            << b1 << QGeoCoordinate(latTI1, lonRI1) << true;
    QTest::newRow("non wrapped - top right")
            << b1 << QGeoCoordinate(latT1, lonR1) << true;
    QTest::newRow("non wrapped - top right - outside")
            << b1 << QGeoCoordinate(latTO1, lonRO1) << false;
    QTest::newRow("non wrapped - bottom left - inside")
            << b1 << QGeoCoordinate(latBI1, lonLI1) << true;
    QTest::newRow("non wrapped - bottom left")
            << b1 << QGeoCoordinate(latB1, lonL1) << true;
    QTest::newRow("non wrapped - bottom left - outside")
            << b1 << QGeoCoordinate(latBO1, lonLO1) << false;
    QTest::newRow("non wrapped - bottom right - inside")
            << b1 << QGeoCoordinate(latBI1, lonRI1) << true;
    QTest::newRow("non wrapped - bottom right")
            << b1 << QGeoCoordinate(latB1, lonR1) << true;
    QTest::newRow("non wrapped - bottom right - outside")
            << b1 << QGeoCoordinate(latBO1, lonRO1) << false;

    QGeoRectangle b2(QGeoCoordinate(70, 150), QGeoCoordinate(30, -170));

    double lonLO2 = 140.0;
    double lonL2 = 150.0;
    double lonLI2 = 160.0;
    double lonC2 = 170.0;
    double lonRI2 = 180.0;
    double lonR2 = -170.0;
    double lonRO2 = -160.0;

    double latTO2 = 80.0;
    double latT2 = 70.0;
    double latTI2 = 60.0;
    double latC2 = 50.0;
    double latBI2 = 40.0;
    double latB2 = 30.0;
    double latBO2 = 20.0;

    QTest::newRow("wrapped - in center")
            << b2 << QGeoCoordinate(latC2, lonC2) << true;
    QTest::newRow("wrapped - left edge - inside")
            << b2 << QGeoCoordinate(latC2, lonLI2) << true;
    QTest::newRow("wrapped - left edge")
            << b2 << QGeoCoordinate(latC2, lonL2) << true;
    QTest::newRow("wrapped - left edge - outside")
            << b2 << QGeoCoordinate(latC2, lonLO2) << false;
    QTest::newRow("wrapped - right edge - inside")
            << b2 << QGeoCoordinate(latC2, lonRI2) << true;
    QTest::newRow("wrapped - right edge")
            << b2 << QGeoCoordinate(latC2, lonR2) << true;
    QTest::newRow("wrapped - right edge - outside")
            << b2 << QGeoCoordinate(latC2, lonRO2) << false;
    QTest::newRow("wrapped - top edge - inside")
            << b2 << QGeoCoordinate(latTI2, lonC2) << true;
    QTest::newRow("wrapped - top edge")
            << b2 << QGeoCoordinate(latT2, lonC2) << true;
    QTest::newRow("wrapped - top edge - outside")
            << b2 << QGeoCoordinate(latTO2, lonC2) << false;
    QTest::newRow("wrapped - bottom edge - inside")
            << b2 << QGeoCoordinate(latBI2, lonC2) << true;
    QTest::newRow("wrapped - bottom edge")
            << b2 << QGeoCoordinate(latB2, lonC2) << true;
    QTest::newRow("wrapped - bottom edge - outside")
            << b2 << QGeoCoordinate(latBO2, lonC2) << false;
    QTest::newRow("wrapped - top left - inside")
            << b2 << QGeoCoordinate(latTI2, lonLI2) << true;
    QTest::newRow("wrapped - top left")
            << b2 << QGeoCoordinate(latT2, lonL2) << true;
    QTest::newRow("wrapped - top left - outside")
            << b2 << QGeoCoordinate(latTO2, lonLO2) << false;
    QTest::newRow("wrapped - top right - inside")
            << b2 << QGeoCoordinate(latTI2, lonRI2) << true;
    QTest::newRow("wrapped - top right")
            << b2 << QGeoCoordinate(latT2, lonR2) << true;
    QTest::newRow("wrapped - top right - outside")
            << b2 << QGeoCoordinate(latTO2, lonRO2) << false;
    QTest::newRow("wrapped - bottom left - inside")
            << b2 << QGeoCoordinate(latBI2, lonLI2) << true;
    QTest::newRow("wrapped - bottom left")
            << b2 << QGeoCoordinate(latB2, lonL2) << true;
    QTest::newRow("wrapped - bottom left - outside")
            << b2 << QGeoCoordinate(latBO2, lonLO2) << false;
    QTest::newRow("wrapped - bottom right - inside")
            << b2 << QGeoCoordinate(latBI2, lonRI2) << true;
    QTest::newRow("wrapped - bottom right")
            << b2 << QGeoCoordinate(latB2, lonR2) << true;
    QTest::newRow("wrapped - bottom right - outside")
            << b2 << QGeoCoordinate(latBO2, lonRO2) << false;

    QGeoRectangle b3(QGeoCoordinate(90, 30), QGeoCoordinate(50, 70));

    double lonLO3 = 20.0;
    double lonL3 = 30.0;
    double lonLI3 = 40.0;
    double lonC3 = 50.0;
    double lonRI3 = 60.0;
    double lonR3 = 70.0;
    double lonRO3 = 80.0;

    double latT3 = 90.0;
    double latTI3 = 80.0;
    double latC3 = 70.0;
    /* current unused:
    double latBI3 = 60.0;
    double latB3 = 50.0;
    double latBO3 = 40.0;
    */

    QTest::newRow("north pole - in center")
            << b3 << QGeoCoordinate(latC3, lonC3) << true;
    QTest::newRow("north pole - left edge - inside")
            << b3 << QGeoCoordinate(latC3, lonLI3) << true;
    QTest::newRow("north pole - left edge")
            << b3 << QGeoCoordinate(latC3, lonL3) << true;
    QTest::newRow("north pole - left edge - outside")
            << b3 << QGeoCoordinate(latC3, lonLO3) << false;
    QTest::newRow("north pole - right edge - inside")
            << b3 << QGeoCoordinate(latC3, lonRI3) << true;
    QTest::newRow("north pole - right edge")
            << b3 << QGeoCoordinate(latC3, lonR3) << true;
    QTest::newRow("north pole - right edge - outside")
            << b3 << QGeoCoordinate(latC3, lonRO3) << false;
    QTest::newRow("north pole - top edge - inside")
            << b3 << QGeoCoordinate(latTI3, lonC3) << true;
    QTest::newRow("north pole - top edge")
            << b3 << QGeoCoordinate(latT3, lonC3) << true;
    QTest::newRow("north pole - top left - inside")
            << b3 << QGeoCoordinate(latTI3, lonLI3) << true;
    QTest::newRow("north pole - top left")
            << b3 << QGeoCoordinate(latT3, lonL3) << true;
    QTest::newRow("north pole - top left - outside")
            << b3 << QGeoCoordinate(latT3, lonLO3) << true;
    QTest::newRow("north pole - top right - inside")
            << b3 << QGeoCoordinate(latTI3, lonRI3) << true;
    QTest::newRow("north pole - top right")
            << b3 << QGeoCoordinate(latT3, lonR3) << true;
    QTest::newRow("north pole - top right - outside")
            << b3 << QGeoCoordinate(latT3, lonRO3) << true;

    QGeoRectangle b4(QGeoCoordinate(-50, 30), QGeoCoordinate(-90, 70));

    double lonLO4 = 20.0;
    double lonL4 = 30.0;
    double lonLI4 = 40.0;
    double lonC4 = 50.0;
    double lonRI4 = 60.0;
    double lonR4 = 70.0;
    double lonRO4 = 80.0;

    /* currently unused:
    double latTO4 = -40.0;
    double latT4 = -50.0;
    double latTI4 = -60.0;
    */
    double latC4 = -70.0;
    double latBI4 = -80.0;
    double latB4 = -90.0;

    QTest::newRow("south pole - in center")
            << b4 << QGeoCoordinate(latC4, lonC4) << true;
    QTest::newRow("south pole - left edge - inside")
            << b4 << QGeoCoordinate(latC4, lonLI4) << true;
    QTest::newRow("south pole - left edge")
            << b4 << QGeoCoordinate(latC4, lonL4) << true;
    QTest::newRow("south pole - left edge - outside")
            << b4 << QGeoCoordinate(latC4, lonLO4) << false;
    QTest::newRow("south pole - right edge - inside")
            << b4 << QGeoCoordinate(latC4, lonRI4) << true;
    QTest::newRow("south pole - right edge")
            << b4 << QGeoCoordinate(latC4, lonR4) << true;
    QTest::newRow("south pole - right edge - outside")
            << b4 << QGeoCoordinate(latC4, lonRO4) << false;
    QTest::newRow("south pole - bottom edge - inside")
            << b4 << QGeoCoordinate(latBI4, lonC4) << true;
    QTest::newRow("south pole - bottom edge")
            << b4 << QGeoCoordinate(latB4, lonC4) << true;
    QTest::newRow("south pole - bottom left - inside")
            << b4 << QGeoCoordinate(latBI4, lonLI4) << true;
    QTest::newRow("south pole - bottom left")
            << b4 << QGeoCoordinate(latB4, lonL4) << true;
    QTest::newRow("south pole - bottom left - outside")
            << b4 << QGeoCoordinate(latB4, lonLO4) << true;
    QTest::newRow("south pole - bottom right - inside")
            << b4 << QGeoCoordinate(latBI4, lonRI4) << true;
    QTest::newRow("south pole - bottom right")
            << b4 << QGeoCoordinate(latB4, lonR4) << true;
    QTest::newRow("south pole - bottom right - outside")
            << b4 << QGeoCoordinate(latB4, lonRO4) << true;
}

void tst_QGeoRectangle::containsBoxAndIntersects()
{
    QFETCH(QGeoRectangle, box1);
    QFETCH(QGeoRectangle, box2);
    QFETCH(bool, contains);
    QFETCH(bool, intersects);

    QCOMPARE(box1.contains(box2), contains);
    QCOMPARE(box1.intersects(box2), intersects);
}

void tst_QGeoRectangle::containsBoxAndIntersects_data()
{
    QTest::addColumn<QGeoRectangle>("box1");
    QTest::addColumn<QGeoRectangle>("box2");
    QTest::addColumn<bool>("contains");
    QTest::addColumn<bool>("intersects");

    QGeoRectangle b1(QGeoCoordinate(30.0, -30.0),
                       QGeoCoordinate(-30.0, 30.0));

    QTest::newRow("non wrapped same")
            << b1
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << true << true;

    QTest::newRow("non wrapped smaller")
            << b1
            << QGeoRectangle(QGeoCoordinate(20.0, -20.0),
                               QGeoCoordinate(-20.0, 20.0))
            << true << true;

    QTest::newRow("non wrapped larger")
            << b1
            << QGeoRectangle(QGeoCoordinate(40.0, -40.0),
                               QGeoCoordinate(-40.0, 40.0))
            << false << true;

    QTest::newRow("non wrapped outside top")
            << b1
            << QGeoRectangle(QGeoCoordinate(80.0, -30.0),
                               QGeoCoordinate(50.0, 30.0))
            << false << false;

    QTest::newRow("non wrapped outside bottom")
            << b1
            << QGeoRectangle(QGeoCoordinate(-50.0, -30.0),
                               QGeoCoordinate(-80.0, 30.0))
            << false << false;

    QTest::newRow("non wrapped outside left")
            << b1
            << QGeoRectangle(QGeoCoordinate(30.0, -80.0),
                               QGeoCoordinate(-30.0, -50.0))
            << false << false;

    QTest::newRow("non wrapped outside wrapped")
            << b1
            << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                               QGeoCoordinate(-30.0, -150.0))
            << false << false;

    QTest::newRow("non wrapped outside right")
            << b1
            << QGeoRectangle(QGeoCoordinate(30.0, 50.0),
                               QGeoCoordinate(-30.0, 80.0))
            << false << false;

    QTest::newRow("non wrapped top left cross")
            << b1
            << QGeoRectangle(QGeoCoordinate(40.0, -40.0),
                               QGeoCoordinate(20.0, -20.0))
            << false << true;

    QTest::newRow("non wrapped top cross")
            << b1
            << QGeoRectangle(QGeoCoordinate(40.0, -10.0),
                               QGeoCoordinate(20.0, 10.0))
            << false << true;

    QTest::newRow("non wrapped top right cross")
            << b1
            << QGeoRectangle(QGeoCoordinate(40.0, 20.0),
                               QGeoCoordinate(20.0, 40.0))
            << false << true;

    QTest::newRow("non wrapped left cross")
            << b1
            << QGeoRectangle(QGeoCoordinate(10.0, -40.0),
                               QGeoCoordinate(-10.0, -20.0))
            << false << true;

    QTest::newRow("non wrapped right cross")
            << b1
            << QGeoRectangle(QGeoCoordinate(10.0, 20.0),
                               QGeoCoordinate(-10.0, 40.0))
            << false << true;

    QTest::newRow("non wrapped bottom left cross")
            << b1
            << QGeoRectangle(QGeoCoordinate(-20.0, -40.0),
                               QGeoCoordinate(-40.0, -20.0))
            << false << true;

    QTest::newRow("non wrapped bottom cross")
            << b1
            << QGeoRectangle(QGeoCoordinate(-20.0, -10.0),
                               QGeoCoordinate(-40.0, 10.0))
            << false << true;

    QTest::newRow("non wrapped bottom right cross")
            << b1
            << QGeoRectangle(QGeoCoordinate(-20.0, 20.0),
                               QGeoCoordinate(-40.0, 40.0))
            << false << true;

    QTest::newRow("non wrapped top left touch outside")
            << b1
            << QGeoRectangle(QGeoCoordinate(50.0, -50.0),
                               QGeoCoordinate(30.0, -30.0))
            << false << true;

    QTest::newRow("non wrapped top touch outside")
            << b1
            << QGeoRectangle(QGeoCoordinate(50.0, -10.0),
                               QGeoCoordinate(30.0, 10.0))
            << false << true;

    QTest::newRow("non wrapped top right touch outside")
            << b1
            << QGeoRectangle(QGeoCoordinate(50.0, 30.0),
                               QGeoCoordinate(30.0, 50.0))
            << false << true;

    QTest::newRow("non wrapped left touch outside")
            << b1
            << QGeoRectangle(QGeoCoordinate(10.0, -50.0),
                               QGeoCoordinate(-10.0, -30.0))
            << false << true;

    QTest::newRow("non wrapped right touch outside")
            << b1
            << QGeoRectangle(QGeoCoordinate(10.0, 30.0),
                               QGeoCoordinate(-10.0, 50.0))
            << false << true;

    QTest::newRow("non wrapped bottom left touch outside")
            << b1
            << QGeoRectangle(QGeoCoordinate(-30.0, -30.0),
                               QGeoCoordinate(-50.0, -50.0))
            << false << true;

    QTest::newRow("non wrapped bottom touch outside")
            << b1
            << QGeoRectangle(QGeoCoordinate(-30.0, -10.0),
                               QGeoCoordinate(-50.0, 10.0))
            << false << true;

    QTest::newRow("non wrapped bottom right touch outside")
            << b1
            << QGeoRectangle(QGeoCoordinate(-30.0, 30.0),
                               QGeoCoordinate(-50.0, 50.0))
            << false << true;

    QTest::newRow("non wrapped top left touch inside")
            << b1
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(10.0, -10.0))
            << true << true;

    QTest::newRow("non wrapped top touch inside")
            << b1
            << QGeoRectangle(QGeoCoordinate(30.0, -10.0),
                               QGeoCoordinate(10.0, 10.0))
            << true << true;

    QTest::newRow("non wrapped top right touch inside")
            << b1
            << QGeoRectangle(QGeoCoordinate(30.0, 10.0),
                               QGeoCoordinate(10.0, 30.0))
            << true << true;

    QTest::newRow("non wrapped left touch inside")
            << b1
            << QGeoRectangle(QGeoCoordinate(10.0, -30.0),
                               QGeoCoordinate(-10.0, -10.0))
            << true << true;

    QTest::newRow("non wrapped right touch inside")
            << b1
            << QGeoRectangle(QGeoCoordinate(10.0, 10.0),
                               QGeoCoordinate(-10.0, 30.0))
            << true << true;

    QTest::newRow("non wrapped bottom left touch inside")
            << b1
            << QGeoRectangle(QGeoCoordinate(-10.0, -30.0),
                               QGeoCoordinate(-30.0, -10.0))
            << true << true;

    QTest::newRow("non wrapped bottom touch inside")
            << b1
            << QGeoRectangle(QGeoCoordinate(-10.0, -10.0),
                               QGeoCoordinate(-30.0, 10.0))
            << true << true;

    QTest::newRow("non wrapped bottom right touch inside")
            << b1
            << QGeoRectangle(QGeoCoordinate(-10.0, 10.0),
                               QGeoCoordinate(-30.0, 30.0))
            << true << true;

    QTest::newRow("non wrapped top lon strip")
            << b1
            << QGeoRectangle(QGeoCoordinate(40.0, -40.0),
                               QGeoCoordinate(20.0, 40.0))
            << false << true;

    QTest::newRow("non wrapped center lon strip")
            << b1
            << QGeoRectangle(QGeoCoordinate(10.0, -40.0),
                               QGeoCoordinate(-10.0, 40.0))
            << false << true;

    QTest::newRow("non wrapped bottom lon strip")
            << b1
            << QGeoRectangle(QGeoCoordinate(-20.0, -40.0),
                               QGeoCoordinate(-40.0, 40.0))
            << false << true;

    QTest::newRow("non wrapped left lat strip")
            << b1
            << QGeoRectangle(QGeoCoordinate(40.0, -40.0),
                               QGeoCoordinate(-40.0, -20.0))
            << false << true;

    QTest::newRow("non wrapped center lat strip")
            << b1
            << QGeoRectangle(QGeoCoordinate(40.0, -10.0),
                               QGeoCoordinate(-40.0, 10.0))
            << false << true;

    QTest::newRow("non wrapped right lat strip")
            << b1
            << QGeoRectangle(QGeoCoordinate(40.0, 20.0),
                               QGeoCoordinate(-40.0, 40.0))
            << false << true;

    QGeoRectangle b2(QGeoCoordinate(30.0, 150.0),
                       QGeoCoordinate(-30.0, -150.0));

    QTest::newRow("wrapped same")
            << b2
            << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                               QGeoCoordinate(-30.0, -150.0))
            << true << true;

    QTest::newRow("wrapped smaller")
            << b2
            << QGeoRectangle(QGeoCoordinate(20.0, 160.0),
                               QGeoCoordinate(-20.0, -160.0))
            << true << true;

    QTest::newRow("wrapped larger")
            << b2
            << QGeoRectangle(QGeoCoordinate(40.0, 140.0),
                               QGeoCoordinate(-40.0, -140.0))
            << false << true;

    QTest::newRow("wrapped outside top")
            << b2
            << QGeoRectangle(QGeoCoordinate(80.0, 150.0),
                               QGeoCoordinate(50.0, -150.0))
            << false << false;

    QTest::newRow("wrapped outside bottom")
            << b2
            << QGeoRectangle(QGeoCoordinate(-50.0, 150.0),
                               QGeoCoordinate(-80.0, -150.0))
            << false << false;

    QTest::newRow("wrapped outside left")
            << b2
            << QGeoRectangle(QGeoCoordinate(30.0, 70.0),
                               QGeoCoordinate(-30.0, 130.0))
            << false << false;

    QTest::newRow("wrapped outside right")
            << b2
            << QGeoRectangle(QGeoCoordinate(30.0, -130.0),
                               QGeoCoordinate(-30.0, -70.0))
            << false << false;

    QTest::newRow("wrapped top left cross")
            << b2
            << QGeoRectangle(QGeoCoordinate(40.0, 140.0),
                               QGeoCoordinate(20.0, 160.0))
            << false << true;

    QTest::newRow("wrapped top cross")
            << b2
            << QGeoRectangle(QGeoCoordinate(40.0, 170.0),
                               QGeoCoordinate(20.0, -170.0))
            << false << true;

    QTest::newRow("wrapped top right cross")
            << b2
            << QGeoRectangle(QGeoCoordinate(40.0, -160.0),
                               QGeoCoordinate(20.0, -140.0))
            << false << true;

    QTest::newRow("wrapped left cross")
            << b2
            << QGeoRectangle(QGeoCoordinate(10.0, 140.0),
                               QGeoCoordinate(-10.0, 160.0))
            << false << true;

    QTest::newRow("wrapped right cross")
            << b2
            << QGeoRectangle(QGeoCoordinate(10.0, -160.0),
                               QGeoCoordinate(-10.0, -140.0))
            << false << true;

    QTest::newRow("wrapped bottom left cross")
            << b2
            << QGeoRectangle(QGeoCoordinate(-20.0, 140.0),
                               QGeoCoordinate(-40.0, 160.0))
            << false << true;

    QTest::newRow("wrapped bottom cross")
            << b2
            << QGeoRectangle(QGeoCoordinate(-20.0, 170.0),
                               QGeoCoordinate(-40.0, -170.0))
            << false << true;

    QTest::newRow("wrapped bottom right cross")
            << b2
            << QGeoRectangle(QGeoCoordinate(-20.0, -160.0),
                               QGeoCoordinate(-40.0, -140.0))
            << false << true;

    QTest::newRow("wrapped top left touch outside")
            << b2
            << QGeoRectangle(QGeoCoordinate(50.0, 130.0),
                               QGeoCoordinate(30.0, 150.0))
            << false << true;

    QTest::newRow("wrapped top touch outside")
            << b2
            << QGeoRectangle(QGeoCoordinate(50.0, 170.0),
                               QGeoCoordinate(30.0, -170.0))
            << false << true;

    QTest::newRow("wrapped top right touch outside")
            << b2
            << QGeoRectangle(QGeoCoordinate(50.0, -150.0),
                               QGeoCoordinate(30.0, -130.0))
            << false << true;

    QTest::newRow("wrapped left touch outside")
            << b2
            << QGeoRectangle(QGeoCoordinate(10.0, 130.0),
                               QGeoCoordinate(-10.0, 150.0))
            << false << true;

    QTest::newRow("wrapped right touch outside")
            << b2
            << QGeoRectangle(QGeoCoordinate(10.0, -150.0),
                               QGeoCoordinate(-10.0, -130.0))
            << false << true;

    QTest::newRow("wrapped bottom left touch outside")
            << b2
            << QGeoRectangle(QGeoCoordinate(-30.0, 150.0),
                               QGeoCoordinate(-50.0, 130.0))
            << false << true;

    QTest::newRow("wrapped bottom touch outside")
            << b2
            << QGeoRectangle(QGeoCoordinate(-30.0, 170.0),
                               QGeoCoordinate(-50.0, -170.0))
            << false << true;

    QTest::newRow("wrapped bottom right touch outside")
            << b2
            << QGeoRectangle(QGeoCoordinate(-30.0, -150.0),
                               QGeoCoordinate(-50.0, -130.0))
            << false << true;

    QTest::newRow("wrapped top left touch inside")
            << b2
            << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                               QGeoCoordinate(10.0, 170.0))
            << true << true;

    QTest::newRow("wrapped top touch inside")
            << b2
            << QGeoRectangle(QGeoCoordinate(30.0, 170.0),
                               QGeoCoordinate(10.0, -170.0))
            << true << true;

    QTest::newRow("wrapped top right touch inside")
            << b2
            << QGeoRectangle(QGeoCoordinate(30.0, -170.0),
                               QGeoCoordinate(10.0, -150.0))
            << true << true;

    QTest::newRow("wrapped left touch inside")
            << b2
            << QGeoRectangle(QGeoCoordinate(10.0, 150.0),
                               QGeoCoordinate(-10.0, 170.0))
            << true << true;

    QTest::newRow("wrapped right touch inside")
            << b2
            << QGeoRectangle(QGeoCoordinate(10.0, -170.0),
                               QGeoCoordinate(-10.0, -150.0))
            << true << true;

    QTest::newRow("wrapped bottom left touch inside")
            << b2
            << QGeoRectangle(QGeoCoordinate(-10.0, 150.0),
                               QGeoCoordinate(-30.0, 170.0))
            << true << true;

    QTest::newRow("wrapped bottom touch inside")
            << b2
            << QGeoRectangle(QGeoCoordinate(-10.0, 170.0),
                               QGeoCoordinate(-30.0, -170.0))
            << true << true;

    QTest::newRow("wrapped bottom right touch inside")
            << b2
            << QGeoRectangle(QGeoCoordinate(-10.0, -170.0),
                               QGeoCoordinate(-30.0, -150.0))
            << true << true;

    QTest::newRow("wrapped top lon strip")
            << b2
            << QGeoRectangle(QGeoCoordinate(40.0, 140.0),
                               QGeoCoordinate(20.0, -140.0))
            << false << true;

    QTest::newRow("wrapped center lon strip")
            << b2
            << QGeoRectangle(QGeoCoordinate(10.0, 140.0),
                               QGeoCoordinate(-10.0, -140.0))
            << false << true;

    QTest::newRow("wrapped bottom lon strip")
            << b2
            << QGeoRectangle(QGeoCoordinate(-20.0, 140.0),
                               QGeoCoordinate(-40.0, -140.0))
            << false << true;

    QTest::newRow("wrapped left lat strip")
            << b2
            << QGeoRectangle(QGeoCoordinate(40.0, 140.0),
                               QGeoCoordinate(-40.0, 160.0))
            << false << true;

    QTest::newRow("wrapped center lat strip")
            << b2
            << QGeoRectangle(QGeoCoordinate(40.0, 170.0),
                               QGeoCoordinate(-40.0, -170.0))
            << false << true;

    QTest::newRow("wrapped right lat strip")
            << b2
            << QGeoRectangle(QGeoCoordinate(40.0, -160.0),
                               QGeoCoordinate(-40.0, -140.0))
            << false << true;

    QTest::newRow("north pole touching")
      << QGeoRectangle(QGeoCoordinate(90.0, 20.0),
                         QGeoCoordinate(40.0, 40.0))
      << QGeoRectangle(QGeoCoordinate(90.0, 60.0),
                         QGeoCoordinate(30.0, 80.0))
      << false << true;

    QTest::newRow("south pole touching")
      << QGeoRectangle(QGeoCoordinate(40.0, 20.0),
                         QGeoCoordinate(-90.0, 40.0))
      << QGeoRectangle(QGeoCoordinate(30.0, 60.0),
                         QGeoCoordinate(-90.0, 80.0))
      << false << true;
}

void tst_QGeoRectangle::translate()
{
    QFETCH(QGeoRectangle, box);
    QFETCH(double, degreesLatitude);
    QFETCH(double, degreesLongitude);
    QFETCH(QGeoRectangle, newBox);

    QGeoRectangle test = box.translated(degreesLatitude, degreesLongitude);
    QCOMPARE(test, newBox);
    box.translate(degreesLatitude, degreesLongitude);
    QCOMPARE(box, newBox);

}

void tst_QGeoRectangle::translate_data()
{
    QTest::addColumn<QGeoRectangle>("box");
    QTest::addColumn<double>("degreesLatitude");
    QTest::addColumn<double>("degreesLongitude");
    QTest::addColumn<QGeoRectangle>("newBox");

    QTest::newRow("invalid")
            << QGeoRectangle()
            << 20.0
            << 20.0
            << QGeoRectangle();

    QTest::newRow("360 width")
            << QGeoRectangle(QGeoCoordinate(30.0, -180.0),
                               QGeoCoordinate(-30.0, 180.0))
            << 20.0
            << 20.0
            << QGeoRectangle(QGeoCoordinate(50.0, -180.0),
                               QGeoCoordinate(-10.0, 180.0));

    QTest::newRow("180 height")
            << QGeoRectangle(QGeoCoordinate(90.0, -30.0),
                               QGeoCoordinate(-90.0, 30.0))
            << 20.0
            << 20.0
            << QGeoRectangle(QGeoCoordinate(90.0, -10.0),
                               QGeoCoordinate(-90.0, 50.0));

    QTest::newRow("non wrapping -> non wrapping")
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << 20.0
            << 20.0
            << QGeoRectangle(QGeoCoordinate(50.0, -10.0),
                               QGeoCoordinate(-10.0, 50.0));

    QTest::newRow("non wrapping -> wrapping")
            << QGeoRectangle(QGeoCoordinate(30.0, 110.0),
                               QGeoCoordinate(-30.0, 170.0))
            << 20.0
            << 20.0
            << QGeoRectangle(QGeoCoordinate(50.0, 130.0),
                               QGeoCoordinate(-10.0, -170.0));

    QTest::newRow("non wrapping -> north clip")
            << QGeoRectangle(QGeoCoordinate(80.0, -30.0),
                               QGeoCoordinate(20.0, 30.0))
            << 20.0
            << 20.0
            << QGeoRectangle(QGeoCoordinate(90.0, -10.0),
                               QGeoCoordinate(30.0, 50.0));

    QTest::newRow("non wrapping -> south clip")
            << QGeoRectangle(QGeoCoordinate(-20.0, -30.0),
                               QGeoCoordinate(-80.0, 30.0))
            << -20.0
            << 20.0
            << QGeoRectangle(QGeoCoordinate(-30.0, -10.0),
                               QGeoCoordinate(-90.0, 50.0));

    QTest::newRow("wrapping -> non wrapping")
            << QGeoRectangle(QGeoCoordinate(30.0, 130.0),
                               QGeoCoordinate(-30.0, -170.0))
            << 20.0
            << -20.0
            << QGeoRectangle(QGeoCoordinate(50.0, 110.0),
                               QGeoCoordinate(-10.0, 170.0));

    QTest::newRow("wrapping -> wrapping")
            << QGeoRectangle(QGeoCoordinate(30.0, 130.0),
                               QGeoCoordinate(-30.0, -170.0))
            << 20.0
            << 20.0
            << QGeoRectangle(QGeoCoordinate(50.0, 150.0),
                               QGeoCoordinate(-10.0, -150.0));

    QTest::newRow("wrapping -> north clip")
            << QGeoRectangle(QGeoCoordinate(80.0, 130.0),
                               QGeoCoordinate(20.0, -170.0))
            << 20.0
            << 20.0
            << QGeoRectangle(QGeoCoordinate(90.0, 150.0),
                               QGeoCoordinate(30.0, -150.0));

    QTest::newRow("wrapping -> south clip")
            << QGeoRectangle(QGeoCoordinate(-20.0, 130.0),
                               QGeoCoordinate(-80.0, -170.0))
            << -20.0
            << 20.0
            << QGeoRectangle(QGeoCoordinate(-30.0, 150.0),
                               QGeoCoordinate(-90.0, -150.0));
}

void tst_QGeoRectangle::unite()
{
    QFETCH(QGeoRectangle, in1);
    QFETCH(QGeoRectangle, in2);
    QFETCH(QGeoRectangle, out);

    QCOMPARE(in1.united(in2), out);
    QCOMPARE(in2.united(in1), out);

    QCOMPARE(in1 | in2, out);
    QCOMPARE(in2 | in1, out);

    QGeoRectangle united1 = QGeoRectangle(in1);
    united1 |= in2;
    QCOMPARE(united1, out);

    QGeoRectangle united2 = QGeoRectangle(in2);
    united2 |= in1;
    QCOMPARE(united2, out);
}

void tst_QGeoRectangle::unite_data()
{
    QTest::addColumn<QGeoRectangle>("in1");
    QTest::addColumn<QGeoRectangle>("in2");
    QTest::addColumn<QGeoRectangle>("out");

    QTest::newRow("central and taller")
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(50.0, -30.0),
                               QGeoCoordinate(-50.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(50.0, -30.0),
                               QGeoCoordinate(-50.0, 30.0));

    QTest::newRow("central and 180 high")
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(90.0, -30.0),
                               QGeoCoordinate(-90.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(90.0, -30.0),
                               QGeoCoordinate(-90.0, 30.0));

    QTest::newRow("central and non overlapping higher")
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(60.0, -30.0),
                               QGeoCoordinate(50.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(60.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0));

    QTest::newRow("central and overlapping higher")
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(60.0, -30.0),
                               QGeoCoordinate(0.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(60.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0));

    QTest::newRow("central and touching higher")
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(60.0, -30.0),
                               QGeoCoordinate(30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(60.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0));

    QTest::newRow("central and non overlapping lower")
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(-50.0, -30.0),
                               QGeoCoordinate(-60.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-60.0, 30.0));

    QTest::newRow("central and overlapping lower")
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(0.0, -30.0),
                               QGeoCoordinate(-60.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-60.0, 30.0));

    QTest::newRow("central and touching lower")
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(-30.0, -30.0),
                               QGeoCoordinate(-60.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-60.0, 30.0));

    QTest::newRow("non wrapping central and wider")
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -50.0),
                               QGeoCoordinate(-30.0, 50.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -50.0),
                               QGeoCoordinate(-30.0, 50.0));

    QTest::newRow("non wrapping central and 360 width")
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -180.0),
                               QGeoCoordinate(-30.0, 180.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -180.0),
                               QGeoCoordinate(-30.0, 180.0));

    QTest::newRow("non wrapping central and non overlapping non wrapping left")
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -110.0),
                               QGeoCoordinate(-30.0, -50.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -110.0),
                               QGeoCoordinate(-30.0, 30.0));

    QTest::newRow("non wrapping central and overlapping non wrapping left")
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -80.0),
                               QGeoCoordinate(-30.0, -20.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -80.0),
                               QGeoCoordinate(-30.0, 30.0));

    QTest::newRow("non wrapping central and touching non wrapping left")
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -90.0),
                               QGeoCoordinate(-30.0, -30.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -90.0),
                               QGeoCoordinate(-30.0, 30.0));

    QTest::newRow("non wrapping central and non overlapping non wrapping right")
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(30.0, 50.0),
                               QGeoCoordinate(-30.0, 110.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 110.0));

    QTest::newRow("non wrapping central and overlapping non wrapping right")
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(30.0, 20.0),
                               QGeoCoordinate(-30.0, 80.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 80.0));

    QTest::newRow("non wrapping central and touching non wrapping right")
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(30.0, 30.0),
                               QGeoCoordinate(-30.0, 90.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 90.0));

    QTest::newRow("wrapping and wider")
            << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                               QGeoCoordinate(-30.0, -150.0))
            << QGeoRectangle(QGeoCoordinate(30.0, 130.0),
                               QGeoCoordinate(-30.0, -130.0))
            << QGeoRectangle(QGeoCoordinate(30.0, 130.0),
                               QGeoCoordinate(-30.0, -130.0));

    QTest::newRow("wrapping and 360 width")
            << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                               QGeoCoordinate(-30.0, -150.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -180.0),
                               QGeoCoordinate(-30.0, 180.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -180.0),
                               QGeoCoordinate(-30.0, 180.0));

    QTest::newRow("wrapping and non overlapping right")
            << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                               QGeoCoordinate(-30.0, -150.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -130.0),
                               QGeoCoordinate(-30.0, -70.0))
            << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                               QGeoCoordinate(-30.0, -70.0));

    QTest::newRow("wrapping and overlapping right")
            << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                               QGeoCoordinate(-30.0, -150.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -160.0),
                               QGeoCoordinate(-30.0, -70.0))
            << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                               QGeoCoordinate(-30.0, -70.0));

    QTest::newRow("wrapping and touching right")
            << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                               QGeoCoordinate(-30.0, -150.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -150.0),
                               QGeoCoordinate(-30.0, -90.0))
            << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                               QGeoCoordinate(-30.0, -90.0));

    QTest::newRow("wrapping and non overlapping left")
            << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                               QGeoCoordinate(-30.0, -150.0))
            << QGeoRectangle(QGeoCoordinate(30.0, 70.0),
                               QGeoCoordinate(-30.0, 130.0))
            << QGeoRectangle(QGeoCoordinate(30.0, 70.0),
                               QGeoCoordinate(-30.0, -150.0));

    QTest::newRow("wrapping and overlapping left")
            << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                               QGeoCoordinate(-30.0, -150.0))
            << QGeoRectangle(QGeoCoordinate(30.0, 100.0),
                               QGeoCoordinate(-30.0, 160.0))
            << QGeoRectangle(QGeoCoordinate(30.0, 100.0),
                               QGeoCoordinate(-30.0, -150.0));

    QTest::newRow("wrapping and touching left")
            << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                               QGeoCoordinate(-30.0, -150.0))
            << QGeoRectangle(QGeoCoordinate(30.0, 90.0),
                               QGeoCoordinate(-30.0, 150.0))
            << QGeoRectangle(QGeoCoordinate(30.0, 90.0),
                               QGeoCoordinate(-30.0, -150.0));

    QTest::newRow("wrapping and non overlapping center")
            << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                               QGeoCoordinate(-30.0, -150.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -30.0),
                               QGeoCoordinate(-30.0, 30.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -180.0),
                               QGeoCoordinate(-30.0, 180.0));

    QTest::newRow("wrapping and overlapping center")
            << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                               QGeoCoordinate(-30.0, -150.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -160.0),
                               QGeoCoordinate(-30.0, 160.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -180.0),
                               QGeoCoordinate(-30.0, 180.0));

    QTest::newRow("wrapping and touching center")
            << QGeoRectangle(QGeoCoordinate(30.0, 150.0),
                               QGeoCoordinate(-30.0, -150.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -150.0),
                               QGeoCoordinate(-30.0, 150.0))
            << QGeoRectangle(QGeoCoordinate(30.0, -180.0),
                               QGeoCoordinate(-30.0, 180.0));

    QTest::newRow("wrapping and one containing other")
            << QGeoRectangle(QGeoCoordinate(30.0, 40.0),
                               QGeoCoordinate(-30.0, -40.0))
            << QGeoRectangle(QGeoCoordinate(30.0, 160.0),
                               QGeoCoordinate(-30.0, 170.0))
            << QGeoRectangle(QGeoCoordinate(30.0, 40.0),
                               QGeoCoordinate(-30.0, -40.0));

    QTest::newRow("small gap over zero line")
            <<  QGeoRectangle(QGeoCoordinate(30.0, -20.0),
                                QGeoCoordinate(-30.0, -10.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, 10.0),
                                QGeoCoordinate(-30.0, 20.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, -20.0),
                                QGeoCoordinate(-30.0, 20.0));

    QTest::newRow("small gap before zero line")
            <<  QGeoRectangle(QGeoCoordinate(30.0, -40.0),
                                QGeoCoordinate(-30.0, -30.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, -20.0),
                                QGeoCoordinate(-30.0, -10.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, -40.0),
                                QGeoCoordinate(-30.0, -10.0));

    QTest::newRow("small gap after zero line")
            <<  QGeoRectangle(QGeoCoordinate(30.0, 10.0),
                                QGeoCoordinate(-30.0, 20.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, 30.0),
                                QGeoCoordinate(-30.0, 40.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, 10.0),
                                QGeoCoordinate(-30.0, 40.0));

    QTest::newRow("small gap over dateline")
            <<  QGeoRectangle(QGeoCoordinate(30.0, 160.0),
                                QGeoCoordinate(-30.0, 170.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, -170.0),
                                QGeoCoordinate(-30.0, -160.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, 160.0),
                                QGeoCoordinate(-30.0, -160.0));

    QTest::newRow("small gap before dateline")
            <<  QGeoRectangle(QGeoCoordinate(30.0, 140.0),
                                QGeoCoordinate(-30.0, 150.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, 160.0),
                                QGeoCoordinate(-30.0, 170.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, 140.0),
                                QGeoCoordinate(-30.0, 170.0));

    QTest::newRow("small gap after dateline")
            <<  QGeoRectangle(QGeoCoordinate(30.0, -170.0),
                                QGeoCoordinate(-30.0, -160.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, -150.0),
                                QGeoCoordinate(-30.0, -140.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, -170.0),
                                QGeoCoordinate(-30.0, -140.0));

    QTest::newRow("90-degree inner gap over zero line")
            <<  QGeoRectangle(QGeoCoordinate(30.0, -55.0),
                                QGeoCoordinate(-30.0, -45.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, 45.0),
                                QGeoCoordinate(-30.0, 55.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, -55.0),
                                QGeoCoordinate(-30.0, 55.0));

    QTest::newRow("90-degree inner gap before zero line")
            <<  QGeoRectangle(QGeoCoordinate(30.0, -20.0),
                                QGeoCoordinate(-30.0, -10.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, -65.0),
                                QGeoCoordinate(-30.0, -55.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, -65.0),
                                QGeoCoordinate(-30.0, -10.0));

    QTest::newRow("90-degree inner gap after zero line")
            <<  QGeoRectangle(QGeoCoordinate(30.0, 65.0),
                                QGeoCoordinate(-30.0, 75.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, 10.0),
                                QGeoCoordinate(-30.0, 20.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, 10.0),
                                QGeoCoordinate(-30.0, 75.0));

    QTest::newRow("90-degree inner gap over dateline")
            <<  QGeoRectangle(QGeoCoordinate(30.0, 125.0),
                                QGeoCoordinate(-30.0, 135.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, -135.0),
                                QGeoCoordinate(-30.0, -125.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, 125.0),
                                QGeoCoordinate(-30.0, -125.0));

    QTest::newRow("90-degree inner gap before dateline")
            <<  QGeoRectangle(QGeoCoordinate(30.0, 160.0),
                                QGeoCoordinate(-30.0, 170.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, 50.0),
                                QGeoCoordinate(-30.0, 60.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, 50.0),
                                QGeoCoordinate(-30.0, 170.0));

    QTest::newRow("90-degree inner gap after dateline")
            <<  QGeoRectangle(QGeoCoordinate(30.0, -170.0),
                                QGeoCoordinate(-30.0, -160.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, -60.0),
                                QGeoCoordinate(-30.0, -50.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, -170.0),
                                QGeoCoordinate(-30.0, -50.0));

    QTest::newRow("180-degree inner gap centered on zero line")
            <<  QGeoRectangle(QGeoCoordinate(30.0, -100.0),
                                QGeoCoordinate(-30.0, -90.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, 90.0),
                                QGeoCoordinate(-30.0, 100.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, 90.0),
                                QGeoCoordinate(-30.0, -90.0));

    QTest::newRow("180-degree outer gap cenetered on zero line")
            <<  QGeoRectangle(QGeoCoordinate(30.0, -90.0),
                                QGeoCoordinate(-30.0, -80.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, 80.0),
                                QGeoCoordinate(-30.0, 90.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, -90.0),
                                QGeoCoordinate(-30.0, 90.0));

    QTest::newRow("180-degree shift centered on zero line")
            <<  QGeoRectangle(QGeoCoordinate(30.0, -100.0),
                                QGeoCoordinate(-30.0, -80.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, 80.0),
                                QGeoCoordinate(-30.0, 100.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, -180.0),
                                QGeoCoordinate(-30.0, 180.0));

    QTest::newRow("180-degree inner gap centered on dateline")
            <<  QGeoRectangle(QGeoCoordinate(30.0, 80.0),
                                QGeoCoordinate(-30.0, 90.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, -90.0),
                                QGeoCoordinate(-30.0, -80.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0,  -90.0),
                                QGeoCoordinate(-30.0, 90.0));

    QTest::newRow("180-degree outer gap centered on dateline")
            <<  QGeoRectangle(QGeoCoordinate(30.0, 90.0),
                                QGeoCoordinate(-30.0, 100.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, -100.0),
                                QGeoCoordinate(-30.0, -90.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, 90.0),
                                QGeoCoordinate(-30.0, -90.0));

    QTest::newRow("180-degree shift centered on dateline")
            <<  QGeoRectangle(QGeoCoordinate(30.0, 80.0),
                                QGeoCoordinate(-30.0, 100.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0, -100.0),
                                QGeoCoordinate(-30.0, -80.0))
            <<  QGeoRectangle(QGeoCoordinate(30.0,  -180.0),
                                QGeoCoordinate(-30.0, 180.0));

    QTest::newRow("Small outer gap centered on dateline")
            << QGeoRectangle(QGeoCoordinate(30, 160), QGeoCoordinate(-30, 170))
            << QGeoRectangle(QGeoCoordinate(30, -170), QGeoCoordinate(-30, 160))
            << QGeoRectangle(QGeoCoordinate(30, -170), QGeoCoordinate(-30, 170));

    QTest::newRow("Overlapping over the dateline")
            << QGeoRectangle(QGeoCoordinate(30, 160), QGeoCoordinate(-30, 170))
            << QGeoRectangle(QGeoCoordinate(30, 160), QGeoCoordinate(-30, -170))
            << QGeoRectangle(QGeoCoordinate(30, 160), QGeoCoordinate(-30, -170));
}


void tst_QGeoRectangle::extendRectangle()
{
    QFETCH(QGeoRectangle, box);
    QFETCH(QGeoCoordinate, coord);
    QFETCH(QGeoRectangle, out);

    box.extendRectangle(coord);
    QCOMPARE(box, out);
}

void tst_QGeoRectangle::extendRectangle_data()
{
    QTest::addColumn<QGeoRectangle>("box");
    QTest::addColumn<QGeoCoordinate>("coord");
    QTest::addColumn<QGeoRectangle>("out");

    QTest::newRow("valid rect - invalid coordinate")
            << QGeoRectangle(QGeoCoordinate(30.0, -20.0),
                             QGeoCoordinate(-30.0, 20.0))
            << QGeoCoordinate(100.0, 190.0)
            << QGeoRectangle(QGeoCoordinate(30.0, -20.0),
                             QGeoCoordinate(-30.0, 20));
    QTest::newRow("invalid rect - valid coordinate")
            << QGeoRectangle()
            << QGeoCoordinate(10.0, 10.0)
            << QGeoRectangle();
    QTest::newRow("inside rect - not wrapped")
            << QGeoRectangle(QGeoCoordinate(30.0, -20.0),
                             QGeoCoordinate(-30.0, 20.0))
            << QGeoCoordinate(10.0, 10.0)
            << QGeoRectangle(QGeoCoordinate(30.0, -20.0),
                             QGeoCoordinate(-30.0, 20));
    QTest::newRow("lat outside rect - not wrapped")
            << QGeoRectangle(QGeoCoordinate(30.0, -20.0),
                             QGeoCoordinate(-30.0, 20.0))
            << QGeoCoordinate(40.0, 10.0)
            << QGeoRectangle(QGeoCoordinate(40.0, -20.0),
                             QGeoCoordinate(-30.0, 20));
    QTest::newRow("positive lon outside rect - not wrapped")
            << QGeoRectangle(QGeoCoordinate(30.0, -20.0),
                             QGeoCoordinate(-30.0, 20.0))
            << QGeoCoordinate(10.0, 40.0)
            << QGeoRectangle(QGeoCoordinate(30.0, -20.0),
                             QGeoCoordinate(-30.0, 40));
    QTest::newRow("negative lon outside rect - not wrapped")
            << QGeoRectangle(QGeoCoordinate(30.0, -20.0),
                             QGeoCoordinate(-30.0, 20.0))
            << QGeoCoordinate(10.0, -40.0)
            << QGeoRectangle(QGeoCoordinate(30.0, -40.0),
                             QGeoCoordinate(-30.0, 20.0));
    QTest::newRow("inside rect - wrapped")
            << QGeoRectangle(QGeoCoordinate(30.0, 160.0),
                             QGeoCoordinate(-30.0, -160.0))
            << QGeoCoordinate(10.0, -170.0)
            << QGeoRectangle(QGeoCoordinate(30.0, 160.0),
                             QGeoCoordinate(-30.0, -160.0));
    QTest::newRow("lat outside rect - wrapped")
            << QGeoRectangle(QGeoCoordinate(30.0, 160.0),
                             QGeoCoordinate(-30.0, -160.0))
            << QGeoCoordinate(-40.0, -170.0)
            << QGeoRectangle(QGeoCoordinate(30.0, 160.0),
                             QGeoCoordinate(-40.0, -160.0));
    QTest::newRow("positive lon outside rect - wrapped")
            << QGeoRectangle(QGeoCoordinate(30.0, 160.0),
                             QGeoCoordinate(-30.0, -160.0))
            << QGeoCoordinate(10.0, 140.0)
            << QGeoRectangle(QGeoCoordinate(30.0, 140.0),
                             QGeoCoordinate(-30.0, -160.0));
    QTest::newRow("negative lon outside rect - wrapped")
            << QGeoRectangle(QGeoCoordinate(30.0, 160.0),
                             QGeoCoordinate(-30.0, -160.0))
            << QGeoCoordinate(10.0, -140.0)
            << QGeoRectangle(QGeoCoordinate(30.0, 160.0),
                             QGeoCoordinate(-30.0, -140.0));
    QTest::newRow("extending over 180 degree line eastward")
            << QGeoRectangle(QGeoCoordinate(30.0, 130.0),
                             QGeoCoordinate(-30.0, 160.0))
            << QGeoCoordinate(10.0, -170.0)
            << QGeoRectangle(QGeoCoordinate(30.0, 130.0),
                             QGeoCoordinate(-30.0, -170));
    QTest::newRow("extending over -180 degree line westward")
            << QGeoRectangle(QGeoCoordinate(30.0, -160.0),
                             QGeoCoordinate(-30.0, -130.0))
            << QGeoCoordinate(10.0, 170.0)
            << QGeoRectangle(QGeoCoordinate(30.0, 170.0),
                             QGeoCoordinate(-30.0, -130));
}

void tst_QGeoRectangle::areaComparison_data()
{
    QTest::addColumn<QGeoShape>("area");
    QTest::addColumn<QGeoRectangle>("box");
    QTest::addColumn<bool>("equal");

    QGeoRectangle b1(QGeoCoordinate(10.0, 0.0), QGeoCoordinate(0.0, 10.0));
    QGeoRectangle b2(QGeoCoordinate(20.0, 0.0), QGeoCoordinate(0.0, 20.0));
    QGeoCircle c(QGeoCoordinate(0.0, 0.0), 10);

    QTest::newRow("default constructed") << QGeoShape() << QGeoRectangle() << false;
    QTest::newRow("b1 b1") << QGeoShape(b1) << b1 << true;
    QTest::newRow("b1 b2") << QGeoShape(b1) << b2 << false;
    QTest::newRow("b2 b1") << QGeoShape(b2) << b1 << false;
    QTest::newRow("b2 b2") << QGeoShape(b2) << b2 << true;
    QTest::newRow("c b1") << QGeoShape(c) << b1 << false;
}

void tst_QGeoRectangle::areaComparison()
{
    QFETCH(QGeoShape, area);
    QFETCH(QGeoRectangle, box);
    QFETCH(bool, equal);

    QCOMPARE((area == box), equal);
    QCOMPARE((area != box), !equal);

    QCOMPARE((box == area), equal);
    QCOMPARE((box != area), !equal);
}

void tst_QGeoRectangle::circleComparison_data()
{
    QTest::addColumn<QGeoCircle>("circle");
    QTest::addColumn<QGeoRectangle>("box");
    QTest::addColumn<bool>("equal");

    QGeoRectangle b(QGeoCoordinate(10.0, 0.0), QGeoCoordinate(0.0, 10.0));
    QGeoCircle c(QGeoCoordinate(0.0, 0.0), 10);

    QTest::newRow("default constructed") << QGeoCircle() << QGeoRectangle() << false;
    QTest::newRow("c b") << c << b << false;
}

void tst_QGeoRectangle::circleComparison()
{
    QFETCH(QGeoCircle, circle);
    QFETCH(QGeoRectangle, box);
    QFETCH(bool, equal);

    QCOMPARE((circle == box), equal);
    QCOMPARE((circle != box), !equal);

    QCOMPARE((box == circle), equal);
    QCOMPARE((box != circle), !equal);
}

void tst_QGeoRectangle::hashing()
{
    const QGeoRectangle rectangle(QGeoCoordinate(10.0, 0.0), QGeoCoordinate(0.0, 10.0));
    const size_t rectangleHash = qHash(rectangle);

    QGeoRectangle otherTopLeftRectangle = rectangle;
    otherTopLeftRectangle.setTopLeft(QGeoCoordinate(20.0, 0.0));
    QVERIFY(qHash(otherTopLeftRectangle) != rectangleHash);

    QGeoRectangle otherBottomRightRectangle = rectangle;
    otherBottomRightRectangle.setBottomRight(QGeoCoordinate(0.0, 5.0));
    QVERIFY(qHash(otherBottomRightRectangle) != rectangleHash);

    // Do not assign, so that they do not share same d_ptr
    QGeoRectangle similarRectangle(QGeoCoordinate(10.0, 0.0), QGeoCoordinate(0.0, 10.0));
    QCOMPARE(qHash(similarRectangle), rectangleHash);
}