~diegosarmentero/+junk/settings-temp

« back to all changes in this revision

Viewing changes to tests/plugins/system-update/fakeprocess.cpp

  • Committer: Diego Sarmentero
  • Date: 2013-11-18 09:55:14 UTC
  • Revision ID: diego.sarmentero@gmail.com-20131118095514-kxfblhzwpfw6m6xz
tests working

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2013 Canonical Ltd.
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or
 
5
 * modify it under the terms of version 3 of the GNU Lesser General Public
 
6
 * License as published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
11
 * General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public
 
14
 * License along with this library; if not, write to the
 
15
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
16
 * Boston, MA 02110-1301, USA.
 
17
 */
 
18
 
 
19
#include "fakeprocess.h"
 
20
#include <QFile>
 
21
#include <QTextStream>
 
22
#include <QDir>
 
23
 
 
24
namespace UpdatePlugin {
 
25
 
 
26
FakeProcess::FakeProcess(QObject *parent) :
 
27
    QObject(parent)
 
28
{
 
29
}
 
30
 
 
31
void FakeProcess::start(QString command, QStringList args)
 
32
{
 
33
    Q_UNUSED(args);
 
34
    if(command == "click") {
 
35
        QString path = QDir::currentPath();
 
36
        path.append("/click.result");
 
37
 
 
38
        this->m_content.clear();
 
39
        QFile file(path);
 
40
        file.open(QIODevice::ReadOnly);
 
41
        QTextStream in(&file);
 
42
        while(!in.atEnd()) {
 
43
            QString line = in.readLine();
 
44
            this->m_content.append(line);
 
45
        }
 
46
 
 
47
        file.close();
 
48
        emit this->finished(0);
 
49
    }
 
50
}
 
51
 
 
52
QString FakeProcess::readAllStandardOutput()
 
53
{
 
54
    return this->m_content;
 
55
}
 
56
 
 
57
void FakeProcess::startDetached(QString command, QStringList args)
 
58
{
 
59
    Q_UNUSED(command);
 
60
    Q_UNUSED(args);
 
61
}
 
62
 
 
63
}