Commit 9a32ead0a962b4492b68ba1ad285e55dca1b1bbf
1 parent
7d9fb6ce
Exists in
master
Novos testes para executar a aplicação de maneira correta.
-Acrescentado arquivo da classe principal.
Showing
7 changed files
with
90 additions
and
20 deletions
Show diff stats
cacic-teste/cacic-teste.pro.user
cacic-teste/testcacic.cpp
| ... | ... | @@ -16,7 +16,7 @@ void CTestCacic::installcacicTest() |
| 16 | 16 | installcacicPath = "E:/Lightbase/cacic-projeto-test/build/cacic-test/debug/cacic-teste.exe"; |
| 17 | 17 | installcacic.execute(installcacicPath,QStringList() << "--host:"); |
| 18 | 18 | if (!installcacic.waitForFinished() and (installcacic.exitCode() == 5)) |
| 19 | - QVERIFY(installcacic.exitCode() == 5); | |
| 19 | + QVERIFY(installcacic.exitStatus() == 5); | |
| 20 | 20 | else |
| 21 | 21 | QSKIP("Installcacic ExitCode: " + QString::number(installcacic.exitCode()).toLocal8Bit()); |
| 22 | 22 | ... | ... |
install-cacic/install-cacic.pro
install-cacic/install-cacic.pro.user
| ... | ... | @@ -0,0 +1,40 @@ |
| 1 | +#include "installcacic.h" | |
| 2 | + | |
| 3 | + | |
| 4 | +QCoreApplication *InstallCacic::getApp() const | |
| 5 | +{ | |
| 6 | + return app; | |
| 7 | +} | |
| 8 | + | |
| 9 | +void InstallCacic::setApp(const QCoreApplication &value) | |
| 10 | +{ | |
| 11 | + app = value; | |
| 12 | +} | |
| 13 | + | |
| 14 | +InstallCacic::InstallCacic(QObject *parent) : | |
| 15 | + QObject(parent) | |
| 16 | +{ | |
| 17 | +} | |
| 18 | + | |
| 19 | + | |
| 20 | +void InstallCacic::runInstall() | |
| 21 | +{ | |
| 22 | + QString argumento; | |
| 23 | + cout << "Testando argumentos" << endl; | |
| 24 | + argumento = "--host"; | |
| 25 | + | |
| 26 | + if (app.arguments().count() > 1){ | |
| 27 | + for(int i=1;i<app.arguments().count();i++){ | |
| 28 | + if (app.arguments().at(i) == argumento){ | |
| 29 | + app.quit(); | |
| 30 | + } else { | |
| 31 | + cout << app.arguments().at(i).toStdString() << endl; | |
| 32 | + } | |
| 33 | + } | |
| 34 | + app.exit(2); | |
| 35 | + } else { | |
| 36 | + app.exit(3); | |
| 37 | + } | |
| 38 | +} | |
| 39 | + | |
| 40 | + | ... | ... |
| ... | ... | @@ -0,0 +1,32 @@ |
| 1 | +#ifndef INSTALLCACIC_H | |
| 2 | +#define INSTALLCACIC_H | |
| 3 | + | |
| 4 | +#include <QObject> | |
| 5 | +#include <QCoreApplication> | |
| 6 | +#include <iostream> | |
| 7 | +#include <QStringList> | |
| 8 | +#include <QTimer> | |
| 9 | + | |
| 10 | +using namespace std; | |
| 11 | + | |
| 12 | +class InstallCacic : public QObject | |
| 13 | +{ | |
| 14 | + Q_OBJECT | |
| 15 | +public: | |
| 16 | + // variaveis | |
| 17 | + | |
| 18 | + explicit InstallCacic(QObject *parent = 0); | |
| 19 | + | |
| 20 | + QCoreApplication *getApp() const; | |
| 21 | + void setApp(const QCoreApplication &value); | |
| 22 | + | |
| 23 | +private: | |
| 24 | + QCoreApplication app; | |
| 25 | +signals: | |
| 26 | + | |
| 27 | +public slots: | |
| 28 | + void runInstall(QCoreApplication*); | |
| 29 | + | |
| 30 | +}; | |
| 31 | + | |
| 32 | +#endif // INSTALLCACIC_H | ... | ... |
install-cacic/main.cpp
| 1 | -#include <QCoreApplication> | |
| 2 | -#include <QStringList> | |
| 3 | -#include <iostream> | |
| 1 | +#include <installcacic.cpp> | |
| 4 | 2 | |
| 5 | 3 | using namespace std; |
| 6 | 4 | |
| 7 | 5 | int main(int argc, char *argv[]) |
| 8 | 6 | { |
| 9 | 7 | QCoreApplication a(argc, argv); |
| 10 | - QString argumento; | |
| 11 | - cout << "Testando argumentos" << endl; | |
| 12 | - if (a.arguments().count()>1){ | |
| 13 | - for(int i=1;i<a.arguments().count();i++){ | |
| 14 | - argumento = "--host"; | |
| 15 | - if (a.arguments().at(i) == argumento){ | |
| 16 | - return 5; | |
| 17 | - } else { | |
| 18 | - cout << a.arguments().at(i).toStdString() << endl; | |
| 19 | - } | |
| 20 | - } | |
| 8 | + InstallCacic CInstallCacic; | |
| 9 | + CInstallCacic.setApp(*a); | |
| 10 | + | |
| 11 | + try { | |
| 12 | + | |
| 13 | + CInstallCacic.runInstall();// TENTAR RODAR COM CONNECT OU ALGO DO TIPO | |
| 14 | + } catch (int e) { | |
| 15 | + cout << "Error: " << e << endl; | |
| 21 | 16 | } |
| 22 | 17 | |
| 23 | - return 1; | |
| 24 | -// return a.exec(); | |
| 18 | + return a.exec(); | |
| 25 | 19 | } | ... | ... |