1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2014 Calin Cruceru <crucerucalincristian@gmail.com>
4 // SPDX-FileCopyrightText: 2014 Sanjiban Bairagya <sanjiban22393@gmail.com>
5 // SPDX-FileCopyrightText: 2014 Abhinav Gangwar <abhgang@gmail.com>
6 //
7
8 #include <QObject>
9
10 #include <MarbleDebug.h>
11 #include <GeoDataAlias.h>
12 #include <GeoDataAccuracy.h>
13 #include <GeoDataSimpleArrayData.h>
14 #include <GeoDataData.h>
15 #include <GeoDataExtendedData.h>
16 #include <GeoDataBalloonStyle.h>
17 #include <GeoDataCamera.h>
18 #include <GeoDataColorStyle.h>
19 #include <GeoDataFlyTo.h>
20 #include <GeoDataHotSpot.h>
21 #include <GeoDataImagePyramid.h>
22 #include <GeoDataItemIcon.h>
23 #include <GeoDataLink.h>
24 #include <GeoDataAnimatedUpdate.h>
25 #include <GeoDataSoundCue.h>
26 #include "GeoDataPlaylist.h"
27 #include <GeoDataTourControl.h>
28 #include <GeoDataWait.h>
29 #include <GeoDataTour.h>
30 #include <GeoDataPoint.h>
31 #include <GeoDataLinearRing.h>
32 #include <GeoDataLineString.h>
33 #include <GeoDataPolygon.h>
34 #include <GeoDataLatLonQuad.h>
35 #include <GeoDataLatLonAltBox.h>
36 #include <GeoDataLatLonBox.h>
37 #include <GeoDataLod.h>
38 #include <GeoDataRegion.h>
39 #include <GeoDataIconStyle.h>
40 #include <GeoDataLabelStyle.h>
41 #include <GeoDataLineStyle.h>
42 #include <GeoDataListStyle.h>
43 #include <GeoDataPolyStyle.h>
44 #include <GeoDataStyle.h>
45 #include <GeoDataStyleMap.h>
46 #include <GeoDataTimeSpan.h>
47 #include <GeoDataTimeStamp.h>
48 #include <GeoDataViewVolume.h>
49 #include <GeoDataVec2.h>
50 #include <GeoDataScreenOverlay.h>
51 #include <GeoDataPhotoOverlay.h>
52 #include <GeoDataGroundOverlay.h>
53 #include <GeoDataSchema.h>
54 #include <GeoDataSimpleField.h>
55 #include <GeoDataScale.h>
56 #include <GeoDataOrientation.h>
57 #include <GeoDataLocation.h>
58 #include <GeoDataResourceMap.h>
59 #include <GeoDataModel.h>
60 #include <GeoDataTrack.h>
61 #include <GeoDataMultiTrack.h>
62 #include <GeoDataSnippet.h>
63 #include <GeoDataLookAt.h>
64 #include <GeoDataNetworkLink.h>
65 #include <GeoDataNetworkLinkControl.h>
66 #include <GeoDataFolder.h>
67 #include <GeoDataSchemaData.h>
68 #include <GeoDataSimpleData.h>
69 #include <GeoDataUpdate.h>
70 #include "TestUtils.h"
71
72 using namespace Marble;
73
74 class TestEquality : public QObject
75 {
76 Q_OBJECT
77 private Q_SLOTS:
78 void initTestCase();
79 void aliasTest();
80 void accuracyTest();
81 void simpleArrayDataTest();
82 void dataTest();
83 void extendedDataTest();
84 void balloonTest();
85 void colorTest();
86 void cameraTest();
87 void flyToTest();
88 void hotSpotTest();
89 void imagePyramidTest();
90 void itemIconTest();
91 void linkTest();
92 void tourTest();
93 void pointTest();
94 void linearRingTest();
95 void lineStringTest();
96 void polygonTest();
97 void latLonQuadTest();
98 void latLonBoxTest();
99 void latLonAltBoxTest();
100 void lodTest();
101 void regionTest();
102 void iconStyleTest();
103 void lineStyleTest();
104 void listStyleTest();
105 void polyStyleTest();
106 void labelStyleTest();
107 void styleTest();
108 void styleMapTest();
109 void timeSpanTest();
110 void timeStampTest();
111 void viewVolumeTest();
112 void vecTest();
113 void screenOverlayTest();
114 void photoOverlayTest();
115 void groundOverlayTest();
116 void simpleFieldTest();
117 void schemaTest();
118 void scaleTest();
119 void orientationTest();
120 void locationTest();
121 void resourceMapTest();
122 void modelTest();
123 void trackTest();
124 void multiTrackTest();
125 void snippetTest();
126 void lookAtTest();
127 void networkLinkTest();
128 void networkLinkControlTest();
129 void folderTest();
130 void simpleDataTest();
131 void schemaDataTest();
132 };
133
134
initTestCase()135 void TestEquality::initTestCase()
136 {
137 MarbleDebug::setEnabled( true );
138 }
139
aliasTest()140 void TestEquality::aliasTest()
141 {
142 GeoDataAlias alias;
143 alias.setSourceHref("test1");
144 alias.setTargetHref("test1");
145
146 GeoDataAlias alias2;
147 alias2.setSourceHref("test1");
148 alias2.setTargetHref("test1");
149
150 QCOMPARE( alias, alias );
151 QCOMPARE( alias2, alias2 );
152 QCOMPARE( alias, alias2 );
153
154 alias.setSourceHref("test2");
155 alias2.setSourceHref("Test2");
156 QCOMPARE( alias == alias2, false );
157 QVERIFY( alias != alias2 );
158
159 alias.setSourceHref("test3");
160 alias.setTargetHref("test3");
161 alias2.setSourceHref("test3");
162 alias2.setTargetHref("test2");
163 QCOMPARE( alias == alias2, false );
164
165 alias2.setSourceHref("Test3");
166 QVERIFY( alias != alias2 );
167
168 alias.setSourceHref("Test3");
169 alias.setTargetHref("test2");
170 QCOMPARE( alias, alias2 );
171 }
172
accuracyTest()173 void TestEquality::accuracyTest()
174 {
175 GeoDataAccuracy accuracy1, accuracy2;
176
177 accuracy1.level = GeoDataAccuracy::Country;
178 accuracy1.vertical = 2;
179 accuracy1.horizontal = 3;
180 accuracy2.level = GeoDataAccuracy::Country;
181 accuracy2.vertical = 2;
182 accuracy2.horizontal = 3;
183 QCOMPARE( accuracy1, accuracy1 );
184 QCOMPARE( accuracy2, accuracy2 );
185 QCOMPARE( accuracy1, accuracy2 );
186
187 accuracy1.vertical = 1;
188 QVERIFY( accuracy1 != accuracy2 );
189
190 accuracy1.horizontal = 1;
191 accuracy2.horizontal = 1;
192
193 QCOMPARE( accuracy1 == accuracy2, false );
194 }
195
simpleArrayDataTest()196 void TestEquality::simpleArrayDataTest()
197 {
198 GeoDataSimpleArrayData simpleArray1, simpleArray2;
199
200 simpleArray1.append("Marble");
201 simpleArray1.append(2014);
202 simpleArray1.append("Globe");
203
204 simpleArray2.append("Globe");
205 simpleArray2.append(2014);
206 simpleArray2.append("Marble");
207
208 QCOMPARE( simpleArray1, simpleArray1 );
209 QCOMPARE( simpleArray2, simpleArray2 );
210 QCOMPARE( simpleArray1 == simpleArray2, false );
211 QVERIFY( simpleArray1 != simpleArray2 );
212 }
213
dataTest()214 void TestEquality::dataTest()
215 {
216 GeoDataData data1, data2;
217
218 data1.setName("Something");
219 data1.setValue(QVariant(23.56));
220 data1.setDisplayName("Marble");
221
222 data2.setName("Something");
223 data2.setValue(QVariant(23.56));
224 data2.setDisplayName("Marble");
225
226 QCOMPARE( data1, data1 );
227 QCOMPARE( data2, data2 );
228 QCOMPARE( data1, data2 );
229 QCOMPARE( data1 != data2, false );
230
231 data1.setName("Marble");
232 data1.setDisplayName("Something");
233
234 QCOMPARE( data1 == data2, false );
235 QVERIFY( data1 != data2 );
236 }
237
extendedDataTest()238 void TestEquality::extendedDataTest()
239 {
240 GeoDataExtendedData extendedData1, extendedData2;
241 GeoDataData data1, data2;
242
243 data1.setName("Something");
244 data1.setValue(QVariant(23.56));
245 data1.setDisplayName("Marble");
246
247 data2.setName("Marble");
248 data2.setValue(QVariant(23.56));
249 data2.setDisplayName("Globe");
250
251 extendedData1.addValue(data1);
252 extendedData2.addValue(data2);
253
254 QCOMPARE( extendedData1, extendedData1 );
255 QCOMPARE( extendedData2, extendedData2 );
256 QCOMPARE( extendedData1 == extendedData2, false );
257 QVERIFY( extendedData1 != extendedData2 );
258 }
259
balloonTest()260 void TestEquality::balloonTest()
261 {
262 GeoDataBalloonStyle balloon1, balloon2;
263
264 balloon1.setBackgroundColor(Qt::white);
265 balloon1.setTextColor(Qt::black);
266 balloon1.setText("Text1");
267 balloon1.setDisplayMode(GeoDataBalloonStyle::Hide);
268
269 balloon2.setBackgroundColor(Qt::white);
270 balloon2.setTextColor(Qt::black);
271 balloon2.setText("Text1");
272 balloon2.setDisplayMode(GeoDataBalloonStyle::Hide);
273
274 QCOMPARE( balloon1, balloon1 );
275 QCOMPARE( balloon2, balloon2 );
276 QCOMPARE( balloon1, balloon2 );
277
278 balloon2.setDisplayMode(GeoDataBalloonStyle::Default);
279 QCOMPARE( balloon1 != balloon2, true );
280
281 balloon1.setDisplayMode(GeoDataBalloonStyle::Default);
282 balloon1.setText("Text2");
283 QCOMPARE( balloon1 == balloon2, false);
284
285 QVERIFY( balloon1 != balloon2 );
286 }
287
colorTest()288 void TestEquality::colorTest()
289 {
290 GeoDataColorStyle color1, color2;
291
292 color1.setColor(Qt::white);
293 color2.setColor(Qt::white);
294
295 QCOMPARE( color1, color1 );
296 QCOMPARE( color2, color2 );
297 QCOMPARE( color1, color2 );
298
299 color1.setId("foo");
300 QVERIFY( color1 != color2 );
301 color2.setId("foo");
302 QCOMPARE( color1, color2 );
303
304 color1.setColorMode(GeoDataColorStyle::Random);
305 QCOMPARE( color1, color1 );
306 QCOMPARE( color2, color2 );
307 // Different color mode, so not equal
308 QVERIFY( color1 != color2 );
309
310 color2.setColorMode(GeoDataColorStyle::Random);
311 QCOMPARE( color1, color1 );
312 QCOMPARE( color2, color2 );
313 // Paint colors are now likely different, but we still consider them equal
314 QCOMPARE( color1, color2 );
315
316 color2.setColor( Qt::yellow );
317 QCOMPARE( color1, color1 );
318 QCOMPARE( color2, color2 );
319 QVERIFY( color1 != color2 );
320 }
321
cameraTest()322 void TestEquality::cameraTest()
323 {
324 GeoDataCamera camera1, camera2;
325
326 camera1.setAltitudeMode(Marble::Absolute);
327 camera1.setAltitude(100);
328 camera1.setLatitude(100);
329 camera1.setLongitude(100);
330 camera1.setHeading(200);
331 camera1.setRoll(300);
332 camera1.setTilt(400);
333
334 camera2.setAltitudeMode(Marble::ClampToGround);
335 camera2.setAltitude(100);
336 camera2.setLatitude(100);
337 camera2.setLongitude(100);
338 camera2.setHeading(200);
339 camera2.setRoll(300);
340 camera2.setTilt(400);
341
342 QCOMPARE( camera1, camera1 );
343 QCOMPARE( camera2, camera2 );
344 QCOMPARE( camera1 == camera2, false );
345 QVERIFY( camera1 != camera2 );
346
347
348 GeoDataTimeStamp timeStampBegin, timeStampEnd;
349 QDateTime date1( QDate(2014, 4, 7) );
350
351 timeStampBegin.setWhen( date1 );
352 timeStampEnd.setWhen( date1 );
353 timeStampBegin.setResolution( GeoDataTimeStamp::YearResolution );
354 timeStampEnd.setResolution( GeoDataTimeStamp::YearResolution );
355
356 GeoDataTimeSpan timeSpan1, timeSpan2;
357 timeSpan1.setBegin( timeStampBegin );
358 timeSpan1.setEnd( timeStampEnd );
359 timeSpan2.setBegin( timeStampBegin );
360 timeSpan2.setEnd( timeStampEnd );
361
362 GeoDataTimeStamp timeStamp1, timeStamp2;
363 QDateTime date2( QDate(2014, 4, 8) );
364 timeStamp1.setWhen( date2 );
365 timeStamp2.setWhen( date2 );
366 timeStamp1.setResolution( GeoDataTimeStamp::SecondResolution );
367 timeStamp2.setResolution( GeoDataTimeStamp::SecondResolution );
368
369 camera1.setTimeSpan( timeSpan1 );
370 camera2.setTimeSpan( timeSpan2 );
371 camera1.setTimeStamp( timeStamp1 );
372 camera2.setTimeStamp( timeStamp2 );
373
374 camera2.setAltitudeMode( Marble::Absolute );
375
376 QCOMPARE( camera1, camera2 );
377 QCOMPARE( camera2, camera2 );
378 QVERIFY( camera1 == camera2 );
379
380 camera1.setId("camera1");
381 camera2.setId("camera2");
382 QVERIFY( camera1 != camera2 );
383
384 camera1.setId("camera2");
385 QVERIFY( camera1 == camera2 );
386
387 timeStamp1.setResolution( GeoDataTimeStamp::YearResolution );
388 camera2.setTimeStamp( timeStamp1 );
389 QVERIFY( camera1 != camera2 );
390 }
391
flyToTest()392 void TestEquality::flyToTest()
393 {
394 GeoDataFlyTo flyTo1, flyTo2;
395
396 flyTo1.setDuration(7.6);
397 flyTo1.setFlyToMode(GeoDataFlyTo::Bounce);
398
399 flyTo2.setDuration( 5.8 );
400 flyTo1.setFlyToMode( GeoDataFlyTo::Smooth );
401
402 QCOMPARE( flyTo1, flyTo1 );
403 QCOMPARE( flyTo2, flyTo2 );
404 QCOMPARE( flyTo1 == flyTo2, false );
405 QVERIFY( flyTo1 != flyTo2 );
406 }
407
hotSpotTest()408 void TestEquality::hotSpotTest()
409 {
410 QPointF point1, point2;
411 point1.setX( 5 );
412 point1.setY( 4 );
413 point2.setX( 6 );
414 point2.setY( 2 );
415
416 GeoDataHotSpot hotSpot1, hotSpot2;
417 hotSpot1.setHotSpot( point1, GeoDataHotSpot::Fraction, GeoDataHotSpot::Fraction );
418 hotSpot2.setHotSpot( point2, GeoDataHotSpot::Pixels, GeoDataHotSpot::Pixels );
419
420 QCOMPARE( &hotSpot1, &hotSpot1 );
421 QCOMPARE( &hotSpot2, &hotSpot2 );
422 QCOMPARE( hotSpot1 == hotSpot2, false );
423 QVERIFY( hotSpot1 != hotSpot2 );
424 }
425
imagePyramidTest()426 void TestEquality::imagePyramidTest()
427 {
428 GeoDataImagePyramid pyramid1, pyramid2;
429 pyramid1.setGridOrigin( GeoDataImagePyramid::LowerLeft );
430 pyramid1.setMaxHeight( 40 );
431 pyramid1.setMaxWidth( 30 );
432 pyramid1.setTileSize( 20 );
433
434 pyramid2.setGridOrigin( GeoDataImagePyramid::UpperLeft );
435 pyramid2.setMaxHeight( 50 );
436 pyramid2.setMaxWidth( 80 );
437 pyramid2.setTileSize( 30 );
438
439 QCOMPARE( &pyramid1, &pyramid1 );
440 QCOMPARE( &pyramid2, &pyramid2 );
441 QCOMPARE( pyramid1 == pyramid2, false );
442 QVERIFY( pyramid1 != pyramid2 );
443 }
444
itemIconTest()445 void TestEquality::itemIconTest()
446 {
447 GeoDataItemIcon icon1, icon2;
448 QImage img1( 10, 20, QImage::Format_Mono );
449 QImage img2( 30, 50, QImage::Format_Mono );
450 img1.fill( Qt::green );
451 img2.fill( Qt::green );
452
453 icon1.setIcon( img1 );
454 icon1.setIconPath( "some/path" );
455 icon1.setState( GeoDataItemIcon::Open );
456
457 icon2.setIcon( img2 );
458 icon2.setIconPath( "some/other/path" );
459 icon2.setState( GeoDataItemIcon::Closed );
460
461 QCOMPARE( &icon1, &icon1 );
462 QCOMPARE( &icon2, &icon2 );
463 QCOMPARE( &icon1 == &icon2, false );
464 QVERIFY( &icon1 != &icon2 );
465
466 }
467
linkTest()468 void TestEquality::linkTest()
469 {
470 GeoDataLink link1, link2;
471
472 link1.setHref("some/example/href.something");
473 link1.setRefreshInterval( 23 );
474 link1.setRefreshMode( GeoDataLink::OnChange );
475 link1.setViewBoundScale( 50 );
476 link1.setViewRefreshTime( 30 );
477
478 link2.setHref("some/other/example/href.something");
479 link1.setRefreshInterval( 32 );
480 link1.setRefreshMode(GeoDataLink::OnChange);
481 link1.setViewBoundScale( 60 );
482 link1.setViewRefreshTime( 40 );
483
484 QCOMPARE( &link1, &link1 );
485 QCOMPARE( &link2, &link2 );
486 QCOMPARE( &link1 == &link2, false );
487 QVERIFY( &link1 != &link2 );
488 }
489
tourTest()490 void TestEquality::tourTest()
491 {
492 GeoDataTour tour1;
493 GeoDataTour tour2;
494 GeoDataPlaylist* playlist1 = new GeoDataPlaylist;
495 GeoDataPlaylist* playlist2 = new GeoDataPlaylist;
496
497 GeoDataAnimatedUpdate* animatedUpdate1 = new GeoDataAnimatedUpdate;
498 GeoDataAnimatedUpdate* animatedUpdate2 = new GeoDataAnimatedUpdate;
499 GeoDataSoundCue* cue1 = new GeoDataSoundCue;
500 GeoDataSoundCue* cue2 = new GeoDataSoundCue;
501 GeoDataTourControl* control1 = new GeoDataTourControl;
502 GeoDataTourControl* control2 = new GeoDataTourControl;
503 GeoDataWait* wait1 = new GeoDataWait;
504 GeoDataWait* wait2 = new GeoDataWait;
505 GeoDataFlyTo* flyTo1 = new GeoDataFlyTo;
506 GeoDataFlyTo* flyTo2 = new GeoDataFlyTo;
507
508 playlist1->addPrimitive( animatedUpdate1 );
509 playlist1->addPrimitive( cue1 );
510 playlist1->addPrimitive( control1 );
511 playlist1->addPrimitive( wait1 );
512 playlist1->addPrimitive( flyTo1 );
513
514 playlist2->addPrimitive( animatedUpdate2 );
515 playlist2->addPrimitive( cue2 );
516 playlist2->addPrimitive( control2 );
517 playlist2->addPrimitive( wait2 );
518 playlist2->addPrimitive( flyTo2 );
519
520 tour1.setPlaylist( playlist1 );
521 tour2.setPlaylist( playlist2 );
522
523 QCOMPARE( tour1, tour1 );
524 QCOMPARE( tour2, tour2 );
525 QCOMPARE( tour1 != tour2, false );
526 QVERIFY( tour1 == tour2 );
527
528 tour1.playlist()->swapPrimitives( 1, 3 );
529
530 QCOMPARE( tour1, tour1 );
531 QCOMPARE( tour2, tour2 );
532 QCOMPARE( tour1 == tour2, false );
533 QVERIFY( tour1 != tour2 );
534
535 tour1.playlist()->swapPrimitives( 1, 3 );
536 QVERIFY( tour1 == tour2 );
537
538 GeoDataSoundCue* cue3 = new GeoDataSoundCue;
539 tour1.playlist()->addPrimitive( cue3 );
540
541 QCOMPARE( tour1, tour1 );
542 QCOMPARE( tour2, tour2 );
543 QCOMPARE( tour1 == tour2, false );
544 QVERIFY( tour1 != tour2 );
545
546 // Test GeoDataFeature properties
547 tour1.setName( QString("Tour1") );
548 tour1.setSnippet( GeoDataSnippet("Text1", 10) );
549 tour1.setDescription( QString("Description1") );
550 tour1.setDescriptionCDATA( true );
551 tour1.setAddress( QString("Address1") );
552 tour1.setPhoneNumber( QString("+40768652156") );
553 tour1.setStyleUrl( QString("/link/to/style1") );
554 tour1.setPopularity( 66666 );
555 tour1.setZoomLevel( 10 );
556 tour1.setVisible( true );
557 tour1.setRole( QString("Role1") );
558
559 GeoDataStyle::Ptr style1(new GeoDataStyle), style2(new GeoDataStyle);
560 GeoDataIconStyle iconStyle;
561 QImage icon( 50, 50, QImage::Format_Mono );
562 icon.fill( Qt::black );
563 QPointF hotSpot = QPointF( 7.6, 6.4 );
564
565 iconStyle.setScale( 1.0 );
566 iconStyle.setIconPath( "path/to/icon" );
567 iconStyle.setIcon( icon );
568 iconStyle.setHotSpot( hotSpot, GeoDataHotSpot::Fraction, GeoDataHotSpot::Fraction );
569 iconStyle.setHeading( 0 );
570
571 GeoDataLabelStyle labelStyle;
572 labelStyle.setColor( Qt::blue );
573 labelStyle.setScale( 1.0 );
574 labelStyle.setAlignment( GeoDataLabelStyle::Center );
575 labelStyle.setFont( QFont( QStringLiteral( "Helvetica" ), 10 ) );
576
577 GeoDataLineStyle lineStyle;
578 QVector< qreal > pattern( 5, 6.2 );
579 lineStyle.setWidth( 1.2 );
580 lineStyle.setPhysicalWidth( 1.0 );
581 lineStyle.setCapStyle( Qt::RoundCap );
582 lineStyle.setPenStyle( Qt::SolidLine );
583 lineStyle.setBackground( false );
584 lineStyle.setDashPattern( pattern );
585
586 GeoDataPolyStyle polyStyle;
587 polyStyle.setColor( Qt::red );
588 polyStyle.setFill( false );
589 polyStyle.setOutline( false );
590 polyStyle.setBrushStyle( Qt::SolidPattern );
591
592 GeoDataBalloonStyle balloon;
593 balloon.setBackgroundColor(Qt::white);
594 balloon.setTextColor(Qt::black);
595 balloon.setText("SomeText");
596 balloon.setDisplayMode(GeoDataBalloonStyle::Hide);
597
598 GeoDataListStyle listStyle;
599 listStyle.setListItemType( GeoDataListStyle::Check );
600 listStyle.setBackgroundColor( Qt::gray );
601 for( int i = 0; i < 5; ++i ) {
602 GeoDataItemIcon *icon = new GeoDataItemIcon;
603 QImage img( 20 * ( i + 1 ), 20 * ( i + 1 ), QImage::Format_Mono );
604 img.fill( Qt::black );
605 icon->setIcon( img );
606 icon->setIconPath( QString("path/to/icon") );
607 icon->setState( GeoDataItemIcon::Open );
608 listStyle.append( icon );
609 }
610
611 style1->setIconStyle( iconStyle );
612 style1->setLineStyle( lineStyle );
613 style1->setLabelStyle( labelStyle );
614 style1->setPolyStyle( polyStyle );
615 style1->setBalloonStyle( balloon );
616 style1->setListStyle( listStyle );
617
618 style2 = style1;
619
620 GeoDataStyleMap styleMap1, styleMap2;
621 styleMap1["germany"] = "gst1";
622 styleMap1["germany"] = "gst2";
623 styleMap1["germany"] = "gst3";
624 styleMap1["poland"] = "pst1";
625 styleMap1["poland"] = "pst2";
626 styleMap1["poland"] = "pst3";
627 styleMap1.setLastKey("poland");
628
629 styleMap2 = styleMap1;
630
631
632 GeoDataRegion region1;
633 GeoDataRegion region2;
634 GeoDataLatLonAltBox latLonAltBox1;
635 GeoDataLod lod1;
636
637 latLonAltBox1.setEast( 40 );
638 latLonAltBox1.setWest( 50 );
639 latLonAltBox1.setNorth( 60 );
640 latLonAltBox1.setSouth( 70 );
641 latLonAltBox1.setRotation( 20 );
642 latLonAltBox1.setBoundaries( 70, 80, 50, 60 );
643 latLonAltBox1.setMaxAltitude( 100 );
644 latLonAltBox1.setMinAltitude( 20 );
645 latLonAltBox1.setAltitudeMode( Marble::Absolute );
646
647 region1.setLatLonAltBox( latLonAltBox1 );
648 region2.setLatLonAltBox( latLonAltBox1 );
649
650 lod1.setMaxFadeExtent( 20 );
651 lod1.setMinFadeExtent( 10 );
652 lod1.setMaxLodPixels( 30 );
653 lod1.setMinLodPixels( 5 );
654
655 region1.setLod( lod1 );
656 region2.setLod( lod1 );
657
658
659 GeoDataExtendedData extendedData1, extendedData2;
660 GeoDataData data1;
661
662 data1.setName( "Something" );
663 data1.setValue( QVariant(23.56) );
664 data1.setDisplayName( "Marble" );
665
666 extendedData1.addValue(data1);
667 extendedData2.addValue(data1);
668
669
670 GeoDataTimeStamp timeStamp1, timeStamp2;
671 QDateTime date1( QDate(1994, 10, 4) );
672
673 timeStamp1.setWhen( date1 );
674 timeStamp1.setResolution( GeoDataTimeStamp::YearResolution );
675 timeStamp2 = timeStamp1;
676
677
678 GeoDataCamera camera1, camera2;
679
680 camera1.setAltitudeMode(Marble::Absolute);
681 camera1.setAltitude(100);
682 camera1.setLatitude(100);
683 camera1.setLongitude(100);
684 camera1.setHeading(200);
685 camera1.setRoll(300);
686 camera1.setTilt(400);
687 camera2 = camera1;
688
689 tour1.setAbstractView( &camera1 );
690 tour1.setTimeStamp( timeStamp1 );
691 tour1.setExtendedData( extendedData1 );
692 tour1.setRegion( region1 );
693 tour1.setStyle( style1 );
694 tour1.setStyleMap( &styleMap1 );
695 tour2 = tour1;
696
697 QCOMPARE( tour1, tour1 );
698 QCOMPARE( tour2, tour2 );
699 QCOMPARE( tour1 != tour2, false );
700 QVERIFY( tour1 == tour2 );
701
702
703 GeoDataLookAt lookAt;
704
705 lookAt.setLatitude( 1.1113 );
706 lookAt.setLongitude( 2.33 );
707 lookAt.setAltitude( 1500 );
708 lookAt.setRange( 500 );
709
710 tour2.setAbstractView( &lookAt );
711 QVERIFY( tour1 != tour2 );
712
713 tour1.setAbstractView( &lookAt );
714 tour1.setStyleMap( nullptr );
715 QVERIFY(tour1 != tour2 );
716
717 tour1.setStyleMap( &styleMap1 );
718 QVERIFY( tour1 == tour2 );
719
720 camera2.setRoll(400);
721 tour1.setAbstractView( &camera2 );
722 QVERIFY( tour1 != tour2 );
723 }
724
pointTest()725 void TestEquality::pointTest()
726 {
727 GeoDataPoint point1, point2;
728 GeoDataCoordinates coord1, coord2;
729
730 coord1.set(100,100,100);
731 coord2.set(200,200,200);
732 point1.setCoordinates(coord1);
733 point2.setCoordinates(coord2);
734
735 QVERIFY( point1 != point2 );
736 QCOMPARE( point1 != point2, true );
737
738 coord1.set(100,150);
739 coord2.set(100,150);
740 point1.setCoordinates(coord1);
741 point2.setCoordinates(coord2);
742
743 QVERIFY( point1 == point2 );
744 QCOMPARE( point1, point2 );
745 QCOMPARE( point1 == point2, true );
746
747 QVERIFY( point1 == point1 );
748 QCOMPARE( point1, point2 );
749 }
750
linearRingTest()751 void TestEquality::linearRingTest()
752 {
753 GeoDataLinearRing linearRing1, linearRing2;
754 GeoDataCoordinates coord1, coord2, coord3, coord4, coord5, coord6;
755
756 coord1.set(123,100);
757 coord2.set(124,101);
758 coord3.set(123,100);
759 coord4.set(123,100);
760 coord5.set(124,101);
761 coord6.set(123,100);
762
763 linearRing1.append(coord1);
764 linearRing1.append(coord2);
765 linearRing1.append(coord3);
766 linearRing2.append(coord4);
767 linearRing2.append(coord5);
768 linearRing2.append(coord6);
769 linearRing1.setTessellate(false);
770 linearRing2.setTessellate(false);
771
772 QVERIFY( linearRing1 == linearRing2 );
773 QCOMPARE( linearRing1 != linearRing2, false );
774
775 linearRing2.clear();
776 linearRing2.append(coord1);
777 linearRing2.append(coord3);
778 linearRing2.append(coord4);
779
780 QVERIFY( linearRing1 != linearRing2 );
781 QCOMPARE( linearRing1 == linearRing2, false );
782 }
783
lineStringTest()784 void TestEquality::lineStringTest()
785 {
786 GeoDataLineString lineString1, lineString2;
787 GeoDataCoordinates coord1, coord2, coord3, coord4, coord5, coord6;
788
789 coord1.set(100,100,100);
790 coord2.set(-100,-100,-100);
791 coord3.set(50,50,50);
792 coord4.set(150,150,150);
793 coord5.set(-150,-150,-150);
794 coord6.set(-50,-50,-50);
795
796 lineString1.append(coord1);
797 lineString1.append(coord3);
798 lineString1.append(coord4);
799 lineString2.append(coord2);
800 lineString2.append(coord5);
801 lineString2.append(coord6);
802 lineString1.setTessellate(false);
803 lineString2.setTessellate(false);
804
805 QVERIFY( lineString1 != lineString2 );
806 QCOMPARE( lineString1 == lineString2, false );
807
808 lineString2.clear();
809 lineString2.append(coord1);
810 lineString2.append(coord3);
811 lineString2.append(coord4);
812
813 QVERIFY( lineString1 == lineString2 );
814 QCOMPARE( lineString1 != lineString2, false );
815 }
816
polygonTest()817 void TestEquality::polygonTest()
818 {
819 GeoDataPolygon polygon1, polygon2;
820
821 GeoDataLinearRing outerBoundary1, outerBoundary2;
822 GeoDataCoordinates coord1, coord2, coord3, coord4, coord5, coord6;
823
824 coord1.set(623,600);
825 coord2.set(624,601);
826 coord3.set(623,600);
827 coord4.set(623,600);
828 coord5.set(624,601);
829 coord6.set(623,600);
830
831 outerBoundary1.append(coord1);
832 outerBoundary1.append(coord2);
833 outerBoundary1.append(coord3);
834 outerBoundary2.append(coord4);
835 outerBoundary2.append(coord5);
836 outerBoundary2.append(coord6);
837 outerBoundary1.setTessellate(true);
838 outerBoundary2.setTessellate(true);
839 polygon1.setOuterBoundary(outerBoundary1);
840 polygon2.setOuterBoundary(outerBoundary2);
841
842
843 GeoDataLinearRing innerBoundary11, innerBoundary12, innerBoundary21, innerBoundary22;
844 GeoDataCoordinates coord111, coord112, coord113, coord121, coord122, coord123;
845 GeoDataCoordinates coord211, coord212, coord213, coord221, coord222, coord223;
846
847 coord111.set(100,100);
848 coord112.set(200,200);
849 coord113.set(100,100);
850 coord121.set(400,400);
851 coord122.set(500,500);
852 coord123.set(400,400);
853 coord211.set(100,100);
854 coord212.set(200,200);
855 coord213.set(100,100);
856 coord221.set(400,400);
857 coord222.set(500,500);
858 coord223.set(400,400);
859
860 innerBoundary11.append(coord111);
861 innerBoundary11.append(coord112);
862 innerBoundary11.append(coord113);
863 innerBoundary12.append(coord121);
864 innerBoundary12.append(coord122);
865 innerBoundary12.append(coord123);
866 innerBoundary21.append(coord211);
867 innerBoundary21.append(coord212);
868 innerBoundary21.append(coord213);
869 innerBoundary22.append(coord221);
870 innerBoundary22.append(coord222);
871 innerBoundary22.append(coord223);
872 innerBoundary11.setTessellate(true);
873 innerBoundary12.setTessellate(true);
874 innerBoundary21.setTessellate(true);
875 innerBoundary22.setTessellate(true);
876
877 polygon1.appendInnerBoundary(innerBoundary11);
878 polygon1.appendInnerBoundary(innerBoundary12);
879 polygon2.appendInnerBoundary(innerBoundary21);
880 polygon2.appendInnerBoundary(innerBoundary22);
881 polygon1.setTessellate(true);
882 polygon2.setTessellate(true);
883
884 QVERIFY( polygon1 == polygon2 );
885 QCOMPARE( polygon1 != polygon2, false );
886
887 polygon1.setTessellate(false);
888 QVERIFY( polygon1 != polygon2 );
889
890 polygon1.setTessellate(true);
891 polygon1.appendInnerBoundary(innerBoundary11);
892 QVERIFY( polygon1 != polygon2 );
893
894 QCOMPARE( polygon1 == polygon2, false );
895
896 /* Prepare for inequality test */
897 polygon2.appendInnerBoundary(innerBoundary11);
898 QVERIFY( polygon1 == polygon2 );
899
900 /* Test for inequality: make sure polygon's coordinates are not equal */
901 polygon2.appendInnerBoundary(innerBoundary11);
902 coord111.set(100,1);
903 innerBoundary11.clear();
904 innerBoundary11.append(coord111);
905 innerBoundary11.append(coord112);
906 innerBoundary11.append(coord113);
907 innerBoundary11.setTessellate(true);
908 polygon1.appendInnerBoundary(innerBoundary11);
909
910 QVERIFY( polygon1 != polygon2 );
911 QCOMPARE( polygon1 == polygon2, false );
912 }
913
latLonQuadTest()914 void TestEquality::latLonQuadTest()
915 {
916 GeoDataLatLonQuad quad1, quad2;
917 quad1.setBottomLeftLatitude( 55, GeoDataCoordinates::Degree );
918 quad1.setBottomLeftLongitude( 60, GeoDataCoordinates::Degree );
919 quad1.setBottomRightLatitude( 45, GeoDataCoordinates::Degree );
920 quad1.setBottomRightLongitude( 50, GeoDataCoordinates::Degree );
921
922 quad1.setTopLeftLatitude( 55, GeoDataCoordinates::Degree );
923 quad1.setTopLeftLongitude( 60, GeoDataCoordinates::Degree );
924 quad1.setTopRightLatitude( 45, GeoDataCoordinates::Degree );
925 quad1.setTopRightLongitude( 50, GeoDataCoordinates::Degree );
926
927 quad2.setBottomLeftLatitude( 55, GeoDataCoordinates::Degree );
928 quad2.setBottomLeftLongitude( 60, GeoDataCoordinates::Degree );
929 quad2.setBottomRightLatitude( 45, GeoDataCoordinates::Degree );
930 quad2.setBottomRightLongitude( 50, GeoDataCoordinates::Degree );
931
932 quad2.setTopLeftLatitude( 55, GeoDataCoordinates::Degree );
933 quad2.setTopLeftLongitude( 60, GeoDataCoordinates::Degree );
934 quad2.setTopRightLatitude( 45, GeoDataCoordinates::Degree );
935 quad2.setTopRightLongitude( 50, GeoDataCoordinates::Degree );
936
937 QCOMPARE( quad1, quad1 );
938 QCOMPARE( quad2, quad2 );
939 QCOMPARE( quad1 != quad2, false );
940 QVERIFY( quad1 == quad2 );
941
942 quad1.setTopLeftLatitude( 65, GeoDataCoordinates::Degree );
943
944 QCOMPARE( quad1, quad1 );
945 QCOMPARE( quad2, quad2 );
946 QCOMPARE( quad1 == quad2, false );
947 QVERIFY( quad1 != quad2 );
948 }
949
latLonBoxTest()950 void TestEquality::latLonBoxTest()
951 {
952 GeoDataLatLonBox latLonBox1, latLonBox2;
953
954 latLonBox1.setEast( 40 );
955 latLonBox1.setWest( 50 );
956 latLonBox1.setNorth( 60 );
957 latLonBox1.setSouth( 70 );
958 latLonBox1.setRotation( 20 );
959 latLonBox1.setBoundaries( 70, 80, 50, 60 );
960
961 latLonBox2.setEast( 40 );
962 latLonBox2.setWest( 50 );
963 latLonBox2.setNorth( 60 );
964 latLonBox2.setSouth( 70 );
965 latLonBox2.setRotation( 20 );
966 latLonBox2.setBoundaries( 70, 80, 50, 60 );
967
968 QCOMPARE( latLonBox1, latLonBox1 );
969 QCOMPARE( latLonBox2, latLonBox2 );
970 QCOMPARE( latLonBox1 != latLonBox2, false );
971 QVERIFY( latLonBox1 == latLonBox2 );
972
973 latLonBox2.setWest( 55 );
974
975 QCOMPARE( latLonBox1, latLonBox1 );
976 QCOMPARE( latLonBox2, latLonBox2 );
977 QCOMPARE( latLonBox1 == latLonBox2, false );
978 QVERIFY( latLonBox1 != latLonBox2 );
979 }
980
latLonAltBoxTest()981 void TestEquality::latLonAltBoxTest()
982 {
983 GeoDataLatLonAltBox latLonAltBox1, latLonAltBox2;
984
985 latLonAltBox1.setEast( 40 );
986 latLonAltBox1.setWest( 50 );
987 latLonAltBox1.setNorth( 60 );
988 latLonAltBox1.setSouth( 70 );
989 latLonAltBox1.setRotation( 20 );
990 latLonAltBox1.setBoundaries( 70, 80, 50, 60 );
991 latLonAltBox1.setMaxAltitude( 100 );
992 latLonAltBox1.setMinAltitude( 20 );
993 latLonAltBox1.setAltitudeMode( Marble::Absolute );
994
995 latLonAltBox2.setEast( 40 );
996 latLonAltBox2.setWest( 50 );
997 latLonAltBox2.setNorth( 60 );
998 latLonAltBox2.setSouth( 70 );
999 latLonAltBox2.setRotation( 20 );
1000 latLonAltBox2.setBoundaries( 70, 80, 50, 60 );
1001 latLonAltBox2.setMaxAltitude( 100 );
1002 latLonAltBox2.setMinAltitude( 20 );
1003 latLonAltBox2.setAltitudeMode( Marble::Absolute );
1004
1005 QCOMPARE( latLonAltBox1, latLonAltBox1 );
1006 QCOMPARE( latLonAltBox2, latLonAltBox2 );
1007 QCOMPARE( latLonAltBox1 != latLonAltBox2, false );
1008 QVERIFY( latLonAltBox1 == latLonAltBox2 );
1009
1010 latLonAltBox2.setEast( 30 );
1011
1012 QCOMPARE( latLonAltBox1, latLonAltBox1 );
1013 QCOMPARE( latLonAltBox2, latLonAltBox2 );
1014 QCOMPARE( latLonAltBox1 == latLonAltBox2, false );
1015 QVERIFY( latLonAltBox1 != latLonAltBox2 );
1016 }
1017
lodTest()1018 void TestEquality::lodTest()
1019 {
1020 GeoDataLod lod1, lod2;
1021 lod1.setMaxFadeExtent( 20 );
1022 lod1.setMinFadeExtent( 10 );
1023 lod1.setMaxLodPixels( 30 );
1024 lod1.setMinLodPixels( 5 );
1025
1026 lod2.setMaxFadeExtent( 20 );
1027 lod2.setMinFadeExtent( 10 );
1028 lod2.setMaxLodPixels( 30 );
1029 lod2.setMinLodPixels( 5 );
1030
1031 QCOMPARE( lod1, lod1 );
1032 QCOMPARE( lod2, lod2 );
1033 QCOMPARE( lod1 != lod2, false );
1034 QVERIFY( lod1 == lod2 );
1035
1036 lod2.setMaxFadeExtent( 30 );
1037
1038 QCOMPARE( lod1, lod1 );
1039 QCOMPARE( lod2, lod2 );
1040 QCOMPARE( lod1 == lod2, false );
1041 QVERIFY( lod1 != lod2 );
1042 }
1043
regionTest()1044 void TestEquality::regionTest()
1045 {
1046 GeoDataRegion region1;
1047 GeoDataRegion region2;
1048
1049 GeoDataLatLonAltBox latLonAltBox1;
1050 GeoDataLatLonAltBox latLonAltBox2;
1051
1052 latLonAltBox1.setEast( 40 );
1053 latLonAltBox1.setWest( 50 );
1054 latLonAltBox1.setNorth( 60 );
1055 latLonAltBox1.setSouth( 70 );
1056 latLonAltBox1.setRotation( 20 );
1057 latLonAltBox1.setBoundaries( 70, 80, 50, 60 );
1058 latLonAltBox1.setMaxAltitude( 100 );
1059 latLonAltBox1.setMinAltitude( 20 );
1060 latLonAltBox1.setAltitudeMode( Marble::Absolute );
1061
1062 latLonAltBox2.setEast( 40 );
1063 latLonAltBox2.setWest( 50 );
1064 latLonAltBox2.setNorth( 60 );
1065 latLonAltBox2.setSouth( 70 );
1066 latLonAltBox2.setRotation( 20 );
1067 latLonAltBox2.setBoundaries( 70, 80, 50, 60 );
1068 latLonAltBox2.setMaxAltitude( 100 );
1069 latLonAltBox2.setMinAltitude( 20 );
1070 latLonAltBox2.setAltitudeMode( Marble::Absolute );
1071
1072 region1.setLatLonAltBox( latLonAltBox1 );
1073 region2.setLatLonAltBox( latLonAltBox2 );
1074
1075 GeoDataLod lod1;
1076 GeoDataLod lod2;
1077 lod1.setMaxFadeExtent( 20 );
1078 lod1.setMinFadeExtent( 10 );
1079 lod1.setMaxLodPixels( 30 );
1080 lod1.setMinLodPixels( 5 );
1081
1082 lod2.setMaxFadeExtent( 20 );
1083 lod2.setMinFadeExtent( 10 );
1084 lod2.setMaxLodPixels( 30 );
1085 lod2.setMinLodPixels( 5 );
1086
1087 region1.setLod( lod1 );
1088 region2.setLod( lod2 );
1089
1090 QCOMPARE( region1, region1 );
1091 QCOMPARE( region2, region2 );
1092 QCOMPARE( region1 != region2, false );
1093 QVERIFY( region1 == region2 );
1094
1095 region2.lod().setMaxFadeExtent( 30 );
1096
1097 QCOMPARE( region1, region1 );
1098 QCOMPARE( region2, region2 );
1099 QCOMPARE( region1 == region2, false );
1100 QVERIFY( region1 != region2 );
1101 }
1102
timeSpanTest()1103 void TestEquality::timeSpanTest()
1104 {
1105 GeoDataTimeSpan timeSpan1, timeSpan2;
1106 GeoDataTimeStamp timeStampBegin, timeStampEnd;
1107
1108 QDateTime date1( QDate(2014, 1, 10) ), date2( QDate(2014, 4, 21) );
1109
1110 timeStampBegin.setWhen( date1 );
1111 timeStampEnd.setWhen( date2 );
1112 timeStampBegin.setResolution( GeoDataTimeStamp::DayResolution );
1113 timeStampEnd.setResolution( GeoDataTimeStamp::DayResolution );
1114
1115 timeSpan1.setBegin( timeStampBegin );
1116 timeSpan1.setEnd( timeStampEnd );
1117 timeSpan2.setBegin( timeStampBegin );
1118 timeSpan2.setEnd( timeStampBegin );
1119
1120 QCOMPARE( timeSpan1, timeSpan1 );
1121 QCOMPARE( timeSpan2, timeSpan2 );
1122 QCOMPARE( timeSpan1 == timeSpan2, false );
1123 QVERIFY( timeSpan1 != timeSpan2 );
1124
1125 timeSpan2.setEnd( timeStampEnd );
1126
1127 timeSpan1.setTargetId("timeSpan2");
1128 timeSpan2.setTargetId("timeSpan1");
1129 QVERIFY( timeSpan1 != timeSpan2 );
1130
1131 timeSpan1.setTargetId("timeSpan1");
1132 QVERIFY( timeSpan1 == timeSpan2 );
1133 }
1134
timeStampTest()1135 void TestEquality::timeStampTest()
1136 {
1137 GeoDataTimeStamp timeStamp1, timeStamp2;
1138 QDateTime date1( QDate(1994, 10, 4) ), date2( QDate(2070, 10, 4) );
1139
1140 timeStamp1.setWhen( date1 );
1141 timeStamp2.setWhen( date2 );
1142 timeStamp1.setResolution( GeoDataTimeStamp::YearResolution );
1143 timeStamp2.setResolution( GeoDataTimeStamp::DayResolution );
1144
1145 QCOMPARE( timeStamp1, timeStamp1 );
1146 QCOMPARE( timeStamp2, timeStamp2 );
1147 QCOMPARE( timeStamp1 == timeStamp2, false );
1148 QVERIFY( timeStamp1 != timeStamp2 );
1149
1150 timeStamp2.setWhen( date1 );
1151 timeStamp1.setResolution( GeoDataTimeStamp::DayResolution );
1152
1153 timeStamp1.setId("timeStamp1");
1154 timeStamp2.setId("timeStamp2");
1155 QVERIFY( timeStamp1 != timeStamp2 );
1156
1157 timeStamp1.setId("timeStamp2");
1158 QVERIFY( timeStamp1 == timeStamp2 );
1159 }
1160
iconStyleTest()1161 void TestEquality::iconStyleTest()
1162 {
1163 GeoDataIconStyle iconStyle1, iconStyle2;
1164 QImage icon( 50, 50, QImage::Format_Mono );
1165 icon.fill( Qt::black );
1166 QPointF hotSpot = QPointF( 6.7, 4.6 );
1167
1168 iconStyle1.setScale( 1.0 );
1169 iconStyle1.setIconPath( "path/to/icon" );
1170 iconStyle1.setIcon( icon );
1171 iconStyle1.setHotSpot( hotSpot, GeoDataHotSpot::Fraction, GeoDataHotSpot::Fraction );
1172 iconStyle1.setHeading( 0 );
1173
1174 iconStyle2.setScale( 1.0 );
1175 iconStyle2.setIconPath( "path/to/icon" );
1176 iconStyle2.setIcon( icon );
1177 iconStyle2.setHotSpot( hotSpot, GeoDataHotSpot::Fraction, GeoDataHotSpot::Fraction );
1178 iconStyle2.setHeading( 0 );
1179
1180 QCOMPARE( iconStyle1, iconStyle1 );
1181 QCOMPARE( iconStyle2, iconStyle2 );
1182 QCOMPARE( iconStyle1 != iconStyle2, false );
1183 QVERIFY( iconStyle1 == iconStyle2 );
1184
1185 iconStyle2.setHeading( 1 );
1186 iconStyle2.setScale( 2.0 );
1187
1188 QCOMPARE( iconStyle1, iconStyle1 );
1189 QCOMPARE( iconStyle2, iconStyle2 );
1190 QCOMPARE( iconStyle1 == iconStyle2, false );
1191 QVERIFY( iconStyle1 != iconStyle2 );
1192
1193 }
1194
lineStyleTest()1195 void TestEquality::lineStyleTest()
1196 {
1197 GeoDataLineStyle lineStyle1, lineStyle2;
1198 QVector< qreal > pattern( 7, 7.8 );
1199
1200 lineStyle1.setWidth( 1.3 );
1201 lineStyle1.setPhysicalWidth( 1.0 );
1202 lineStyle1.setCapStyle( Qt::RoundCap );
1203 lineStyle1.setPenStyle( Qt::SolidLine );
1204 lineStyle1.setBackground( false );
1205 lineStyle1.setDashPattern( pattern );
1206
1207 lineStyle2.setWidth( 1.3 );
1208 lineStyle2.setPhysicalWidth( 1.0 );
1209 lineStyle2.setCapStyle( Qt::RoundCap );
1210 lineStyle2.setPenStyle( Qt::SolidLine );
1211 lineStyle2.setBackground( false );
1212 lineStyle2.setDashPattern( pattern );
1213
1214 QCOMPARE( lineStyle1, lineStyle2 );
1215 QCOMPARE( lineStyle2, lineStyle2 );
1216 QCOMPARE( lineStyle1 != lineStyle2, false );
1217 QVERIFY( lineStyle1 == lineStyle2 );
1218
1219 lineStyle2.setCapStyle( Qt::FlatCap );
1220 lineStyle2.setBackground( true );
1221
1222 QCOMPARE( lineStyle1, lineStyle1 );
1223 QCOMPARE( lineStyle2, lineStyle2 );
1224 QCOMPARE( lineStyle1 == lineStyle2, false );
1225 QVERIFY( lineStyle1 != lineStyle2 );
1226 }
1227
listStyleTest()1228 void TestEquality::listStyleTest()
1229 {
1230 GeoDataListStyle listStyle1, listStyle2;
1231
1232 listStyle1.setListItemType( GeoDataListStyle::Check );
1233 listStyle1.setBackgroundColor( Qt::gray );
1234 for( int i = 0; i < 5; ++i ) {
1235 GeoDataItemIcon *icon = new GeoDataItemIcon;
1236 QImage img( 10 * ( i + 1 ), 10 * ( i + 1 ), QImage::Format_Mono );
1237 img.fill( Qt::black );
1238 icon->setIcon( img );
1239 icon->setIconPath( QString("path/to/icon") );
1240 icon->setState( GeoDataItemIcon::Open );
1241 listStyle1.append( icon );
1242 }
1243
1244 listStyle2.setListItemType( GeoDataListStyle::Check );
1245 listStyle2.setBackgroundColor( Qt::gray );
1246 for( int i = 0; i < 5; ++i ) {
1247 GeoDataItemIcon *icon = new GeoDataItemIcon;
1248 QImage img( 10 * ( i + 1 ), 10 * ( i + 1 ), QImage::Format_Mono );
1249 img.fill( Qt::black );
1250 icon->setIcon( img );
1251 icon->setIconPath( QString("path/to/icon") );
1252 icon->setState( GeoDataItemIcon::Open );
1253 listStyle2.append( icon );
1254 }
1255
1256 QCOMPARE( listStyle1, listStyle1 );
1257 QCOMPARE( listStyle2, listStyle2 );
1258 QCOMPARE( listStyle1 != listStyle2, false );
1259 QVERIFY( listStyle1 == listStyle2 );
1260
1261 listStyle2.setBackgroundColor( Qt::green );
1262 listStyle2.setListItemType( GeoDataListStyle::RadioFolder );
1263
1264 QCOMPARE( listStyle1, listStyle1 );
1265 QCOMPARE( listStyle2, listStyle2 );
1266 QCOMPARE( listStyle1 == listStyle2, false );
1267 QVERIFY( listStyle1 != listStyle2 );
1268 }
1269
polyStyleTest()1270 void TestEquality::polyStyleTest()
1271 {
1272 GeoDataPolyStyle polyStyle1, polyStyle2;
1273
1274 polyStyle1.setColor( Qt::red );
1275 polyStyle1.setFill( false );
1276 polyStyle1.setOutline( false );
1277 polyStyle1.setBrushStyle( Qt::SolidPattern );
1278
1279 polyStyle2.setColor( Qt::red );
1280 polyStyle2.setFill( false );
1281 polyStyle2.setOutline( false );
1282 polyStyle2.setBrushStyle( Qt::SolidPattern );
1283
1284 QCOMPARE( polyStyle1, polyStyle1 );
1285 QCOMPARE( polyStyle2, polyStyle2 );
1286 QCOMPARE( polyStyle1 != polyStyle2, false );
1287 QVERIFY( polyStyle1 == polyStyle2 );
1288
1289 polyStyle2.setOutline( true );
1290 polyStyle2.setBrushStyle( Qt::CrossPattern );
1291
1292 QCOMPARE( polyStyle1, polyStyle1 );
1293 QCOMPARE( polyStyle2, polyStyle2 );
1294 QCOMPARE( polyStyle1 == polyStyle2, false );
1295 QVERIFY( polyStyle1 != polyStyle2 );
1296 }
1297
labelStyleTest()1298 void TestEquality::labelStyleTest()
1299 {
1300 GeoDataLabelStyle labelStyle1, labelStyle2;
1301
1302 labelStyle1.setColor( Qt::blue );
1303 labelStyle1.setScale( 1.0 );
1304 labelStyle1.setAlignment( GeoDataLabelStyle::Center );
1305 labelStyle1.setFont( QFont( QStringLiteral( "Helvetica" ), 10 ) );
1306
1307 labelStyle2.setColor( Qt::blue );
1308 labelStyle2.setScale( 1.0 );
1309 labelStyle2.setAlignment( GeoDataLabelStyle::Center );
1310 labelStyle2.setFont( QFont( QStringLiteral( "Helvetica" ), 10 ) );
1311
1312 QCOMPARE( labelStyle1, labelStyle1 );
1313 QCOMPARE( labelStyle2, labelStyle2 );
1314 QCOMPARE( labelStyle1 != labelStyle2, false );
1315 QVERIFY( labelStyle1 == labelStyle2);
1316
1317 labelStyle2.setAlignment( GeoDataLabelStyle::Corner );
1318 labelStyle2.setFont( QFont( QStringLiteral( "Helvetica [Cronyx]" ), 12 ) );
1319
1320 QCOMPARE( labelStyle1, labelStyle1 );
1321 QCOMPARE( labelStyle2, labelStyle2 );
1322 QCOMPARE( labelStyle1 == labelStyle2, false);
1323 QVERIFY( labelStyle1 != labelStyle2 );
1324 }
1325
styleTest()1326 void TestEquality::styleTest()
1327 {
1328 GeoDataStyle style1, style2;
1329 GeoDataIconStyle iconStyle;
1330 QImage icon( 50, 50, QImage::Format_Mono );
1331 icon.fill( Qt::black );
1332 QPointF hotSpot = QPointF( 7.6, 6.4 );
1333
1334 iconStyle.setScale( 1.0 );
1335 iconStyle.setIconPath( "path/to/icon" );
1336 iconStyle.setIcon( icon );
1337 iconStyle.setHotSpot( hotSpot, GeoDataHotSpot::Fraction, GeoDataHotSpot::Fraction );
1338 iconStyle.setHeading( 0 );
1339
1340 GeoDataLabelStyle labelStyle;
1341 labelStyle.setColor( Qt::blue );
1342 labelStyle.setScale( 1.0 );
1343 labelStyle.setAlignment( GeoDataLabelStyle::Center );
1344 labelStyle.setFont( QFont( QStringLiteral( "Helvetica" ), 10 ) );
1345
1346 GeoDataLineStyle lineStyle;
1347 QVector< qreal > pattern( 5, 6.2 );
1348 lineStyle.setWidth( 1.2 );
1349 lineStyle.setPhysicalWidth( 1.0 );
1350 lineStyle.setCapStyle( Qt::RoundCap );
1351 lineStyle.setPenStyle( Qt::SolidLine );
1352 lineStyle.setBackground( false );
1353 lineStyle.setDashPattern( pattern );
1354
1355 GeoDataPolyStyle polyStyle;
1356 polyStyle.setColor( Qt::red );
1357 polyStyle.setFill( false );
1358 polyStyle.setOutline( false );
1359 polyStyle.setBrushStyle( Qt::SolidPattern );
1360
1361 GeoDataBalloonStyle balloon;
1362 balloon.setBackgroundColor(Qt::white);
1363 balloon.setTextColor(Qt::black);
1364 balloon.setText("SomeText");
1365 balloon.setDisplayMode(GeoDataBalloonStyle::Hide);
1366
1367 GeoDataListStyle listStyle;
1368 listStyle.setListItemType( GeoDataListStyle::Check );
1369 listStyle.setBackgroundColor( Qt::gray );
1370 for( int i = 0; i < 5; ++i ) {
1371 GeoDataItemIcon *icon = new GeoDataItemIcon;
1372 QImage img( 20 * ( i + 1 ), 20 * ( i + 1 ), QImage::Format_Mono );
1373 img.fill( Qt::black );
1374 icon->setIcon( img );
1375 icon->setIconPath( QString("path/to/icon") );
1376 icon->setState( GeoDataItemIcon::Open );
1377 listStyle.append( icon );
1378 }
1379
1380 style1.setIconStyle( iconStyle );
1381 style1.setLineStyle( lineStyle );
1382 style1.setLabelStyle( labelStyle );
1383 style1.setPolyStyle( polyStyle );
1384 style1.setBalloonStyle( balloon );
1385 style1.setListStyle( listStyle );
1386
1387 style2.setIconStyle( iconStyle );
1388 style2.setLineStyle( lineStyle );
1389 style2.setLabelStyle( labelStyle );
1390 style2.setPolyStyle( polyStyle );
1391 style2.setBalloonStyle( balloon );
1392 style2.setListStyle( listStyle );
1393
1394 QCOMPARE( style1, style1 );
1395 QCOMPARE( style2, style2 );
1396 QCOMPARE( style1 != style2, false );
1397 QVERIFY( style1 == style2 );
1398
1399 iconStyle.setScale( 2.0 );
1400 labelStyle.setAlignment( GeoDataLabelStyle::Corner );
1401 lineStyle.setBackground( true );
1402 polyStyle.setOutline( true );
1403
1404 style2.setIconStyle( iconStyle );
1405 style2.setLabelStyle( labelStyle );
1406 style2.setLineStyle( lineStyle );
1407 style2.setPolyStyle( polyStyle );
1408
1409 QCOMPARE( style1, style1 );
1410 QCOMPARE( style2, style2 );
1411 QCOMPARE( style1 == style2, false );
1412 QVERIFY( style1 != style2 );
1413 }
1414
styleMapTest()1415 void TestEquality::styleMapTest()
1416 {
1417 GeoDataStyleMap styleMap1, styleMap2;
1418 styleMap1["germany"] = "gst1";
1419 styleMap1["germany"] = "gst2";
1420 styleMap1["germany"] = "gst3";
1421 styleMap1["poland"] = "pst1";
1422 styleMap1["poland"] = "pst2";
1423 styleMap1["poland"] = "pst3";
1424 styleMap1.setLastKey("poland");
1425
1426 styleMap2["germany"] = "gst1";
1427 styleMap2["germany"] = "gst2";
1428 styleMap2["germany"] = "gst3";
1429 styleMap2["poland"] = "pst1";
1430 styleMap2["poland"] = "pst2";
1431 styleMap2["poland"] = "pst3";
1432 styleMap2.setLastKey("poland");
1433
1434 QCOMPARE( styleMap1, styleMap1 );
1435 QCOMPARE( styleMap2, styleMap2 );
1436 QCOMPARE( styleMap1 != styleMap2, false );
1437
1438 styleMap2.insert("Romania", "rst1");
1439 styleMap2.insert("Romania", "rst2");
1440 styleMap2.insert("Romania", "rst3");
1441 styleMap2.setLastKey("Romania");
1442
1443 QCOMPARE( styleMap1, styleMap1 );
1444 QCOMPARE( styleMap2, styleMap2 );
1445 QCOMPARE( styleMap1 == styleMap2, false );
1446 QVERIFY( styleMap1 != styleMap2 );
1447 }
1448
viewVolumeTest()1449 void TestEquality::viewVolumeTest()
1450 {
1451 GeoDataViewVolume volume1, volume2;
1452
1453 volume1.setLeftFov( 5.6 );
1454 volume1.setRightFov( 6.5 );
1455 volume1.setTopFov( 2.3 );
1456 volume1.setBottomFov( 9.2 );
1457 volume1.setNear( 8.6 );
1458
1459 volume2.setLeftFov( 5.6 );
1460 volume2.setRightFov( 6.5 );
1461 volume2.setTopFov( 2.3 );
1462 volume2.setBottomFov( 9.2 );
1463 volume2.setNear( 8.6 );
1464
1465 QCOMPARE( volume1, volume1 );
1466 QCOMPARE( volume2, volume2 );
1467 QCOMPARE( volume1 != volume2, false );
1468 QVERIFY( volume1 == volume2 );
1469
1470 volume2.setRightFov( 7.3 );
1471
1472 QCOMPARE( volume1, volume1 );
1473 QCOMPARE( volume2, volume2 );
1474 QCOMPARE( volume1 == volume2, false );
1475 QVERIFY( volume1 != volume2 );
1476 }
1477
vecTest()1478 void TestEquality::vecTest()
1479 {
1480 GeoDataVec2 vec1, vec2;
1481
1482 vec1.setXunits( GeoDataVec2::Fraction );
1483 vec1.setYunits( GeoDataVec2::Pixels );
1484
1485 vec2.setXunits( GeoDataVec2::Fraction );
1486 vec2.setYunits( GeoDataVec2::Pixels );
1487
1488 QCOMPARE( vec1, vec1 );
1489 QCOMPARE( vec2, vec2 );
1490 QCOMPARE( vec1 != vec2, false );
1491 QVERIFY( vec1 == vec2 );
1492
1493 vec2.setYunits( GeoDataVec2::Fraction );
1494
1495 QCOMPARE( vec1, vec1 );
1496 QCOMPARE( vec2, vec2 );
1497 QCOMPARE( vec1 == vec2, false );
1498 QVERIFY( vec1 != vec2 );
1499 }
1500
screenOverlayTest()1501 void TestEquality::screenOverlayTest()
1502 {
1503 GeoDataVec2 vec1, vec2, vec3, vec4;
1504
1505 vec1.setXunits( GeoDataVec2::Fraction );
1506 vec1.setYunits( GeoDataVec2::Pixels );
1507
1508 vec2.setXunits( GeoDataVec2::Fraction );
1509 vec2.setYunits( GeoDataVec2::InsetPixels );
1510
1511 vec3.setXunits( GeoDataVec2::Pixels );
1512 vec3.setYunits( GeoDataVec2::Pixels );
1513
1514 vec4.setXunits( GeoDataVec2::Fraction );
1515 vec4.setYunits( GeoDataVec2::Fraction );
1516
1517 GeoDataScreenOverlay overlay1, overlay2;
1518
1519 overlay1.setOverlayXY( vec1 );
1520 overlay1.setRotationXY( vec2 );
1521 overlay1.setScreenXY( vec3 );
1522 overlay1.setSize( vec4 );
1523 overlay1.setRotation( 3.4 );
1524
1525 overlay2.setOverlayXY( vec1 );
1526 overlay2.setRotationXY( vec2 );
1527 overlay2.setScreenXY( vec3 );
1528 overlay2.setSize( vec4 );
1529 overlay2.setRotation( 3.4 );
1530
1531 QCOMPARE( overlay1, overlay1 );
1532 QCOMPARE( overlay2, overlay2 );
1533 QCOMPARE( overlay1 != overlay2, false );
1534 QVERIFY( overlay1 == overlay2 );
1535
1536 overlay2.setRotation( 7.3 );
1537
1538 QCOMPARE( overlay1, overlay1 );
1539 QCOMPARE( overlay2, overlay2 );
1540 QCOMPARE( overlay1 == overlay2, false );
1541 QVERIFY( overlay1 != overlay2 );
1542 }
1543
photoOverlayTest()1544 void TestEquality::photoOverlayTest()
1545 {
1546 GeoDataPhotoOverlay overlay1, overlay2;
1547 GeoDataViewVolume volume1, volume2;
1548
1549 volume1.setLeftFov( 5.6 );
1550 volume1.setRightFov( 6.5 );
1551 volume1.setTopFov( 2.3 );
1552 volume1.setBottomFov( 9.2 );
1553 volume1.setNear( 8.6 );
1554
1555 volume2.setLeftFov( 5.6 );
1556 volume2.setRightFov( 6.5 );
1557 volume2.setTopFov( 2.3 );
1558 volume2.setBottomFov( 9.2 );
1559 volume2.setNear( 8.6 );
1560
1561 overlay1.setViewVolume( volume1 );
1562 overlay2.setViewVolume( volume2 );
1563
1564 GeoDataImagePyramid pyramid1, pyramid2;
1565
1566 pyramid1.setTileSize( 3 );
1567 pyramid1.setMaxWidth( 5 );
1568 pyramid1.setMaxHeight( 8 );
1569 pyramid1.setGridOrigin( GeoDataImagePyramid::UpperLeft );
1570
1571 pyramid2.setTileSize( 3 );
1572 pyramid2.setMaxWidth( 5 );
1573 pyramid2.setMaxHeight( 8 );
1574 pyramid2.setGridOrigin( GeoDataImagePyramid::UpperLeft );
1575
1576 overlay1.setImagePyramid( pyramid1 );
1577 overlay2.setImagePyramid( pyramid2 );
1578
1579 GeoDataPoint point1, point2;
1580 GeoDataCoordinates coord1, coord2;
1581
1582 coord1.set(100,100,100);
1583 coord2.set(100,100,100);
1584 point1.setCoordinates(coord1);
1585 point2.setCoordinates(coord2);
1586 overlay1.setPoint( point1 );
1587 overlay2.setPoint( point2 );
1588
1589 overlay1.setShape( GeoDataPhotoOverlay::Cylinder );
1590 overlay2.setShape( GeoDataPhotoOverlay::Cylinder );
1591
1592 overlay1.setRotation( 2.5 );
1593 overlay2.setRotation( 2.5 );
1594
1595 QCOMPARE( overlay1, overlay1 );
1596 QCOMPARE( overlay2, overlay2 );
1597 QCOMPARE( overlay1 != overlay2, false );
1598 QVERIFY( overlay1 == overlay2 );
1599
1600 overlay2.setRotation( 4.3 );
1601
1602 QCOMPARE( overlay1, overlay1 );
1603 QCOMPARE( overlay2, overlay2 );
1604 QCOMPARE( overlay1 == overlay2, false );
1605 QVERIFY( overlay1 != overlay2 );
1606 }
1607
groundOverlayTest()1608 void TestEquality::groundOverlayTest()
1609 {
1610 GeoDataGroundOverlay overlay1, overlay2;
1611 GeoDataLatLonBox latLonBox1, latLonBox2;
1612
1613 latLonBox1.setEast( 40 );
1614 latLonBox1.setWest( 50 );
1615 latLonBox1.setNorth( 60 );
1616 latLonBox1.setSouth( 70 );
1617 latLonBox1.setRotation( 20 );
1618 latLonBox1.setBoundaries( 70, 80, 50, 60 );
1619
1620 latLonBox2.setEast( 40 );
1621 latLonBox2.setWest( 50 );
1622 latLonBox2.setNorth( 60 );
1623 latLonBox2.setSouth( 70 );
1624 latLonBox2.setRotation( 20 );
1625 latLonBox2.setBoundaries( 70, 80, 50, 60 );
1626
1627 overlay1.setLatLonBox( latLonBox1 );
1628 overlay2.setLatLonBox( latLonBox2 );
1629
1630 GeoDataLatLonQuad quad1, quad2;
1631 quad1.setBottomLeftLatitude( 55, GeoDataCoordinates::Degree );
1632 quad1.setBottomLeftLongitude( 60, GeoDataCoordinates::Degree );
1633 quad1.setBottomRightLatitude( 45, GeoDataCoordinates::Degree );
1634 quad1.setBottomRightLongitude( 50, GeoDataCoordinates::Degree );
1635
1636 quad1.setTopLeftLatitude( 55, GeoDataCoordinates::Degree );
1637 quad1.setTopLeftLongitude( 60, GeoDataCoordinates::Degree );
1638 quad1.setTopRightLatitude( 45, GeoDataCoordinates::Degree );
1639 quad1.setTopRightLongitude( 50, GeoDataCoordinates::Degree );
1640
1641 quad2.setBottomLeftLatitude( 55, GeoDataCoordinates::Degree );
1642 quad2.setBottomLeftLongitude( 60, GeoDataCoordinates::Degree );
1643 quad2.setBottomRightLatitude( 45, GeoDataCoordinates::Degree );
1644 quad2.setBottomRightLongitude( 50, GeoDataCoordinates::Degree );
1645
1646 quad2.setTopLeftLatitude( 55, GeoDataCoordinates::Degree );
1647 quad2.setTopLeftLongitude( 60, GeoDataCoordinates::Degree );
1648 quad2.setTopRightLatitude( 45, GeoDataCoordinates::Degree );
1649 quad2.setTopRightLongitude( 50, GeoDataCoordinates::Degree );
1650
1651 overlay1.setLatLonQuad( quad1 );
1652 overlay2.setLatLonQuad( quad2 );
1653
1654 overlay1.setAltitude( 23.5 );
1655 overlay2.setAltitude( 23.5 );
1656
1657 overlay1.setAltitudeMode( Marble::Absolute );
1658 overlay2.setAltitudeMode( Marble::Absolute );
1659
1660 QCOMPARE( overlay1, overlay1 );
1661 QCOMPARE( overlay2, overlay2 );
1662 QCOMPARE( overlay1 != overlay2, false );
1663 QVERIFY( overlay1 == overlay2 );
1664
1665 overlay2.setAltitude( 42.3 );
1666
1667 QCOMPARE( overlay1, overlay1 );
1668 QCOMPARE( overlay2, overlay2 );
1669 QCOMPARE( overlay1 == overlay2, false );
1670 QVERIFY( overlay1 != overlay2 );
1671 }
1672
simpleFieldTest()1673 void TestEquality::simpleFieldTest()
1674 {
1675 GeoDataSimpleField field1, field2;
1676 field1.setDisplayName("Simple Field");
1677 field1.setName("Field Name");
1678 field1.setType(GeoDataSimpleField::Int);
1679
1680 field2.setDisplayName("Simple Field");
1681 field2.setName("Field Name");
1682 field2.setType(GeoDataSimpleField::Int);
1683
1684 QCOMPARE( field1, field1 );
1685 QCOMPARE( field2, field2 );
1686 QCOMPARE( field1 != field2, false );
1687 QVERIFY( field1 == field2 );
1688
1689 field2.setType( GeoDataSimpleField::Double );
1690
1691 QCOMPARE( field1, field1 );
1692 QCOMPARE( field2, field2 );
1693 QCOMPARE( field1 == field2, false );
1694 QVERIFY( field1 != field2 );
1695 }
1696
schemaTest()1697 void TestEquality::schemaTest()
1698 {
1699 GeoDataSimpleField field1, field2;
1700 field1.setDisplayName("Simple Field 1");
1701 field1.setName("Field Name 1");
1702 field1.setType(GeoDataSimpleField::Int);
1703
1704 field2.setDisplayName("Simple Field 2");
1705 field2.setName("Field Name 2");
1706 field2.setType(GeoDataSimpleField::Double);
1707
1708 GeoDataSchema schema1, schema2;
1709 schema1.setId( "Some ID" );
1710 schema1.setSchemaName( "Some Name" );
1711 schema1.addSimpleField( field1 );
1712 schema1.addSimpleField( field2 );
1713
1714 schema2.setId( "Some ID" );
1715 schema2.setSchemaName( "Some Name" );
1716 schema2.addSimpleField( field1 );
1717 schema2.addSimpleField( field2 );
1718
1719 QCOMPARE( schema1, schema1 );
1720 QCOMPARE( schema2, schema2 );
1721 QCOMPARE( schema1 != schema2, false );
1722 QVERIFY( schema1 == schema2 );
1723
1724 schema2.setSchemaName( "Changed Name" );
1725
1726 QCOMPARE( schema1, schema1 );
1727 QCOMPARE( schema2, schema2 );
1728 QCOMPARE( schema1 == schema2, false );
1729 QVERIFY( schema1 != schema2 );
1730 }
1731
scaleTest()1732 void TestEquality::scaleTest()
1733 {
1734 GeoDataScale scale1, scale2;
1735
1736 scale1.setX( 1.0 );
1737 scale1.setY( 2.0 );
1738 scale1.setZ( 3.0 );
1739
1740 scale2 = scale1;
1741 scale2.setZ( 3.5 );
1742
1743 QCOMPARE( scale1, scale1 );
1744 QCOMPARE( scale2, scale2 );
1745 QCOMPARE( scale1 == scale2, false );
1746 QVERIFY( scale1 != scale2 );
1747
1748 scale2.setZ( 3.0 );
1749 QVERIFY( scale1 == scale2 );
1750 }
1751
orientationTest()1752 void TestEquality::orientationTest()
1753 {
1754 GeoDataOrientation obj1, obj2;
1755
1756 obj1.setHeading( 90 );
1757 obj1.setTilt( 45 );
1758 obj1.setRoll( -90 );
1759
1760 obj2 = obj1;
1761 obj2.setRoll( -45 );
1762
1763 QCOMPARE( obj1, obj1 );
1764 QCOMPARE( obj2, obj2 );
1765 QCOMPARE( obj1 == obj2, false );
1766 QVERIFY( obj1 != obj2 );
1767
1768 obj2.setRoll( - 90 );
1769 QVERIFY( obj1 == obj2 );
1770 }
1771
locationTest()1772 void TestEquality::locationTest()
1773 {
1774 GeoDataLocation loc1, loc2;
1775
1776 loc1.setLatitude( M_PI_4, GeoDataCoordinates::Degree );
1777 loc1.setLongitude( M_PI_4, GeoDataCoordinates::Degree );
1778 loc1.setAltitude( 2500.0 );
1779
1780 loc2 = loc1;
1781 loc2.setAltitude( 2000.0 );
1782
1783 QCOMPARE( loc1, loc1 );
1784 QCOMPARE( loc2, loc2 );
1785 QCOMPARE( loc1 == loc2, false );
1786 QVERIFY( loc1 != loc2 );
1787
1788 loc2.setAltitude( 2500.0 );
1789 QVERIFY( loc1 == loc2 );
1790 }
1791
resourceMapTest()1792 void TestEquality::resourceMapTest()
1793 {
1794 GeoDataResourceMap rMap1, rMap2;
1795
1796 rMap1.setSourceHref( "/path/to/source/href" );
1797 rMap1.setTargetHref( "/path/to/target/href" );
1798
1799 rMap2 = rMap1;
1800 rMap2.setTargetHref( "/path/to/target/href2" );
1801
1802 QCOMPARE( rMap1, rMap1 );
1803 QCOMPARE( rMap2, rMap2 );
1804 QCOMPARE( rMap1 == rMap2, false );
1805 QVERIFY( rMap1 != rMap2 );
1806
1807 rMap2.setTargetHref( "/path/to/target/href" );
1808 QVERIFY( rMap1 == rMap2 );
1809 }
1810
modelTest()1811 void TestEquality::modelTest()
1812 {
1813 GeoDataModel model1, model2;
1814
1815
1816 GeoDataLink link1, link2;
1817 link1.setHref("some/example/href.something");
1818 link1.setRefreshInterval( 23 );
1819 link1.setRefreshMode( GeoDataLink::OnChange );
1820 link1.setViewBoundScale( 50 );
1821 link1.setViewRefreshTime( 30 );
1822
1823 link2 = link1;
1824 link2.setRefreshMode( GeoDataLink::OnExpire );
1825
1826 model1.setLink( link1 );
1827 model1.setLink( link2 );
1828
1829
1830 GeoDataCoordinates coord1, coord2;
1831 coord1.set(100, 200, 300);
1832 coord2.set(100, 200, 200);
1833
1834 model1.setCoordinates( coord1 );
1835 model2.setCoordinates( coord2 );
1836
1837
1838 GeoDataScale scale1, scale2;
1839
1840 scale1.setX( 1.0 );
1841 scale1.setY( 2.0 );
1842 scale1.setZ( 3.0 );
1843
1844 scale2 = scale1;
1845 scale2.setZ( 3.5 );
1846
1847 model1.setScale( scale1 );
1848 model2.setScale( scale2 );
1849
1850
1851 GeoDataOrientation obj1, obj2;
1852
1853 obj1.setHeading( 90 );
1854 obj1.setTilt( 45 );
1855 obj1.setRoll( -90 );
1856
1857 obj2 = obj1;
1858 obj2.setRoll( -45 );
1859
1860 model1.setOrientation( obj1 );
1861 model2.setOrientation( obj2 );
1862
1863
1864 GeoDataLocation loc1, loc2;
1865
1866 loc1.setLatitude( M_PI_4, GeoDataCoordinates::Degree );
1867 loc1.setLongitude( M_PI_4, GeoDataCoordinates::Degree );
1868 loc1.setAltitude( 2500.0 );
1869
1870 loc2 = loc1;
1871 loc2.setAltitude( 2000.0 );
1872
1873 model1.setLocation( loc1 );
1874 model2.setLocation( loc2 );
1875
1876
1877 GeoDataResourceMap rMap1, rMap2;
1878
1879 rMap1.setSourceHref( "/path/to/source/href" );
1880 rMap1.setTargetHref( "/path/to/target/href" );
1881
1882 rMap2 = rMap1;
1883 rMap2.setTargetHref( "/path/to/target/href2" );
1884
1885 model1.setResourceMap( rMap1 );
1886 model2.setResourceMap( rMap2 );
1887
1888
1889 QCOMPARE( model1, model1 );
1890 QCOMPARE( model2, model2 );
1891 QCOMPARE( model1 == model2, false );
1892 QVERIFY( model1 != model2 );
1893
1894
1895 link2.setRefreshMode( GeoDataLink::OnExpire );
1896 model2.setLink( link2 );
1897
1898 coord2.setAltitude( 300 );
1899 model2.setCoordinates( coord2 );
1900
1901 scale2.setZ( 3.0 );
1902 model2.setScale( scale2 );
1903
1904 obj2.setRoll( -90 );
1905 model2.setOrientation( obj2 );
1906
1907 loc2.setAltitude( 2500.0 );
1908 model2.setLocation( loc2 );
1909
1910 rMap2.setTargetHref( "/path/to/target/href" );
1911 model2.setResourceMap( rMap2 );
1912
1913 QVERIFY( model1 == model2 );
1914 }
1915
trackTest()1916 void TestEquality::trackTest()
1917 {
1918 GeoDataTrack track1, track2;
1919 QDateTime date11( QDate(2000, 10, 4) ), date12( QDate(2001, 10, 4) );
1920 QDateTime date21( QDate(2002, 10, 4) ), date22( QDate(2003, 10, 4) );
1921 GeoDataCoordinates coord1(100, 100), coord2(200, 300), coord3(300, 300), coord4(400, 400);
1922 GeoDataExtendedData extendedData1, extendedData2;
1923 GeoDataData data1, data2;
1924
1925 data1.setName("Something");
1926 data1.setValue(QVariant(23.56));
1927 data1.setDisplayName("Marble");
1928
1929 data2.setName("Marble");
1930 data2.setValue(QVariant(23.56));
1931 data2.setDisplayName("Globe");
1932
1933 extendedData1.addValue(data1);
1934 extendedData2.addValue(data2);
1935
1936 track1.addPoint(date11, coord1);
1937 track1.addPoint(date12, coord2);
1938 track2.addPoint(date21, coord3);
1939 track2.addPoint(date22, coord4);
1940
1941 track1.setExtendedData(extendedData1);
1942 track2.setExtendedData(extendedData2);
1943
1944 track1.setInterpolate( true );
1945 track2.setInterpolate( true );
1946
1947 QCOMPARE(track1, track1);
1948 QCOMPARE(track2, track2);
1949 QCOMPARE(track1 == track2, false);
1950 QVERIFY(track1 != track2);
1951
1952 track1.clear();
1953 track1.addPoint(date21, coord3);
1954 track1.addPoint(date22, coord4);
1955 track1.setExtendedData(extendedData2);
1956 QVERIFY(track1 == track2);
1957 }
1958
multiTrackTest()1959 void TestEquality::multiTrackTest()
1960 {
1961 GeoDataMultiTrack multiTrack1, multiTrack2;
1962 GeoDataTrack *track1, *track2, *track3, *track4;
1963 QDateTime date11( QDate(2000, 10, 4) ), date12( QDate(2001, 10, 4) );
1964 QDateTime date21( QDate(2002, 10, 4) ), date22( QDate(2003, 10, 4) );
1965 GeoDataCoordinates coord1(100, 100), coord2(200, 300), coord3(300, 300), coord4(400, 400);
1966 GeoDataExtendedData extendedData1, extendedData2;
1967 GeoDataData data1, data2;
1968
1969 data1.setName("Something");
1970 data1.setValue(QVariant(23.56));
1971 data1.setDisplayName("Marble");
1972
1973 data2.setName("Marble");
1974 data2.setValue(QVariant(23.56));
1975 data2.setDisplayName("Globe");
1976
1977 extendedData1.addValue(data1);
1978 extendedData2.addValue(data2);
1979
1980 track1 = new GeoDataTrack();
1981 track2 = new GeoDataTrack();
1982 track1->addPoint(date11, coord1);
1983 track1->addPoint(date12, coord2);
1984 track2->addPoint(date11, coord1);
1985 track2->addPoint(date12, coord2);
1986 track1->setExtendedData(extendedData1);
1987 track2->setExtendedData(extendedData1);
1988 track1->setInterpolate( true );
1989 track2->setInterpolate( true );
1990
1991 track3 = new GeoDataTrack();
1992 track4 = new GeoDataTrack();
1993 track3->addPoint(date21, coord3);
1994 track3->addPoint(date22, coord4);
1995 track4->addPoint(date21, coord3);
1996 track4->addPoint(date22, coord4);
1997 track3->setExtendedData(extendedData2);
1998 track4->setExtendedData(extendedData2);
1999 track3->setInterpolate( false );
2000 track4->setInterpolate( false );
2001
2002 multiTrack1.append(track1);
2003 multiTrack2.append(track2);
2004 multiTrack1.append(track3);
2005 multiTrack2.append(track4);
2006
2007 QCOMPARE(*track1, *track2);
2008 QCOMPARE(*track3, *track4);
2009
2010 QCOMPARE(multiTrack1, multiTrack1);
2011 QCOMPARE(multiTrack2, multiTrack2);
2012 QCOMPARE(multiTrack1 != multiTrack2, false);
2013 QVERIFY(multiTrack1 == multiTrack2);
2014 }
2015
snippetTest()2016 void TestEquality::snippetTest()
2017 {
2018 GeoDataSnippet snipp1, snipp2;
2019
2020 snipp1.setText( QString("Text1") );
2021 snipp2.setText( QString("Text2") );
2022
2023 snipp1.setMaxLines( 10 );
2024 snipp2.setMaxLines( 666013 );
2025
2026 QCOMPARE( snipp1, snipp1 );
2027 QCOMPARE( snipp2, snipp2 );
2028 QCOMPARE( snipp1 == snipp2, false );
2029 QVERIFY( snipp1 != snipp2 );
2030
2031 snipp1.setText( QString("Text2") );
2032 snipp2.setMaxLines( 10 );
2033 QVERIFY( snipp1 == snipp2 );
2034 }
2035
lookAtTest()2036 void TestEquality::lookAtTest()
2037 {
2038 GeoDataLookAt lookAt1, lookAt2;
2039
2040 lookAt1.setLatitude(1.112);
2041 lookAt1.setLongitude(2.33);
2042 lookAt1.setAltitude(1500);
2043 lookAt2 = lookAt1;
2044
2045 GeoDataTimeStamp timeStampBegin, timeStampEnd;
2046 QDateTime date1( QDate(2014, 4, 7) );
2047
2048 timeStampBegin.setWhen( date1 );
2049 timeStampEnd.setWhen( date1 );
2050 timeStampBegin.setResolution( GeoDataTimeStamp::YearResolution );
2051 timeStampEnd.setResolution( GeoDataTimeStamp::YearResolution );
2052
2053 GeoDataTimeSpan timeSpan1, timeSpan2;
2054 timeSpan1.setBegin( timeStampBegin );
2055 timeSpan1.setEnd( timeStampEnd );
2056 timeSpan2 = timeSpan1;
2057
2058 GeoDataTimeStamp timeStamp1, timeStamp2;
2059 QDateTime date2( QDate(2014, 4, 8) );
2060 timeStamp1.setWhen( date2 );
2061 timeStamp2.setWhen( date2 );
2062 timeStamp1.setResolution( GeoDataTimeStamp::SecondResolution );
2063 timeStamp2.setResolution( GeoDataTimeStamp::SecondResolution );
2064
2065 lookAt1.setTimeSpan( timeSpan1 );
2066 lookAt2.setTimeSpan( timeSpan2 );
2067 lookAt1.setTimeStamp( timeStamp1 );
2068 lookAt2.setTimeStamp( timeStamp2 );
2069
2070 lookAt1.setRange( 500 );
2071 lookAt2.setRange( 300 );
2072
2073 QCOMPARE( lookAt1, lookAt1 );
2074 QCOMPARE( lookAt2, lookAt2 );
2075 QCOMPARE( lookAt1 == lookAt2, false );
2076 QVERIFY( lookAt1 != lookAt2 );
2077
2078 lookAt2.setRange( 500 );
2079 QVERIFY( lookAt1 == lookAt2 );
2080
2081 timeStamp1.setResolution( GeoDataTimeStamp::YearResolution );
2082 lookAt1.setTimeStamp( timeStamp1 );
2083 QVERIFY( lookAt1 != lookAt2 );
2084
2085 lookAt2.setTimeStamp( timeStamp1 );
2086 QVERIFY( lookAt1 == lookAt2 );
2087
2088 lookAt2.setAltitude( 2000 );
2089 QVERIFY( lookAt1 != lookAt2 );
2090 }
2091
networkLinkTest()2092 void TestEquality::networkLinkTest()
2093 {
2094 GeoDataNetworkLink netL1, netL2;
2095
2096 netL1.setRefreshVisibility( true );
2097 netL2.setRefreshVisibility( false );
2098 netL1.setFlyToView( true );
2099 netL2.setFlyToView( false );
2100
2101 GeoDataLink link;
2102 link.setHref(QString("/link/to/something"));
2103 link.setRefreshMode( GeoDataLink::OnExpire );
2104 link.setRefreshInterval( 20.22 );
2105 link.setViewRefreshMode( GeoDataLink::OnRequest );
2106 link.setViewRefreshTime( 3.22 );
2107 link.setViewBoundScale( 1.132 );
2108 link.setViewFormat( QString("Format 1") );
2109 link.setHttpQuery( QString("HttpQueryy1") );
2110
2111 netL1.setLink( link );
2112 netL2.setLink( link );
2113
2114 QCOMPARE( netL1, netL1 );
2115 QCOMPARE( netL2, netL2 );
2116 QCOMPARE( netL1 == netL2, false );
2117 QVERIFY( netL1 != netL2 );
2118
2119 netL1.setName( QString("NetL1") );
2120 netL1.setSnippet( GeoDataSnippet("Textttt", 10) );
2121 netL1.setDescription( QString("Descr1") );
2122 netL1.setDescriptionCDATA( false );
2123 netL1.setAddress( QString("Some address") );
2124 netL1.setPhoneNumber( QString("Some phone number") );
2125 netL1.setStyleUrl( QString("/link/to/style1") );
2126 netL1.setPopularity( 66666 );
2127 netL1.setZoomLevel( 10 );
2128 netL1.setVisible( true );
2129 netL1.setRole( QString("Role1") );
2130 netL2.setName( QString("NetL1") );
2131 netL2.setSnippet( GeoDataSnippet("Textttt", 10) );
2132 netL2.setDescription( QString("Descr1") );
2133 netL2.setDescriptionCDATA( false );
2134 netL2.setAddress( QString("Some address") );
2135 netL2.setPhoneNumber( QString("Some phone number") );
2136 netL2.setStyleUrl( QString("/link/to/style1") );
2137 netL2.setPopularity( 66666 );
2138 netL2.setZoomLevel( 10 );
2139 netL2.setVisible( true );
2140 netL2.setRole( QString("Role1") );
2141
2142 GeoDataLookAt lookAt1, lookAt2;
2143
2144 lookAt1.setAltitudeMode( Marble::ClampToGround );
2145 lookAt1.setAltitude( 100 );
2146 lookAt1.setLatitude( 100 );
2147 lookAt1.setLongitude( 100 );
2148 lookAt1.setRange( 500 );
2149 lookAt2 = lookAt1;
2150
2151 netL1.setAbstractView( &lookAt1 );
2152 netL2.setAbstractView( &lookAt2 );
2153 netL1.setFlyToView( false );
2154 netL2.setRefreshVisibility( true );
2155
2156 QVERIFY( netL1 == netL2 );
2157 }
2158
networkLinkControlTest()2159 void TestEquality::networkLinkControlTest()
2160 {
2161 GeoDataNetworkLinkControl netLC1, netLC2;
2162
2163 netLC1.setMinRefreshPeriod( 25 );
2164 netLC1.setMaxSessionLength( 100 );
2165 netLC1.setCookie( QString("Coookiiee") );
2166 netLC1.setMessage( QString("Some message here") );
2167 netLC1.setLinkName( QString("Link name") );
2168 netLC1.setLinkDescription( QString("Some link description here") );
2169 netLC1.setLinkSnippet( QString("Link snippet") );
2170 netLC1.setMaxLines( 100 );
2171 netLC1.setExpires( QDateTime(QDate(2014, 5, 4)) );
2172 netLC2.setMinRefreshPeriod( 25 );
2173 netLC2.setMaxSessionLength( 100 );
2174 netLC2.setCookie( QString("Coookiiee") );
2175 netLC2.setMessage( QString("Some message here") );
2176 netLC2.setLinkName( QString("Link name") );
2177 netLC2.setLinkDescription( QString("Some link description here") );
2178 netLC2.setLinkSnippet( QString("Link snippet") );
2179 netLC2.setMaxLines( 100 );
2180 netLC2.setExpires( QDateTime(QDate(2014, 5, 4)) );
2181
2182 GeoDataUpdate update;
2183 update.setTargetHref( QString("Target href") );
2184
2185 netLC1.setUpdate( update );
2186 netLC2.setUpdate( update );
2187
2188
2189 GeoDataCamera *camera1 = new GeoDataCamera;
2190 GeoDataCamera *camera2 = new GeoDataCamera;
2191
2192 camera1->setAltitudeMode( Marble::ClampToGround );
2193 camera1->setAltitude( 2000 );
2194 camera1->setLatitude( 2.555 );
2195 camera1->setLongitude( 1.32 );
2196 camera1->setHeading( 200 );
2197 camera1->setRoll( 300 );
2198 camera1->setTilt( 400 );
2199 *camera2 = *camera1;
2200
2201
2202 netLC1.setAbstractView( camera1 );
2203 netLC2.setAbstractView( camera2 );
2204 QVERIFY( netLC1 == netLC2 );
2205
2206 camera2->setAltitudeMode( Marble::Absolute );
2207 QVERIFY( netLC1 != netLC2 );
2208
2209 camera1->setAltitudeMode( Marble::Absolute );
2210 QVERIFY( netLC1 == netLC2 );
2211
2212 netLC1.setMaxLines( 50 );
2213 QVERIFY( netLC1 != netLC2 );
2214
2215 netLC1.setStyleMap(nullptr);
2216 netLC2.setStyleMap(nullptr);
2217
2218 GeoDataStyleMap styleMap1, styleMap2;
2219 styleMap1["germany"] = "gst1";
2220 styleMap1["germany"] = "gst2";
2221 styleMap1["germany"] = "gst3";
2222 styleMap1["poland"] = "pst1";
2223 styleMap1["poland"] = "pst2";
2224 styleMap1["poland"] = "pst3";
2225 styleMap1.setLastKey("poland");
2226 styleMap2["germany"] = "gst1";
2227 styleMap2["germany"] = "gst2";
2228 styleMap2["germany"] = "gst3";
2229 styleMap2["poland"] = "pst1";
2230 styleMap2["poland"] = "pst2";
2231 styleMap2["poland"] = "pst3";
2232 styleMap2.setLastKey("romania");
2233
2234
2235 netLC2.setMaxLines( 50 );
2236 netLC1.setStyleMap( &styleMap1 );
2237 netLC2.setStyleMap( &styleMap2 );
2238 QVERIFY( netLC1 != netLC2 );
2239
2240 styleMap1.setLastKey("romania");
2241 QVERIFY( netLC1 == netLC2 );
2242 }
2243
folderTest()2244 void TestEquality::folderTest()
2245 {
2246 GeoDataFolder folder1, folder2;
2247
2248 GeoDataGroundOverlay *overlay11, *overlay12, *overlay21, *overlay22;
2249 GeoDataLatLonBox latLonBox1, latLonBox2;
2250
2251 overlay11 = new GeoDataGroundOverlay;
2252 overlay12 = new GeoDataGroundOverlay;
2253 overlay21 = new GeoDataGroundOverlay;
2254 overlay22 = new GeoDataGroundOverlay;
2255
2256 latLonBox1.setEast( 33 );
2257 latLonBox1.setWest( 52 );
2258 latLonBox1.setNorth( 61 );
2259 latLonBox1.setSouth( 72 );
2260 latLonBox1.setRotation( 51 );
2261 latLonBox1.setBoundaries( 23, 54, 33, 21 );
2262
2263 latLonBox2.setEast( 40 );
2264 latLonBox2.setWest( 50 );
2265 latLonBox2.setNorth( 60 );
2266 latLonBox2.setSouth( 70 );
2267 latLonBox2.setRotation( 20 );
2268 latLonBox2.setBoundaries( 70, 80, 50, 60 );
2269
2270 overlay11->setLatLonBox( latLonBox1 );
2271 overlay12->setLatLonBox( latLonBox2 );
2272
2273 GeoDataLatLonQuad quad1, quad2;
2274 quad1.setBottomLeftLatitude( 1.23, GeoDataCoordinates::Radian );
2275 quad1.setBottomLeftLongitude( 2.60, GeoDataCoordinates::Radian );
2276 quad1.setBottomRightLatitude( 0.45, GeoDataCoordinates::Radian );
2277 quad1.setBottomRightLongitude( 1.260, GeoDataCoordinates::Radian );
2278
2279 quad1.setTopLeftLatitude( 2.55, GeoDataCoordinates::Radian );
2280 quad1.setTopLeftLongitude( 1.65, GeoDataCoordinates::Radian );
2281 quad1.setTopRightLatitude( 1.245, GeoDataCoordinates::Radian );
2282 quad1.setTopRightLongitude( 1.350, GeoDataCoordinates::Radian );
2283
2284 quad2.setBottomLeftLatitude( 55, GeoDataCoordinates::Degree );
2285 quad2.setBottomLeftLongitude( 60, GeoDataCoordinates::Degree );
2286 quad2.setBottomRightLatitude( 45, GeoDataCoordinates::Degree );
2287 quad2.setBottomRightLongitude( 50, GeoDataCoordinates::Degree );
2288
2289 quad2.setTopLeftLatitude( 55, GeoDataCoordinates::Degree );
2290 quad2.setTopLeftLongitude( 60, GeoDataCoordinates::Degree );
2291 quad2.setTopRightLatitude( 45, GeoDataCoordinates::Degree );
2292 quad2.setTopRightLongitude( 50, GeoDataCoordinates::Degree );
2293
2294 overlay11->setLatLonQuad( quad1 );
2295 overlay12->setLatLonQuad( quad2 );
2296
2297 overlay11->setAltitude( 23.5 );
2298 overlay12->setAltitude( 23.5 );
2299
2300 overlay11->setAltitudeMode( Marble::Absolute );
2301 overlay12->setAltitudeMode( Marble::Absolute );
2302
2303 *overlay21 = *overlay11;
2304 *overlay22 = *overlay12;
2305
2306 folder1.append( overlay11 );
2307 folder1.append( overlay12 );
2308 folder2.append( overlay21 );
2309 folder2.append( overlay22 );
2310
2311 QCOMPARE( folder1, folder1 );
2312 QCOMPARE( folder2, folder2 );
2313 QCOMPARE( folder1 != folder2, false );
2314 QVERIFY( folder1 == folder2 );
2315 }
2316
simpleDataTest()2317 void TestEquality::simpleDataTest()
2318 {
2319 GeoDataSimpleData simpleData1, simpleData2;
2320 simpleData1.setName( "height" );
2321 simpleData1.setData( "4.65" );
2322
2323 simpleData2.setName( "height" );
2324 simpleData2.setData( "4.65" );
2325
2326 QCOMPARE( simpleData1, simpleData1 );
2327 QCOMPARE( simpleData2, simpleData2 );
2328 QCOMPARE( simpleData1 != simpleData2, false );
2329 QVERIFY( simpleData1 == simpleData2 );
2330
2331 simpleData2.setData( "7.45" );
2332
2333 QCOMPARE( simpleData1, simpleData1 );
2334 QCOMPARE( simpleData2, simpleData2 );
2335 QCOMPARE( simpleData1 == simpleData2, false );
2336 QVERIFY( simpleData1 != simpleData2 );
2337 }
2338
schemaDataTest()2339 void TestEquality::schemaDataTest()
2340 {
2341 GeoDataSimpleData simpleData1, simpleData2;
2342 simpleData1.setName( "width" );
2343 simpleData1.setData( "6.24" );
2344
2345 simpleData2.setName( "width" );
2346 simpleData2.setData( "6.24" );
2347
2348 GeoDataSchemaData schemaData1, schemaData2;
2349 schemaData1.setSchemaUrl( "dimensions" );
2350 schemaData1.addSimpleData( simpleData1 );
2351 schemaData1.addSimpleData( simpleData2 );
2352 schemaData2.setSchemaUrl( "dimensions" );
2353 schemaData2.addSimpleData( simpleData1 );
2354 schemaData2.addSimpleData( simpleData2 );
2355
2356 QCOMPARE( schemaData1, schemaData1 );
2357 QCOMPARE( schemaData2, schemaData2 );
2358 QCOMPARE( schemaData1 != schemaData2, false );
2359 QVERIFY( schemaData1 == schemaData2 );
2360
2361 schemaData2.setSchemaUrl( "some other id" );
2362
2363 QCOMPARE( schemaData1, schemaData1 );
2364 QCOMPARE( schemaData2, schemaData2 );
2365 QCOMPARE( schemaData1 == schemaData2, false );
2366 QVERIFY( schemaData1 != schemaData2 );
2367 }
2368
2369 QTEST_MAIN( TestEquality )
2370
2371 #include "TestEquality.moc"
2372