Changeset View
Changeset View
Standalone View
Standalone View
src/tests/quick-tests/tst_StickerPicker.qml
| Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | ListModel { | ||||
| body: 'some1' | body: 'some1' | ||||
| mxcUri: 'mxc://example.org/some1' | mxcUri: 'mxc://example.org/some1' | ||||
| makeEventJson: () => makeSticker(stickerPack0.get(1)) | makeEventJson: () => makeSticker(stickerPack0.get(1)) | ||||
| } | } | ||||
| function at(index) { | function at(index) { | ||||
| return stickerPack0.get(index); | return stickerPack0.get(index); | ||||
| } | } | ||||
| }, | |||||
| ListModel { | |||||
| id: stickerPack1 | |||||
| ListElement { | |||||
| shortCode: 'some2' | |||||
| body: 'some2' | |||||
| mxcUri: 'mxc://example.org/some2' | |||||
| makeEventJson: () => makeSticker(stickerPack1.get(0)) | |||||
| } | } | ||||
| ListElement { | |||||
| shortCode: 'some3' | |||||
| body: 'some3' | |||||
| mxcUri: 'mxc://example.org/some3' | |||||
| makeEventJson: () => makeSticker(stickerPack1.get(1)) | |||||
| } | |||||
| function at(index) { | |||||
| return stickerPack1.get(index); | |||||
| } | |||||
| } | |||||
| ] | ] | ||||
| SignalSpy { | SignalSpy { | ||||
| id: sendMessageRequestedSpy | id: sendMessageRequestedSpy | ||||
| signalName: 'sendMessageRequested' | signalName: 'sendMessageRequested' | ||||
| } | } | ||||
| Kazv.StickerPicker { | Kazv.StickerPicker { | ||||
| id: stickerPicker | id: stickerPicker | ||||
| stickerPackList: ListModel { | stickerPackList: ListModel { | ||||
| id: stickerPackListModel | id: stickerPackListModel | ||||
| ListElement { | ListElement { | ||||
| } | } | ||||
| ListElement { | |||||
| } | |||||
| function at(index) { | function at(index) { | ||||
| return stickerPacks[index]; | return stickerPacks[index]; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| TestCase { | TestCase { | ||||
| id: stickerPickerTest | id: stickerPickerTest | ||||
| name: 'StickerPickerTest' | name: 'StickerPickerTest' | ||||
| when: windowShown | when: windowShown | ||||
| function init() { | function init() { | ||||
| sendMessageRequestedSpy.clear(); | sendMessageRequestedSpy.clear(); | ||||
| sendMessageRequestedSpy.target = stickerPicker; | sendMessageRequestedSpy.target = stickerPicker; | ||||
| } | } | ||||
| function test_stickerPicker() { | function test_stickerPicker() { | ||||
| verify(findChild(stickerPicker, 'stickerPack0')); | verify(findChild(stickerPicker, 'stickerPack0')); | ||||
| verify(findChild(stickerPicker, 'stickerPack1')); | |||||
| verify(findChild(stickerPicker, 'sticker0')); | verify(findChild(stickerPicker, 'sticker0')); | ||||
| verify(findChild(stickerPicker, 'sticker1')); | verify(findChild(stickerPicker, 'sticker1')); | ||||
| const stickerButton = findChild(stickerPicker, 'sticker1'); | const stickerButton = findChild(stickerPicker, 'sticker1'); | ||||
| mouseClick(stickerButton); | mouseClick(stickerButton); | ||||
| tryVerify(() => sendMessageRequestedSpy.count, 1000); | tryVerify(() => sendMessageRequestedSpy.count === 1, 1000); | ||||
| verify(Helpers.deepEqual(sendMessageRequestedSpy.signalArguments[0][0], makeSticker(stickerPack0.get(1)))); | verify(Helpers.deepEqual(sendMessageRequestedSpy.signalArguments[0][0], makeSticker(stickerPack0.get(1)))); | ||||
| mouseClick(findChild(stickerPicker, 'stickerPack1')); | |||||
| tryVerify(() => findChild(stickerPicker, 'sticker0').sticker.mxcUri === 'mxc://example.org/some2'); | |||||
| mouseClick(findChild(stickerPicker, 'sticker0')); | |||||
| tryVerify(() => sendMessageRequestedSpy.count === 2, 1000); | |||||
| verify(Helpers.deepEqual(sendMessageRequestedSpy.signalArguments[1][0], makeSticker(stickerPack1.get(0)))); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||