+zouba (0.5) unstable; urgency=low
+
+ * Changed package description
+ * Changed 'fakegps' button from two actions to a single toggle one
+ * Fixed core dump in gpscontroller caused by deleting the fakelocation
+
+ -- Max Waterman <davidmaxwaterman@fastmail.co.uk> Mon, 19 Apr 2010 11:18:00 +0200
+
zouba (0.4) unstable; urgency=low
* Fix for routes with bus changes (only displays first bus)
Package: zouba
Architecture: armel
Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: Tells you which bus is next.
+Description: Tells you which bus is next (in Helsinki area).
Allows you to easily find how to get the bus home. Uses HSL Journey Planner API <http://developer.reittiopas.fi/pages/en/home.php>. Uses GPS for current location. Uses Qt and QtMobility.
# XB-Maemo-Icon-26 field contains the application icon file encoded in
# base64. This is the icon that is shown in the Application Manager,
-zouba_0.3_armel.deb user/navigation extra
+zouba_0.5_armel.deb user/navigation extra
void GpsController::useLiveGps()
{
q->setUseFakeLocation( false );
- q->setCurrentLocation(0);
+ q->setCurrentLocation( new Location( "livegps" ) );
q->startGps();
}
void GpsController::useFakeGps( Location *fakeLocation )
{
+ qDebug() << "using fake gps (" << fakeLocation->label() << ")";
q->stopGps();
q->setUseFakeLocation( true );
q->setCurrentLocation( fakeLocation );
void GpsControllerPrivate::setCurrentLocation( Location *location )
{
- delete m_currentLocation;
+ if ( m_currentLocation && m_currentLocation->label() == "livegps" ) {
+ delete m_currentLocation;
+ m_currentLocation=0;
+ }
m_currentLocation = location;
}
void GpsControllerPrivate::setUseFakeLocation( bool useFake )
{
+ // delete previous GPS if it was live and we're switching to fake
+ if ( m_currentLocation && m_currentLocation->label() == "livegps" ) {
+ delete m_currentLocation;
+ m_currentLocation = 0;
+ }
m_useFakeLocation = useFake;
}
void GpsControllerPrivate::updateLocation( QGeoPositionInfo positionInfo )
{
- if ( !m_useFakeLocation ) {
+ if ( m_currentLocation && m_currentLocation->label() == "livegps" ) {
delete m_currentLocation;
- m_currentLocation = new Location( positionInfo );
}
+ m_currentLocation = new Location( positionInfo, "livegps" );
}
q( new LocationPrivate( label ) ),
manager(0)
{
+ qDebug() << "Location::Location( QGeoPositionInfo, label=" << label << " )";
qreal latitude = positionInfo.coordinate().latitude();
qreal longitude = positionInfo.coordinate().longitude();
q( new LocationPrivate( from.label() ) ),
manager(0)
{
+ qDebug() << "Location::Location( const Location [" << from.label() << "] )";
q->setAddress( from.address() );
q->setX( from.x() );
q->setY( from.y() );
q( new LocationPrivate( label ) ),
manager( new QNetworkAccessManager(this) )
{
+ qDebug() << "Location::Location( const QString &label=" << label << " )";
connect( manager, SIGNAL( finished(QNetworkReply*) ), this, SLOT( replyFinished(QNetworkReply*) ) );
}
Location &Location::operator=( const Location &from )
{
+ qDebug() << "Location::Location( const Location &from )";
q = new LocationPrivate( from.label() );
q->setAddress( from.address() );
q->setX( from.x() );
q->setY( from.y() );
q->setValid( from.isValid() );
+
if ( from.manager != 0 ) {
manager = new QNetworkAccessManager(this);
connect( manager, SIGNAL( finished(QNetworkReply*) ), this, SLOT( replyFinished(QNetworkReply*) ) );
} else {
manager = 0;
}
-
+
return *this;
}
// Function: WGS84lalo_to_KKJlalo
-void Location::WGS84lola_to_KKJlola(double longitude, double latitude, double *outLongitude, double *outLatitude)
+void Location::WGS84lola_to_KKJlola(double longitude, double latitude, double *outLongitude, double *outLatitude)
{
double dLa = radians(-0.124766E+01 + 0.269941E+00 * latitude + -0.191342E+00 * longitude + -0.356086E-02 * latitude * latitude + 0.122353E-02 * latitude * longitude + 0.335456E-03 * longitude * longitude) / 3600.0;
double dLo = radians(0.286008E+02 + -0.114139E+01 * latitude + 0.581329E+00 * longitude + 0.152376E-01 * latitude * latitude + -0.118166E-01 * latitude * longitude + -0.826201E-03 * longitude * longitude) / 3600.0;
// Function: KKJlalo_to_KKJxy
-void Location::KKJlola_to_KKJxy(double lon, double lat, int zoneNumber, KKJ *outX, KKJ *outY)
+void Location::KKJlola_to_KKJxy(double lon, double lat, int zoneNumber, KKJ *outX, KKJ *outY)
{
// Hayford ellipsoid
double a = 6378388.0;
LocationPrivate::~LocationPrivate()
{
+ m_label="deleted";
+ m_address="";
+ m_x="";
+ m_y="";
+ m_valid=false;
}
void LocationPrivate::parseReply( const QByteArray &reply )
void Route::setFromLocation( Location *location )
{
- qDebug() << "setting new From location";
+ qDebug() << "setting new From location (" << location->label() << ")";
if ( location && location->isValid() ) {
qDebug() << "From is valid";
}
} else {
qDebug() << "ERROR:From is not valid";
+ qDebug() << "location=" << location;
}
}
void Route::setToLocation( Location *location )
{
- qDebug() << "setting new To location";
+ qDebug() << "setting new To location (" << location->label() << ")";
if ( location && location->isValid() ) {
qDebug() << "To is valid";
Ui::Ui() :
centralWidget(0),
destinationButtons(0),
- routeTable(0)
+ routeTable(0),
+ usingFakeGps( false ),
+ messagesShown( false ),
+ fakeLocation()
{
+ Locations *locations = Locations::instance();
+ Location *workLocation = locations->location( "work" );
+ fakeLocation = new Location();
+ *fakeLocation = *workLocation;
+ fakeLocation->setLabel( "fakegps" );
}
Ui::~Ui()
QAction *setHomeAddressAction = new QAction("Set home address", this);
QAction *setWorkAddressAction = new QAction("Set work address", this);
- hideMessagesAction = new QAction("Hide messages", this);
- showMessagesAction = new QAction("Show messages", this);
- useFakeGpsAction = new QAction("Use fake GPS", this);
- useLiveGpsAction = new QAction("Use live GPS", this);
+ toggleMessagesAction = new QAction("Show messages", this);
+ toggleFakeGpsAction = new QAction("Use fake GPS", this);
menu->addAction(setHomeAddressAction);
menu->addAction(setWorkAddressAction);
- menu->addAction(showMessagesAction);
- menu->addAction(useFakeGpsAction);
+ menu->addAction(toggleMessagesAction);
+ menu->addAction(toggleFakeGpsAction);
connect(
setHomeAddressAction, SIGNAL(triggered()),
this, SLOT(setWorkAddress())
);
connect(
- hideMessagesAction, SIGNAL(triggered()),
- this, SLOT(hideMessages())
- );
- connect(
- showMessagesAction, SIGNAL(triggered()),
- this, SLOT(showMessages())
- );
- connect(
- useFakeGpsAction, SIGNAL(triggered()),
- this, SLOT(useFakeGps())
+ toggleMessagesAction, SIGNAL(triggered()),
+ this, SLOT(toggleMessages())
);
connect(
- useLiveGpsAction, SIGNAL(triggered()),
- this, SLOT(useLiveGps())
+ toggleFakeGpsAction, SIGNAL(triggered()),
+ this, SLOT(toggleFakeGps())
);
centralWidget = new QWidget( mainWindow );
setAddress( "work" );
}
+void Ui::toggleMessages()
+{
+ messagesShown = !messagesShown;
+
+ if ( messagesShown ) {
+ showMessages();
+ } else {
+ hideMessages();
+ }
+}
+
void Ui::hideMessages()
{
messageTable->hide();
- menu->removeAction( hideMessagesAction );
- menu->addAction( showMessagesAction );
+ toggleMessagesAction->setText( "Show messages" );
}
void Ui::showMessages()
{
messageTable->show();
- menu->removeAction( showMessagesAction );
- menu->addAction( hideMessagesAction );
+ toggleMessagesAction->setText( "Hide messages" );
}
-void Ui::useFakeGps()
+void Ui::toggleFakeGps()
{
- // really want a dialog here
- Locations *locations = Locations::instance();
- Location *fakeLocation = locations->location( "work" );
+ usingFakeGps = !usingFakeGps;
+ if ( usingFakeGps ) {
+ useFakeGps();
+ } else {
+ useLiveGps();
+ }
+}
+
+void Ui::useFakeGps()
+{
emit fakeGpsPressed( fakeLocation );
- menu->removeAction( useFakeGpsAction );
- menu->addAction( useLiveGpsAction );
+ toggleFakeGpsAction->setText( "Use Live GPS" );
}
void Ui::useLiveGps()
{
emit liveGpsPressed();
- menu->removeAction( useLiveGpsAction );
- menu->addAction( useFakeGpsAction );
+ toggleFakeGpsAction->setText( "Use Fake GPS" );
}
void Ui::setAddress( const QString &label )
&ok
);
- qDebug() << "ok=" << ok;
-
if ( ok ) {
qDebug() << "new address" << address;
Locations *locations = Locations::instance();
QHBoxLayout *mainLayout;
QVBoxLayout *buttonLayout;
QMenu *menu;
- QAction *hideMessagesAction;
- QAction *showMessagesAction;
- QAction *useFakeGpsAction;
+ QAction *toggleMessagesAction;
+ QAction *toggleFakeGpsAction;
QAction *useLiveGpsAction;
+ bool usingFakeGps;
+ bool messagesShown;
+ Location *fakeLocation;
Q_SIGNALS:
void homeAddressChanged( QString address );
private Q_SLOTS:
void setHomeAddress();
void setWorkAddress();
- void hideMessages();
- void showMessages();
- void useFakeGps();
- void useLiveGps();
+ void toggleMessages();
+ void toggleFakeGps();
private:
+ void useFakeGps();
+ void useLiveGps();
+ void hideMessages();
+ void showMessages();
void setAddress( const QString &label );
};
#endif //UI_H
--- /dev/null
+#! /usr/bin/perl
+require 5.008_004; # we need at least Perl version v5.8.4
+$ENV{MALLOC_CHECK_} = 2;
+
+use Term::ANSIColor;
+
+my $startTime = time();
+
+my %opts = (
+ "a" => 0, # all directories, irrespective of if they're in tests.pro
+ "r" => 0, # don't reverse sort
+ "s" => "D", # by default, sort by directory name
+ "j" => 1, # one make job at a time by default
+);
+
+for ( my $argNo=0; $argNo<@ARGV; $argNo++ ) {
+ my $arg = $ARGV[ $argNo ];
+ if ( $arg eq "-h" ) {
+ print "usage: $0 [-a] [-s letter] [-r] [-j number] [-h]\n";
+ print " -a include all ut_*/ directories - default is just the ones in tests.pro\n";
+ print " -s [DTPFS] sort by column (Dirs, Tests, P(ass), F(ail), S(kipped)\n";
+ print " -r reverse sort\n";
+ print " -j <number> use <number> make jobs. Default is 1\n";
+ print " -h this help\n";
+ exit;
+ } elsif ( $arg eq "-r" ) {
+ $opts{ "r" } = 1;
+ } elsif ( $arg eq "-a" ) {
+ $opts{ "a" } = 1;
+ } elsif ( $arg eq "-s" ) {
+ $opts{ "s" } = $ARGV[ ++$argNo ];
+ if ( $opts{ "s" } !~ /[DTPFS]/ ) {
+ print "Unrecognised column identifier\n";
+ print "Must be one of [DTPFS] :\n";
+ print " D = Dirs\n";
+ print " T = Tests\n";
+ print " P = Pass\n";
+ print " F = Fail\n";
+ print " S = Skipped\n";
+ exit(-1);
+ }
+ } elsif ( $arg eq "-j" ) {
+ my $jobs = $ARGV[ ++$argNo ];
+ # Test that the argument is a positive integer number
+ if ( $jobs * 1 eq $jobs && $jobs > 0 ) {
+ $opts{ "j" } = $jobs;
+ }
+ }
+}
+
+# some globals to help sort be faster
+$sortCol = $opts{ "s" };
+$sortIsNumeric = ( $sortCol =~ /[PFS]/ );
+$reverseSort = $opts{ "r" };
+# helper variable for the number of jobs
+$numJobs = $opts{ "j" };
+
+%maxLen = ();
+%segFault = ();
+
+my @rowHeaders = (
+ "D", # Dirs
+ "T", # Tests
+);
+my @rowData = (
+ "P", # Passed
+ "F", # Failed
+ "S", # Skipped
+);
+
+my @keys = ( @rowHeaders, @rowData );
+
+my %title = (
+ "D"=>"Dirs",
+ "T"=>"Tests",
+ "P"=>"P",
+ "F"=>"F",
+ "S"=>"S",
+);
+
+my $headerLabelFormat = "%-*s";
+my $headerDataFormat = "%*s";
+
+my $labelFormat = "%s%-*s%s%*s";
+my $dataFormat = "%*s%s%*s%s";
+
+my %format = (
+ "D" => $labelFormat,
+ "T" => $labelFormat,
+ "P" => $dataFormat,
+ "F" => $dataFormat,
+ "S" => $dataFormat,
+);
+
+my %separator = (
+ "D" => " ",
+ "T" => " : ",
+ "P" => " ",
+ "F" => " ",
+ "S" => " ",
+);
+
+my %data = (
+);
+
+foreach $key ( @keys ) {
+ $maxLen{ $key } = length( $title{ key } );
+}
+
+# set the maximum length of the directories
+if ( $opts{ "a" } ) {
+ push @allDirs, <ut_*>;
+ push @allDirs, <ft_*>;
+ foreach ( @allDirs ) {
+ setMaxLen( "D", length( $_ ) );
+ $tested{ $_ } = 0;
+ }
+}
+
+# Compile first with possibly multiple jobs
+print "Compiling...";
+`make -j$numJobs -k > /dev/null 2>&1`;
+print "done.\nNow checking...\n";
+
+# then check with only one job so that the parsing succeeds
+open( MAKE, "make -k check 2>&1|" ) || die( "Could not run make:$!" );
+
+#$|=1;
+
+my $thisDir = "";
+while (<MAKE>) {
+ chomp;
+
+ if ( /Entering directory \`.*tests\/(\w+)\'/ ) {
+ $thisDir = $1;
+ print STDERR "Tests: $thisDir", ' 'x( $maxLen{ "D" }-length( $thisDir )+length("Tests: ") ), "\r";
+ $tested{ $thisDir } = 1;
+ push @allDirs, $thisDir if ( !grep( /^$thisDir$/, @allDirs ) );
+ setMaxLen( "D", length( $thisDir ) );
+ } elsif ( /Segmentation fault/ ) {
+ $segFault{ $thisDir } = $_;
+ } elsif ( /Start testing of (\w+)/ ) {
+ $thisTest = $1;
+ $data{ "T" }{ $thisDir } = $thisTest;
+ setMaxLen( "T", length( $data{ "T" }{ $thisDir } ) );
+ } elsif ( /^Totals: (\d+) passed, (\d+) failed, (\d+) skipped/ ) {
+ $data{ "P" }{ $thisDir } = "$1";
+ $data{ "F" }{ $thisDir } = "$2";
+ $data{ "S" }{ $thisDir } = "$3";
+ setMaxLen( "P", length( $data{ "P" }{ $thisDir } ) );
+ setMaxLen( "F", length( $data{ "F" }{ $thisDir } ) );
+ setMaxLen( "S", length( $data{ "S" }{ $thisDir } ) );
+ }
+}
+
+close( MAKE );
+
+print STDERR ' 'x( $maxLen{ "D" } + length( "Tests: " ) ), "\r";
+
+foreach $thisDir ( @allDirs ) {
+ if ( !defined( $data{ "P" }{ $thisDir } ) || $data{ "P" }{ $thisDir } eq "" ) {
+ $data{ "P" }{ $thisDir } = "0";
+ setMaxLen( "P", length( $data{ "P" }{ $thisDir } ) );
+ }
+ if ( !defined( $data{ "F" }{ $thisDir } ) ) {
+ $data{ "F" }{ $thisDir } = "0";
+ setMaxLen( "F", length( $data{ "F" }{ $thisDir } ) );
+ }
+ if ( !defined( $data{ "S" }{ $thisDir } ) ) {
+ $data{ "S" }{ $thisDir } = "0";
+ setMaxLen( "S", length( $data{ "S" }{ $thisDir } ) );
+ }
+
+ $data{ "D" }{ $thisDir } = $thisDir;
+}
+
+my ( $testsPassed, $testsNeedWork ) = ( 0, 0 );
+my $noTests = scalar( @allDirs );
+my $noDigits = ($noTests>0)?int( log( $noTests )/log( 10 ) )+1:1;
+
+my $header = sprintf( "%*s ", $noDigits, "" );
+
+foreach ( @rowHeaders ) {
+ $header .= sprintf( $headerLabelFormat.$separator{ $_ }, $maxLen{ $_ }, $title{ $_ } );
+}
+
+foreach ( @rowData ) {
+ $header .= sprintf( $headerDataFormat.$separator{ $_ }, $maxLen{ $_ }, $title{ $_ } );
+}
+
+my $headerLen = length( $header );
+
+my $headerColor = color( 'reset' );
+
+print "P = Pass, F = Fail, S = Skip\n";
+print $headerColor, "$header\n";
+print '-'x$headerLen, "\n";
+
+my $testNo = 1;
+
+foreach $thisDir ( sort byCol @allDirs ) {
+ my %colors = ();
+
+ foreach $key ( @keys ) {
+ $colors{ $key } = color( 'reset' );
+ }
+
+ if (
+ ( defined( $data{ "P" }{ $thisDir } ) && $data{ "P" }{ $thisDir } ne "0" ) &&
+ ( defined( $data{ "F" }{ $thisDir } ) && $data{ "F" }{ $thisDir } eq "0" ) &&
+ ( defined( $data{ "S" }{ $thisDir } ) && $data{ "S" }{ $thisDir } eq "0" ) &&
+ ( defined( $data{ "T" }{ $thisDir } ) && $data{ "T" }{ $thisDir } ne "" )
+ ) {
+ $testsPassed++;
+ } else {
+ $testsNeedWork++;
+ }
+
+ if ( defined( $data{ "P" }{ $thisDir } ) && $data{ "P" }{ $thisDir } eq "0" ) {
+ $colors{ "D" } .= color( 'reverse green' );
+ $colors{ "T" } .= color( 'reverse green' );
+ $colors{ "P" } .= color( 'reverse green' );
+ } else {
+ $colors{ "D" } .= color( 'green' );
+ $colors{ "T" } .= color( 'green' );
+ $colors{ "P" } .= color( 'green' );
+ }
+
+ if ( defined( $data{ "F" }{ $thisDir} ) && $data{ "F" }{ $thisDir } eq "0" ) {
+ $colors{ "F" } .= color( 'red' );
+ } else {
+ $colors{ "F" } .= color( 'reverse red' );
+ }
+
+ if ( defined( $data{ "S" }{ $thisDir } ) && $data{ "S" }{ $thisDir } eq "0" ) {
+ $colors{ "S" } .= color( 'blue' );
+ } else {
+ $colors{ "S" } .= color( 'reverse blue' );
+ }
+
+ if ( !defined( $data{ "T" }{ $thisDir } ) || $data{ "T" }{ $thisDir } eq "" || $segFault{ $thisDir } ) {
+ $colors{ "T" } .= color( 'reverse red' );
+ }
+
+ printf( "%*s ", $noDigits, $testNo );
+
+ foreach ( @rowHeaders ) {
+ my $thisData = $data{ $_ }{ $thisDir };
+ my $dataLength = length( $thisData );
+ my $spaceLength = $maxLen{ $_ }-$dataLength;
+
+ printf(
+ $format{ $_ }.$separator{ $_ },
+ $colors{ $_ }, $dataLength, $thisData,
+ color( 'reset' ), $spaceLength, "" );
+ }
+
+ foreach ( @rowData ) {
+ my $thisData = $data{ $_ }{ $thisDir };
+ my $dataLength = length( $thisData );
+ my $spaceLength = $maxLen{ $_ }-$dataLength;
+
+ printf(
+ $format{ $_ }.$separator{ $_ },
+ $spaceLength, "",
+ $colors{ $_ }, $dataLength, $thisData,
+ color( 'reset' ) );
+ }
+
+ printf( $headerColor."\n" );
+
+ $testNo++;
+}
+
+print '-'x$headerLen, "\n";
+print( "Tests with zero fails/skips : $testsPassed\n" );
+print( "Tests needing further work : $testsNeedWork\n" );
+
+printf( "Elapsed time : %d seconds\n", time() - $startTime );
+
+sub setMaxLen
+{
+ my ( $test, $length ) = @_;
+
+ $maxLen{ $test } = $length if ( defined( $maxLen{ $test} ) && $length > $maxLen{ $test } );
+}
+
+sub byCol
+{
+ my $retVal = 0;
+
+ my $localA = $a;
+ my $localB = $b;
+
+ if ( $reverseSort ) {
+ my $tmp = $localA;
+ $localA = $localB;
+ $localB = $tmp;
+ }
+
+ if ( $sortIsNumeric ) {
+ # numeric comparison
+ $retVal = $data{ $sortCol }{ $localA } <=> $data{ $sortCol }{ $localB };
+ } else {
+ # string comparison
+ $retVal = $data{ $sortCol }{ $localA } cmp $data{ $sortCol }{ $localB };
+ }
+
+ return $retVal;
+}
SUBDIRS = \
ut_location/ \
ut_route/ \
+ ut_gpscontroller/ \
+
+check.target = check
+check.CONFIG = recursive
+QMAKE_EXTRA_TARGETS += check
#############################################################################
# Makefile for building: ut_gpscontroller
-# Generated by qmake (2.01a) (Qt 4.6.2) on: Wed Apr 14 08:39:47 2010
+# Generated by qmake (2.01a) (Qt 4.6.2) on: Mon Apr 19 11:20:53 2010
# Project: ut_gpscontroller.pro
# Template: app
# Command: /usr/bin/qmake -unix -o Makefile ut_gpscontroller.pro
-$(DEL_FILE) Makefile
+check: ut_gpscontroller
+ ./ut_gpscontroller
+
mocclean: compiler_moc_header_clean compiler_moc_source_clean
mocables: compiler_moc_header_make_all compiler_moc_source_make_all
void MyGpsControllerPrivate::updateLocation()
{
- if ( !m_useFakeLocation ) {
+ if ( m_currentLocation && m_currentLocation->label() == "livegps" ) {
delete m_currentLocation;
- m_currentLocation = new Location();
}
+ m_currentLocation = new Location( "livegps" );
}
void Ut_GpsController::init()
m_subject_p->updateLocation(); // pretend GPS has given an update
Location *gpsLocation = m_subject_p->m_currentLocation; // position from GPS
- Location *fakeLocation = new Location();
+ Location *fakeLocation = new Location("fakegps");
// make test call
m_subject->useFakeGps( fakeLocation ); // ownership -> m_subject
// both args should be the fake gps position supplied to useFakeGps()
arguments = spy.takeFirst();
- QCOMPARE(arguments.at(0).value<Location*>(), m_subject_p->m_currentLocation);
+ QCOMPARE( arguments.at(0).value<Location*>(), m_subject_p->m_currentLocation );
+ QCOMPARE( arguments.at(0).value<Location*>()->label(), QString( "fakegps" ) );
arguments = spy.takeFirst();
- QCOMPARE(arguments.at(0).value<Location*>(), m_subject_p->m_currentLocation);
- QCOMPARE(m_subject_p->m_currentLocation, fakeLocation);
+ QCOMPARE( arguments.at(0).value<Location*>(), m_subject_p->m_currentLocation );
+ QCOMPARE( arguments.at(0).value<Location*>()->label(), QString( "fakegps" ) );
+ QCOMPARE( m_subject_p->m_currentLocation, fakeLocation );
// should not be the gpsLocation or zero
QVERIFY(m_subject_p->m_currentLocation != gpsLocation);
// gps should be on
QCOMPARE(m_subject_p->m_gpsOn, true);
- // should be zero
- QVERIFY(m_subject_p->m_currentLocation == 0);
-
- // should not get any signals because useFakeGps sets the location to 0
- QVERIFY2(spy.count()==0, "should not receive any signals" );
+ QVERIFY2(spy.count()==1, "should get a locationChanged signal from getGps" );
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.at(0).value<Location*>(), m_subject_p->m_currentLocation);
+ QCOMPARE( arguments.at(0).value<Location*>()->label(), QString( "livegps" ) );
+ QVERIFY(m_subject_p->m_currentLocation != fakeLocation);
// fake a GPS update
m_subject_p->updateLocation(); // pretend GPS has given an update
QCOMPARE(spy.count(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).value<Location*>(), m_subject_p->m_currentLocation);
+ QCOMPARE( arguments.at(0).value<Location*>()->label(), QString( "livegps" ) );
QVERIFY(m_subject_p->m_currentLocation != 0);
}
+void Ut_GpsController::testLiveToFakeToLive()
+{
+ m_subject_p->updateLocation(); // pretend GPS has given an update
+ Location *fakeLocation = new Location();
+
+ m_subject->useFakeGps( fakeLocation ); // ownership -> m_subject
+ m_subject->getGps();
+
+ // switch back to live GPS
+ m_subject->useLiveGps();
+ m_subject->getGps();
+
+ // fake a GPS update
+ m_subject_p->updateLocation(); // pretend GPS has given an update
+
+ // get GPS location
+ m_subject->getGps();
+
+ m_subject->useFakeGps( fakeLocation ); // ownership -> m_subject
+ m_subject->getGps();
+
+ // fake a GPS update
+ m_subject_p->updateLocation(); // pretend GPS has given an update
+
+ // get GPS location
+ m_subject->getGps();
+}
+
QTEST_APPLESS_MAIN(Ut_GpsController)
void testGetGpsWithNoGpsUpdates();
void testGetGpsWithGpsUpdates();
void testFakeGps();
+ void testLiveToFakeToLive();
private:
GpsController *m_subject;
$$ZOUBASRC/location.h \
$$ZOUBASRC/location_p.h \
+QMAKE_EXTRA_TARGETS += check
+check.depends = $$TARGET
+check.commands = ./$$TARGET
$$ZOUBASRC/location.h \
$$ZOUBASRC/location_p.h \
+QMAKE_EXTRA_TARGETS += check
+check.depends = $$TARGET
+check.commands = ./$$TARGET
$$ZOUBASRC/location.h \
$$ZOUBASRC/location_p.h \
+QMAKE_EXTRA_TARGETS += check
+check.depends = $$TARGET
+check.commands = ./$$TARGET