Changeset View
Changeset View
Standalone View
Standalone View
autotests/libs/fakesession.cpp
Show All 17 Lines | |||||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "fakesession.h" | 20 | #include "fakesession.h" | ||
21 | #include "session_p.h" | 21 | #include "session_p.h" | ||
22 | #include "job.h" | 22 | #include "job.h" | ||
23 | #include "private/protocol_p.h" | 23 | #include "private/protocol_p.h" | ||
24 | 24 | | |||
25 | #include <QCoreApplication> | 25 | #include <QCoreApplication> | ||
26 | #include <QTimer> | ||||
26 | 27 | | |||
27 | class FakeSessionPrivate : public SessionPrivate | 28 | class FakeSessionPrivate : public SessionPrivate | ||
28 | { | 29 | { | ||
29 | public: | 30 | public: | ||
30 | FakeSessionPrivate(FakeSession *parent, FakeSession::Mode mode) | 31 | FakeSessionPrivate(FakeSession *parent, FakeSession::Mode mode) | ||
31 | : SessionPrivate(parent), q_ptr(parent), m_mode(mode) | 32 | : SessionPrivate(parent), q_ptr(parent), m_mode(mode) | ||
32 | { | 33 | { | ||
33 | protocolVersion = Protocol::version(); | 34 | protocolVersion = Protocol::version(); | ||
Show All 19 Lines | |||||
53 | 54 | | |||
54 | /* reimp */ | 55 | /* reimp */ | ||
55 | void reconnect() override | 56 | void reconnect() override | ||
56 | { | 57 | { | ||
57 | if (m_mode == FakeSession::EndJobsImmediately) { | 58 | if (m_mode == FakeSession::EndJobsImmediately) { | ||
58 | return; | 59 | return; | ||
59 | } | 60 | } | ||
60 | 61 | | |||
62 | // Like Session does: delay the actual disconnect+reconnect | ||||
63 | QTimer::singleShot(10, q_ptr, [&]() { | ||||
64 | socketDisconnected(); | ||||
61 | Q_EMIT q_ptr->reconnected(); | 65 | Q_EMIT q_ptr->reconnected(); | ||
62 | connected = true; | 66 | connected = true; | ||
63 | startNext(); | 67 | startNext(); | ||
68 | }); | ||||
64 | } | 69 | } | ||
65 | 70 | | |||
66 | /* reimp */ | 71 | /* reimp */ | ||
67 | void addJob(Job *job) override | 72 | void addJob(Job *job) override | ||
68 | { | 73 | { | ||
69 | Q_EMIT q_ptr->jobAdded(job); | 74 | Q_EMIT q_ptr->jobAdded(job); | ||
70 | // Return immediately so that no actual communication happens with the server and | 75 | // Return immediately so that no actual communication happens with the server and | ||
71 | // the started jobs are completed. | 76 | // the started jobs are completed. | ||
Show All 21 Lines |