~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to ksysguard/gui/tests/ksysguarddtest.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
#include <QtTest>
 
3
#include <Qt>
 
4
 
 
5
#include <QObject>
 
6
#include <QProcess>
 
7
#include "../ksgrd/SensorManager.h"
 
8
#include "../ksgrd/SensorAgent.h"
 
9
#include "../ksgrd/SensorClient.h"
 
10
#include <QDebug>
 
11
class SensorClientTest;
 
12
 
 
13
class TestKsysguardd : public QObject
 
14
{
 
15
    Q_OBJECT
 
16
    private slots:
 
17
        void init();
 
18
        void cleanup();
 
19
        void initTestCase();
 
20
        void cleanupTestCase();
 
21
 
 
22
        void testSetup();
 
23
        void testFormatting_data();
 
24
        void testFormatting();
 
25
        void testQueueing();
 
26
    private:
 
27
        KSGRD::SensorManager manager;
 
28
        SensorClientTest *client;
 
29
        QSignalSpy *hostConnectionLostSpy;
 
30
        QSignalSpy *updateSpy;
 
31
        QSignalSpy *hostAddedSpy;
 
32
        int nextId;
 
33
};
 
34
struct Answer {
 
35
    Answer() {
 
36
        id = -1;
 
37
        isSensorLost = false;
 
38
    }
 
39
    int id;
 
40
    QList<QByteArray> answer;
 
41
    bool isSensorLost;
 
42
};
 
43
struct SensorClientTest : public KSGRD::SensorClient
 
44
{
 
45
    SensorClientTest() {
 
46
        isSensorLost = false;
 
47
        haveAnswer = false;
 
48
    }
 
49
    virtual void answerReceived( int id, const QList<QByteArray>& answer_ ) {
 
50
        Answer answer;
 
51
        answer.id = id;
 
52
        answer.answer = answer_;
 
53
        answers << answer;
 
54
        haveAnswer = true;
 
55
    }
 
56
    virtual void sensorLost(int id)
 
57
    {
 
58
        Answer answer;
 
59
        answer.id = id;
 
60
        answer.isSensorLost = true;
 
61
        answers << answer;
 
62
        isSensorLost = true;
 
63
    }
 
64
    bool isSensorLost;
 
65
    bool haveAnswer;
 
66
    QList<Answer> answers;
 
67
};