Commit 73c8bddbd5b14df834f1e0716bc62e314c44297d
1 parent
5757e377
Exists in
master
Json da classe computador sendo gerado. Falta só acrescentar o SO, que pegarei agora no pull
Showing
6 changed files
with
24 additions
and
40 deletions
Show diff stats
cacic-teste/testcacic.cpp
| ... | ... | @@ -88,6 +88,7 @@ void CTestCacic::testInterfaceDeRede(){ |
| 88 | 88 | |
| 89 | 89 | void CTestCacic::testpegarOS(){ |
| 90 | 90 | //basta que seja um retorno válido, não precisa validar todos. |
| 91 | + qDebug() << OCacicComp.getOs(); | |
| 91 | 92 | QVERIFY(OCacicComp.getOs() != -1 ); |
| 92 | 93 | } |
| 93 | 94 | |
| ... | ... | @@ -160,6 +161,11 @@ void CTestCacic::testInstallCacicStart() |
| 160 | 161 | QVERIFY(false); |
| 161 | 162 | } |
| 162 | 163 | |
| 164 | +void CTestCacic::testCacicCompToJsonObject() | |
| 165 | +{ | |
| 166 | + QVERIFY(!OCacicComp.toJsonObject().empty()); | |
| 167 | +} | |
| 168 | + | |
| 163 | 169 | void CTestCacic::cleanupTestCase() |
| 164 | 170 | { |
| 165 | 171 | ... | ... |
cacic-teste/testcacic.h
| 1 | 1 | #ifndef TESTINSTALLCACIC_H |
| 2 | 2 | #define TESTINSTALLCACIC_H |
| 3 | 3 | |
| 4 | -#include <../src/cacic_comm.h> | |
| 5 | -#include <../src/ccacic.h> | |
| 6 | -#include <../src/cacic_computer.h> | |
| 7 | -#include <../src/console.h> | |
| 4 | +#include <cacic_comm.h> | |
| 5 | +#include <ccacic.h> | |
| 6 | +#include <cacic_computer.h> | |
| 7 | +#include <console.h> | |
| 8 | 8 | #include <QtTest/QtTest> |
| 9 | 9 | #include <QDebug> |
| 10 | 10 | #include <QList> |
| ... | ... | @@ -52,6 +52,7 @@ private slots: |
| 52 | 52 | void testEnCrypt(); |
| 53 | 53 | void testDeCrypt(); |
| 54 | 54 | void testInstallCacicStart(); |
| 55 | + void testCacicCompToJsonObject(); | |
| 55 | 56 | void cleanupTestCase(); |
| 56 | 57 | }; |
| 57 | 58 | ... | ... |
install-cacic/install-cacic.pro.user
install-cacic/installcacic.cpp
install-cacic/installcacic.h
src/cacic_computer.cpp
| ... | ... | @@ -52,22 +52,17 @@ QList<QVariantMap> CACIC_Computer::networkInterfacesRunning(){ |
| 52 | 52 | |
| 53 | 53 | QJsonObject CACIC_Computer::toJsonObject() |
| 54 | 54 | { |
| 55 | -// QJsonObject json; | |
| 56 | -// QJsonValue valor; | |
| 57 | -// QVariant aux; | |
| 58 | -// QJsonArray jsonArray; | |
| 59 | -// aux = this->os; | |
| 60 | -// valor.fromVariant(aux); | |
| 61 | -// json.insert("so", valor); | |
| 62 | -// aux = this->usuario; | |
| 63 | -// valor.fromVariant(aux); | |
| 64 | -// json.insert("usuario", this->usuario); | |
| 65 | -// aux.clear(); | |
| 66 | -// foreach(QVariantMap auxMap, this->getNetworkInterface()){ | |
| 67 | -// json.insert() | |
| 68 | -// } | |
| 69 | - | |
| 70 | -// json.insert("network", network); | |
| 55 | + QJsonObject json; | |
| 56 | + QJsonObject network; | |
| 57 | + int count = 1; | |
| 58 | + json["usuario"] = QJsonValue::fromVariant(QString::fromStdString(this->usuario)); | |
| 59 | + foreach(QVariantMap auxMap, this->getNetworkInterface()){ | |
| 60 | + network["network" + QVariant::fromValue(count).toString()] = QJsonObject::fromVariantMap(auxMap); | |
| 61 | + count++; | |
| 62 | + } | |
| 63 | + json["networkDevices"] = network; | |
| 64 | +// qDebug() << json; | |
| 65 | + return json; | |
| 71 | 66 | } |
| 72 | 67 | |
| 73 | 68 | |
| ... | ... | @@ -83,24 +78,6 @@ QJsonObject CACIC_Computer::toJsonObject() |
| 83 | 78 | * 0 = unkown |
| 84 | 79 | */ |
| 85 | 80 | int CACIC_Computer::pegarOS(){ |
| 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. | |
| 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. | |
| 92 | - */ | |
| 93 | -//#if defined (Q_OS_WIN) || defined(Q_OS_CYGWIN) | |
| 94 | -// if(QSysInfo::WindowsVersion == QSysInfo::WV_XP) | |
| 95 | -// return WIN_XP; | |
| 96 | -// else if(QSysInfo::WindowsVersion == QSysInfo::WV_VISTA) | |
| 97 | -// return WIN_VISTA; | |
| 98 | -// else if(QSysInfo::WindowsVersion == QSysInfo::WV_WINDOWS7) | |
| 99 | -// return WIN_7; | |
| 100 | -// else if(QSysInfo::WindowsVersion == QSysInfo::WV_WINDOWS8) | |
| 101 | -// return WIN_8; | |
| 102 | -// else if(QSysInfo::WindowsVersion == QSysInfo::WV_WINDOWS8_1) | |
| 103 | -// return WIN_8_1; | |
| 104 | 81 | #if defined (Q_OS_WIN) |
| 105 | 82 | return QSysInfo::WindowsVersion; |
| 106 | 83 | #elif defined(Q_OS_MAC) | ... | ... |