diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-01-24 09:46:42 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-01-24 09:46:42 +0100 |
commit | af2e92982b722ed0ea8f465649b843cb5ed4fda7 (patch) | |
tree | 4e4567ccb803c004402d4050a2317bc000335b68 | |
parent | 5f17e726ad63eec6ef78d15baa8ed42625679197 (diff) | |
download | kube-af2e92982b722ed0ea8f465649b843cb5ed4fda7.tar.gz kube-af2e92982b722ed0ea8f465649b843cb5ed4fda7.zip |
Tested account setup
-rw-r--r-- | accounts/kolabnow/qml/AccountSettings.qml | 2 | ||||
-rw-r--r-- | components/accounts/qml/AccountWizard.qml | 1 | ||||
-rw-r--r-- | components/accounts/qml/AccountWizardPage.qml | 1 | ||||
-rw-r--r-- | tests/teststore.cpp | 51 | ||||
-rw-r--r-- | tests/teststore.h | 1 | ||||
-rw-r--r-- | views/accounts/tests/tst_accountsview.qml | 38 |
6 files changed, 75 insertions, 19 deletions
diff --git a/accounts/kolabnow/qml/AccountSettings.qml b/accounts/kolabnow/qml/AccountSettings.qml index 4161bc49..35493bd1 100644 --- a/accounts/kolabnow/qml/AccountSettings.qml +++ b/accounts/kolabnow/qml/AccountSettings.qml | |||
@@ -56,6 +56,7 @@ Item { | |||
56 | } | 56 | } |
57 | Kube.RequiredTextField { | 57 | Kube.RequiredTextField { |
58 | id: nameField | 58 | id: nameField |
59 | objectName: "nameTextField" | ||
59 | focus: true | 60 | focus: true |
60 | Layout.fillWidth: true | 61 | Layout.fillWidth: true |
61 | placeholderText: qsTr("Your name") | 62 | placeholderText: qsTr("Your name") |
@@ -71,6 +72,7 @@ Item { | |||
71 | } | 72 | } |
72 | Kube.RequiredTextField { | 73 | Kube.RequiredTextField { |
73 | id: emailField | 74 | id: emailField |
75 | objectName: "emailTextField" | ||
74 | Layout.fillWidth: true | 76 | Layout.fillWidth: true |
75 | 77 | ||
76 | text: kolabnowSettings.emailAddress | 78 | text: kolabnowSettings.emailAddress |
diff --git a/components/accounts/qml/AccountWizard.qml b/components/accounts/qml/AccountWizard.qml index 58ef4509..b928fd8b 100644 --- a/components/accounts/qml/AccountWizard.qml +++ b/components/accounts/qml/AccountWizard.qml | |||
@@ -70,6 +70,7 @@ Kube.Popup { | |||
70 | Repeater { | 70 | Repeater { |
71 | model: root.availableAccountPlugins | 71 | model: root.availableAccountPlugins |
72 | delegate: Kube.Button { | 72 | delegate: Kube.Button { |
73 | objectName: "accountTypeButton" + modelData | ||
73 | Layout.fillWidth: true | 74 | Layout.fillWidth: true |
74 | text: modelData | 75 | text: modelData |
75 | onClicked: stack.push(wizardPage.createObject(stack, {accountType:modelData})) | 76 | onClicked: stack.push(wizardPage.createObject(stack, {accountType:modelData})) |
diff --git a/components/accounts/qml/AccountWizardPage.qml b/components/accounts/qml/AccountWizardPage.qml index 9f11ac36..99bad388 100644 --- a/components/accounts/qml/AccountWizardPage.qml +++ b/components/accounts/qml/AccountWizardPage.qml | |||
@@ -146,6 +146,7 @@ FocusScope { | |||
146 | right: parent.right | 146 | right: parent.right |
147 | bottom: parent.bottom | 147 | bottom: parent.bottom |
148 | } | 148 | } |
149 | objectName: "saveButton" | ||
149 | 150 | ||
150 | text: qsTr("Save") | 151 | text: qsTr("Save") |
151 | onClicked: save() | 152 | onClicked: save() |
diff --git a/tests/teststore.cpp b/tests/teststore.cpp index 4716fa2e..07310640 100644 --- a/tests/teststore.cpp +++ b/tests/teststore.cpp | |||
@@ -157,27 +157,42 @@ void TestStore::setup(const QVariantMap &map) | |||
157 | QVariant TestStore::load(const QByteArray &type, const QVariantMap &filter) | 157 | QVariant TestStore::load(const QByteArray &type, const QVariantMap &filter) |
158 | { | 158 | { |
159 | using namespace Sink::ApplicationDomain; | 159 | using namespace Sink::ApplicationDomain; |
160 | const auto list = loadList(type, filter); | ||
161 | if (!list.isEmpty()) { | ||
162 | return list.first(); | ||
163 | } | ||
164 | return {}; | ||
165 | } | ||
166 | |||
167 | template <typename T> | ||
168 | QVariantList toVariantList(const QList<T> &list) | ||
169 | { | ||
170 | QVariantList result; | ||
171 | std::transform(list.constBegin(), list.constEnd(), std::back_inserter(result), [] (const T &m) { | ||
172 | return QVariant::fromValue(T::Ptr::create(m)); | ||
173 | }); | ||
174 | Q_ASSERT(list.size() == result.size()); | ||
175 | return result; | ||
176 | } | ||
177 | |||
178 | QVariantList TestStore::loadList(const QByteArray &type, const QVariantMap &filter) | ||
179 | { | ||
180 | using namespace Sink::ApplicationDomain; | ||
181 | Sink::Query query; | ||
182 | if (filter.contains("resource")) { | ||
183 | query.resourceFilter(filter.value("resource").toByteArray()); | ||
184 | } | ||
160 | if (type == "mail") { | 185 | if (type == "mail") { |
161 | Sink::Query query; | 186 | return toVariantList(Sink::Store::read<Mail>(query)); |
162 | if (filter.contains("resource")) { | ||
163 | query.resourceFilter(filter.value("resource").toByteArray()); | ||
164 | } | ||
165 | auto list = Sink::Store::read<Mail>(query); | ||
166 | if (!list.isEmpty()) { | ||
167 | return QVariant::fromValue(Mail::Ptr::create(list.first())); | ||
168 | } | ||
169 | return {}; | ||
170 | } | 187 | } |
171 | if (type == "folder") { | 188 | if (type == "folder") { |
172 | Sink::Query query; | 189 | return toVariantList(Sink::Store::read<Folder>(query)); |
173 | if (filter.contains("resource")) { | 190 | } |
174 | query.resourceFilter(filter.value("resource").toByteArray()); | 191 | if (type == "resource") { |
175 | } | 192 | return toVariantList(Sink::Store::read<SinkResource>(query)); |
176 | auto list = Sink::Store::read<Folder>(query); | 193 | } |
177 | if (!list.isEmpty()) { | 194 | if (type == "account") { |
178 | return QVariant::fromValue(Folder::Ptr::create(list.first())); | 195 | return toVariantList(Sink::Store::read<SinkAccount>(query)); |
179 | } | ||
180 | return {}; | ||
181 | } | 196 | } |
182 | 197 | ||
183 | Q_ASSERT(false); | 198 | Q_ASSERT(false); |
diff --git a/tests/teststore.h b/tests/teststore.h index 5df20416..1a6a2563 100644 --- a/tests/teststore.h +++ b/tests/teststore.h | |||
@@ -28,6 +28,7 @@ class TestStore : public QObject { | |||
28 | public: | 28 | public: |
29 | Q_INVOKABLE void setup(const QVariantMap &); | 29 | Q_INVOKABLE void setup(const QVariantMap &); |
30 | Q_INVOKABLE QVariant load(const QByteArray &type, const QVariantMap &); | 30 | Q_INVOKABLE QVariant load(const QByteArray &type, const QVariantMap &); |
31 | Q_INVOKABLE QVariantList loadList(const QByteArray &type, const QVariantMap &); | ||
31 | Q_INVOKABLE QVariantMap read(const QVariant &); | 32 | Q_INVOKABLE QVariantMap read(const QVariant &); |
32 | }; | 33 | }; |
33 | 34 | ||
diff --git a/views/accounts/tests/tst_accountsview.qml b/views/accounts/tests/tst_accountsview.qml index c278136f..c280ea54 100644 --- a/views/accounts/tests/tst_accountsview.qml +++ b/views/accounts/tests/tst_accountsview.qml | |||
@@ -29,14 +29,50 @@ TestCase { | |||
29 | name: "AccountsView" | 29 | name: "AccountsView" |
30 | when: windowShown | 30 | when: windowShown |
31 | 31 | ||
32 | function visitChildren(item) { | ||
33 | console.warn(item) | ||
34 | for (var i = 0; i < item.children.length; i++) { | ||
35 | visitChildren(item.children[i]) | ||
36 | } | ||
37 | } | ||
38 | |||
32 | Component { | 39 | Component { |
33 | id: accountsComponent | 40 | id: accountsComponent |
34 | View { | 41 | View { |
35 | } | 42 | } |
36 | } | 43 | } |
37 | 44 | ||
38 | function test_start() { | 45 | function test_1start() { |
46 | var accountsView = createTemporaryObject(accountsComponent, testCase, {}) | ||
47 | verify(accountsView) | ||
48 | } | ||
49 | |||
50 | function test_2createAccount() { | ||
39 | var accountsView = createTemporaryObject(accountsComponent, testCase, {}) | 51 | var accountsView = createTemporaryObject(accountsComponent, testCase, {}) |
40 | verify(accountsView) | 52 | verify(accountsView) |
53 | |||
54 | var accountWizard = findChild(accountsView, "accountWizard"); | ||
55 | verify(accountWizard) | ||
56 | |||
57 | var typeButton = findChild(accountWizard.contentItem, "accountTypeButton" + "kolabnow") | ||
58 | verify(typeButton) | ||
59 | typeButton.clicked() | ||
60 | |||
61 | var name = findChild(accountWizard.contentItem, "nameTextField") | ||
62 | verify(name) | ||
63 | name.text = "Name" | ||
64 | |||
65 | var email = findChild(accountWizard.contentItem, "emailTextField") | ||
66 | verify(email) | ||
67 | email.text = "email@test.com" | ||
68 | |||
69 | var save = findChild(accountWizard.contentItem, "saveButton") | ||
70 | verify(save) | ||
71 | save.clicked() | ||
72 | |||
73 | var accounts = TestStore.loadList("account", {}) | ||
74 | compare(accounts.length, 1) | ||
75 | var resources = TestStore.loadList("resource", {}) | ||
76 | compare(resources.length, 3) | ||
41 | } | 77 | } |
42 | } | 78 | } |