Commit 73c8bddbd5b14df834f1e0716bc62e314c44297d

Authored by Eric Menezes Noronha
1 parent 5757e377
Exists in master

Json da classe computador sendo gerado. Falta só acrescentar o SO, que pegarei agora no pull

cacic-teste/testcacic.cpp
@@ -88,6 +88,7 @@ void CTestCacic::testInterfaceDeRede(){ @@ -88,6 +88,7 @@ void CTestCacic::testInterfaceDeRede(){
88 88
89 void CTestCacic::testpegarOS(){ 89 void CTestCacic::testpegarOS(){
90 //basta que seja um retorno válido, não precisa validar todos. 90 //basta que seja um retorno válido, não precisa validar todos.
  91 + qDebug() << OCacicComp.getOs();
91 QVERIFY(OCacicComp.getOs() != -1 ); 92 QVERIFY(OCacicComp.getOs() != -1 );
92 } 93 }
93 94
@@ -160,6 +161,11 @@ void CTestCacic::testInstallCacicStart() @@ -160,6 +161,11 @@ void CTestCacic::testInstallCacicStart()
160 QVERIFY(false); 161 QVERIFY(false);
161 } 162 }
162 163
  164 +void CTestCacic::testCacicCompToJsonObject()
  165 +{
  166 + QVERIFY(!OCacicComp.toJsonObject().empty());
  167 +}
  168 +
163 void CTestCacic::cleanupTestCase() 169 void CTestCacic::cleanupTestCase()
164 { 170 {
165 171
cacic-teste/testcacic.h
1 #ifndef TESTINSTALLCACIC_H 1 #ifndef TESTINSTALLCACIC_H
2 #define TESTINSTALLCACIC_H 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 #include <QtTest/QtTest> 8 #include <QtTest/QtTest>
9 #include <QDebug> 9 #include <QDebug>
10 #include <QList> 10 #include <QList>
@@ -52,6 +52,7 @@ private slots: @@ -52,6 +52,7 @@ private slots:
52 void testEnCrypt(); 52 void testEnCrypt();
53 void testDeCrypt(); 53 void testDeCrypt();
54 void testInstallCacicStart(); 54 void testInstallCacicStart();
  55 + void testCacicCompToJsonObject();
55 void cleanupTestCase(); 56 void cleanupTestCase();
56 }; 57 };
57 58
install-cacic/install-cacic.pro.user
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE QtCreatorProject> 2 <!DOCTYPE QtCreatorProject>
3 -<!-- Written by QtCreator 3.1.2, 2014-08-13T18:44:40. --> 3 +<!-- Written by QtCreator 3.1.2, 2014-08-14T10:57:32. -->
4 <qtcreator> 4 <qtcreator>
5 <data> 5 <data>
6 <variable>ProjectExplorer.Project.ActiveTarget</variable> 6 <variable>ProjectExplorer.Project.ActiveTarget</variable>
install-cacic/installcacic.cpp
1 #include "installcacic.h" 1 #include "installcacic.h"
2 -#include "iostream"  
3 2
4 InstallCacic::InstallCacic(QObject *parent) : 3 InstallCacic::InstallCacic(QObject *parent) :
5 QObject(parent) 4 QObject(parent)
install-cacic/installcacic.h
@@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
6 #include <cacic_comm.h> 6 #include <cacic_comm.h>
7 #include <cacic_computer.h> 7 #include <cacic_computer.h>
8 #include <ccacic.h> 8 #include <ccacic.h>
  9 +#include "iostream"
9 10
10 class InstallCacic : public QObject 11 class InstallCacic : public QObject
11 { 12 {
src/cacic_computer.cpp
@@ -52,22 +52,17 @@ QList&lt;QVariantMap&gt; CACIC_Computer::networkInterfacesRunning(){ @@ -52,22 +52,17 @@ QList&lt;QVariantMap&gt; CACIC_Computer::networkInterfacesRunning(){
52 52
53 QJsonObject CACIC_Computer::toJsonObject() 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,24 +78,6 @@ QJsonObject CACIC_Computer::toJsonObject()
83 * 0 = unkown 78 * 0 = unkown
84 */ 79 */
85 int CACIC_Computer::pegarOS(){ 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 #if defined (Q_OS_WIN) 81 #if defined (Q_OS_WIN)
105 return QSysInfo::WindowsVersion; 82 return QSysInfo::WindowsVersion;
106 #elif defined(Q_OS_MAC) 83 #elif defined(Q_OS_MAC)