Commit 5145564d02d8c7e0d95cce6faaed51a1d5630cd8

Authored by Thiago Rocha
1 parent 496eb90c
Exists in master

Classe ConsoleObject feita, e teste da chamada de console() passando.

cacic-teste/testcacic.cpp
... ... @@ -96,7 +96,7 @@ void CTestCacic::testConsole()
96 96 {
97 97 ConsoleObject console;
98 98  
99   - QVERIFY(console("echo teste").toStdString() == "teste");
  99 + QVERIFY(console("echo teste").toStdString() == "teste\n");
100 100 }
101 101  
102 102 void CTestCacic::testPegarUsu(){
... ...
src/console.h
... ... @@ -2,16 +2,31 @@
2 2 #define CONSOLE_H
3 3  
4 4 #include <QDebug>
  5 +#include <QProcess>
5 6 #include <QString>
  7 +#include <QSysInfo>
6 8  
7 9 class ConsoleObject:public std::unary_function<std::string,QString>
8 10 {
9 11  
10 12 public:
11   - QString operator() (std::string)
  13 +
  14 +#if defined(Q_OS_LINUX)
  15 + QString operator() (std::string input)
12 16 {
13   - return "";
  17 + QProcess* process = new QProcess();
  18 +
  19 + QStringList options;
  20 + options << "-c" << QString::fromStdString(input);
  21 + process->start("/bin/sh", options);
  22 + process->waitForFinished();
  23 + QString output = process->readAll();
  24 +// qDebug() << output;
  25 +
  26 + delete process;
  27 + return output;
14 28 }
  29 +#endif
15 30 };
16 31  
17 32 #endif // CONSOLE_H
... ...
src/operatingsystem.cpp
... ... @@ -14,7 +14,7 @@ int OperatingSystem::pegarOS(){
14 14 #if defined (Q_OS_WIN)
15 15 return QSysInfo::WindowsVersion;
16 16 #elif defined (Q_OS_LINUX)
17   - return 200;
  17 + return LINUX_ARCH;
18 18 #else
19 19 return 0;
20 20 #endif
... ...