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 --- framework/qml/ConversationView.qml | 1 + framework/qml/InlineAccountSwitcher.qml | 1 + framework/qml/MailListView.qml | 1 + tests/teststore.cpp | 11 +++ views/conversation/qml/View.qml | 3 + views/conversation/tests/tst_conversationview.qml | 89 ++++++++++++++++++++++- 6 files changed, 103 insertions(+), 3 deletions(-) diff --git a/framework/qml/ConversationView.qml b/framework/qml/ConversationView.qml index c4cdea32..c8ea74ae 100644 --- a/framework/qml/ConversationView.qml +++ b/framework/qml/ConversationView.qml @@ -53,6 +53,7 @@ FocusScope { Kube.ConversationListView { id: listView + objectName: "listView" focus: true anchors { diff --git a/framework/qml/InlineAccountSwitcher.qml b/framework/qml/InlineAccountSwitcher.qml index 746891f9..b7f69588 100644 --- a/framework/qml/InlineAccountSwitcher.qml +++ b/framework/qml/InlineAccountSwitcher.qml @@ -74,6 +74,7 @@ FocusScope { } Kube.FolderListView { + objectName: "folderListView" anchors { top: accountButton.bottom left: parent.left diff --git a/framework/qml/MailListView.qml b/framework/qml/MailListView.qml index 074f004c..f3e6a7a6 100644 --- a/framework/qml/MailListView.qml +++ b/framework/qml/MailListView.qml @@ -109,6 +109,7 @@ FocusScope { Kube.ListView { id: listView + objectName: "listView" Layout.fillWidth: true Layout.fillHeight: true diff --git a/tests/teststore.cpp b/tests/teststore.cpp index 294aca8f..4716fa2e 100644 --- a/tests/teststore.cpp +++ b/tests/teststore.cpp @@ -168,6 +168,17 @@ QVariant TestStore::load(const QByteArray &type, const QVariantMap &filter) } return {}; } + if (type == "folder") { + Sink::Query query; + if (filter.contains("resource")) { + query.resourceFilter(filter.value("resource").toByteArray()); + } + auto list = Sink::Store::read(query); + if (!list.isEmpty()) { + return QVariant::fromValue(Folder::Ptr::create(list.first())); + } + return {}; + } Q_ASSERT(false); return {}; 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