-
Notifications
You must be signed in to change notification settings - Fork 135
QtTest driver v2 #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
QtTest driver v2 #142
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
964af78
Rework CMake logic around Qt and use Qt in CI
konserw 26e6feb
QtTestDriver + tests and examples
konserw 411cdbd
Run qttest calculator example in travis
konserw d833723
Pipe fix for mingw
konserw b1eaf2c
fix setting qt5_found variable
konserw 795ced6
If c++11 is needed enable for all
konserw 15164eb
First review
konserw d1b3ffd
Update CMake verision requirement
konserw 5b10e66
removed submodule added by mistake
konserw 3218931
Merge branch 'cirework' into qttest2
konserw 0202bed
Most of frirst review
konserw ff88570
convert qtCapture to normal class
konserw 0858492
revert change to add_test
konserw e2373da
Temporary file based solution
konserw 288a6ad
Second review
konserw 742b88d
examples
konserw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,20 @@ | ||
set PATH=C:\Ruby200\bin;%BOOST_LIBRARYDIR%;%PATH% | ||
if defined MINGW_ROOT set PATH=%MINGW_ROOT%\bin;C:\msys64\usr\bin\;%PATH% | ||
if defined QT_DIR set PATH=%QT_DIR%\bin;%PATH% | ||
if "%CMAKE_GENERATOR%"=="NMake Makefiles" call "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" %PLATFORM% | ||
echo %PATH% | ||
|
||
git submodule init | ||
git submodule update | ||
call gem install bundle | ||
call bundle install | ||
if defined MINGW_ARCH bash -lc "pacman --needed --noconfirm -S mingw-w64-%MINGW_ARCH%-boost | ||
|
||
cmake -E make_directory build | ||
cmake -E chdir build cmake -G "%CMAKE_GENERATOR%" -DCUKE_ENABLE_EXAMPLES=on -DBOOST_ROOT="%BOOST_ROOT%" -DBOOST_INCLUDEDIR="%BOOST_INCLUDEDIR%" -DBOOST_LIBRARYDIR="%BOOST_LIBRARYDIR%" -DQT_QMAKE_EXECUTABLE="%QT_DIR%/bin/qmake.exe" .. | ||
cmake --build build | ||
|
||
set CTEST_OUTPUT_ON_FAILURE=ON | ||
cmake --build build --target test | ||
cmake --build build --target features | ||
|
This file contains hidden or 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
This file contains hidden or 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
38 changes: 38 additions & 0 deletions
38
examples/Calc/features/step_definitions/QtTestCalculatorSteps.cpp
This file contains hidden or 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,38 @@ | ||
#include <QTest> | ||
#include <cucumber-cpp/autodetect.hpp> | ||
|
||
#include "Calculator.h" | ||
|
||
using cucumber::ScenarioScope; | ||
|
||
struct CalcCtx { | ||
Calculator calc; | ||
double result; | ||
}; | ||
|
||
GIVEN("^I have entered (\\d+) into the calculator$") { | ||
REGEX_PARAM(double, n); | ||
ScenarioScope<CalcCtx> context; | ||
|
||
context->calc.push(n); | ||
} | ||
|
||
WHEN("^I press add") { | ||
ScenarioScope<CalcCtx> context; | ||
|
||
context->result = context->calc.add(); | ||
} | ||
|
||
WHEN("^I press divide") { | ||
ScenarioScope<CalcCtx> context; | ||
|
||
context->result = context->calc.divide(); | ||
} | ||
|
||
THEN("^the result should be (.*) on the screen$") { | ||
REGEX_PARAM(double, expected); | ||
ScenarioScope<CalcCtx> context; | ||
|
||
QCOMPARE(context->result, expected); | ||
} | ||
|
This file contains hidden or 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
73 changes: 73 additions & 0 deletions
73
examples/CalcQt/features/step_definitions/QtTestCalculatorQtSteps.cpp
This file contains hidden or 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,73 @@ | ||
#include <QTest> | ||
#include "cucumber-cpp/autodetect.hpp" | ||
#include <cstdlib> | ||
#include <QApplication> | ||
#include "CalculatorWidget.h" | ||
|
||
std::istream& operator>> (std::istream& in, QString& val) { std::string s; in >> s; val = QString::fromLocal8Bit(s.c_str()); return in; } | ||
std::ostream& operator<< (std::ostream& out, const QString& val) { out << val.toLocal8Bit().data(); return out; } | ||
|
||
static int argc = 0; | ||
static QApplication app(argc, 0); | ||
static int milliseconds = -1; | ||
|
||
int millisecondsToWait() { | ||
if (milliseconds < 0) | ||
{ | ||
char* envVariable = getenv("CALCQT_STEP_DELAY"); | ||
milliseconds = (envVariable) ? atoi(envVariable) : 0; | ||
} | ||
return milliseconds; | ||
} | ||
|
||
AFTER_STEP(){ | ||
QTest::qWait(millisecondsToWait()); | ||
} | ||
|
||
GIVEN("^I just turned on the calculator$") { | ||
cucumber::ScenarioScope<CalculatorWidget> calculator; | ||
calculator->move(0, 0); | ||
calculator->show(); | ||
#if QT_VERSION >= 0x050000 | ||
QTest::qWaitForWindowExposed(calculator.get()); | ||
#else | ||
QTest::qWaitForWindowShown(calculator.get()); | ||
#endif | ||
} | ||
|
||
WHEN("^I press (\\d+)$") { | ||
REGEX_PARAM(unsigned int, n); | ||
cucumber::ScenarioScope<CalculatorWidget> calculator; | ||
QTest::keyClick(calculator.get(), Qt::Key_0 + n, Qt::NoModifier, 0); | ||
} | ||
|
||
WHEN("^I press add") { | ||
cucumber::ScenarioScope<CalculatorWidget> calculator; | ||
QTest::keyClick(calculator.get(), Qt::Key_Plus, Qt::NoModifier, 0); | ||
} | ||
|
||
WHEN("^I press calculate") { | ||
cucumber::ScenarioScope<CalculatorWidget> calculator; | ||
QTest::keyClick(calculator.get(), Qt::Key_Return, Qt::NoModifier, 0); | ||
} | ||
|
||
WHEN("^I press clear") { | ||
cucumber::ScenarioScope<CalculatorWidget> calculator; | ||
QTest::keyClick(calculator.get(), Qt::Key_Escape, Qt::NoModifier, 0); | ||
} | ||
|
||
WHEN("^I press subtract") { | ||
cucumber::ScenarioScope<CalculatorWidget> calculator; | ||
QTest::keyClick(calculator.get(), Qt::Key_Minus, Qt::NoModifier, 0); | ||
} | ||
|
||
THEN("^the display should be empty$") { | ||
cucumber::ScenarioScope<CalculatorWidget> calculator; | ||
QCOMPARE(calculator->display().size(), 0); | ||
} | ||
|
||
THEN("^the display should show (.*)$") { | ||
REGEX_PARAM(QString, expected); | ||
cucumber::ScenarioScope<CalculatorWidget> calculator; | ||
QCOMPARE(calculator->display(), expected); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I think we already needed 3.1 anyway (for both
find_dependency()
andThreads::Threads
).