45
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// System include
|
|
19 |
#include <QtTest/QtTest>
|
|
20 |
#include <HbMainWindow>
|
|
21 |
#include <NotesEditorInterface>
|
|
22 |
#include <AgendaUtil>
|
|
23 |
#include <AgendaEntry>
|
|
24 |
|
|
25 |
// User includes
|
|
26 |
#include "unittest_noteseditorplugin.h"
|
|
27 |
|
|
28 |
|
|
29 |
/*!
|
|
30 |
\class TestNotesEditorPlugin
|
|
31 |
|
|
32 |
Unit test clas for Notes Editor Plugin apis
|
|
33 |
*/
|
|
34 |
|
|
35 |
|
|
36 |
/*!
|
|
37 |
Constructor
|
|
38 |
*/
|
|
39 |
|
|
40 |
TestNotesEditorPlugin::TestNotesEditorPlugin()
|
|
41 |
{
|
|
42 |
}
|
|
43 |
|
|
44 |
/*!
|
|
45 |
Destructor
|
|
46 |
*/
|
|
47 |
TestNotesEditorPlugin::~TestNotesEditorPlugin()
|
|
48 |
{
|
|
49 |
}
|
|
50 |
|
|
51 |
/*!
|
|
52 |
Initialise before calling the test case
|
|
53 |
*/
|
|
54 |
void TestNotesEditorPlugin::init()
|
|
55 |
{
|
|
56 |
}
|
|
57 |
|
|
58 |
/*!
|
|
59 |
Do cleanup after each test case
|
|
60 |
*/
|
|
61 |
void TestNotesEditorPlugin::cleanup()
|
|
62 |
{
|
|
63 |
}
|
|
64 |
|
|
65 |
/*!
|
|
66 |
Test the api NotesEditor::NotesEditor()
|
|
67 |
*/
|
|
68 |
|
|
69 |
void TestNotesEditorPlugin::testPluginLoadUnLoad()
|
|
70 |
{
|
|
71 |
QDir dir(NOTES_EDITOR_PLUGIN_PATH);
|
|
72 |
QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
|
|
73 |
|
|
74 |
// Create NotesEditor object
|
|
75 |
QPluginLoader *pluginLoader = new QPluginLoader(pluginName);
|
|
76 |
|
|
77 |
// Load the plugin
|
|
78 |
QVERIFY(pluginLoader->load());
|
|
79 |
|
|
80 |
QObject *plugin = qobject_cast<QObject*> (pluginLoader->instance());
|
|
81 |
|
|
82 |
NotesEditorInterface* interface =
|
|
83 |
qobject_cast<NotesEditorInterface*>(plugin);
|
|
84 |
|
|
85 |
QVERIFY(interface);
|
|
86 |
|
|
87 |
// Unload the plugin
|
|
88 |
QVERIFY(pluginLoader->unload());
|
|
89 |
delete pluginLoader;
|
|
90 |
}
|
|
91 |
|
|
92 |
/*!
|
|
93 |
Test the api NotesEditorInterface::edit(const QString &string)
|
|
94 |
*/
|
|
95 |
void TestNotesEditorPlugin::testEditingNoteWithText()
|
|
96 |
{
|
|
97 |
HbMainWindow window;
|
|
98 |
window.show();
|
|
99 |
|
|
100 |
QDir dir(NOTES_EDITOR_PLUGIN_PATH);
|
|
101 |
QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
|
|
102 |
|
|
103 |
// Create plugin loader.
|
|
104 |
QPluginLoader *pluginLoader = new QPluginLoader(pluginName);
|
|
105 |
|
|
106 |
// Load the plugin.
|
|
107 |
QVERIFY(pluginLoader->load());
|
|
108 |
|
|
109 |
QObject *plugin = qobject_cast<QObject*> (pluginLoader->instance());
|
|
110 |
NotesEditorInterface* interface =
|
|
111 |
qobject_cast<NotesEditorInterface*>(plugin);
|
|
112 |
|
|
113 |
QString noteText("Test editing of Note by providing text(QString)");
|
|
114 |
// Call edit using the text.
|
|
115 |
interface->edit(noteText);
|
|
116 |
|
|
117 |
// Wait for Editor to launch.
|
|
118 |
QTest::qWait(2000);
|
|
119 |
|
|
120 |
// Call close on editor by saving the note
|
|
121 |
ulong id = interface->close(NotesEditorInterface::CloseWithSave);
|
|
122 |
QVERIFY(id);
|
|
123 |
|
|
124 |
// Create agenda Utility.
|
|
125 |
AgendaUtil *agendaUtil = new AgendaUtil();
|
|
126 |
// Wait for completion of instance view/entryview creation.
|
|
127 |
QTest::qWait(1);
|
|
128 |
QVERIFY(agendaUtil);
|
|
129 |
|
|
130 |
// Fetch the entry using the id.
|
|
131 |
AgendaEntry entry = agendaUtil->fetchById(id);
|
|
132 |
|
|
133 |
QString entryDescription = entry.description();
|
|
134 |
int compareResult = noteText.compare(entryDescription);
|
|
135 |
|
|
136 |
QVERIFY(!compareResult);
|
|
137 |
|
|
138 |
// cleanup
|
|
139 |
delete agendaUtil;
|
|
140 |
|
|
141 |
// Unload the plugin.
|
|
142 |
QVERIFY(pluginLoader->unload());
|
|
143 |
delete pluginLoader;
|
|
144 |
}
|
|
145 |
|
|
146 |
/*!
|
|
147 |
Test the api NotesEditor::edit(const QFile &handle)
|
|
148 |
*/
|
|
149 |
void TestNotesEditorPlugin::testEditingNoteWithFileHandle()
|
|
150 |
{
|
|
151 |
// Nothing yet
|
|
152 |
}
|
|
153 |
|
|
154 |
/*!
|
|
155 |
Test the api NotesEditor::edit(AgendaEntry entry)
|
|
156 |
*/
|
|
157 |
void TestNotesEditorPlugin::testEditingNoteWithAgendaEntry()
|
|
158 |
{
|
|
159 |
HbMainWindow window;
|
|
160 |
window.show();
|
|
161 |
|
|
162 |
QDir dir(NOTES_EDITOR_PLUGIN_PATH);
|
|
163 |
QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
|
|
164 |
|
|
165 |
// Create plugin loader.
|
|
166 |
QPluginLoader *pluginLoader = new QPluginLoader(pluginName);
|
|
167 |
|
|
168 |
// Load the plugin.
|
|
169 |
QVERIFY(pluginLoader->load());
|
|
170 |
|
|
171 |
QObject *plugin = qobject_cast<QObject*> (pluginLoader->instance());
|
|
172 |
NotesEditorInterface* interface =
|
|
173 |
qobject_cast<NotesEditorInterface*>(plugin);
|
|
174 |
|
|
175 |
AgendaEntry entry;
|
|
176 |
entry.setType(AgendaEntry::TypeNote);
|
|
177 |
entry.setDescription(QString("Test Editing Note by providing Agenda Entry"));
|
|
178 |
|
|
179 |
// Call edit on agenda entry
|
|
180 |
interface->edit(entry);
|
|
181 |
|
|
182 |
// Wait for Editor to launch.
|
|
183 |
QTest::qWait(2000);
|
|
184 |
|
|
185 |
ulong id = interface->close(NotesEditorInterface::CloseWithSave);
|
|
186 |
|
|
187 |
AgendaUtil *agendaUtil = new AgendaUtil();
|
|
188 |
// Wait for completion of instance view/entryview creation.
|
|
189 |
QTest::qWait(1);
|
|
190 |
QVERIFY(agendaUtil);
|
|
191 |
|
|
192 |
// Compare the description after saving.
|
|
193 |
AgendaEntry afterSave = agendaUtil->fetchById(id);
|
|
194 |
QCOMPARE(afterSave.description(), entry.description());
|
|
195 |
|
|
196 |
// cleanup.
|
|
197 |
delete agendaUtil;
|
|
198 |
|
|
199 |
// Unload the plugin.
|
|
200 |
QVERIFY(pluginLoader->unload());
|
|
201 |
delete pluginLoader;
|
|
202 |
}
|
|
203 |
|
|
204 |
/*!
|
|
205 |
Test the api NotesEditor::edit(ulong id)
|
|
206 |
*/
|
|
207 |
void TestNotesEditorPlugin::testEditingNoteWithId()
|
|
208 |
{
|
|
209 |
HbMainWindow window;
|
|
210 |
window.show();
|
|
211 |
|
|
212 |
QDir dir(NOTES_EDITOR_PLUGIN_PATH);
|
|
213 |
QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
|
|
214 |
|
|
215 |
// Create plugin loader.
|
|
216 |
QPluginLoader *pluginLoader = new QPluginLoader(pluginName);
|
|
217 |
|
|
218 |
// Load the plugin.
|
|
219 |
QVERIFY(pluginLoader->load());
|
|
220 |
|
|
221 |
QObject *plugin = qobject_cast<QObject*> (pluginLoader->instance());
|
|
222 |
NotesEditorInterface* interface =
|
|
223 |
qobject_cast<NotesEditorInterface*>(plugin);
|
|
224 |
|
|
225 |
AgendaUtil *agendaUtil = new AgendaUtil();
|
|
226 |
// Wait for completion of instance view/entryview creation.
|
|
227 |
QTest::qWait(1);
|
|
228 |
|
|
229 |
QVERIFY(agendaUtil);
|
|
230 |
|
|
231 |
AgendaEntry entry;
|
|
232 |
entry.setType(AgendaEntry::TypeNote);
|
|
233 |
entry.setDescription(
|
|
234 |
QString("Test Editing of Note by providing entry local Id"));
|
|
235 |
|
|
236 |
ulong id = agendaUtil->addEntry(entry);
|
|
237 |
|
|
238 |
interface->edit(id);
|
|
239 |
|
|
240 |
// Wait for Editor to launch.
|
|
241 |
QTest::qWait(1000);
|
|
242 |
|
|
243 |
ulong savedId = interface->close(NotesEditorInterface::CloseWithSave);
|
|
244 |
|
|
245 |
// Compare the entry after saving. Using the old entry id since
|
|
246 |
// text is not modified in the editor. Wait can be increased to allow user
|
|
247 |
// to modify the text.
|
|
248 |
AgendaEntry afterSave = agendaUtil->fetchById(id);
|
|
249 |
QCOMPARE(afterSave.description(), entry.description());
|
|
250 |
|
|
251 |
// cleanup.
|
|
252 |
delete agendaUtil;
|
|
253 |
|
|
254 |
// Unload the plugin.
|
|
255 |
QVERIFY(pluginLoader->unload());
|
|
256 |
delete pluginLoader;
|
|
257 |
}
|
|
258 |
|
|
259 |
|
|
260 |
/*!
|
|
261 |
Test the api NotesEditor::edit(const QFile &handle)
|
|
262 |
*/
|
|
263 |
void TestNotesEditorPlugin::testEditingTodoWithFileHandle()
|
|
264 |
{
|
|
265 |
// Nothing yet.
|
|
266 |
}
|
|
267 |
|
|
268 |
/*!
|
|
269 |
Test the api NotesEditor::edit(AgendaEntry entry)
|
|
270 |
*/
|
|
271 |
void TestNotesEditorPlugin::testEditingTodoWithAgendaEntry()
|
|
272 |
{
|
|
273 |
HbMainWindow mainWindow;
|
|
274 |
mainWindow.show();
|
|
275 |
|
|
276 |
QDir dir(NOTES_EDITOR_PLUGIN_PATH);
|
|
277 |
QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
|
|
278 |
|
|
279 |
// Create plugin loader.
|
|
280 |
QPluginLoader *pluginLoader = new QPluginLoader(pluginName);
|
|
281 |
|
|
282 |
// Load the plugin.
|
|
283 |
QVERIFY(pluginLoader->load());
|
|
284 |
|
|
285 |
QObject *plugin = qobject_cast<QObject*> (pluginLoader->instance());
|
|
286 |
NotesEditorInterface* interface =
|
|
287 |
qobject_cast<NotesEditorInterface*>(plugin);
|
|
288 |
|
|
289 |
AgendaUtil *agendaUtil = new AgendaUtil();
|
|
290 |
// Wait for completion of instance view/entryview creation.
|
|
291 |
QTest::qWait(1);
|
|
292 |
QVERIFY(agendaUtil);
|
|
293 |
|
|
294 |
// Create a agenda entry with type to-do
|
|
295 |
AgendaEntry entry;
|
|
296 |
entry.setType(AgendaEntry::TypeTodo);
|
|
297 |
entry.setSummary(QString("Test Editing of Todo by providing AgendaEntry"));
|
|
298 |
entry.setDescription(QString("@QTest Framework."));
|
|
299 |
entry.setStartAndEndTime(
|
|
300 |
QDateTime::currentDateTime(),QDateTime::currentDateTime());
|
|
301 |
entry.setStatus(AgendaEntry::TodoNeedsAction);
|
|
302 |
entry.setPriority(2);
|
|
303 |
|
|
304 |
ulong id = agendaUtil->addEntry(entry);
|
|
305 |
|
|
306 |
AgendaEntry storedEntry = agendaUtil->fetchById(id);
|
|
307 |
|
|
308 |
// Call edit on agenda entry
|
|
309 |
interface->edit(storedEntry);
|
|
310 |
|
|
311 |
// Wait for Editor to launch.
|
|
312 |
QTest::qWait(3000);
|
|
313 |
|
|
314 |
ulong afterSaveId = interface->close(NotesEditorInterface::CloseWithSave);
|
|
315 |
|
|
316 |
// Compare the entry after saving.
|
|
317 |
AgendaEntry afterSave = agendaUtil->fetchById(id);
|
|
318 |
QCOMPARE(afterSave.id(),id);
|
|
319 |
QCOMPARE(afterSave.type(),entry.type());
|
|
320 |
QCOMPARE(afterSave.summary(), entry.summary());
|
|
321 |
QCOMPARE(afterSave.description(), entry.description());
|
|
322 |
|
|
323 |
// cleanup.
|
|
324 |
delete agendaUtil;
|
|
325 |
|
|
326 |
// Unload the plugin.
|
|
327 |
QVERIFY(pluginLoader->unload());
|
|
328 |
delete pluginLoader;
|
|
329 |
}
|
|
330 |
|
|
331 |
/*!
|
|
332 |
Test the api NotesEditor::edit(ulong id)
|
|
333 |
*/
|
|
334 |
void TestNotesEditorPlugin::testEditingTodoWithId()
|
|
335 |
{
|
|
336 |
HbMainWindow window;
|
|
337 |
window.show();
|
|
338 |
|
|
339 |
QDir dir(NOTES_EDITOR_PLUGIN_PATH);
|
|
340 |
QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
|
|
341 |
|
|
342 |
// Create plugin loader.
|
|
343 |
QPluginLoader *pluginLoader = new QPluginLoader(pluginName);
|
|
344 |
|
|
345 |
// Load the plugin.
|
|
346 |
QVERIFY(pluginLoader->load());
|
|
347 |
|
|
348 |
QObject *plugin = qobject_cast<QObject*> (pluginLoader->instance());
|
|
349 |
NotesEditorInterface* interface =
|
|
350 |
qobject_cast<NotesEditorInterface*>(plugin);
|
|
351 |
|
|
352 |
AgendaUtil *agendaUtil = new AgendaUtil();
|
|
353 |
// Wait for completion of instance view/entryview creation.
|
|
354 |
QTest::qWait(1);
|
|
355 |
QVERIFY(agendaUtil);
|
|
356 |
|
|
357 |
// Create a agenda entry with type to-do
|
|
358 |
AgendaEntry entry;
|
|
359 |
entry.setType(AgendaEntry::TypeTodo);
|
|
360 |
entry.setSummary(
|
|
361 |
QString("Test Editing of Todo by providing entry local Id"));
|
|
362 |
entry.setDescription(QString("@QTest Framework"));
|
|
363 |
entry.setStartAndEndTime(
|
|
364 |
QDateTime::currentDateTime(),QDateTime::currentDateTime());
|
|
365 |
entry.setStatus(AgendaEntry::TodoNeedsAction);
|
|
366 |
entry.setPriority(2);
|
|
367 |
|
|
368 |
ulong id = agendaUtil->addEntry(entry);
|
|
369 |
AgendaEntry storedEntry = agendaUtil->fetchById(id);
|
|
370 |
|
|
371 |
// Call edit on agenda entry
|
|
372 |
interface->edit(storedEntry);
|
|
373 |
|
|
374 |
// Wait for Editor to launch.
|
|
375 |
QTest::qWait(3000);
|
|
376 |
|
|
377 |
ulong afterSaveId = interface->close(NotesEditorInterface::CloseWithSave);
|
|
378 |
|
|
379 |
// Compare the entry after saving.
|
|
380 |
AgendaEntry afterSave = agendaUtil->fetchById(id);
|
|
381 |
QCOMPARE(afterSave.id(),id);
|
|
382 |
QCOMPARE(afterSave.type(),entry.type());
|
|
383 |
QCOMPARE(afterSave.summary(), entry.summary());
|
|
384 |
QCOMPARE(afterSave.description(), entry.description());
|
|
385 |
|
|
386 |
// cleanup.
|
|
387 |
delete agendaUtil;
|
|
388 |
|
|
389 |
// Unload the plugin.
|
|
390 |
QVERIFY(pluginLoader->unload());
|
|
391 |
delete pluginLoader;
|
|
392 |
}
|
|
393 |
|
|
394 |
/*!
|
|
395 |
Test the api NotesEditor::create(CreateType type)
|
|
396 |
*/
|
|
397 |
void TestNotesEditorPlugin::testCreationOfNote()
|
|
398 |
{
|
|
399 |
HbMainWindow window;
|
|
400 |
window.show();
|
|
401 |
|
|
402 |
QDir dir(NOTES_EDITOR_PLUGIN_PATH);
|
|
403 |
QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
|
|
404 |
|
|
405 |
// Create plugin loader.
|
|
406 |
QPluginLoader *pluginLoader = new QPluginLoader(pluginName);
|
|
407 |
|
|
408 |
// Load the plugin.
|
|
409 |
QVERIFY(pluginLoader->load());
|
|
410 |
|
|
411 |
QObject *plugin = qobject_cast<QObject*> (pluginLoader->instance());
|
|
412 |
NotesEditorInterface* interface =
|
|
413 |
qobject_cast<NotesEditorInterface*>(plugin);
|
|
414 |
|
|
415 |
interface->create(NotesEditorInterface::CreateNote);
|
|
416 |
|
|
417 |
// Wait for Editor to launch.
|
|
418 |
QTest::qWait(3000);
|
|
419 |
|
|
420 |
ulong afterSaveId = interface->close(NotesEditorInterface::CloseWithSave);
|
|
421 |
|
|
422 |
// Note is not saved since description is empty
|
|
423 |
// TODO use key press events here
|
|
424 |
|
|
425 |
QVERIFY(!afterSaveId);
|
|
426 |
|
|
427 |
// Unload the plugin.
|
|
428 |
QVERIFY(pluginLoader->unload());
|
|
429 |
delete pluginLoader;
|
|
430 |
}
|
|
431 |
|
|
432 |
/*!
|
|
433 |
Test the api NotesEditor::create(CreateType type)
|
|
434 |
*/
|
|
435 |
void TestNotesEditorPlugin::testCreationofTodo()
|
|
436 |
{
|
|
437 |
HbMainWindow window;
|
|
438 |
window.show();
|
|
439 |
|
|
440 |
QDir dir(NOTES_EDITOR_PLUGIN_PATH);
|
|
441 |
QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
|
|
442 |
|
|
443 |
// Create plugin loader.
|
|
444 |
QPluginLoader *pluginLoader = new QPluginLoader(pluginName);
|
|
445 |
|
|
446 |
// Load the plugin.
|
|
447 |
QVERIFY(pluginLoader->load());
|
|
448 |
|
|
449 |
QObject *plugin = qobject_cast<QObject*> (pluginLoader->instance());
|
|
450 |
NotesEditorInterface* interface =
|
|
451 |
qobject_cast<NotesEditorInterface*>(plugin);
|
|
452 |
|
|
453 |
interface->create(NotesEditorInterface::CreateTodo);
|
|
454 |
|
|
455 |
// TODO
|
|
456 |
// Needs key interaction to edit the fields in to-do editor.
|
|
457 |
|
|
458 |
// Wait for Editor to launch.
|
|
459 |
QTest::qWait(3000);
|
|
460 |
|
|
461 |
// Unload the plugin.
|
|
462 |
QVERIFY(pluginLoader->unload());
|
|
463 |
delete pluginLoader;
|
|
464 |
}
|
|
465 |
|
|
466 |
/*!
|
|
467 |
Test the api NotesEditor::close(CloseType type);
|
|
468 |
*/
|
|
469 |
|
|
470 |
void TestNotesEditorPlugin::testClosingOfNotesEditorWithSave()
|
|
471 |
{
|
|
472 |
HbMainWindow window;
|
|
473 |
window.show();
|
|
474 |
|
|
475 |
QDir dir(NOTES_EDITOR_PLUGIN_PATH);
|
|
476 |
QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
|
|
477 |
|
|
478 |
// Create plugin loader.
|
|
479 |
QPluginLoader *pluginLoader = new QPluginLoader(pluginName);
|
|
480 |
|
|
481 |
// Load the plugin.
|
|
482 |
QVERIFY(pluginLoader->load());
|
|
483 |
|
|
484 |
QObject *plugin = qobject_cast<QObject*> (pluginLoader->instance());
|
|
485 |
NotesEditorInterface* interface =
|
|
486 |
qobject_cast<NotesEditorInterface*>(plugin);
|
|
487 |
|
|
488 |
QString noteText("Test Closing Of NotesEditor With Save");
|
|
489 |
// Call edit using the text.
|
|
490 |
interface->edit(noteText);
|
|
491 |
|
|
492 |
// Wait for Editor to launch.
|
|
493 |
QTest::qWait(1000);
|
|
494 |
|
|
495 |
// Call close on editor by saving the note
|
|
496 |
ulong id = interface->close(NotesEditorInterface::CloseWithSave);
|
|
497 |
QVERIFY(id);
|
|
498 |
|
|
499 |
// Create agenda Utility.
|
|
500 |
AgendaUtil *agendaUtil = new AgendaUtil();
|
|
501 |
// Wait for completion of instance view/entryview creation.
|
|
502 |
QTest::qWait(1);
|
|
503 |
QVERIFY(agendaUtil);
|
|
504 |
|
|
505 |
// Fetch the entry using the id
|
|
506 |
AgendaEntry entry = agendaUtil->fetchById(id);
|
|
507 |
|
|
508 |
QCOMPARE(noteText,entry.description());
|
|
509 |
|
|
510 |
// cleanup.
|
|
511 |
delete agendaUtil;
|
|
512 |
|
|
513 |
// Unload the plugin.
|
|
514 |
QVERIFY(pluginLoader->unload());
|
|
515 |
delete pluginLoader;
|
|
516 |
}
|
|
517 |
|
|
518 |
/*!
|
|
519 |
Test the api NotesEditor::close(CloseType type);
|
|
520 |
*/
|
|
521 |
void TestNotesEditorPlugin::testClosingOfNotesEditorWithoutSave()
|
|
522 |
{
|
|
523 |
HbMainWindow window;
|
|
524 |
window.show();
|
|
525 |
|
|
526 |
QDir dir(NOTES_EDITOR_PLUGIN_PATH);
|
|
527 |
QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
|
|
528 |
|
|
529 |
// Create plugin loader.
|
|
530 |
QPluginLoader *pluginLoader = new QPluginLoader(pluginName);
|
|
531 |
|
|
532 |
// Load the plugin.
|
|
533 |
QVERIFY(pluginLoader->load());
|
|
534 |
|
|
535 |
QObject *plugin = qobject_cast<QObject*> (pluginLoader->instance());
|
|
536 |
NotesEditorInterface* interface =
|
|
537 |
qobject_cast<NotesEditorInterface*>(plugin);
|
|
538 |
|
|
539 |
QString noteText("Test Closing Of Notes Editor Without Save");
|
|
540 |
// Call edit using the text.
|
|
541 |
interface->edit(noteText);
|
|
542 |
|
|
543 |
// Wait for Editor to launch.
|
|
544 |
QTest::qWait(1000);
|
|
545 |
|
|
546 |
// Call close on editor by saving the note
|
|
547 |
ulong id = interface->close(NotesEditorInterface::CloseWithoutSave);
|
|
548 |
QVERIFY(!id);
|
|
549 |
|
|
550 |
// Unload the plugin.
|
|
551 |
QVERIFY(pluginLoader->unload());
|
|
552 |
delete pluginLoader;
|
|
553 |
}
|
|
554 |
|
|
555 |
/*!
|
|
556 |
Test the api NotesEditor::close(CloseType type);
|
|
557 |
*/
|
|
558 |
void TestNotesEditorPlugin::testClosingOfTodoEditorWithSave()
|
|
559 |
{
|
|
560 |
HbMainWindow window;
|
|
561 |
window.show();
|
|
562 |
|
|
563 |
QDir dir(NOTES_EDITOR_PLUGIN_PATH);
|
|
564 |
QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
|
|
565 |
|
|
566 |
// Create plugin loader.
|
|
567 |
QPluginLoader *pluginLoader = new QPluginLoader(pluginName);
|
|
568 |
|
|
569 |
// Load the plugin.
|
|
570 |
QVERIFY(pluginLoader->load());
|
|
571 |
|
|
572 |
QObject *plugin = qobject_cast<QObject*> (pluginLoader->instance());
|
|
573 |
NotesEditorInterface* interface =
|
|
574 |
qobject_cast<NotesEditorInterface*>(plugin);
|
|
575 |
|
|
576 |
AgendaUtil *agendaUtil = new AgendaUtil();
|
|
577 |
// Wait for completion of instance view/entryview creation.
|
|
578 |
QTest::qWait(1);
|
|
579 |
QVERIFY(agendaUtil);
|
|
580 |
|
|
581 |
// Create a agenda entry with type to-do
|
|
582 |
AgendaEntry entry;
|
|
583 |
entry.setType(AgendaEntry::TypeTodo);
|
|
584 |
entry.setSummary(
|
|
585 |
QString("Test Closing Of Todo Editor With Save"));
|
|
586 |
entry.setDescription(QString("@QTest Framework"));
|
|
587 |
entry.setStartAndEndTime(
|
|
588 |
QDateTime::currentDateTime(),QDateTime::currentDateTime());
|
|
589 |
entry.setStatus(AgendaEntry::TodoNeedsAction);
|
|
590 |
entry.setPriority(2);
|
|
591 |
|
|
592 |
ulong id = agendaUtil->addEntry(entry);
|
|
593 |
|
|
594 |
AgendaEntry storedEntry = agendaUtil->fetchById(id);
|
|
595 |
// Call edit on agenda entry
|
|
596 |
interface->edit(storedEntry);
|
|
597 |
|
|
598 |
// Wait for Editor to launch.
|
|
599 |
QTest::qWait(1000);
|
|
600 |
|
|
601 |
ulong afterSaveId = interface->close(NotesEditorInterface::CloseWithSave);
|
|
602 |
|
|
603 |
AgendaEntry afterSave = agendaUtil->fetchById(id);
|
|
604 |
QCOMPARE(afterSave.id(),id);
|
|
605 |
QCOMPARE(afterSave.type(),entry.type());
|
|
606 |
QCOMPARE(afterSave.summary(), entry.summary());
|
|
607 |
QCOMPARE(afterSave.description(), entry.description());
|
|
608 |
|
|
609 |
// cleanup.
|
|
610 |
delete agendaUtil;
|
|
611 |
|
|
612 |
// Unload the plugin.
|
|
613 |
QVERIFY(pluginLoader->unload());
|
|
614 |
delete pluginLoader;
|
|
615 |
}
|
|
616 |
|
|
617 |
/*!
|
|
618 |
Test the api NotesEditor::close(CloseType type);
|
|
619 |
*/
|
|
620 |
void TestNotesEditorPlugin::testClosingOfTodoEditorWithoutSave()
|
|
621 |
{
|
|
622 |
HbMainWindow window;
|
|
623 |
window.show();
|
|
624 |
|
|
625 |
QDir dir(NOTES_EDITOR_PLUGIN_PATH);
|
|
626 |
QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
|
|
627 |
|
|
628 |
// Create plugin loader.
|
|
629 |
QPluginLoader *pluginLoader = new QPluginLoader(pluginName);
|
|
630 |
|
|
631 |
// Load the plugin.
|
|
632 |
QVERIFY(pluginLoader->load());
|
|
633 |
|
|
634 |
QObject *plugin = qobject_cast<QObject*> (pluginLoader->instance());
|
|
635 |
NotesEditorInterface* interface =
|
|
636 |
qobject_cast<NotesEditorInterface*>(plugin);
|
|
637 |
|
|
638 |
AgendaUtil *agendaUtil = new AgendaUtil();
|
|
639 |
// Wait for completion of instance view/entryview creation.
|
|
640 |
QTest::qWait(1);
|
|
641 |
QVERIFY(agendaUtil);
|
|
642 |
|
|
643 |
// Create a agenda entry with type to-do
|
|
644 |
AgendaEntry entry;
|
|
645 |
entry.setType(AgendaEntry::TypeTodo);
|
|
646 |
entry.setSummary(
|
|
647 |
QString("Test Closing Of Todo Editor Without Save"));
|
|
648 |
entry.setDescription(QString("@QTest framework"));
|
|
649 |
entry.setStartAndEndTime(
|
|
650 |
QDateTime::currentDateTime(),QDateTime::currentDateTime());
|
|
651 |
entry.setStatus(AgendaEntry::TodoNeedsAction);
|
|
652 |
entry.setPriority(2);
|
|
653 |
|
|
654 |
ulong id = agendaUtil->addEntry(entry);
|
|
655 |
|
|
656 |
AgendaEntry storedEntry = agendaUtil->fetchById(id);
|
|
657 |
// Call edit on agenda entry
|
|
658 |
interface->edit(storedEntry);
|
|
659 |
|
|
660 |
// Wait for Editor to launch.
|
|
661 |
QTest::qWait(3000);
|
|
662 |
|
|
663 |
ulong afterSaveId = interface->close(
|
|
664 |
NotesEditorInterface::CloseWithoutSave);
|
|
665 |
QVERIFY(!afterSaveId);
|
|
666 |
|
|
667 |
// cleanup.
|
|
668 |
delete agendaUtil;
|
|
669 |
|
|
670 |
// Unload the plugin.
|
|
671 |
QVERIFY(pluginLoader->unload());
|
|
672 |
delete pluginLoader;
|
|
673 |
}
|
|
674 |
|
|
675 |
/*!
|
|
676 |
Test editing of note by owning agenda util.
|
|
677 |
*/
|
|
678 |
void TestNotesEditorPlugin::testAgendaUtilEditingNoteWithText()
|
|
679 |
{
|
|
680 |
HbMainWindow window;
|
|
681 |
window.show();
|
|
682 |
|
|
683 |
QDir dir(NOTES_EDITOR_PLUGIN_PATH);
|
|
684 |
QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
|
|
685 |
|
|
686 |
// Create plugin loader.
|
|
687 |
QPluginLoader *pluginLoader = new QPluginLoader(pluginName);
|
|
688 |
|
|
689 |
// Load the plugin.
|
|
690 |
QVERIFY(pluginLoader->load());
|
|
691 |
|
|
692 |
QObject *plugin = qobject_cast<QObject*> (pluginLoader->instance());
|
|
693 |
NotesEditorInterface* interface =
|
|
694 |
qobject_cast<NotesEditorInterface*>(plugin);
|
|
695 |
|
|
696 |
// Create agenda Utility.
|
|
697 |
AgendaUtil *agendaUtil = new AgendaUtil();
|
|
698 |
// Wait for completion of instance view/entryview creation.
|
|
699 |
QTest::qWait(1);
|
|
700 |
QVERIFY(agendaUtil);
|
|
701 |
|
|
702 |
QString noteText("Test Editing of Note With Text by passing created "
|
|
703 |
"agenda util to notes editor plugin");
|
|
704 |
// Call edit using the text.
|
|
705 |
interface->edit(noteText, agendaUtil);
|
|
706 |
|
|
707 |
// Call close on editor by saving the note
|
|
708 |
ulong id = interface->close(NotesEditorInterface::CloseWithSave);
|
|
709 |
QVERIFY(id);
|
|
710 |
|
|
711 |
// Fetch the entry using the id
|
|
712 |
AgendaEntry entry = agendaUtil->fetchById(id);
|
|
713 |
|
|
714 |
QString entryDescription = entry.description();
|
|
715 |
int compareResult = noteText.compare(entryDescription);
|
|
716 |
|
|
717 |
QVERIFY(!compareResult);
|
|
718 |
|
|
719 |
// cleanup.
|
|
720 |
delete agendaUtil;
|
|
721 |
|
|
722 |
// Unload the plugin.
|
|
723 |
QVERIFY(pluginLoader->unload());
|
|
724 |
delete pluginLoader;
|
|
725 |
}
|
|
726 |
|
|
727 |
/*!
|
|
728 |
Test editing to-do entry by owning agenda util.
|
|
729 |
*/
|
|
730 |
void TestNotesEditorPlugin::testAgendaUtilEditingTodoWithId()
|
|
731 |
{
|
|
732 |
HbMainWindow window;
|
|
733 |
window.show();
|
|
734 |
|
|
735 |
QDir dir(NOTES_EDITOR_PLUGIN_PATH);
|
|
736 |
QString pluginName = dir.absoluteFilePath(NOTES_EDITOR_PLUGIN_NAME);
|
|
737 |
|
|
738 |
// Create plugin loader.
|
|
739 |
QPluginLoader *pluginLoader = new QPluginLoader(pluginName);
|
|
740 |
|
|
741 |
// Load the plugin.
|
|
742 |
QVERIFY(pluginLoader->load());
|
|
743 |
|
|
744 |
QObject *plugin = qobject_cast<QObject*> (pluginLoader->instance());
|
|
745 |
NotesEditorInterface* interface =
|
|
746 |
qobject_cast<NotesEditorInterface*>(plugin);
|
|
747 |
|
|
748 |
AgendaUtil *agendaUtil = new AgendaUtil();
|
|
749 |
// Wait for completion of instance view/entryview creation.
|
|
750 |
QTest::qWait(1);
|
|
751 |
|
|
752 |
QVERIFY(agendaUtil);
|
|
753 |
|
|
754 |
AgendaEntry entry;
|
|
755 |
entry.setType(AgendaEntry::TypeNote);
|
|
756 |
entry.setDescription(
|
|
757 |
QString("Test Editing of Note by providing entry local Id"));
|
|
758 |
|
|
759 |
ulong id = agendaUtil->addEntry(entry);
|
|
760 |
|
|
761 |
// Edits to-do entry by providing entry id and agendautil.
|
|
762 |
interface->edit(id, agendaUtil);
|
|
763 |
|
|
764 |
// Wait for Editor to launch.
|
|
765 |
QTest::qWait(1000);
|
|
766 |
|
|
767 |
ulong savedId = interface->close(NotesEditorInterface::CloseWithSave);
|
|
768 |
|
|
769 |
// Compare the entry after saving. Using the old entry id since
|
|
770 |
// text is not modified in the editor. Wait can be increased to allow user
|
|
771 |
// to modify the text.
|
|
772 |
AgendaEntry afterSave = agendaUtil->fetchById(id);
|
|
773 |
QCOMPARE(afterSave.description(), entry.description());
|
|
774 |
|
|
775 |
// cleanup.
|
|
776 |
delete agendaUtil;
|
|
777 |
|
|
778 |
// Unload the plugin.
|
|
779 |
QVERIFY(pluginLoader->unload());
|
|
780 |
delete pluginLoader;
|
|
781 |
}
|
|
782 |
// End of file --Don't remove this.
|