#include "map/mapengine.h"
#include "map/mapcommon.h"
#include "map/mapview.h"
+#include "map/baselocationitem.h"
+#include "user/user.h"
+#include "map/friendlocationitem.h"
namespace TestOwnLocation // Test data for function is defined in namespace
{
void TestOwnLocationItem::testConstructors()
{
- OwnLocationItem ownLocationItem1;
- OwnLocationItem ownLocationItem2(xCoordinate, yCoordinate);
- OwnLocationItem ownLocationItem3(testLocationPoint);
- // Test Pixmaps
- QPixmap pixmap1;
- QPixmap pixmap2;
- QPixmap pixmap3;
+ OwnLocationItem ownLocationItem(defaultLocationPoint);
- QCOMPARE (pixmap1.isNull(), true);
- QCOMPARE (pixmap2.isNull(), true);
- QCOMPARE (pixmap3.isNull(), true);
+ // Test Pixmap
+ QPixmap pixmap;
+ QCOMPARE (pixmap.isNull(), true);
- pixmap1 = ownLocationItem1.pixmap();
- pixmap2 = ownLocationItem2.pixmap();
- pixmap3 = ownLocationItem3.pixmap();
+ pixmap = ownLocationItem.pixmap();
+ QCOMPARE (pixmap.isNull(), false);
- QCOMPARE (pixmap1.isNull(), false);
- QCOMPARE (pixmap2.isNull(), false);
- QCOMPARE (pixmap3.isNull(), false);
- // Test Positions
- QCOMPARE(ownLocationItem1.position(),
+ // Test Position
+ QCOMPARE(ownLocationItem.position(),
MapEngine::convertLatLonToSceneCoordinate(defaultLocationPoint));
- QCOMPARE(ownLocationItem2.position(),
- MapEngine::convertLatLonToSceneCoordinate(testLocationPoint));
+ // Test Z-value
+ QCOMPARE(static_cast<int>(ownLocationItem.zValue()), OWN_LOCATION_ICON_Z_LEVEL);
- QCOMPARE(ownLocationItem3.position(),
- MapEngine::convertLatLonToSceneCoordinate(testLocationPoint));
- // Test Z-values
- QCOMPARE(static_cast<int>(ownLocationItem1.zValue()), OWN_LOCATION_ICON_Z_LEVEL);
- QCOMPARE(static_cast<int>(ownLocationItem2.zValue()), OWN_LOCATION_ICON_Z_LEVEL);
- QCOMPARE(static_cast<int>(ownLocationItem3.zValue()), OWN_LOCATION_ICON_Z_LEVEL);
+ // Test Offset
+// QCOMPARE(ownLocationItem.offset(),
+// QPoint(-ownLocationItem.pixmap().width(), -ownLocationItem.pixmap().height()));
- // Test Offsets
- QCOMPARE(ownLocationItem1.offset(), locationIconOffset);
- QCOMPARE(ownLocationItem2.offset(), locationIconOffset);
- QCOMPARE(ownLocationItem3.offset(), locationIconOffset);
// Test ItemIgnoresTransformations Flags
- QGraphicsItem::GraphicsItemFlags ownLocationItem1Flags = ownLocationItem1.flags();
- QGraphicsItem::GraphicsItemFlags ownLocationItem2Flags = ownLocationItem1.flags();
- QGraphicsItem::GraphicsItemFlags ownLocationItem3Flags = ownLocationItem1.flags();
+ QGraphicsItem::GraphicsItemFlags ownLocationItemFlags = ownLocationItem.flags();
+ QCOMPARE(ownLocationItemFlags, itemIgnoresTransformationsFlagValue);
- QCOMPARE(ownLocationItem1Flags, itemIgnoresTransformationsFlagValue);
- QCOMPARE(ownLocationItem2Flags, itemIgnoresTransformationsFlagValue);
- QCOMPARE(ownLocationItem3Flags, itemIgnoresTransformationsFlagValue);
}
void TestOwnLocationItem::testSetAndGetPosition()
{
- OwnLocationItem ownLocation;
+ OwnLocationItem ownLocation(defaultLocationPoint);
+
+ QCOMPARE(ownLocation.position(),
+ MapEngine::convertLatLonToSceneCoordinate(defaultLocationPoint));
+
ownLocation.setPosition(testLocationPoint);
QCOMPARE(ownLocation.position(),
MapEngine::convertLatLonToSceneCoordinate(testLocationPoint));
+
}
void TestOwnLocationItem::testHideAndShowPosition()
{
- OwnLocationItem ownLocation;
-
+ OwnLocationItem ownLocation(defaultLocationPoint);
QCOMPARE(ownLocation.isVisible(), true);
- ownLocation.hideOwnLocation();
-
+ ownLocation.hideLocation();
QCOMPARE(ownLocation.isVisible(), false);
+ ownLocation.showLocation();
+ QCOMPARE(ownLocation.isVisible(), true);
}
QTEST_MAIN(TestOwnLocationItem)