From 5757e37723fdbce44a7d689cb46ab8a8ce4ffec7 Mon Sep 17 00:00:00 2001 From: Thiago Rocha Date: Thu, 14 Aug 2014 10:26:46 -0300 Subject: [PATCH] Alteração em resposta ao comentario em pegarOs, e criação de um teste para o console. --- cacic-teste/cacic-teste.pro | 3 ++- cacic-teste/testcacic.cpp | 7 +++++++ cacic-teste/testcacic.h | 2 ++ src/cacic_computer.cpp | 14 +++++++++----- src/console.h | 17 +++++++++++++++++ 5 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 src/console.h diff --git a/cacic-teste/cacic-teste.pro b/cacic-teste/cacic-teste.pro index dead633..65019f8 100644 --- a/cacic-teste/cacic-teste.pro +++ b/cacic-teste/cacic-teste.pro @@ -27,7 +27,8 @@ HEADERS += \ testcacic.h \ ../src/ccacic.h \ ../src/cacic_computer.h \ - ../src/cacic_comm.h + ../src/cacic_comm.h \ + ../src/console.h INCLUDEPATH += ../src \ ../src/crypto++/include/ diff --git a/cacic-teste/testcacic.cpp b/cacic-teste/testcacic.cpp index 667968c..2c971c0 100644 --- a/cacic-teste/testcacic.cpp +++ b/cacic-teste/testcacic.cpp @@ -91,6 +91,13 @@ void CTestCacic::testpegarOS(){ QVERIFY(OCacicComp.getOs() != -1 ); } +void CTestCacic::testConsole() +{ + ConsoleObject console; + + QVERIFY(console("echo teste").toStdString() == "teste"); +} + void CTestCacic::testPegarUsu(){ QVERIFY(OCacicComp.getUser() != ""); } diff --git a/cacic-teste/testcacic.h b/cacic-teste/testcacic.h index 25fbf1a..5f3d224 100644 --- a/cacic-teste/testcacic.h +++ b/cacic-teste/testcacic.h @@ -4,6 +4,7 @@ #include <../src/cacic_comm.h> #include <../src/ccacic.h> #include <../src/cacic_computer.h> +#include <../src/console.h> #include #include #include @@ -42,6 +43,7 @@ private slots: void testDeleteFolder(); void testDeleteFile(); void testInterfaceDeRede(); + void testConsole(); void testPegarUsu(); void testJsonValueFromJsonString(); void testpegarOS(); diff --git a/src/cacic_computer.cpp b/src/cacic_computer.cpp index f93e1db..febd9d6 100644 --- a/src/cacic_computer.cpp +++ b/src/cacic_computer.cpp @@ -85,17 +85,21 @@ QJsonObject CACIC_Computer::toJsonObject() int CACIC_Computer::pegarOS(){ /*Não entendi o que você tentou fazer aqui, mas não funcionou. * Você chegou a testar? Comenta o que era pra fazer. + * ====== + * Não testei, mas quis pegar os valores definidos no enum do QSysInfo + * para Windows e, em vez de retornar estes valores ( que estão + * comentados acima), retornar os valores do enum da própria CACIC_Computer. */ //#if defined (Q_OS_WIN) || defined(Q_OS_CYGWIN) -// if(QSysInfo::WindowsVersion == QSysInfo::QSysInfo.WinVersion.WV_XP) +// if(QSysInfo::WindowsVersion == QSysInfo::WV_XP) // return WIN_XP; -// else if(QSysInfo::WindowsVersion == QSysInfo::QSysInfo.WinVersion.WV_VISTA) +// else if(QSysInfo::WindowsVersion == QSysInfo::WV_VISTA) // return WIN_VISTA; -// else if(QSysInfo::WindowsVersion == QSysInfo::QSysInfo.WinVersion.WV_WINDOWS7) +// else if(QSysInfo::WindowsVersion == QSysInfo::WV_WINDOWS7) // return WIN_7; -// else if(QSysInfo::WindowsVersion == QSysInfo::QSysInfo.WinVersion.WV_WINDOWS8) +// else if(QSysInfo::WindowsVersion == QSysInfo::WV_WINDOWS8) // return WIN_8; -// else if(QSysInfo::WindowsVersion == QSysInfo::QSysInfo.WinVersion.WV_WINDOWS8_1) +// else if(QSysInfo::WindowsVersion == QSysInfo::WV_WINDOWS8_1) // return WIN_8_1; #if defined (Q_OS_WIN) return QSysInfo::WindowsVersion; diff --git a/src/console.h b/src/console.h new file mode 100644 index 0000000..6e8d278 --- /dev/null +++ b/src/console.h @@ -0,0 +1,17 @@ +#ifndef CONSOLE_H +#define CONSOLE_H + +#include +#include + +class ConsoleObject:public std::unary_function +{ + +public: + QString operator() (std::string) + { + return ""; + } +}; + +#endif // CONSOLE_H -- libgit2 0.21.2