Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F112046
matrix-sdk-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
matrix-sdk-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
<memory>
#include
<QtTest>
#include
<QSignalSpy>
#include
<matrix-sdk.hpp>
#include
<matrix-device-list.hpp>
#include
<matrix-device.hpp>
#include
<matrix-promise.hpp>
#include
"test-model.hpp"
#include
"test-utils.hpp"
using
namespace
Kazv
;
class
MatrixSdkTest
:
public
QObject
{
Q_OBJECT
private
Q_SLOTS
:
void
testDevicesOfUser
();
void
testSetDeviceTrustLevel
();
};
void
MatrixSdkTest::testDevicesOfUser
()
{
auto
model
=
makeTestModel
();
std
::
unique_ptr
<
MatrixSdk
>
sdk
{
new
MatrixSdk
(
model
,
/* testing = */
true
)};
auto
devices
=
toUniquePtr
(
sdk
->
devicesOfUser
(
QStringLiteral
(
"@test1:test1.org"
)));
QVERIFY
(
devices
->
count
()
==
2
);
auto
dev
=
toUniquePtr
(
devices
->
at
(
0
));
QVERIFY
(
dev
->
deviceId
()
==
"device1"
);
QVERIFY
(
dev
->
trustLevel
()
==
"unseen"
);
}
void
MatrixSdkTest::testSetDeviceTrustLevel
()
{
auto
model
=
makeTestModel
();
std
::
unique_ptr
<
MatrixSdk
>
sdk
{
new
MatrixSdk
(
model
,
/* testing = */
true
)};
sdk
->
startThread
();
auto
promise
=
toUniquePtr
(
sdk
->
setDeviceTrustLevel
(
QStringLiteral
(
"@test1:test1.org"
),
QStringLiteral
(
"device1"
),
QStringLiteral
(
"verified"
)
)
);
auto
spy
=
QSignalSpy
(
promise
.
get
(),
&
MatrixPromise
::
succeeded
);
spy
.
wait
();
auto
devices
=
toUniquePtr
(
sdk
->
devicesOfUser
(
QStringLiteral
(
"@test1:test1.org"
)));
QVERIFY
(
devices
->
count
()
==
2
);
auto
dev
=
toUniquePtr
(
devices
->
at
(
0
));
QVERIFY
(
dev
->
deviceId
()
==
"device1"
);
QTRY_VERIFY
(
dev
->
trustLevel
()
==
"verified"
);
// wait for the change to propagate to this thread
}
QTEST_MAIN
(
MatrixSdkTest
)
#include
"matrix-sdk-test.moc"
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Fri, Nov 22, 10:17 PM (1 d, 17 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38730
Default Alt Text
matrix-sdk-test.cpp (1 KB)
Attached To
Mode
rK kazv
Attached
Detach File
Event Timeline
Log In to Comment