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
cacic-teste/testcacic.cpp
| ... | ... | @@ -91,6 +91,13 @@ void CTestCacic::testpegarOS(){ |
| 91 | 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 | 101 | void CTestCacic::testPegarUsu(){ |
| 95 | 102 | QVERIFY(OCacicComp.getUser() != ""); |
| 96 | 103 | } | ... | ... |
cacic-teste/testcacic.h
| ... | ... | @@ -4,6 +4,7 @@ |
| 4 | 4 | #include <../src/cacic_comm.h> |
| 5 | 5 | #include <../src/ccacic.h> |
| 6 | 6 | #include <../src/cacic_computer.h> |
| 7 | +#include <../src/console.h> | |
| 7 | 8 | #include <QtTest/QtTest> |
| 8 | 9 | #include <QDebug> |
| 9 | 10 | #include <QList> |
| ... | ... | @@ -42,6 +43,7 @@ private slots: |
| 42 | 43 | void testDeleteFolder(); |
| 43 | 44 | void testDeleteFile(); |
| 44 | 45 | void testInterfaceDeRede(); |
| 46 | + void testConsole(); | |
| 45 | 47 | void testPegarUsu(); |
| 46 | 48 | void testJsonValueFromJsonString(); |
| 47 | 49 | void testpegarOS(); | ... | ... |
src/cacic_computer.cpp
| ... | ... | @@ -85,17 +85,21 @@ QJsonObject CACIC_Computer::toJsonObject() |
| 85 | 85 | int CACIC_Computer::pegarOS(){ |
| 86 | 86 | /*Não entendi o que você tentou fazer aqui, mas não funcionou. |
| 87 | 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 | 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 | 95 | // return WIN_XP; |
| 92 | -// else if(QSysInfo::WindowsVersion == QSysInfo::QSysInfo.WinVersion.WV_VISTA) | |
| 96 | +// else if(QSysInfo::WindowsVersion == QSysInfo::WV_VISTA) | |
| 93 | 97 | // return WIN_VISTA; |
| 94 | -// else if(QSysInfo::WindowsVersion == QSysInfo::QSysInfo.WinVersion.WV_WINDOWS7) | |
| 98 | +// else if(QSysInfo::WindowsVersion == QSysInfo::WV_WINDOWS7) | |
| 95 | 99 | // return WIN_7; |
| 96 | -// else if(QSysInfo::WindowsVersion == QSysInfo::QSysInfo.WinVersion.WV_WINDOWS8) | |
| 100 | +// else if(QSysInfo::WindowsVersion == QSysInfo::WV_WINDOWS8) | |
| 97 | 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 | 103 | // return WIN_8_1; |
| 100 | 104 | #if defined (Q_OS_WIN) |
| 101 | 105 | return QSysInfo::WindowsVersion; | ... | ... |
| ... | ... | @@ -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 | ... | ... |