-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include <QString> | ||
|
||
#include <QtTest/QtTest> | ||
|
||
#include "fileselectorwidget.h" | ||
|
||
#include "testsettings.h" | ||
|
||
using ViewshedBinaries::FileSelectorWidget; | ||
|
||
namespace ViewshedBinaries | ||
{ | ||
class TestFileSelectorWidget : public QObject | ||
{ | ||
Q_OBJECT | ||
private slots: | ||
|
||
void initTestCase() { widget = new FileSelectorWidget(); } | ||
|
||
void sendKeysNotPath() | ||
{ | ||
widget->clearValue(); | ||
widget->setStorageMode( FileSelectorWidget::StorageMode::GetFile ); | ||
|
||
QSignalSpy spyFileChanged( widget, &FileSelectorWidget::fileChanged ); | ||
|
||
QTest::keyClicks( widget->mText, "a/b/c" ); | ||
|
||
QCOMPARE( spyFileChanged.count(), 0 ); | ||
QCOMPARE( widget->mFilePath, QString() ); | ||
} | ||
|
||
void sendKeysPath() | ||
{ | ||
widget->clearValue(); | ||
widget->setStorageMode( FileSelectorWidget::StorageMode::GetFile ); | ||
|
||
QSignalSpy spyFileChanged( widget, &FileSelectorWidget::fileChanged ); | ||
|
||
QTest::keyClicks( widget->mText, QString( TEST_DATA_DSM ) ); | ||
|
||
QCOMPARE( spyFileChanged.count(), 1 ); | ||
QCOMPARE( widget->mFilePath, TEST_DATA_DSM ); | ||
} | ||
|
||
void sendKeysFolder() | ||
{ | ||
widget->clearValue(); | ||
widget->setStorageMode( FileSelectorWidget::StorageMode::GetDirectory ); | ||
|
||
QSignalSpy spyFileChanged( widget, &FileSelectorWidget::fileChanged ); | ||
|
||
QTest::keyClicks( widget->mText, QString( TEST_DATA_RESULTS_DIR ) ); | ||
|
||
QCOMPARE( spyFileChanged.count(), 16 ); | ||
QCOMPARE( widget->mFilePath, TEST_DATA_RESULTS_DIR ); | ||
} | ||
|
||
private: | ||
FileSelectorWidget *widget; | ||
}; | ||
} // namespace ViewshedBinaries | ||
|
||
QTEST_MAIN( ViewshedBinaries::TestFileSelectorWidget ) | ||
|
||
#include "testfileselectorwidget.moc" |