cf7bcb287a6b15c6ad83e9e5443a5b966b793532
[ptas] / zouba.sb1 / tests / ut_location / ut_location.cpp
1 #include <QObject>
2 #include <QtDebug>
3 #include <QByteArray>
4 #include <QGeoPositionInfo>
5 #include "location.h"
6 #include "location_p.h"
7 #include "ut_location.h"
8
9 QTM_USE_NAMESPACE
10
11 QByteArray sampleInput(
12 "\
13 <?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?><MTRXML version=\"1.0\">\
14 <GEOCODE key=\"taivaanvuohentie 7,helsinki\">\
15 <LOC name1=\"Taivaanvuohentie\" number=\"7\" city=\"Helsinki\" code=\"\" address=\"\" type=\"900\" category=\"street\" x=\"2549182\" y=\"6672569\" lon=\"24.88256\" lat=\"60.16183\" />\
16 </GEOCODE>\
17 </MTRXML>\
18 "
19
20 );
21
22 void Ut_Location::init()
23 {
24 }
25
26 void Ut_Location::cleanup()
27 {
28 }
29
30 void Ut_Location::initTestCase()
31 {
32 }
33
34 void Ut_Location::cleanupTestCase()
35 {
36 }
37
38 void Ut_Location::testParseReply()
39 {
40   LocationPrivate m_subject;
41
42   m_subject.parseReply( sampleInput );
43
44   QCOMPARE( m_subject.x(), QString( "2549182" ) );
45   QCOMPARE( m_subject.y(), QString( "6672569" ) );
46 }
47
48 void Ut_Location::testSet()
49 {
50   LocationPrivate m_subject;
51
52   QString x( "2549182" );
53   QString y( "6672569" );
54   m_subject.setX( x );
55   m_subject.setY( y );
56   QCOMPARE( x, m_subject.x() );
57   QCOMPARE( y, m_subject.y() );
58 }
59
60 void Ut_Location::testConstructorQGeoPositionInfo()
61 {
62   QGeoPositionInfo thisPositionInfo( QGeoCoordinate( 60.16183, 24.88256 ), QDateTime( QDate( 1965, 11, 11 ) ) );
63   Location subject( thisPositionInfo );
64
65   QString x( "2549182" );
66   QString y( "6672569" );
67   QCOMPARE( subject.x(), x );
68   QCOMPARE( subject.y(), y );
69 }
70
71 QTEST_MAIN(Ut_Location)