~ci-train-bot/ubuntu-settings-components/ubuntu-settings-components-ubuntu-zesty-2236

« back to all changes in this revision

Viewing changes to tests/unittests/Printers/tst_signalhandler.cpp

  • Committer: Jonas G. Drange
  • Date: 2017-02-16 14:06:42 UTC
  • mto: (176.2.56 printer-components)
  • mto: This revision was merged to the branch mainline in revision 183.
  • Revision ID: jonas.drange@canonical.com-20170216140642-30rrjhecc5myeznc
adds signalhandler to buffer printer change signals

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2017 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Lesser General Public License as published by
 
6
 * the Free Software Foundation; version 3.
 
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
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 */
 
16
 
 
17
#include "printer/printersignalhandler.h"
 
18
 
 
19
#include <QDebug>
 
20
#include <QObject>
 
21
#include <QSignalSpy>
 
22
#include <QTest>
 
23
 
 
24
class TestSignalHandler : public QObject
 
25
{
 
26
    Q_OBJECT
 
27
private Q_SLOTS:
 
28
    void testEmptyCount()
 
29
    {
 
30
        PrinterSignalHandler handler(500);
 
31
        QSignalSpy modifiedSpy(&handler, SIGNAL(printerModified(const QString&)));
 
32
 
 
33
        for (int i = 0; i < 500; i++) {
 
34
            handler.onPrinterStateChanged("spam!", "ipp://bar/baz", "printer-a", 0, "none", true);
 
35
        }
 
36
 
 
37
        modifiedSpy.wait(1000);
 
38
        QCOMPARE(modifiedSpy.count(), 1);
 
39
    }
 
40
};
 
41
 
 
42
QTEST_GUILESS_MAIN(TestSignalHandler)
 
43
#include "tst_signalhandler.moc"
 
44