Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F113180
qt-job-handler-test.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
qt-job-handler-test.cpp
View Options
/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2023 tusooa <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#include
<kazv-defs.hpp>
#include
<basejob.hpp>
#include
"tests.hpp"
#include
"qt-job-handler-test.hpp"
#include
"qt-job-handler.hpp"
using
namespace
Kazv
;
void
QtJobHandlerTest::testBaseJob
()
{
BaseJob
job
(
TEST_SERVER_URL
,
"/.well-known/matrix/client"
,
BaseJob
::
Get
{},
"TestJob"
);
QEventLoop
loop
;
auto
h
=
new
QtJobHandler
(
&
loop
);
h
->
submit
(
job
.
withData
(
json
{{
"test"
,
"bar"
}}),
[
&
loop
](
auto
r
)
{
if
(
r
.
statusCode
==
200
)
{
QVERIFY
(
isBodyJson
(
r
.
body
)
);
json
j
=
r
.
jsonBody
().
get
();
qDebug
()
<<
QString
::
fromStdString
(
j
.
dump
());
try
{
QVERIFY
(
(
j
.
at
(
"m.homeserver"
).
at
(
"base_url"
)
!=
""
)
);
}
catch
(...)
{
QFAIL
(
"thrown"
);
}
QVERIFY
(
r
.
dataStr
(
"test"
)
==
"bar"
);
}
loop
.
quit
();
});
loop
.
exec
();
}
void
QtJobHandlerTest::testSetTimeout
()
{
QEventLoop
loop
;
auto
h
=
new
QtJobHandler
(
&
loop
);
std
::
vector
<
int
>
v
;
h
->
setTimeout
(
[
&
v
,
&
loop
]
{
v
.
push_back
(
500
);
loop
.
quit
();
},
500
);
h
->
setTimeout
(
[
&
v
]
{
v
.
push_back
(
100
);
},
100
);
loop
.
exec
();
QVERIFY
(
v
.
size
()
==
2
);
QVERIFY
(
v
[
0
]
==
100
);
QVERIFY
(
v
[
1
]
==
500
);
}
QTEST_MAIN
(
QtJobHandlerTest
)
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sun, Nov 24, 3:46 PM (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39445
Default Alt Text
qt-job-handler-test.cpp (1 KB)
Attached To
Mode
rK kazv
Attached
Detach File
Event Timeline
Log In to Comment