From: Max Waterman Date: Mon, 12 Apr 2010 05:59:08 +0000 (+0300) Subject: Changes: (re)added and corrected zouba tests X-Git-Url: http://vcs.maemo.org/git/?p=ptas;a=commitdiff_plain;h=0d70dc928448f04a34f82968abe1aca62a57039d Changes: (re)added and corrected zouba tests --- diff --git a/zouba/tests/tests.pri b/zouba/tests/tests.pri new file mode 100644 index 0000000..c8e85f1 --- /dev/null +++ b/zouba/tests/tests.pri @@ -0,0 +1,2 @@ +ZOUBASRC = ../../src + diff --git a/zouba/tests/tests.pro b/zouba/tests/tests.pro new file mode 100644 index 0000000..d8fd0f2 --- /dev/null +++ b/zouba/tests/tests.pro @@ -0,0 +1,4 @@ +TEMPLATE=subdirs +SUBDIRS = \ + ut_location/ \ + ut_route/ \ diff --git a/zouba/tests/ut_location/ut_location.cpp b/zouba/tests/ut_location/ut_location.cpp new file mode 100644 index 0000000..88295c8 --- /dev/null +++ b/zouba/tests/ut_location/ut_location.cpp @@ -0,0 +1,77 @@ +#include +#include +#include +#include +#include "location.h" +#include "location_p.h" +#include "ut_location.h" + +QTM_USE_NAMESPACE + +QByteArray sampleInput( +"\ +\ +\ +\ +\ +\ +" + +); + +void Ut_Location::init() +{ +} + +void Ut_Location::cleanup() +{ +} + +void Ut_Location::initTestCase() +{ +} + +void Ut_Location::cleanupTestCase() +{ +} + +void Ut_Location::testParseReply() +{ + QString label("home"); + LocationPrivate m_subject(label); + + m_subject.parseReply( sampleInput ); + + QCOMPARE( m_subject.label(), label ); + QCOMPARE( m_subject.x(), QString( "2549182" ) ); + QCOMPARE( m_subject.y(), QString( "6672569" ) ); +} + +void Ut_Location::testSet() +{ + QString label( "home" ); + LocationPrivate m_subject(label); + + label = "work"; + QString x( "2549182" ); + QString y( "6672569" ); + m_subject.setLabel( label ); + m_subject.setX( x ); + m_subject.setY( y ); + QCOMPARE( m_subject.label(), label ); + QCOMPARE( m_subject.x(), x ); + QCOMPARE( m_subject.y(), y ); +} + +void Ut_Location::testConstructorQGeoPositionInfo() +{ + QGeoPositionInfo thisPositionInfo( QGeoCoordinate( 60.16183, 24.88256 ), QDateTime( QDate( 1965, 11, 11 ) ) ); + Location subject( thisPositionInfo ); + + QString x( "2549182" ); + QString y( "6672569" ); + QCOMPARE( subject.x(), x ); + QCOMPARE( subject.y(), y ); +} + +QTEST_APPLESS_MAIN(Ut_Location) diff --git a/zouba/tests/ut_location/ut_location.h b/zouba/tests/ut_location/ut_location.h new file mode 100644 index 0000000..552c4eb --- /dev/null +++ b/zouba/tests/ut_location/ut_location.h @@ -0,0 +1,29 @@ +#ifndef UT_LOCATION_H +#define UT_LOCATION_H + +#include +#include + +#include + +Q_DECLARE_METATYPE(LocationPrivate*); + +class Ut_Location : public QObject +{ +Q_OBJECT + +public: + +private slots: + void init(); + void cleanup(); + void initTestCase(); + void cleanupTestCase(); + void testParseReply(); + void testSet(); + void testConstructorQGeoPositionInfo(); + +private: + LocationPrivate *m_subject; +}; +#endif // UT_LOCATION_H diff --git a/zouba/tests/ut_location/ut_location.pro b/zouba/tests/ut_location/ut_location.pro new file mode 100644 index 0000000..9923ffd --- /dev/null +++ b/zouba/tests/ut_location/ut_location.pro @@ -0,0 +1,34 @@ +include( ../tests.pri ) +CONFIG += \ + qt \ + debug \ + mobility \ + +MOBILITY = \ + location \ + bearer \ + +QT += \ + testlib \ + network \ + +INCLUDEPATH += \ + $$ZOUBASRC \ + +DEPENDPATH += $$INCLUDEPATH + +LIBS += \ + /usr/lib/libQtLocation.so \ + +TEMPLATE = app + +SOURCES = \ + ut_location.cpp \ + $$ZOUBASRC/location.cpp \ + $$ZOUBASRC/location_p.cpp \ + +HEADERS += \ + ut_location.h \ + $$ZOUBASRC/location.h \ + $$ZOUBASRC/location_p.h \ + diff --git a/zouba/tests/ut_route/ut_route.cpp b/zouba/tests/ut_route/ut_route.cpp new file mode 100644 index 0000000..138b8c0 --- /dev/null +++ b/zouba/tests/ut_route/ut_route.cpp @@ -0,0 +1,390 @@ +#include +#include +#include +#include "ut_route.h" + +QByteArray sampleInput( +"\ +\ +\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +\ +" + +); + +void Ut_Route::init() +{ + m_subject = new RoutePrivate(); +} + +void Ut_Route::cleanup() +{ + delete m_subject; + m_subject = 0; +} + +void Ut_Route::initTestCase() +{ +} + +void Ut_Route::cleanupTestCase() +{ +} + +void Ut_Route::testParseReply() +{ + QList routeData = m_subject->parseReply( sampleInput ); + + QVERIFY( routeData.count()==3 ); + QCOMPARE( routeData.at(0).lineCode, QString( "65A" ) ); + QCOMPARE( routeData.at(0).arrivalTime, QString( "18:20" ) ); + QCOMPARE( routeData.at(1).lineCode, QString( "102T" ) ); + QCOMPARE( routeData.at(1).arrivalTime, QString( "18:26" ) ); + QCOMPARE( routeData.at(2).lineCode, QString( "110T" ) ); + QCOMPARE( routeData.at(2).arrivalTime, QString( "18:34" ) ); +} + +void Ut_Route::testSetFromLocation() +{ + Location work( "2551042", "6672829" ); + m_subject->setFromLocation( &work ); + QCOMPARE( work.x(), m_subject->fromLocation()->x() ); + QCOMPARE( work.y(), m_subject->fromLocation()->y() ); +} + +void Ut_Route::testSetToLocation() +{ + Location work( "2551042", "6672829" ); + m_subject->setToLocation( &work ); + QCOMPARE( work.x(), m_subject->toLocation()->x() ); + QCOMPARE( work.y(), m_subject->toLocation()->y() ); +} + +QTEST_APPLESS_MAIN(Ut_Route) diff --git a/zouba/tests/ut_route/ut_route.h b/zouba/tests/ut_route/ut_route.h new file mode 100644 index 0000000..8571d3b --- /dev/null +++ b/zouba/tests/ut_route/ut_route.h @@ -0,0 +1,29 @@ +#ifndef UT_ROUTE_H +#define UT_ROUTE_H + +#include +#include + +#include + +Q_DECLARE_METATYPE(RoutePrivate*); + +class Ut_Route : public QObject +{ + Q_OBJECT + +public: + +private slots: + void init(); + void cleanup(); + void initTestCase(); + void cleanupTestCase(); + void testParseReply(); + void testSetFromLocation(); + void testSetToLocation(); + +private: + RoutePrivate *m_subject; +}; +#endif // UT_ROUTE_H diff --git a/zouba/tests/ut_route/ut_route.pro b/zouba/tests/ut_route/ut_route.pro new file mode 100644 index 0000000..5dc7779 --- /dev/null +++ b/zouba/tests/ut_route/ut_route.pro @@ -0,0 +1,36 @@ +include( ../tests.pri ) +CONFIG += \ + qt \ + debug \ + mobility \ + +MOBILITY = \ + location \ + bearer \ + +QT += \ + testlib \ + network \ + +INCLUDEPATH += \ + $$ZOUBASRC \ + +DEPENDPATH += $INCLUDEPATH + +TEMPLATE = app + +LIBS += \ + /usr/lib/libQtLocation.so \ + +SOURCES = \ + ut_route.cpp \ + $$ZOUBASRC/route_p.cpp \ + $$ZOUBASRC/location.cpp \ + $$ZOUBASRC/location_p.cpp \ + +HEADERS += \ + ut_route.h \ + $$ZOUBASRC/route_p.h \ + $$ZOUBASRC/location.h \ + $$ZOUBASRC/location_p.h \ +