Commit 618b7fb69bc4dbae7c25277e2eb9724bacfa7c60
1 parent
facf4f9b
Exists in
master
Adicionado testReadConfig() para começar a mexer com o Gercol. E mudando algumas…
… coisas nos projetos para integrar o Gercol no teste.
Showing
6 changed files
with
67 additions
and
4 deletions
Show diff stats
cacic-teste/cacic-teste.pro
| ... | ... | @@ -21,7 +21,8 @@ SOURCES += \ |
| 21 | 21 | testcacic.cpp \ |
| 22 | 22 | ../src/ccacic.cpp \ |
| 23 | 23 | ../src/cacic_computer.cpp \ |
| 24 | - ../src/operatingsystem.cpp | |
| 24 | + ../src/operatingsystem.cpp \ | |
| 25 | + ../gercols/gercols.cpp | |
| 25 | 26 | |
| 26 | 27 | |
| 27 | 28 | HEADERS += \ |
| ... | ... | @@ -30,7 +31,8 @@ HEADERS += \ |
| 30 | 31 | ../src/cacic_computer.h \ |
| 31 | 32 | ../src/cacic_comm.h \ |
| 32 | 33 | ../src/console.h \ |
| 33 | - ../src/operatingsystem.h | |
| 34 | + ../src/operatingsystem.h \ | |
| 35 | + ../gercols/gercols.cpp | |
| 34 | 36 | |
| 35 | 37 | INCLUDEPATH += ../src \ |
| 36 | 38 | ../src/crypto++/include/ | ... | ... |
cacic-teste/testcacic.cpp
| ... | ... | @@ -191,7 +191,31 @@ void CTestCacic::testJsonFromFile() |
| 191 | 191 | QVERIFY(OCacic.getJsonFromFile("teste.json")["teste"].toString() == "teste"); |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | +void CTestCacic::testReadConfig() | |
| 195 | +{ | |
| 196 | + | |
| 197 | + // Inicializa um arquivo de configuração stub | |
| 198 | + // que seria parecido com o recebido do Gerente | |
| 199 | + QJsonObject configJson; | |
| 200 | + QJsonObject configHardware; | |
| 201 | + QJsonObject configSoftware; | |
| 202 | + | |
| 203 | + configHardware["network_interface"] = QJsonValue::fromVariant(QString("")); | |
| 204 | + configSoftware["operating_system"] = QJsonValue::fromVariant(QString("")); | |
| 205 | + | |
| 206 | + configJson["hardware"] = configHardware; | |
| 207 | + configJson["software"] = configSoftware; | |
| 208 | + | |
| 209 | + OCacic.setJsonToFile(configJson,"configRequest.json"); | |
| 210 | + | |
| 211 | + // Leitura do arquivo de configuração | |
| 212 | + OGercols.readConfig(); | |
| 213 | + | |
| 214 | + QVERIFY(OGercols.getConfigJson() == configJson); | |
| 215 | +} | |
| 216 | + | |
| 194 | 217 | void CTestCacic::cleanupTestCase() |
| 195 | 218 | { |
| 219 | + OCacic.deleteFile("configRequest.json"); | |
| 196 | 220 | OCacic.deleteFile("teste.json"); |
| 197 | 221 | } | ... | ... |
cacic-teste/testcacic.h
| ... | ... | @@ -15,6 +15,7 @@ |
| 15 | 15 | #include <QtNetwork/QtNetwork> |
| 16 | 16 | #include <QJsonObject> |
| 17 | 17 | #include "../install-cacic/installcacic.h" |
| 18 | +#include "../gercols/gercols.h" | |
| 18 | 19 | |
| 19 | 20 | class CTestCacic : public QObject |
| 20 | 21 | { |
| ... | ... | @@ -26,6 +27,7 @@ private: |
| 26 | 27 | CacicComm OCacicComm; |
| 27 | 28 | CCacic OCacic; |
| 28 | 29 | CACIC_Computer OCacicComp; |
| 30 | + Gercols OGercols; | |
| 29 | 31 | QString testPath; |
| 30 | 32 | QString testIniPath; |
| 31 | 33 | QJsonObject session; |
| ... | ... | @@ -59,6 +61,7 @@ private slots: |
| 59 | 61 | void testOperatingSystemToJsonObject(); |
| 60 | 62 | void testJsonToFile(); |
| 61 | 63 | void testJsonFromFile(); |
| 64 | + void testReadConfig(); | |
| 62 | 65 | void cleanupTestCase(); |
| 63 | 66 | }; |
| 64 | 67 | ... | ... |
gercols/gercols.pro
| ... | ... | @@ -23,13 +23,17 @@ TEMPLATE = app |
| 23 | 23 | SOURCES += \ |
| 24 | 24 | main.cpp \ |
| 25 | 25 | ../src/ccacic.cpp \ |
| 26 | - ../src/cacic_computer.cpp | |
| 26 | + ../src/cacic_computer.cpp \ | |
| 27 | + ../src/operatingsystem.cpp \ | |
| 28 | + ./gercols.cpp | |
| 27 | 29 | |
| 28 | 30 | |
| 29 | 31 | HEADERS += \ |
| 30 | 32 | ../src/ccacic.h \ |
| 31 | 33 | ../src/cacic_computer.h \ |
| 32 | - ../src/cacic_comm.h | |
| 34 | + ../src/operatingsystem.h \ | |
| 35 | + ../src/console.h \ | |
| 36 | + ./gercols.h | |
| 33 | 37 | |
| 34 | 38 | INCLUDEPATH += ../src \ |
| 35 | 39 | ../src/crypto++/include/ | ... | ... |