/*! Implementation for traverse so always true. */ bool PopupFixture::execute(void * objectInstance, QString actionName, QHash<QString, QString> parameters, QString & stdOut) { Q_UNUSED(objectInstance); TasLogger::logger()->debug("PopupFixture::execute"); bool result = true; if(actionName == "waitPopup"){ QString className = parameters[CLASS_NAME].trimmed(); int interval = parameters[INTERVAL].toInt(); TasLogger::logger()->debug("PopupFixture::execute waitpopup for " + className); startPopupDetection(className, interval); } else if(actionName == "printPopup"){ QString className = parameters[CLASS_NAME].trimmed(); TasLogger::logger()->debug("PopupFixture::execute get data for " + className); if(mPopupData.contains(className)){ TasLogger::logger()->debug("PopupFixture::execute data found serialize model."); TasDataModel *model = mPopupData.value(className); mPopupData.remove(className); QByteArray xml; model->serializeModel(xml); stdOut.append(QString::fromUtf8(xml.data())); delete model; mClassNames.remove(className); } else{ TasLogger::logger()->debug("PopupFixture::execute no data for item."); result = false; stdOut = "No data for the given class name. Maybe widget was not shown!"; } if(mClassNames.isEmpty()){ qApp->removeEventFilter(this); mFiltering = false; } } else{ stdOut = "Unknown action for PopupFixture. Make sure action name is correct or that you are using the correct fixture."; result = false; } return result; }
QByteArray TasInfoLoggerUtil::loadLoggedData(QFile* file, const QString& name, QHash<QString,QString> params) { TasDataModel* tasModel = new TasDataModel(); QString qtVersion = "Qt" + QString(qVersion()); TasObjectContainer& container = tasModel->addNewObjectContainer(1, qtVersion, "qt"); TasObject& parentData = container.addNewObject("0", name, "logData"); int counter = 0; QTextStream in(file); in.seek(0); while (!in.atEnd()) { TasObject& obj = parentData.addObject(); obj.setId(QString::number(counter)); obj.setType("logEntry"); obj.setName("LogEntry"); //load attributes format is: title:value;title:value.... QStringList line = in.readLine().split(ATTR_DELIM, QString::SkipEmptyParts); QString attrPair; foreach(attrPair, line){ QStringList attribute = attrPair.split(VALUE_DELIM, QString::SkipEmptyParts); obj.addAttribute(attribute.first(),attribute.last()); } counter++; }
void ShellCommandService::shellStatus(qint64 pid, TasResponse& response) { TasLogger::logger()->debug("ShellCommandService::service: looking for pid " + QString::number(pid)); if (mTasks.contains(pid)) { TasLogger::logger()->debug("ShellCommandService::got it"); ShellTask* task = mTasks.value(pid); TasLogger::logger()->debug("ShellCommandService::setting run data"); TasDataModel* model = new TasDataModel(); QString qtVersion = "Qt" + QString(qVersion()); TasObjectContainer& container = model->addNewObjectContainer(1, qtVersion, "qt"); TasObject& output = container.addNewObject("2","Response","Response"); ShellTask::Status status = task->status(); switch (status) { case ShellTask::ERR: output.addAttribute("status", "ERROR"); break; case ShellTask::RUNNING: output.addAttribute("status", "RUNNING"); break; case ShellTask::FINISHED: output.addAttribute("status", "FINISHED"); output.addAttribute("exitCode", task->returnCode()); break; case ShellTask::NOT_STARTED: default: output.addAttribute("status", "NOT_STARTED"); break; } output.addAttribute("output", QString(task->responseData())); // Clean up if process is done. if (status != ShellTask::RUNNING) { mTasks.remove(pid); if (task->isRunning()) { task->endTask(); } else { task->deleteLater(); task = 0; } TasLogger::logger()->debug("ShellCommandService::service: deleting"); TasLogger::logger()->debug("ShellCommandService::service: donne"); } QByteArray xml; model->serializeModel(xml); delete model; response.setData(xml); } TasLogger::logger()->debug("ShellCommandService::service: shell status done"); }