| 1 | /* |
| 2 | * Copyright (C) 2013 Canonical Ltd. |
| 3 | * |
| 4 | * Contact: Alberto Mardegan <[email protected]> |
| 5 | * |
| 6 | * This file is part of lomiri-online-accounts-service |
| 7 | * |
| 8 | * This program is free software: you can redistribute it and/or modify it |
| 9 | * under the terms of the GNU General Public License version 3, as published |
| 10 | * by the Free Software Foundation. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranties of |
| 14 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
| 15 | * PURPOSE. See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along |
| 18 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #include "inactivity-timer.h"cxx . . $ `<file>/online-accounts-service/src/inactivity-timer.h`/ |
| 22 | |
| 23 | #include <QDebug> |
| 24 | #include <QSignalSpy> |
| 25 | #include <QTest> |
| 26 | |
| 27 | using namespace OnlineAccountsUi; |
| 28 | |
| 29 | class Servicecxx . . $ Service#: public QObjectcxx . . $ QObject# |
| 30 | { |
| 31 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 32 | Q_PROPERTYcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:104:9`!(bool isIdle READ isIdle NOTIFY isIdleChanged) |
| 33 | |
| 34 | public: |
| 35 | Servicecxx . . $ Service#Service(49f6e7a06ebc5aa8).(): QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(), m_isIdlecxx . . $ Service#m_isIdle.(true) {} |
| 36 | |
| 37 | bool isIdlecxx . . $ Service#isIdle(50ce9a9e25b4a850).() const { return m_isIdlecxx . . $ Service#m_isIdle.; } |
| 38 | |
| 39 | void setIdlecxx . . $ Service#setIdle(b45ddcbc8423892c).(bool idle) { |
| 40 | if (idle == m_isIdlecxx . . $ Service#m_isIdle.) return; |
| 41 | m_isIdlecxx . . $ Service#m_isIdle. = idle; |
| 42 | Q_EMITcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:95:10`! isIdleChangedcxx . . $ Service#isIdleChanged(49f6e7a06ebc5aa8).(); |
| 43 | } |
| 44 | |
| 45 | Q_SIGNALScxx . . $ `<external>/1208926524888476972/qobjectdefs.h:93:10`!: |
| 46 | void isIdleChangedcxx . . $ Service#isIdleChanged(49f6e7a06ebc5aa8).(); |
| 47 | |
| 48 | private: |
| 49 | bool m_isIdlecxx . . $ Service#m_isIdle.; |
| 50 | }; |
| 51 | |
| 52 | class InactivityTimerTestcxx . . $ InactivityTimerTest#: public QObjectcxx . . $ QObject# |
| 53 | { |
| 54 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 55 | |
| 56 | public: |
| 57 | InactivityTimerTestcxx . . $ InactivityTimerTest#InactivityTimerTest(49f6e7a06ebc5aa8).(); |
| 58 | |
| 59 | private Q_SLOTScxx . . $ `<external>/1208926524888476972/qobjectdefs.h:92:10`!: |
| 60 | void testAlwaysIdlecxx . . $ InactivityTimerTest#testAlwaysIdle(49f6e7a06ebc5aa8).(); |
| 61 | void testBecomeIdlecxx . . $ InactivityTimerTest#testBecomeIdle(49f6e7a06ebc5aa8).(); |
| 62 | void testManyServicescxx . . $ InactivityTimerTest#testManyServices(49f6e7a06ebc5aa8).(); |
| 63 | }; |
| 64 | |
| 65 | InactivityTimerTestcxx . . $ InactivityTimerTest#::InactivityTimerTestcxx . . $ InactivityTimerTest#InactivityTimerTest(49f6e7a06ebc5aa8).(): |
| 66 | QObjectcxx . . $ QObject#QObject(749de1b6ae65bddd).(0) |
| 67 | { |
| 68 | } |
| 69 | |
| 70 | void InactivityTimerTestcxx . . $ InactivityTimerTest#::testAlwaysIdlecxx . . $ InactivityTimerTest#testAlwaysIdle(49f6e7a06ebc5aa8).() |
| 71 | { |
| 72 | InactivityTimercxx . . $ OnlineAccountsUi/InactivityTimer# timercxx . . $ OnlineAccountsUi/InactivityTimer#InactivityTimer(1ee1e1ac455d3e6e).(10); |
| 73 | QSignalSpycxx . . $ QSignalSpy# timeoutcxx . . $ QSignalSpy#QSignalSpy(593025bf41bda872).(&timer, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(timeout())); |
| 74 | |
| 75 | Servicecxx . . $ Service# servicecxx . . $ Service#Service(49f6e7a06ebc5aa8).; |
| 76 | timer.watchObjectcxx . . $ OnlineAccountsUi/InactivityTimer#watchObject(749de1b6ae65bddd).(&service); |
| 77 | |
| 78 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(timeout.wait(100)); |
| 79 | } |
| 80 | |
| 81 | void InactivityTimerTestcxx . . $ InactivityTimerTest#::testBecomeIdlecxx . . $ InactivityTimerTest#testBecomeIdle(49f6e7a06ebc5aa8).() |
| 82 | { |
| 83 | InactivityTimercxx . . $ OnlineAccountsUi/InactivityTimer# timercxx . . $ OnlineAccountsUi/InactivityTimer#InactivityTimer(1ee1e1ac455d3e6e).(10); |
| 84 | QSignalSpycxx . . $ QSignalSpy# timeoutcxx . . $ QSignalSpy#QSignalSpy(593025bf41bda872).(&timer, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(timeout())); |
| 85 | |
| 86 | Servicecxx . . $ Service# servicecxx . . $ Service#Service(49f6e7a06ebc5aa8).; |
| 87 | service.setIdlecxx . . $ Service#setIdle(b45ddcbc8423892c).(false); |
| 88 | timer.watchObjectcxx . . $ OnlineAccountsUi/InactivityTimer#watchObject(749de1b6ae65bddd).(&service); |
| 89 | |
| 90 | /* No signal should be emitted, as the service is not idle */ |
| 91 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(!timeout.wait(100)); |
| 92 | |
| 93 | service.setIdlecxx . . $ Service#setIdle(b45ddcbc8423892c).(true); |
| 94 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(timeout.wait(100)); |
| 95 | } |
| 96 | |
| 97 | void InactivityTimerTestcxx . . $ InactivityTimerTest#::testManyServicescxx . . $ InactivityTimerTest#testManyServices(49f6e7a06ebc5aa8).() |
| 98 | { |
| 99 | InactivityTimercxx . . $ OnlineAccountsUi/InactivityTimer# timercxx . . $ OnlineAccountsUi/InactivityTimer#InactivityTimer(1ee1e1ac455d3e6e).(50); |
| 100 | QSignalSpycxx . . $ QSignalSpy# timeoutcxx . . $ QSignalSpy#QSignalSpy(593025bf41bda872).(&timer, SIGNALcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:271:10`!(timeout())); |
| 101 | |
| 102 | Servicecxx . . $ Service# service1cxx . . $ Service#Service(49f6e7a06ebc5aa8).; |
| 103 | timer.watchObjectcxx . . $ OnlineAccountsUi/InactivityTimer#watchObject(749de1b6ae65bddd).(&service1); |
| 104 | |
| 105 | Servicecxx . . $ Service# service2cxx . . $ Service#Service(49f6e7a06ebc5aa8).; |
| 106 | timer.watchObjectcxx . . $ OnlineAccountsUi/InactivityTimer#watchObject(749de1b6ae65bddd).(&service2); |
| 107 | |
| 108 | Servicecxx . . $ Service# service3cxx . . $ Service#Service(49f6e7a06ebc5aa8).; |
| 109 | service3.setIdlecxx . . $ Service#setIdle(b45ddcbc8423892c).(false); |
| 110 | timer.watchObjectcxx . . $ OnlineAccountsUi/InactivityTimer#watchObject(749de1b6ae65bddd).(&service3); |
| 111 | |
| 112 | /* No signal should be emitted, as service3 is not idle */ |
| 113 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(!timeout.wait(100)); |
| 114 | |
| 115 | /* Now set it is as idle, but soon afterwards set service1 as busy */ |
| 116 | service3.setIdlecxx . . $ Service#setIdle(b45ddcbc8423892c).(true); |
| 117 | QTestcxx . . $ QTest/::qWaitcxx . . $ QTest/qWait(d4f767463ce0a6b3).(10); |
| 118 | service1.setIdlecxx . . $ Service#setIdle(b45ddcbc8423892c).(false); |
| 119 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(!timeout.wait(100)); |
| 120 | |
| 121 | service1.setIdlecxx . . $ Service#setIdle(b45ddcbc8423892c).(true); |
| 122 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(timeout.wait(100)); |
| 123 | } |
| 124 | |
| 125 | QTEST_MAINcxx . . $ `<external>/4204159469433502174/qtest.h:508:9`!(InactivityTimerTest); |
| 126 | |
| 127 | #include "tst_inactivity_timer.moc"cxx . . $ `<file>/build/tests/online-accounts-service/tst_inactivity_timer/tst_inactivity_timer_autogen/include/tst_inactivity_timer.moc`/ |