Skip to content

Commit b60c851

Browse files
committed
reformat code with clang-format 6.0.0
1 parent 7d396f0 commit b60c851

28 files changed

+129
-97
lines changed

agent.cpp

+24-18
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include <QApplication>
1212
#include <QWidget>
1313
#include <QtCore/QAbstractEventDispatcher>
14-
#include <QtCore/QThread>
1514
#include <QtCore/QDir>
15+
#include <QtCore/QThread>
1616

1717
#include "agent_qtmonkey_communication.hpp"
1818
#include "common.hpp"
@@ -24,11 +24,11 @@
2424
using qt_monkey_agent::Agent;
2525
using qt_monkey_agent::CustomEventAnalyzer;
2626
using qt_monkey_agent::PopulateScriptContext;
27+
using qt_monkey_agent::UserEventsAnalyzer;
2728
using qt_monkey_agent::Private::CommunicationAgentPart;
2829
using qt_monkey_agent::Private::PacketTypeForMonkey;
2930
using qt_monkey_agent::Private::Script;
3031
using qt_monkey_agent::Private::ScriptRunner;
31-
using qt_monkey_agent::UserEventsAnalyzer;
3232
using qt_monkey_common::Semaphore;
3333

3434
Agent *Agent::gAgent_ = nullptr;
@@ -57,6 +57,7 @@ class FuncEvent final : public QEvent
5757
{
5858
}
5959
void exec() { func_(); }
60+
6061
private:
6162
std::function<void()> func_;
6263
};
@@ -76,6 +77,7 @@ class EventsReciever final : public QObject
7677
static_cast<FuncEvent *>(event)->exec();
7778
}
7879
QEvent::Type eventType() const { return eventType_; }
80+
7981
private:
8082
std::atomic<QEvent::Type> eventType_;
8183
};
@@ -150,14 +152,15 @@ void removeObsolete(const QString &path, unsigned nSteps)
150152
}
151153
if (i > nSteps) {
152154
if (!QFile::remove(entryPath)) {
153-
qWarning("%s: can not remove '%s'\n", Q_FUNC_INFO, qPrintable(entryPath));
155+
qWarning("%s: can not remove '%s'\n", Q_FUNC_INFO,
156+
qPrintable(entryPath));
154157
}
155158
} else {
156159
++i;
157160
}
158161
}
159162
}
160-
}
163+
} // namespace
161164

162165
Agent::Agent(const QKeySequence &showObjectShortcut,
163166
std::list<CustomEventAnalyzer> customEventAnalyzers,
@@ -221,7 +224,8 @@ void Agent::onRunScriptCommand(const Script &script)
221224
QString errMsg;
222225
{
223226
CurrentScriptContext context(&sr, curScriptRunner_);
224-
DBGPRINT("%s: scrit file name %s", Q_FUNC_INFO, qPrintable(script.fileName()));
227+
DBGPRINT("%s: scrit file name %s", Q_FUNC_INFO,
228+
qPrintable(script.fileName()));
225229
QFileInfo fi(script.fileName());
226230
scriptBaseName_ = fi.baseName();
227231
sr.runScript(script, errMsg);
@@ -273,12 +277,14 @@ void Agent::scriptCheckPoint()
273277
if (nSteps > 0) {
274278
removeObsolete(savePath, static_cast<unsigned>(nSteps));
275279
savePath = QString("%1%2screenshot_%4_%3.png")
276-
.arg(savePath).arg(QDir::separator()).arg(lineno)
277-
.arg(scriptBaseName_);
280+
.arg(savePath)
281+
.arg(QDir::separator())
282+
.arg(lineno)
283+
.arg(scriptBaseName_);
278284
runCodeInGuiThreadSync([savePath]() -> QString {
279-
saveScreenShot(savePath);
280-
return QString();
281-
});
285+
saveScreenShot(savePath);
286+
return QString();
287+
});
282288
}
283289
}
284290

@@ -352,23 +358,23 @@ QString Agent::runCodeInGuiThreadSyncWithTimeout(std::function<QString()> func,
352358
});
353359

354360
for (unsigned int iter = 0; nowDialog == wasDialog; ++iter) {
355-
if (waitSem->tryAcquire(
356-
1, std::chrono::milliseconds(waitIntervalMsec))) {
361+
if (waitSem->tryAcquire(1,
362+
std::chrono::milliseconds(waitIntervalMsec))) {
357363
return *res;
358364
}
359365
if ((iter % 10) == 0) {
360366
nowDialog = nullptr;
361367
runCodeInGuiThreadSync([&nowDialog] {
362-
nowDialog = qApp->activeModalWidget();
363-
return QString();
364-
});
365-
DBGPRINT("%s: wasDialog %p, nowDialog %p, attempt %d", Q_FUNC_INFO, wasDialog, nowDialog, attempt);
368+
nowDialog = qApp->activeModalWidget();
369+
return QString();
370+
});
371+
DBGPRINT("%s: wasDialog %p, nowDialog %p, attempt %d", Q_FUNC_INFO,
372+
wasDialog, nowDialog, attempt);
366373
}
367374
}
368375

369376
for (; attempt < N; ++attempt) {
370-
if (waitSem->tryAcquire(
371-
1, std::chrono::milliseconds(waitIntervalMsec)))
377+
if (waitSem->tryAcquire(1, std::chrono::milliseconds(waitIntervalMsec)))
372378
return *res;
373379
qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
374380
}

agent.hpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace Private
2626
class Script;
2727
class ScriptRunner;
2828
class MacMenuActionWatcher;
29-
}
29+
} // namespace Private
3030
/**
3131
* This class is used as agent inside user's program
3232
* to catch/apply Qt events
@@ -51,7 +51,8 @@ class Agent
5151
*/
5252
explicit Agent(const QKeySequence &showObjectShortcut
5353
= QKeySequence(Qt::Key_F12 | Qt::SHIFT),
54-
std::list<CustomEventAnalyzer> customEventAnalyzers = std::list<CustomEventAnalyzer>(),
54+
std::list<CustomEventAnalyzer> customEventAnalyzers
55+
= std::list<CustomEventAnalyzer>(),
5556
PopulateScriptContext = {});
5657
~Agent();
5758
Agent(const Agent &) = delete;
@@ -98,6 +99,7 @@ private slots:
9899
global_ = cur;
99100
}
100101
~CurrentScriptContext() { global_ = nullptr; }
102+
101103
private:
102104
Private::ScriptRunner *&global_;
103105
};
@@ -118,4 +120,4 @@ private slots:
118120

119121
void customEvent(QEvent *event) override;
120122
};
121-
}
123+
} // namespace qt_monkey_agent

agent_qtmonkey_communication.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static std::pair<uint32_t, QString> extractFromPacket(QByteArray &buf)
9292
buf.remove(0, headerSize + packetSize);
9393
return res;
9494
}
95-
}
95+
} // namespace
9696

9797
CommunicationMonkeyPart::CommunicationMonkeyPart(QObject *parent)
9898
: QObject(parent), controlSock_{new QTcpServer}

agent_qtmonkey_communication.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,5 @@ private slots:
105105

106106
void timerEvent(QTimerEvent *) override;
107107
};
108-
}
109-
}
108+
} // namespace Private
109+
} // namespace qt_monkey_agent

common.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ inline std::ostream &operator<<(std::ostream &os, const QByteArray &str)
3131
std::copy(str.begin(), str.end(), std::ostreambuf_iterator<char>(os));
3232
return os;
3333
}
34-
}
34+
} // namespace qt_monkey_common

custom_event_analyzer.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ struct EventInfo final {
3838
* @tparam const EventInfo & information about event
3939
*/
4040
using CustomEventAnalyzer = std::function<QString(const EventInfo &)>;
41-
}
41+
} // namespace qt_monkey_agent

custom_script_extension.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ namespace qt_monkey_agent
1212
* @tparam QScriptEngine & script engine which is used to run monkey script
1313
*/
1414
using PopulateScriptContext = std::function<void(QScriptEngine &)>;
15-
}
15+
} // namespace qt_monkey_agent

qtmonkey.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030

3131
using qt_monkey_agent::Private::PacketTypeForAgent;
3232
using qt_monkey_agent::Private::Script;
33-
using qt_monkey_app::Private::StdinReader;
3433
using qt_monkey_app::QtMonkey;
34+
using qt_monkey_app::Private::StdinReader;
3535
using qt_monkey_common::operator<<;
3636

3737
namespace
@@ -198,7 +198,7 @@ void ReadStdinThread::stop()
198198
throw std::runtime_error("close(stdin) failure: " + std::to_string(errno));
199199
}
200200
#endif
201-
} // namespace {
201+
} // namespace
202202

203203
QtMonkey::QtMonkey(bool exitOnScriptError)
204204
: exitOnScriptError_(exitOnScriptError)

qtmonkey.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class StdinReader
3232
void emitError(const QString &msg) { emit error(msg); }
3333
void emitDataReady() { emit dataReady(); }
3434
};
35-
}
35+
} // namespace Private
3636
//! main class to control agent
3737
class QtMonkey
3838
#ifndef Q_MOC_RUN
@@ -81,4 +81,4 @@ private slots:
8181

8282
void setScriptRunningState(bool val);
8383
};
84-
}
84+
} // namespace qt_monkey_app

qtmonkey_app.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static inline std::ostream &operator<<(std::ostream &os, const QString &str)
3434
os << str.toLocal8Bit();
3535
return os;
3636
}
37-
}
37+
} // namespace
3838

3939
#if QT_VERSION >= 0x050000
4040
static void msgHandler(QtMsgType type, const QMessageLogContext &,
@@ -120,16 +120,20 @@ int main(int argc, char *argv[])
120120
++i;
121121
encoding = argv[i];
122122
} else if (std::strcmp(argv[i], "--trace-script-exec") == 0) {
123-
codeToRunBeforeAll += QStringLiteral("Test.setTraceEnabled(true);\n");
123+
codeToRunBeforeAll
124+
+= QStringLiteral("Test.setTraceEnabled(true);\n");
124125
} else if (std::strcmp(argv[i], "--save-screenshots") == 0) {
125-
int nSteps = -1 ;
126+
int nSteps = -1;
126127
if ((i + 2) >= argc || sscanf(argv[i + 2], "%d", &nSteps) != 1) {
127128
std::cerr << qPrintable(usage());
128129
return EXIT_FAILURE;
129130
}
130131
const QString path = argv[i + 1];
131132
i += 2;
132-
codeToRunBeforeAll += QStringLiteral("Test.saveScreenshots(\"%1\", %2);\n").arg(path).arg(nSteps);
133+
codeToRunBeforeAll
134+
+= QStringLiteral("Test.saveScreenshots(\"%1\", %2);\n")
135+
.arg(path)
136+
.arg(nSteps);
133137
} else if (std::strcmp(argv[i], "--help") == 0
134138
|| std::strcmp(argv[i], "-h") == 0) {
135139
std::cout << qPrintable(usage());

qtmonkey_app_api.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ namespace
1515
struct QStringJsonTrait final {
1616
explicit QStringJsonTrait(const QString &s) : str_(s) {}
1717
std::string to_json() const { return str_.toUtf8().data(); }
18+
1819
private:
1920
const QString &str_;
2021
};
21-
}
22+
} // namespace
2223

2324
std::string createPacketFromUserAppEvent(const QString &scriptLines)
2425
{
@@ -149,4 +150,4 @@ void parseOutputFromGui(
149150
}
150151
}
151152
}
152-
}
153+
} // namespace qt_monkey_app

qtmonkey_app_api.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ void parseOutputFromMonkeyApp(
3232
const std::function<void()> &onScriptEnd,
3333
const std::function<void(QString)> &onScriptLog,
3434
const std::function<void(QString)> &onParseError);
35-
}
35+
} // namespace qt_monkey_app

script.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ class Script final
2929
const QString &fileName() const { return fileName_; }
3030
bool runAfterAppStart() const { return runAfterStart_; }
3131
void setRunAfterAppStart(bool val) { runAfterStart_ = val; }
32+
3233
private:
3334
QString fileName_;
3435
int lineno_ = 1;
3536
QString code_;
3637
bool runAfterStart_ = false;
3738
};
38-
}
39-
}
39+
} // namespace Private
40+
} // namespace qt_monkey_agent
4041

4142
Q_DECLARE_METATYPE(qt_monkey_agent::Private::Script);

script_api.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ static QString activateItemInGuiThread(qt_monkey_agent::Agent &agent,
467467
}
468468
}
469469

470-
} // namespace {
470+
} // namespace
471471

472472
void qt_monkey_agent::clickInGuiThread(qt_monkey_agent::Agent &agent,
473473
const QPoint &posA, QWidget &wA,
@@ -841,7 +841,8 @@ void ScriptAPI::expandItemInTreeView(const QString &treeName,
841841
}
842842
}
843843

844-
void ScriptAPI::keyClick(const QString &widgetName, const QString &keyseqStr, const QString &real_syms)
844+
void ScriptAPI::keyClick(const QString &widgetName, const QString &keyseqStr,
845+
const QString &real_syms)
845846
{
846847
Step step(agent_);
847848

@@ -875,8 +876,8 @@ void ScriptAPI::keyClick(const QString &widgetName, const QString &keyseqStr, co
875876
DBGPRINT("%s: key(%s) click for widget", Q_FUNC_INFO,
876877
qPrintable(keySeq.toString()));
877878
auto ascii_key = static_cast<Qt::Key>(keySeq[keySeq.count() - 1]);
878-
QTest::sendKeyEvent(QTest::KeyAction::Click, w, ascii_key, real_syms,
879-
modifiers);
879+
QTest::sendKeyEvent(QTest::KeyAction::Click, w, ascii_key,
880+
real_syms, modifiers);
880881
DBGPRINT("%s: key(%s) click for widget DONE", Q_FUNC_INFO,
881882
qPrintable(keySeq.toString()));
882883
return QString();
@@ -1079,7 +1080,7 @@ void ScriptAPI::AssertEqual(const QString &s1, const QString &s2)
10791080
if (s1 != s2) {
10801081
agent_.throwScriptError(
10811082
QStringLiteral("Assertion failed: Expect \"%1\", Actual \"%2\"")
1082-
.arg(s1, s2));
1083+
.arg(s1, s2));
10831084
}
10841085
}
10851086

@@ -1111,7 +1112,7 @@ void ScriptAPI::quitApp()
11111112
{
11121113
Step step(agent_);
11131114
agent_.runCodeInGuiThreadSync([] {
1114-
QCoreApplication::exit(0);
1115-
return QString();
1116-
});
1115+
QCoreApplication::exit(0);
1116+
return QString();
1117+
});
11171118
}

script_api.hpp

+7-5
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ class ScriptAPI
3939
explicit ScriptAPI(Agent &agent, QObject *parent = nullptr);
4040
public slots:
4141
/**
42-
* send message to log
43-
* @param msgStr string with message
44-
*/
42+
* send message to log
43+
* @param msgStr string with message
44+
*/
4545
void log(const QString &msgStr);
4646

4747
//@{
@@ -63,7 +63,8 @@ public slots:
6363
* for example Ctrl+P
6464
*/
6565
void keyClick(const QString &widgetName, const QString &ascii_keyseq);
66-
void keyClick(const QString &widgetName, const QString &ascii_keyseq, const QString &real_syms);
66+
void keyClick(const QString &widgetName, const QString &ascii_keyseq,
67+
const QString &real_syms);
6768
//@{
6869
/**
6970
* Group of functions to emulate activate item (menu item, list item etc)
@@ -157,6 +158,7 @@ public slots:
157158

158159
//! Call QCoreApplication::exit(0)
159160
void quitApp();
161+
160162
private:
161163
Agent &agent_;
162164
int waitWidgetAppearTimeoutSec_ = 30;
@@ -168,4 +170,4 @@ public slots:
168170
bool isDblClick,
169171
Qt::MatchFlag searchItemFlag = Qt::MatchStartsWith);
170172
};
171-
}
173+
} // namespace qt_monkey_agent

script_runner.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
#include "script.hpp"
77
#include "script_api.hpp"
88

9-
using qt_monkey_agent::Private::ScriptRunner;
10-
using qt_monkey_agent::Private::Script;
11-
using qt_monkey_agent::ScriptAPI;
129
using qt_monkey_agent::PopulateScriptContext;
10+
using qt_monkey_agent::ScriptAPI;
11+
using qt_monkey_agent::Private::Script;
12+
using qt_monkey_agent::Private::ScriptRunner;
1313

1414
static int extractLineNumFromBacktraceLine(const QString &line)
1515
{

0 commit comments

Comments
 (0)