2 * Copyright 2013 Canonical Ltd.
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * version 3 along with this program. If not, see
15 * <http://www.gnu.org/licenses/>
17 * Authored by: Michael Terry <michael.terry@canonical.com>
20#include "SessionManager.h"
21#include <QtTest/QSignalSpy>
22#include <QtTest/QTest>
25// These tests assume the following behavior from our mock logind server:
26// * IsActive will return false
27// * Lock() will emit an ActiveChanged(true) signal
29// This should lead to the following behavior from our SessionManager plugin:
31// * Becomes inactive once it connects to logind and sees IsActive result
32// * Becomes active once Lock() is called (which isn't really sensible, but
35class SessionManagerTest : public QObject
41 void waitForChange(SessionManager *session)
43 // Wait 5 seconds for initial activeChanged signal
44 QSignalSpy spy(session, SIGNAL(activeChanged()));
46 while (spy.count() == 0 && i++ < 50)
48 QCOMPARE(spy.count(), 1);
51 void testAssumeActive()
53 // Test that active() starts as true before we connect to service
54 SessionManager session;
55 QCOMPARE(session.active(), true);
60 // Test that lock() doesn't crash if used before we connect to service
61 // (i.e. just test that we're not being stupid about pointers)
62 SessionManager session;
66 void testInitialSignal()
68 // Test that we get notified of change once we connect to service
69 SessionManager session;
70 waitForChange(&session);
71 QCOMPARE(session.active(), false);
76 // Test that lock() gets called correctly and that we listen for
77 // the activeChanged signal too.
78 SessionManager session;
79 waitForChange(&session);
81 waitForChange(&session);
82 QCOMPARE(session.active(), true);
86QTEST_MAIN(SessionManagerTest)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list