From 89231902b7fa7d8c9143ebc775dc25013294f6a4 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 11 Jan 2018 14:39:57 +0100 Subject: More conversationview testing --- views/conversation/qml/View.qml | 3 + views/conversation/tests/tst_conversationview.qml | 89 ++++++++++++++++++++++- 2 files changed, 89 insertions(+), 3 deletions(-) (limited to 'views') diff --git a/views/conversation/qml/View.qml b/views/conversation/qml/View.qml index 8b2b0caf..7f1c78bb 100644 --- a/views/conversation/qml/View.qml +++ b/views/conversation/qml/View.qml @@ -35,6 +35,7 @@ FocusScope { Kube.PositiveButton { id: newMailButton + objectName: "newMailButton" anchors { top: parent.top @@ -104,6 +105,7 @@ FocusScope { Kube.MailListView { id: mailListView + objectName: "mailListView" anchors.fill: parent activeFocusOnTab: true Layout.minimumWidth: Kube.Units.gridUnit * 10 @@ -112,6 +114,7 @@ FocusScope { Kube.ConversationView { id: mailView + objectName: "mailView" Layout.fillWidth: true Layout.fillHeight: parent.height activeFocusOnTab: true diff --git a/views/conversation/tests/tst_conversationview.qml b/views/conversation/tests/tst_conversationview.qml index 467c049a..610c28b3 100644 --- a/views/conversation/tests/tst_conversationview.qml +++ b/views/conversation/tests/tst_conversationview.qml @@ -20,6 +20,8 @@ import QtQuick 2.7 import QtTest 1.0 import "../qml" +import org.kube.framework 1.0 as Kube +import org.kube.test 1.0 TestCase { id: testCase @@ -27,11 +29,92 @@ TestCase { height: 400 name: "MailView" - View { - id: mailView + Component { + id: mailViewComponent + View { + focus: true + } } - function test_start() { + function test_1start() { + var mailView = createTemporaryObject(mailViewComponent, testCase, {}) verify(mailView) } + + function test_2verifyInitialFocus() { + var mailView = createTemporaryObject(mailViewComponent, testCase, {}) + var newMailButton = findChild(mailView, "newMailButton"); + verify(newMailButton) + // verify(newMailButton.activeFocus) + } + + function test_3selectMessage() { + var initialState = { + accounts: [{ + id: "account1", + name: "Test Account" + }], + identities: [{ + account: "account1", + name: "Test Identity", + address: "identity@example.org" + }], + resources: [{ + id: "resource1", + account: "account1", + type: "dummy" + }, + { + id: "resource2", + account: "account1", + type: "mailtransport" + }], + folders: [{ + id: "folder1", + resource: "resource1", + name: "Folder 1", + specialpurpose: ["inbox"], + mails: [{ + resource: "resource1", + subject: "subject1", + body: "body", + to: ["to@example.org"], + cc: ["cc@example.org"], + bcc: ["bcc@example.org"], + draft: true + }, + { + resource: "resource1", + subject: "subject2", + body: "body", + to: ["to@example.org"], + cc: ["cc@example.org"], + bcc: ["bcc@example.org"], + draft: true + } + ], + }], + } + TestStore.setup(initialState) + var mailView = createTemporaryObject(mailViewComponent, testCase, {}) + var folderListView = findChild(mailView, "folderListView"); + verify(folderListView) + + var folder = TestStore.load("folder", {resource: "resource1"}) + verify(folder) + + Kube.Fabric.postMessage(Kube.Messages.folderSelection, {"folder": folder, "trash": false}); + + var mailListView = findChild(mailView, "mailListView"); + verify(mailListView) + var listView = findChild(mailListView, "listView"); + verify(listView) + tryCompare(listView, "count", 2) + + var conversationView = findChild(mailView, "mailView"); + verify(conversationView) + var listView = findChild(conversationView, "listView"); + verify(listView) + // tryCompare(listView, "count", 2) + } } -- cgit v1.2.3