Commit 5757e37723fdbce44a7d689cb46ab8a8ce4ffec7
1 parent
e665e55d
Exists in
master
Alteração em resposta ao comentario em pegarOs, e criação de um teste para o console.
Showing
5 changed files
with
37 additions
and
6 deletions
Show diff stats
cacic-teste/cacic-teste.pro
@@ -27,7 +27,8 @@ HEADERS += \ | @@ -27,7 +27,8 @@ HEADERS += \ | ||
27 | testcacic.h \ | 27 | testcacic.h \ |
28 | ../src/ccacic.h \ | 28 | ../src/ccacic.h \ |
29 | ../src/cacic_computer.h \ | 29 | ../src/cacic_computer.h \ |
30 | - ../src/cacic_comm.h | 30 | + ../src/cacic_comm.h \ |
31 | + ../src/console.h | ||
31 | 32 | ||
32 | INCLUDEPATH += ../src \ | 33 | INCLUDEPATH += ../src \ |
33 | ../src/crypto++/include/ | 34 | ../src/crypto++/include/ |
cacic-teste/testcacic.cpp
@@ -91,6 +91,13 @@ void CTestCacic::testpegarOS(){ | @@ -91,6 +91,13 @@ void CTestCacic::testpegarOS(){ | ||
91 | QVERIFY(OCacicComp.getOs() != -1 ); | 91 | QVERIFY(OCacicComp.getOs() != -1 ); |
92 | } | 92 | } |
93 | 93 | ||
94 | +void CTestCacic::testConsole() | ||
95 | +{ | ||
96 | + ConsoleObject console; | ||
97 | + | ||
98 | + QVERIFY(console("echo teste").toStdString() == "teste"); | ||
99 | +} | ||
100 | + | ||
94 | void CTestCacic::testPegarUsu(){ | 101 | void CTestCacic::testPegarUsu(){ |
95 | QVERIFY(OCacicComp.getUser() != ""); | 102 | QVERIFY(OCacicComp.getUser() != ""); |
96 | } | 103 | } |
cacic-teste/testcacic.h
@@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
4 | #include <../src/cacic_comm.h> | 4 | #include <../src/cacic_comm.h> |
5 | #include <../src/ccacic.h> | 5 | #include <../src/ccacic.h> |
6 | #include <../src/cacic_computer.h> | 6 | #include <../src/cacic_computer.h> |
7 | +#include <../src/console.h> | ||
7 | #include <QtTest/QtTest> | 8 | #include <QtTest/QtTest> |
8 | #include <QDebug> | 9 | #include <QDebug> |
9 | #include <QList> | 10 | #include <QList> |
@@ -42,6 +43,7 @@ private slots: | @@ -42,6 +43,7 @@ private slots: | ||
42 | void testDeleteFolder(); | 43 | void testDeleteFolder(); |
43 | void testDeleteFile(); | 44 | void testDeleteFile(); |
44 | void testInterfaceDeRede(); | 45 | void testInterfaceDeRede(); |
46 | + void testConsole(); | ||
45 | void testPegarUsu(); | 47 | void testPegarUsu(); |
46 | void testJsonValueFromJsonString(); | 48 | void testJsonValueFromJsonString(); |
47 | void testpegarOS(); | 49 | void testpegarOS(); |
src/cacic_computer.cpp
@@ -85,17 +85,21 @@ QJsonObject CACIC_Computer::toJsonObject() | @@ -85,17 +85,21 @@ QJsonObject CACIC_Computer::toJsonObject() | ||
85 | int CACIC_Computer::pegarOS(){ | 85 | int CACIC_Computer::pegarOS(){ |
86 | /*Não entendi o que você tentou fazer aqui, mas não funcionou. | 86 | /*Não entendi o que você tentou fazer aqui, mas não funcionou. |
87 | * Você chegou a testar? Comenta o que era pra fazer. | 87 | * Você chegou a testar? Comenta o que era pra fazer. |
88 | + * ====== | ||
89 | + * Não testei, mas quis pegar os valores definidos no enum do QSysInfo | ||
90 | + * para Windows e, em vez de retornar estes valores ( que estão | ||
91 | + * comentados acima), retornar os valores do enum da própria CACIC_Computer. | ||
88 | */ | 92 | */ |
89 | //#if defined (Q_OS_WIN) || defined(Q_OS_CYGWIN) | 93 | //#if defined (Q_OS_WIN) || defined(Q_OS_CYGWIN) |
90 | -// if(QSysInfo::WindowsVersion == QSysInfo::QSysInfo.WinVersion.WV_XP) | 94 | +// if(QSysInfo::WindowsVersion == QSysInfo::WV_XP) |
91 | // return WIN_XP; | 95 | // return WIN_XP; |
92 | -// else if(QSysInfo::WindowsVersion == QSysInfo::QSysInfo.WinVersion.WV_VISTA) | 96 | +// else if(QSysInfo::WindowsVersion == QSysInfo::WV_VISTA) |
93 | // return WIN_VISTA; | 97 | // return WIN_VISTA; |
94 | -// else if(QSysInfo::WindowsVersion == QSysInfo::QSysInfo.WinVersion.WV_WINDOWS7) | 98 | +// else if(QSysInfo::WindowsVersion == QSysInfo::WV_WINDOWS7) |
95 | // return WIN_7; | 99 | // return WIN_7; |
96 | -// else if(QSysInfo::WindowsVersion == QSysInfo::QSysInfo.WinVersion.WV_WINDOWS8) | 100 | +// else if(QSysInfo::WindowsVersion == QSysInfo::WV_WINDOWS8) |
97 | // return WIN_8; | 101 | // return WIN_8; |
98 | -// else if(QSysInfo::WindowsVersion == QSysInfo::QSysInfo.WinVersion.WV_WINDOWS8_1) | 102 | +// else if(QSysInfo::WindowsVersion == QSysInfo::WV_WINDOWS8_1) |
99 | // return WIN_8_1; | 103 | // return WIN_8_1; |
100 | #if defined (Q_OS_WIN) | 104 | #if defined (Q_OS_WIN) |
101 | return QSysInfo::WindowsVersion; | 105 | return QSysInfo::WindowsVersion; |
@@ -0,0 +1,17 @@ | @@ -0,0 +1,17 @@ | ||
1 | +#ifndef CONSOLE_H | ||
2 | +#define CONSOLE_H | ||
3 | + | ||
4 | +#include <QDebug> | ||
5 | +#include <QString> | ||
6 | + | ||
7 | +class ConsoleObject:public std::unary_function<std::string,QString> | ||
8 | +{ | ||
9 | + | ||
10 | +public: | ||
11 | + QString operator() (std::string) | ||
12 | + { | ||
13 | + return ""; | ||
14 | + } | ||
15 | +}; | ||
16 | + | ||
17 | +#endif // CONSOLE_H |