Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
af6676b6
Commit
af6676b6
authored
Aug 12, 2014
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated for QGCUASFileManager changes
parent
0cda5053
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
37 deletions
+38
-37
QGCUASFileManagerTest.cc
src/qgcunittest/QGCUASFileManagerTest.cc
+28
-26
QGCUASFileManagerTest.h
src/qgcunittest/QGCUASFileManagerTest.h
+10
-11
No files found.
src/qgcunittest/QGCUASFileManagerTest.cc
View file @
af6676b6
...
...
@@ -59,15 +59,17 @@ void QGCUASFileManagerUnitTest::init(void)
Q_ASSERT
(
connected
);
Q_UNUSED
(
connected
);
// Silent release build compiler warning
connected
=
connect
(
_fileManager
,
SIGNAL
(
statusMessage
(
const
QString
&
)),
this
,
SLOT
(
statusMessage
(
const
QString
&
)));
connected
=
connect
(
_fileManager
,
SIGNAL
(
listEntry
(
const
QString
&
)),
this
,
SLOT
(
listEntry
(
const
QString
&
)));
Q_ASSERT
(
connected
);
_rgSignals
[
statusMessageSignalIndex
]
=
SIGNAL
(
statusMessage
(
const
QString
&
));
_rgSignals
[
errorMessageSignalIndex
]
=
SIGNAL
(
errorMessage
(
const
QString
&
));
_rgSignals
[
resetStatusMessagesSignalIndex
]
=
SIGNAL
(
resetStatusMessages
(
void
));
_rgSignals
[
listEntrySignalIndex
]
=
SIGNAL
(
listEntry
(
const
QString
&
));
_rgSignals
[
listCompleteSignalIndex
]
=
SIGNAL
(
listComplete
(
void
));
_rgSignals
[
openFileLengthSignalIndex
]
=
SIGNAL
(
openFileLength
(
unsigned
int
));
_rgSignals
[
downloadFileLengthSignalIndex
]
=
SIGNAL
(
downloadFileLength
(
unsigned
int
));
_rgSignals
[
downloadFileCompleteSignalIndex
]
=
SIGNAL
(
downloadFileComplete
(
void
));
_rgSignals
[
errorMessageSignalIndex
]
=
SIGNAL
(
errorMessage
(
const
QString
&
));
_multiSpy
=
new
MultiSignalSpy
();
Q_CHECK_PTR
(
_multiSpy
);
QCOMPARE
(
_multiSpy
->
init
(
_fileManager
,
_rgSignals
,
_cSignals
),
true
);
...
...
@@ -86,11 +88,11 @@ void QGCUASFileManagerUnitTest::cleanup(void)
_multiSpy
=
NULL
;
}
/// @brief Connected to QGCUASFileManager
statusMessage signal in order to catch list command output
void
QGCUASFileManagerUnitTest
::
statusMessage
(
const
QString
&
msg
)
/// @brief Connected to QGCUASFileManager
listEntry signal in order to catch list entries
void
QGCUASFileManagerUnitTest
::
listEntry
(
const
QString
&
entry
)
{
// Keep a list of all names received so we can test it for correctness
_fileListReceived
+=
msg
;
_fileListReceived
+=
entry
;
}
...
...
@@ -151,14 +153,13 @@ void QGCUASFileManagerUnitTest::_listTest(void)
Q_ASSERT
(
_multiSpy
->
checkNoSignals
()
==
true
);
// QGCUASFileManager::listDirectory signalling as follows:
// Emits the resetStatusMessages signal
// Emits a statusMessage signal for each list entry
// Emits a listEntry signal for each list entry
// Emits an errorMessage signal if:
// It gets a Nak back
// Sequence number is incorrrect on any response
// CRC is incorrect on any responses
// List entry is formatted incorrectly
// It is possible to get a number of good
statusMessage
signals, followed by an errorMessage signal
// It is possible to get a number of good
listEntry
signals, followed by an errorMessage signal
// Emits listComplete after it receives the final list entry
// If an errorMessage signal is signalled no listComplete is signalled
...
...
@@ -166,7 +167,7 @@ void QGCUASFileManagerUnitTest::_listTest(void)
// We should get a single resetStatusMessages signal
// We should get a single errorMessage signal
_fileManager
->
listDirectory
(
"/bogus"
);
QCOMPARE
(
_multiSpy
->
checkOnlySignalByMask
(
errorMessageSignalMask
|
resetStatusMessagesSignalMask
),
true
);
QCOMPARE
(
_multiSpy
->
checkOnlySignalByMask
(
errorMessageSignalMask
),
true
);
_multiSpy
->
clearAllSignals
();
// Setup the mock file server with a valid directory list
...
...
@@ -187,15 +188,15 @@ void QGCUASFileManagerUnitTest::_listTest(void)
// For simulated server errors on subsequent Acks, the first Ack will go through. This means we should have gotten some
// partial results. In the case of the directory list test set, all entries fit into the first ack, so we should have
// gotten back all of them.
QCOMPARE
(
_multiSpy
->
getSpyByIndex
(
statusMessage
SignalIndex
)
->
count
(),
fileList
.
count
());
_multiSpy
->
clearSignalByIndex
(
statusMessage
SignalIndex
);
QCOMPARE
(
_multiSpy
->
getSpyByIndex
(
listEntry
SignalIndex
)
->
count
(),
fileList
.
count
());
_multiSpy
->
clearSignalByIndex
(
listEntry
SignalIndex
);
// And then it should have errored out because the next list Request would have failed.
QCOMPARE
(
_multiSpy
->
checkOnlySignalByMask
(
errorMessageSignalMask
|
resetStatusMessagesSignalMask
),
true
);
QCOMPARE
(
_multiSpy
->
checkOnlySignalByMask
(
errorMessageSignalMask
),
true
);
}
else
{
// For the simulated errors which failed the intial response we should not have gotten any results back at all.
// Just an error.
QCOMPARE
(
_multiSpy
->
checkOnlySignalByMask
(
errorMessageSignalMask
|
resetStatusMessagesSignalMask
),
true
);
QCOMPARE
(
_multiSpy
->
checkOnlySignalByMask
(
errorMessageSignalMask
),
true
);
}
// Set everything back to initial state
...
...
@@ -206,9 +207,9 @@ void QGCUASFileManagerUnitTest::_listTest(void)
// Send a list command at the root of the directory tree which should succeed
_fileManager
->
listDirectory
(
"/"
);
QCOMPARE
(
_multiSpy
->
checkSignalByMask
(
resetStatusMessagesSignalMask
|
listCompleteSignalMask
),
true
);
QCOMPARE
(
_multiSpy
->
checkSignalByMask
(
listCompleteSignalMask
),
true
);
QCOMPARE
(
_multiSpy
->
checkNoSignalByMask
(
errorMessageSignalMask
),
true
);
QCOMPARE
(
_multiSpy
->
getSpyByIndex
(
statusMessage
SignalIndex
)
->
count
(),
fileList
.
count
());
QCOMPARE
(
_multiSpy
->
getSpyByIndex
(
listEntry
SignalIndex
)
->
count
(),
fileList
.
count
());
QVERIFY
(
_fileListReceived
==
fileList
);
}
...
...
@@ -238,26 +239,26 @@ void QGCUASFileManagerUnitTest::_downloadTest(void)
Q_ASSERT
(
_multiSpy
->
checkNoSignals
()
==
true
);
// QGCUASFileManager::downloadPath works as follows:
// Emits the resetStatusMessages signal
// Sends an Open Command to the server
// Expects an Ack Response back from the server with the correct sequence numner
// Emits an errorMessage signal if it gets a Nak back
// Emits an
open
FileLength signal with the file length if it gets back a good Ack
// Emits an
download
FileLength signal with the file length if it gets back a good Ack
// Sends subsequent Read commands to the server until it gets the full file contents back
// Emits a downloadFileProgress for each read command ack it gets back
// Sends Terminate command to server when download is complete to close Open command
// Mock file server will signal terminateCommandReceived when it gets a Terminate command
// Sends
statusMessag
e signal to indicate the download is complete
// Sends
downloadFileComplet
e signal to indicate the download is complete
// Emits an errorMessage signal if sequence number is incorrrect on any response
// Emits an errorMessage signal if CRC is incorrect on any responses
// Expected signals if the Open command fails for any reason
quint16
signalMaskOpenFailure
=
resetStatusMessagesSignalMask
|
errorMessageSignalMask
;
quint16
signalMaskOpenFailure
=
errorMessageSignalMask
;
// Expected signals if the Read command fails for any reason
quint16
signalMaskReadFailure
=
resetStatusMessagesSignalMask
|
open
FileLengthSignalMask
|
errorMessageSignalMask
;
quint16
signalMaskReadFailure
=
download
FileLengthSignalMask
|
errorMessageSignalMask
;
// Expected signals if the downloadPath command succeeds
quint16
signalMaskDownloadSuccess
=
resetStatusMessagesSignalMask
|
openFileLengthSignalMask
|
statusMessag
eSignalMask
;
quint16
signalMaskDownloadSuccess
=
downloadFileLengthSignalMask
|
downloadFileComplet
eSignalMask
;
// Send a bogus path
// We should get a single resetStatusMessages signal
...
...
@@ -296,7 +297,8 @@ void QGCUASFileManagerUnitTest::_downloadTest(void)
// For simulated server errors on subsequent Acks, the first Ack will go through. We must handle things differently depending
// on whether the downloaded file requires multiple packets to complete the download.
if
(
testCase
->
fMultiPacketResponse
)
{
// The downloaded file requires multiple Acks to complete. Hence second Read should have failed.
// The downloaded file requires multiple Acks to complete. Hence first Read should have succeeded and sent one downloadFileComplete.
// Second Read should have failed.
QCOMPARE
(
_multiSpy
->
checkOnlySignalByMask
(
signalMaskReadFailure
),
true
);
// Open command succeeded, so we should get a Terminate for the open
...
...
@@ -333,7 +335,7 @@ void QGCUASFileManagerUnitTest::_downloadTest(void)
QCOMPARE
(
_multiSpy
->
checkOnlySignalByMask
(
signalMaskDownloadSuccess
),
true
);
// Make sure the file length coming back through the openFileLength signal is correct
QVERIFY
(
_multiSpy
->
getSpyByIndex
(
open
FileLengthSignalIndex
)
->
takeFirst
().
at
(
0
).
toInt
()
==
testCase
->
length
);
QVERIFY
(
_multiSpy
->
getSpyByIndex
(
download
FileLengthSignalIndex
)
->
takeFirst
().
at
(
0
).
toInt
()
==
testCase
->
length
);
_multiSpy
->
clearAllSignals
();
...
...
src/qgcunittest/QGCUASFileManagerTest.h
View file @
af6676b6
...
...
@@ -58,29 +58,28 @@ private slots:
void
_listTest
(
void
);
void
_downloadTest
(
void
);
// Connected to QGCUASFileManager
statusMessage
signal
void
statusMessage
(
const
QString
&
);
// Connected to QGCUASFileManager
listEntry
signal
void
listEntry
(
const
QString
&
entry
);
private:
void
_validateFileContents
(
const
QString
&
filePath
,
uint8_t
length
);
enum
{
statusMessageSignalIndex
=
0
,
errorMessageSignalIndex
,
resetStatusMessagesSignalIndex
,
listEntrySignalIndex
=
0
,
listCompleteSignalIndex
,
openFileLengthSignalIndex
,
downloadFileLengthSignalIndex
,
downloadFileCompleteSignalIndex
,
errorMessageSignalIndex
,
maxSignalIndex
};
enum
{
statusMessageSignalMask
=
1
<<
statusMessageSignalIndex
,
errorMessageSignalMask
=
1
<<
errorMessageSignalIndex
,
resetStatusMessagesSignalMask
=
1
<<
resetStatusMessagesSignalIndex
,
listEntrySignalMask
=
1
<<
listEntrySignalIndex
,
listCompleteSignalMask
=
1
<<
listCompleteSignalIndex
,
openFileLengthSignalMask
=
1
<<
openFileLengthSignalIndex
,
downloadFileLengthSignalMask
=
1
<<
downloadFileLengthSignalIndex
,
downloadFileCompleteSignalMask
=
1
<<
downloadFileCompleteSignalIndex
,
errorMessageSignalMask
=
1
<<
errorMessageSignalIndex
,
};
MockUAS
_mockUAS
;
MockMavlinkFileServer
_mockFileServer
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment