Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2700034
tst_StickerPicker.qml
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
tst_StickerPicker.qml
View Options
/*
* This file is part of kazv.
* SPDX-FileCopyrightText: 2024 tusooa <tusooa@kazv.moe>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import
QtQuick
2.15
import
QtQuick
.
Layouts
1.15
import
QtTest
1.0
import
'../../contents/ui'
as
Kazv
import
'test-helpers.js'
as
Helpers
import
'test-helpers'
as
TestHelpers
import
moe
.
kazv
.
mxc
.
kazv
0.0
as
MK
Item
{
id: item
width:
800
height:
600
property
var
l10n:
Helpers
.
fluentMock
property
var
matrixSdk:
TestHelpers
.
MatrixSdkMock
{}
property
var
sdkVars:
({})
function
makeSticker
(
sticker
)
{
return
{
type:
'm.sticker'
,
content:
{
body:
sticker
.
body
,
url:
sticker
.
mxcUri
,
info:
sticker
.
info
,
},
};
}
property
list
<
ListModel
>
stickerPacks:
[
ListModel
{
id: stickerPack0
ListElement
{
shortCode:
'some'
body:
'some'
mxcUri:
'mxc://example.org/some'
makeEventJson:
()
=>
makeSticker
(
stickerPack0
.
get
(
0
))
}
ListElement
{
shortCode:
'some1'
body:
'some1'
mxcUri:
'mxc://example.org/some1'
makeEventJson:
()
=>
makeSticker
(
stickerPack0
.
get
(
1
))
}
function
at
(
index
)
{
return
stickerPack0
.
get
(
index
);
}
}
]
Kazv
.
StickerPicker
{
id: stickerPicker
property
var
_sendMessageRequested
:
0
property
var
_lastEventJson
:
undefined
stickerPackList:
ListModel
{
id: stickerPackListModel
ListElement
{
}
function
at
(
index
)
{
return
stickerPacks
[
index
];
}
}
onSendMessageRequested:
(
eventJson
)
=>
{
++
stickerPicker
.
_sendMessageRequested
;
stickerPicker
.
_lastEventJson
=
eventJson
;
}
}
TestCase
{
id: stickerPickerTest
name:
'StickerPickerTest'
when:
windowShown
function
cleanup
()
{
stickerPicker
.
_sendMessageRequested
=
0
;
stickerPicker
.
_lastEventJson
=
undefined
;
}
function
test_stickerPicker
()
{
verify
(
findChild
(
stickerPicker
,
'stickerPack0'
));
verify
(
findChild
(
stickerPicker
,
'sticker0'
));
verify
(
findChild
(
stickerPicker
,
'sticker1'
));
const
stickerButton
=
findChild
(
stickerPicker
,
'sticker1'
);
mouseClick
(
stickerButton
);
tryVerify
(()
=>
stickerPicker
.
_sendMessageRequested
,
1000
);
verify
(
Helpers
.
deepEqual
(
stickerPicker
.
_lastEventJson
,
makeSticker
(
stickerPack0
.
get
(
1
))));
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jul 18, 12:08 PM (1 d, 2 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
246103
Default Alt Text
tst_StickerPicker.qml (2 KB)
Attached To
Mode
rK kazv
Attached
Detach File
Event Timeline
Log In to Comment