File indexing completed on 2024-06-09 05:06:59
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Daniel Vrátil <dvratil@redhat.com> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-or-later 0005 * 0006 */ 0007 0008 #pragma once 0009 0010 #include "datastream_p_p.h" 0011 #include <QRecursiveMutex> 0012 #include <QThread> 0013 0014 #include "fakeakonadiserver.h" 0015 0016 class QLocalSocket; 0017 0018 namespace Akonadi 0019 { 0020 namespace Server 0021 { 0022 class FakeClient : public QThread 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 explicit FakeClient(QObject *parent = nullptr); 0028 ~FakeClient() override; 0029 0030 void setScenarios(const TestScenario::List &scenarios); 0031 0032 bool isScenarioDone() const; 0033 0034 void start(); 0035 void startScenario(); 0036 void cleanup(); 0037 0038 private Q_SLOTS: 0039 void do_connectToServer(); 0040 void do_startScenario(); 0041 0042 bool dataAvailable(); 0043 void readServerPart(); 0044 void writeClientPart(); 0045 void connectionLost(); 0046 0047 private: 0048 mutable QRecursiveMutex mMutex; 0049 0050 TestScenario::List mScenarios; 0051 QLocalSocket *mSocket = nullptr; 0052 Protocol::DataStream mStream; 0053 }; 0054 } 0055 }