| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the test suite of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
| 21 | ** included in the packaging of this file. Please review the following |
| 22 | ** information to ensure the GNU General Public License requirements will |
| 23 | ** be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 24 | ** |
| 25 | ** $QT_END_LICENSE$ |
| 26 | ** |
| 27 | ****************************************************************************/ |
| 28 | |
| 29 | #include <QtCore/QString> |
| 30 | #include <QtTest/QtTest> |
| 31 | |
| 32 | #include <QtPositioning/qgeoaddress.h> |
| 33 | |
| 34 | QT_USE_NAMESPACE |
| 35 | |
| 36 | class tst_QGeoAddress : public QObject |
| 37 | { |
| 38 | Q_OBJECT |
| 39 | |
| 40 | public: |
| 41 | tst_QGeoAddress(); |
| 42 | |
| 43 | private Q_SLOTS: |
| 44 | void constructorTest(); |
| 45 | void textTest(); |
| 46 | //TODO: there are various field we don't have yet in QGeoAddress |
| 47 | // will need to either remove or enable these tests |
| 48 | // void additionalDataTest(); |
| 49 | // void alternativeAttributesTest(); |
| 50 | void cityTest(); |
| 51 | void countryCodeTest(); |
| 52 | void countryTest(); |
| 53 | void countyTest(); |
| 54 | void districtTest(); |
| 55 | // void floorTest(); |
| 56 | // void houseNumberTest(); |
| 57 | // void labelTest(); |
| 58 | void postalCodeTest(); |
| 59 | void stateTest(); |
| 60 | void streetTest(); |
| 61 | // void suiteTest(); |
| 62 | void generatedText(); |
| 63 | void generatedText_data(); |
| 64 | void operatorsTest(); |
| 65 | void emptyClearTest(); |
| 66 | }; |
| 67 | |
| 68 | tst_QGeoAddress::tst_QGeoAddress() |
| 69 | { |
| 70 | } |
| 71 | |
| 72 | void tst_QGeoAddress::constructorTest() |
| 73 | { |
| 74 | QGeoAddress testObj; |
| 75 | |
| 76 | testObj.setStreet("testId" ); |
| 77 | QGeoAddress *testObjPtr = new QGeoAddress(testObj); |
| 78 | QVERIFY2(testObjPtr != NULL, "Copy constructor - null" ); |
| 79 | QVERIFY2(*testObjPtr == testObj, "Copy constructor - compare" ); |
| 80 | delete testObjPtr; |
| 81 | } |
| 82 | |
| 83 | void tst_QGeoAddress::textTest() |
| 84 | { |
| 85 | QGeoAddress address; |
| 86 | QVERIFY(address.text().isEmpty()); |
| 87 | address.setText(QStringLiteral("123 Fake Street\nSpringfield" )); |
| 88 | QCOMPARE(address.text(), QStringLiteral("123 Fake Street\nSpringfield" )); |
| 89 | } |
| 90 | |
| 91 | void tst_QGeoAddress::cityTest() |
| 92 | { |
| 93 | QGeoAddress testObj; |
| 94 | QVERIFY2(testObj.city() == QString(), "Wrong default value" ); |
| 95 | testObj.setCity("testText" ); |
| 96 | QVERIFY2(testObj.city() == "testText" , "Wrong value returned" ); |
| 97 | } |
| 98 | |
| 99 | void tst_QGeoAddress::countryCodeTest() |
| 100 | { |
| 101 | QGeoAddress testObj; |
| 102 | QVERIFY2(testObj.countryCode() == QString(), "Wrong default value" ); |
| 103 | testObj.setCountryCode("testText" ); |
| 104 | QVERIFY2(testObj.countryCode() == "testText" , "Wrong value returned" ); |
| 105 | } |
| 106 | |
| 107 | void tst_QGeoAddress::countryTest() |
| 108 | { |
| 109 | QGeoAddress testObj; |
| 110 | QVERIFY2(testObj.country() == QString(), "Wrong default value" ); |
| 111 | testObj.setCountry("testText" ); |
| 112 | QVERIFY2(testObj.country() == "testText" , "Wrong value returned" ); |
| 113 | } |
| 114 | |
| 115 | void tst_QGeoAddress::countyTest() |
| 116 | { |
| 117 | QGeoAddress testObj; |
| 118 | QVERIFY2(testObj.county() == QString(), "Wrong default value" ); |
| 119 | testObj.setCounty("testText" ); |
| 120 | QVERIFY2(testObj.county() == "testText" , "Wrong value returned" ); |
| 121 | } |
| 122 | |
| 123 | void tst_QGeoAddress::districtTest() |
| 124 | { |
| 125 | QGeoAddress testObj; |
| 126 | QVERIFY2(testObj.district() == QString(), "Wrong default value" ); |
| 127 | testObj.setDistrict("testText" ); |
| 128 | QVERIFY2(testObj.district() == "testText" , "Wrong value returned" ); |
| 129 | } |
| 130 | |
| 131 | // TODO: currently don't have floor in QGeoAddress |
| 132 | //void tst_QGeoAddress::floorTest() |
| 133 | //{ |
| 134 | // QGeoAddress testObj; |
| 135 | // QVERIFY2(testObj.floor() == QString(), "Wrong default value"); |
| 136 | // testObj.setFloor("testText"); |
| 137 | // QVERIFY2(testObj.floor() == "testText", "Wrong value returned"); |
| 138 | //} |
| 139 | |
| 140 | //TODO: Atm not sure if we will have house number in API. |
| 141 | //void tst_QGeoAddress::houseNumberTest() |
| 142 | //{ |
| 143 | // QGeoAddress testObj; |
| 144 | // QVERIFY2(testObj.houseNumber() == QString(), "Wrong default value"); |
| 145 | // testObj.setHouseNumber("testText"); |
| 146 | // QVERIFY2(testObj.houseNumber() == "testText", "Wrong value returned"); |
| 147 | //} |
| 148 | |
| 149 | //void tst_QGeoAddress::labelTest() |
| 150 | //{ |
| 151 | // QGeoAddress testObj; |
| 152 | // QVERIFY2(testObj.label() == QString(), "Wrong default value"); |
| 153 | // testObj.setLabel("testText"); |
| 154 | // QVERIFY2(testObj.label() == "testText", "Wrong value returned"); |
| 155 | //} |
| 156 | |
| 157 | void tst_QGeoAddress::postalCodeTest() |
| 158 | { |
| 159 | QGeoAddress testObj; |
| 160 | QVERIFY2(testObj.postalCode() == QString(), "Wrong default value" ); |
| 161 | testObj.setPostalCode("testText" ); |
| 162 | QVERIFY2(testObj.postalCode() == "testText" , "Wrong value returned" ); |
| 163 | } |
| 164 | |
| 165 | void tst_QGeoAddress::stateTest() |
| 166 | { |
| 167 | QGeoAddress testObj; |
| 168 | QVERIFY2(testObj.state() == QString(), "Wrong default value" ); |
| 169 | testObj.setState("testText" ); |
| 170 | QVERIFY2(testObj.state() == "testText" , "Wrong value returned" ); |
| 171 | } |
| 172 | |
| 173 | void tst_QGeoAddress::streetTest() |
| 174 | { |
| 175 | QGeoAddress testObj; |
| 176 | QVERIFY2(testObj.street() == QString(), "Wrong default value" ); |
| 177 | testObj.setStreet("testText" ); |
| 178 | QVERIFY2(testObj.street() == "testText" , "Wrong value returned" ); |
| 179 | } |
| 180 | |
| 181 | void tst_QGeoAddress::generatedText() |
| 182 | { |
| 183 | QFETCH(QString, countryCode); |
| 184 | QFETCH(QString, expectedPostalCodeOnly); |
| 185 | QFETCH(QString, expectedFullAddress); |
| 186 | |
| 187 | QGeoAddress streetOnly; |
| 188 | streetOnly.setStreet("street" ); |
| 189 | streetOnly.setCountryCode(countryCode); |
| 190 | |
| 191 | QCOMPARE(streetOnly.text(), QStringLiteral("street" )); |
| 192 | |
| 193 | QGeoAddress cityOnly; |
| 194 | cityOnly.setCity("city" ); |
| 195 | cityOnly.setCountryCode(countryCode); |
| 196 | if (countryCode == QLatin1String("CYM" ) || countryCode == QLatin1String("IRL" )) |
| 197 | QCOMPARE(cityOnly.text(), QString()); |
| 198 | else |
| 199 | QCOMPARE(cityOnly.text(), QStringLiteral("city" )); |
| 200 | |
| 201 | QGeoAddress postalCodeOnly; |
| 202 | postalCodeOnly.setPostalCode("postcode" ); |
| 203 | postalCodeOnly.setCountryCode(countryCode); |
| 204 | QCOMPARE(postalCodeOnly.text(), expectedPostalCodeOnly); |
| 205 | |
| 206 | QGeoAddress fullAddress; |
| 207 | fullAddress.setStreet("street" ); |
| 208 | fullAddress.setDistrict("district" ); |
| 209 | fullAddress.setPostalCode("postcode" ); |
| 210 | fullAddress.setCity("city" ); |
| 211 | fullAddress.setState("state" ); |
| 212 | fullAddress.setCountry("country" ); |
| 213 | fullAddress.setCountryCode(countryCode); |
| 214 | |
| 215 | QCOMPARE(fullAddress.text(), expectedFullAddress); |
| 216 | } |
| 217 | |
| 218 | void tst_QGeoAddress::generatedText_data() |
| 219 | { |
| 220 | QTest::addColumn<QString>(name: "countryCode" ); |
| 221 | QTest::addColumn<QString>(name: "expectedPostalCodeOnly" ); |
| 222 | QTest::addColumn<QString>(name: "expectedFullAddress" ); |
| 223 | |
| 224 | QTest::newRow(dataTag: "Albania" ) << QString::fromLatin1(str: "ALB" ) |
| 225 | << QString::fromLatin1(str: "postcode" ) /* postal code only */ |
| 226 | << QString::fromLatin1(str: "street<br/>" /* full address */ |
| 227 | "postcode, city<br/>" |
| 228 | "country" ); |
| 229 | |
| 230 | QTest::newRow(dataTag: "Andorra" ) << QString::fromLatin1(str: "AND" ) |
| 231 | << QString::fromLatin1(str: "postcode" ) |
| 232 | << QString::fromLatin1(str: "street<br/>" |
| 233 | "postcode city<br/>" |
| 234 | "country" ); |
| 235 | QTest::newRow(dataTag: "United Arab Emirates" ) << QString::fromLatin1(str: "ARE" ) |
| 236 | << QString() |
| 237 | << QString::fromLatin1(str: "street<br/>" |
| 238 | "district city<br/>" |
| 239 | "country" ); |
| 240 | QTest::newRow(dataTag: "Australia" ) << QString::fromLatin1(str: "AUS" ) |
| 241 | << QString::fromLatin1(str: "postcode" ) |
| 242 | << QString::fromLatin1(str: "street<br/>" |
| 243 | "district state postcode<br/>" |
| 244 | "country" ); |
| 245 | QTest::newRow(dataTag: "Austria" ) << QString::fromLatin1(str: "AUT" ) |
| 246 | << QString::fromLatin1(str: "postcode" ) |
| 247 | << QString::fromLatin1(str: "street<br/>" |
| 248 | "postcode city<br/>" |
| 249 | "country" ); |
| 250 | QTest::newRow(dataTag: "Bahamas" ) << QString::fromLatin1(str: "BHS" ) |
| 251 | << QString() |
| 252 | << QString::fromLatin1(str: "street<br/>" |
| 253 | "district city<br/>" |
| 254 | "country" ); |
| 255 | QTest::newRow(dataTag: "Bahrain" ) << QString::fromLatin1(str: "BHR" ) |
| 256 | << QString() |
| 257 | << QString::fromLatin1(str: "street<br/>" |
| 258 | "district, city, state<br/>" |
| 259 | "country" ); |
| 260 | QTest::newRow(dataTag: "Brazil" ) << QString::fromLatin1(str: "BRA" ) |
| 261 | << QString::fromLatin1(str: "postcode" ) |
| 262 | << QString::fromLatin1(str: "street<br/>" |
| 263 | "district city-state postcode<br/>" |
| 264 | "country" ); |
| 265 | QTest::newRow(dataTag: "Brunei Darussalam" ) << QString::fromLatin1(str: "BRN" ) |
| 266 | << QString::fromLatin1(str: "postcode" ) |
| 267 | << QString::fromLatin1(str: "street<br/>" |
| 268 | "district city postcode<br/>" |
| 269 | "country" ); |
| 270 | QTest::newRow(dataTag: "Canada" ) << QString::fromLatin1(str: "CAN" ) |
| 271 | << QString::fromLatin1(str: "postcode" ) |
| 272 | << QString::fromLatin1(str: "street<br/>" |
| 273 | "city, state postcode<br/>" |
| 274 | "country" ); |
| 275 | QTest::newRow(dataTag: "China" ) << QString::fromLatin1(str: "CHN" ) |
| 276 | << QString::fromLatin1(str: "postcode" ) |
| 277 | << QString::fromLatin1(str: "street, city<br/>" |
| 278 | "postcode state<br/>" |
| 279 | "country" ); |
| 280 | QTest::newRow(dataTag: "Chile" ) << QString::fromLatin1(str: "CHL" ) |
| 281 | << QString::fromLatin1(str: "postcode" ) |
| 282 | << QString::fromLatin1(str: "street<br/>" |
| 283 | "postcode district, city, state<br/>" |
| 284 | "country" ); |
| 285 | QTest::newRow(dataTag: "Cayman Islands" ) << QString::fromLatin1(str: "CYM" ) |
| 286 | << QString::fromLatin1(str: "postcode" ) |
| 287 | << QString::fromLatin1(str: "street<br/>" |
| 288 | "state postcode<br/>" |
| 289 | "country" ); |
| 290 | QTest::newRow(dataTag: "France" ) << QString::fromLatin1(str: "FRA" ) |
| 291 | << QString::fromLatin1(str: "postcode" ) |
| 292 | << QString::fromLatin1(str: "street<br/>" |
| 293 | "postcode city<br/>" |
| 294 | "country" ); |
| 295 | |
| 296 | QTest::newRow(dataTag: "United Kingdom" ) << QString::fromLatin1(str: "GBR" ) |
| 297 | << QString::fromLatin1(str: "postcode" ) |
| 298 | << QString::fromLatin1(str: "street<br/>" |
| 299 | "district, city, postcode<br/>" |
| 300 | "country" ); |
| 301 | QTest::newRow(dataTag: "Gibraltar" ) << QString::fromLatin1(str: "GIB" ) |
| 302 | << QString() |
| 303 | << QString::fromLatin1(str: "street<br/>" |
| 304 | "city<br/>" |
| 305 | "country" ); |
| 306 | QTest::newRow(dataTag: "Guadeloupe" ) << QString::fromLatin1(str: "GLP" ) |
| 307 | << QString::fromLatin1(str: "postcode" ) |
| 308 | << QString::fromLatin1(str: "street<br/>" |
| 309 | "postcode city<br/>" |
| 310 | "country" ); |
| 311 | QTest::newRow(dataTag: "French Guiana" ) << QString::fromLatin1(str: "GUF" ) |
| 312 | << QString::fromLatin1(str: "postcode" ) |
| 313 | << QString::fromLatin1(str: "street<br/>" |
| 314 | "postcode city<br/>" |
| 315 | "country" ); |
| 316 | QTest::newRow(dataTag: "Hong Kong" ) << QString::fromLatin1(str: "HKG" ) |
| 317 | << QString() |
| 318 | << QString::fromLatin1(str: "street<br/>" |
| 319 | "district<br/>" |
| 320 | "city" ); |
| 321 | QTest::newRow(dataTag: "India" ) << QString::fromLatin1(str: "IND" ) |
| 322 | << QString::fromLatin1(str: "postcode" ) |
| 323 | << QString::fromLatin1(str: "street<br/>" |
| 324 | "city postcode state<br/>" |
| 325 | "country" ); |
| 326 | QTest::newRow(dataTag: "Indonesia" ) << QString::fromLatin1(str: "IDN" ) |
| 327 | << QString::fromLatin1(str: "postcode" ) |
| 328 | << QString::fromLatin1(str: "street<br/>" |
| 329 | "city, postcode<br/>" |
| 330 | "country" ); |
| 331 | QTest::newRow(dataTag: "Ireland" ) << QString::fromLatin1(str: "IRL" ) |
| 332 | << QString() |
| 333 | << QString::fromLatin1(str: "street<br/>" |
| 334 | "district, state<br/>" |
| 335 | "country" ); |
| 336 | QTest::newRow(dataTag: "Italy" ) << QString::fromLatin1(str: "ITA" ) |
| 337 | << QString::fromLatin1(str: "postcode" ) |
| 338 | << QString::fromLatin1(str: "street<br/>" |
| 339 | "postcode city<br/>" |
| 340 | "country" ); |
| 341 | QTest::newRow(dataTag: "Jersey" ) << QString::fromLatin1(str: "JEY" ) |
| 342 | << QString::fromLatin1(str: "postcode" ) |
| 343 | << QString::fromLatin1(str: "street<br/>" |
| 344 | "city, postcode<br/>" |
| 345 | "country" ); |
| 346 | QTest::newRow(dataTag: "Jordan" ) << QString::fromLatin1(str: "JOR" ) |
| 347 | << QString::fromLatin1(str: "postcode" ) |
| 348 | << QString::fromLatin1(str: "street<br/>" |
| 349 | "district city postcode<br/>" |
| 350 | "country" ); |
| 351 | QTest::newRow(dataTag: "Kuwait" ) << QString::fromLatin1(str: "KWT" ) |
| 352 | << QString::fromLatin1(str: "postcode" ) |
| 353 | << QString::fromLatin1(str: "street<br/>" |
| 354 | "postcode, district, city<br/>" |
| 355 | "country" ); |
| 356 | QTest::newRow(dataTag: "Latvia" ) << QString::fromLatin1(str: "LVA" ) |
| 357 | << QString::fromLatin1(str: "postcode" ) |
| 358 | << QString::fromLatin1(str: "street<br/>" |
| 359 | "city, postcode<br/>" |
| 360 | "country" ); |
| 361 | QTest::newRow(dataTag: "Lebanon" ) << QString::fromLatin1(str: "LBN" ) |
| 362 | << QString::fromLatin1(str: "postcode" ) |
| 363 | << QString::fromLatin1(str: "street<br/>" |
| 364 | "district city postcode<br/>" |
| 365 | "country" ); |
| 366 | QTest::newRow(dataTag: "Luxembourg" ) << QString::fromLatin1(str: "LUX" ) |
| 367 | << QString::fromLatin1(str: "postcode" ) |
| 368 | << QString::fromLatin1(str: "street<br/>" |
| 369 | "postcode city<br/>" |
| 370 | "country" ); |
| 371 | QTest::newRow(dataTag: "Malta" ) << QString::fromLatin1(str: "MLT" ) |
| 372 | << QString::fromLatin1(str: "postcode" ) |
| 373 | << QString::fromLatin1(str: "street<br/>" |
| 374 | "city postcode<br/>" |
| 375 | "country" ); |
| 376 | QTest::newRow(dataTag: "Monaco" ) << QString::fromLatin1(str: "MCO" ) |
| 377 | << QString::fromLatin1(str: "postcode" ) |
| 378 | << QString::fromLatin1(str: "street<br/>" |
| 379 | "postcode city<br/>" |
| 380 | "country" ); |
| 381 | QTest::newRow(dataTag: "Mexico" ) << QString::fromLatin1(str: "MEX" ) |
| 382 | << QString::fromLatin1(str: "postcode" ) |
| 383 | << QString::fromLatin1(str: "street<br/>" |
| 384 | "district<br/>" |
| 385 | "postcode city, state<br/>" |
| 386 | "country" ); |
| 387 | QTest::newRow(dataTag: "Martinique" ) << QString::fromLatin1(str: "MTQ" ) |
| 388 | << QString::fromLatin1(str: "postcode" ) |
| 389 | << QString::fromLatin1(str: "street<br/>" |
| 390 | "postcode, city<br/>" |
| 391 | "country" ); |
| 392 | QTest::newRow(dataTag: "Malaysia" ) << QString::fromLatin1(str: "MYS" ) |
| 393 | << QString::fromLatin1(str: "postcode" ) |
| 394 | << QString::fromLatin1(str: "street<br/>" |
| 395 | "postcode city<br/>" |
| 396 | "state<br/>" |
| 397 | "country" ); |
| 398 | QTest::newRow(dataTag: "New Zealand" ) << QString::fromLatin1(str: "NZL" ) |
| 399 | << QString::fromLatin1(str: "postcode" ) |
| 400 | << QString::fromLatin1(str: "street<br/>" |
| 401 | "district city postcode<br/>" |
| 402 | "country" ); |
| 403 | QTest::newRow(dataTag: "Oman" ) << QString::fromLatin1(str: "OMN" ) |
| 404 | << QString::fromLatin1(str: "postcode" ) |
| 405 | << QString::fromLatin1(str: "street<br/>" |
| 406 | "district, postcode, city, country" ); |
| 407 | QTest::newRow(dataTag: "Puerto Rico" ) << QString::fromLatin1(str: "PRI" ) |
| 408 | << QString::fromLatin1(str: "postcode" ) |
| 409 | << QString::fromLatin1(str: "street<br/>" |
| 410 | "district, city, state, postcode<br/>" |
| 411 | "country" ); |
| 412 | QTest::newRow(dataTag: "Qatar" ) << QString::fromLatin1(str: "QAT" ) |
| 413 | << QString() |
| 414 | << QString::fromLatin1(str: "street<br/>" |
| 415 | "district city, country" ); |
| 416 | QTest::newRow(dataTag: "Reunion" ) << QString::fromLatin1(str: "REU" ) |
| 417 | << QString::fromLatin1(str: "postcode" ) |
| 418 | << QString::fromLatin1(str: "street<br/>" |
| 419 | "postcode city<br/>" |
| 420 | "country" ); |
| 421 | QTest::newRow(dataTag: "Russian Federation" ) << QString::fromLatin1(str: "RUS" ) |
| 422 | << QString::fromLatin1(str: "postcode" ) |
| 423 | << QString::fromLatin1(str: "street<br/>" |
| 424 | "postcode city<br/>" |
| 425 | "country" ); |
| 426 | QTest::newRow(dataTag: "Saudi Arabia" ) << QString::fromLatin1(str: "SAU" ) |
| 427 | << QString::fromLatin1(str: "postcode" ) |
| 428 | << QString::fromLatin1(str: "street district<br/>" |
| 429 | "city postcode<br/>" |
| 430 | "country" ); |
| 431 | QTest::newRow(dataTag: "Singapore" ) << QString::fromLatin1(str: "SGP" ) |
| 432 | << QString::fromLatin1(str: "postcode" ) |
| 433 | << QString::fromLatin1(str: "street<br/>" |
| 434 | "city postcode<br/>" |
| 435 | "country" ); |
| 436 | QTest::newRow(dataTag: "Marino" ) << QString::fromLatin1(str: "SMR" ) |
| 437 | << QString::fromLatin1(str: "postcode" ) |
| 438 | << QString::fromLatin1(str: "street<br/>" |
| 439 | "postcode city<br/>" |
| 440 | "country" ); |
| 441 | QTest::newRow(dataTag: "Taiwan" ) << QString::fromLatin1(str: "TWN" ) |
| 442 | << QString() |
| 443 | << QString::fromLatin1(str: "street, district, city<br/>" |
| 444 | "country" ); |
| 445 | QTest::newRow(dataTag: "Thailand" ) << QString::fromLatin1(str: "THA" ) |
| 446 | << QString("postcode" ) |
| 447 | << QString::fromLatin1(str: "street<br/>" |
| 448 | "district, city postcode<br/>" |
| 449 | "country" ); |
| 450 | QTest::newRow(dataTag: "Turkey" ) << QString::fromLatin1(str: "TUR" ) |
| 451 | << QString("postcode" ) |
| 452 | << QString::fromLatin1(str: "street<br/>" |
| 453 | "postcode district, city<br/>" |
| 454 | "country" ); |
| 455 | QTest::newRow(dataTag: "Ukraine" ) << QString::fromLatin1(str: "UKR" ) |
| 456 | << QString::fromLatin1(str: "postcode" ) |
| 457 | << QString::fromLatin1(str: "street<br/>" |
| 458 | "city postcode<br/>" |
| 459 | "country" ); |
| 460 | QTest::newRow(dataTag: "United States" ) << QString::fromLatin1(str: "USA" ) |
| 461 | << QString::fromLatin1(str: "postcode" ) |
| 462 | << QString::fromLatin1(str: "street<br/>" |
| 463 | "city, state postcode<br/>" |
| 464 | "country" ); |
| 465 | QTest::newRow(dataTag: "Virgin Islands, US" ) << QString::fromLatin1(str: "VIR" ) |
| 466 | << QString("postcode" ) |
| 467 | << QString::fromLatin1(str: "street<br/>" |
| 468 | "city, state postcode<br/>" |
| 469 | "country" ); |
| 470 | QTest::newRow(dataTag: "Vatican City State" ) << QString::fromLatin1(str: "VAT" ) |
| 471 | << QString::fromLatin1(str: "postcode" ) |
| 472 | << QString::fromLatin1(str: "street<br/>" |
| 473 | "postcode city<br/>" |
| 474 | "country" ); |
| 475 | QTest::newRow(dataTag: "Venezuela" ) << QString::fromLatin1(str: "VEN" ) |
| 476 | << QString::fromLatin1(str: "postcode" ) |
| 477 | << QString::fromLatin1(str: "street<br/>" |
| 478 | "city postcode, state<br/>" |
| 479 | "country" ); |
| 480 | QTest::newRow(dataTag: "South Africa" ) << QString::fromLatin1(str: "ZAF" ) |
| 481 | << QString() |
| 482 | << QString::fromLatin1(str: "street<br/>" |
| 483 | "district, city<br/>" |
| 484 | "country" ); |
| 485 | QTest::newRow(dataTag: "Finland" ) << QString::fromLatin1(str: "FIN" ) |
| 486 | << QString::fromLatin1(str: "postcode" ) |
| 487 | << QString::fromLatin1(str: "street<br/>" |
| 488 | "postcode city<br/>" |
| 489 | "country" ); |
| 490 | } |
| 491 | |
| 492 | // TODO: curenlty we don't have suite in QGeoAddress |
| 493 | // will need to either remove or enable |
| 494 | //void tst_QGeoAddress::suiteTest() |
| 495 | //{ |
| 496 | // QGeoAddress testObj; |
| 497 | // QVERIFY2(testObj.suite() == QString(), "Wrong default value"); |
| 498 | // testObj.setSuite("testText"); |
| 499 | // QVERIFY2(testObj.suite() == "testText", "Wrong value returned"); |
| 500 | //} |
| 501 | |
| 502 | void tst_QGeoAddress::operatorsTest() |
| 503 | { |
| 504 | QGeoAddress testObj; |
| 505 | testObj.setStreet("testValue" ); |
| 506 | QGeoAddress testObj2; |
| 507 | testObj2 = testObj; |
| 508 | QVERIFY2(testObj == testObj2, "Not copied correctly" ); |
| 509 | testObj2.setCountry("testValue2" ); |
| 510 | QVERIFY2(testObj != testObj2, "Object should be different" ); |
| 511 | } |
| 512 | |
| 513 | void tst_QGeoAddress::emptyClearTest() |
| 514 | { |
| 515 | QGeoAddress testObj; |
| 516 | QVERIFY(testObj.isEmpty()); |
| 517 | |
| 518 | testObj.setCountry(QStringLiteral("country" )); |
| 519 | QVERIFY(!testObj.isEmpty()); |
| 520 | testObj.clear(); |
| 521 | |
| 522 | testObj.setCountryCode(QStringLiteral("countryCode" )); |
| 523 | QVERIFY(!testObj.isEmpty()); |
| 524 | testObj.clear(); |
| 525 | |
| 526 | testObj.setState(QStringLiteral("state" )); |
| 527 | QVERIFY(!testObj.isEmpty()); |
| 528 | testObj.clear(); |
| 529 | |
| 530 | testObj.setCounty(QStringLiteral("county" )); |
| 531 | QVERIFY(!testObj.isEmpty()); |
| 532 | testObj.clear(); |
| 533 | |
| 534 | testObj.setCity(QStringLiteral("city" )); |
| 535 | QVERIFY(!testObj.isEmpty()); |
| 536 | testObj.clear(); |
| 537 | |
| 538 | testObj.setDistrict(QStringLiteral("district" )); |
| 539 | QVERIFY(!testObj.isEmpty()); |
| 540 | testObj.clear(); |
| 541 | |
| 542 | testObj.setPostalCode(QStringLiteral("postalCode" )); |
| 543 | QVERIFY(!testObj.isEmpty()); |
| 544 | testObj.clear(); |
| 545 | |
| 546 | testObj.setStreet(QStringLiteral("street" )); |
| 547 | QVERIFY(!testObj.isEmpty()); |
| 548 | testObj.clear(); |
| 549 | |
| 550 | testObj.setText(QStringLiteral("formatted address" )); |
| 551 | QVERIFY(!testObj.isEmpty()); |
| 552 | testObj.clear(); |
| 553 | |
| 554 | QVERIFY(testObj.isEmpty()); |
| 555 | } |
| 556 | |
| 557 | QTEST_APPLESS_MAIN(tst_QGeoAddress) |
| 558 | |
| 559 | #include "tst_qgeoaddress.moc" |
| 560 | |