Moved files to make zouba the only project.
[ptas] / 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   QString label("home");
41   LocationPrivate m_subject(label);
42
43   m_subject.parseReply( sampleInput );
44
45   QCOMPARE( m_subject.label(), label );
46   QCOMPARE( m_subject.x(), QString( "2549182" ) );
47   QCOMPARE( m_subject.y(), QString( "6672569" ) );
48 }
49
50 void Ut_Location::testSet()
51 {
52   QString label( "home" );
53   LocationPrivate m_subject(label);
54
55   label = "work";
56   QString address( "Taivaanvuohentie 7 B 27, Helsinki" );
57   QString x( "2549182" );
58   QString y( "6672569" );
59   m_subject.setAddress( address );
60   m_subject.setLabel( label );
61   m_subject.setX( x );
62   m_subject.setY( y );
63   QCOMPARE( m_subject.address(), address );
64   QCOMPARE( m_subject.label(), label );
65   QCOMPARE( m_subject.x(), x );
66   QCOMPARE( m_subject.y(), y );
67 }
68
69 void Ut_Location::testConstructorQGeoPositionInfo()
70 {
71   QGeoPositionInfo thisPositionInfo( QGeoCoordinate( 60.16183, 24.88256 ), QDateTime( QDate( 1965, 11, 11 ) ) );
72   Location subject( thisPositionInfo );
73
74   QString x( "2549182" );
75   QString y( "6672569" );
76   QCOMPARE( subject.x(), x );
77   QCOMPARE( subject.y(), y );
78 }
79
80 QTEST_APPLESS_MAIN(Ut_Location)