Merge lp:~ara/mago/tomboy_tests into lp:~mago-contributors/mago/mago-1.0

Proposed by Ara Pulido
Status: Merged
Merged at revision: 151
Proposed branch: lp:~ara/mago/tomboy_tests
Merge into: lp:~mago-contributors/mago/mago-1.0
Diff against target: 301 lines (+276/-0)
5 files modified
mago/application/tomboy.py (+199/-0)
mago/test_suite/tomboy.py (+20/-0)
tomboy/README (+18/-0)
tomboy/tomboy_basics.py (+21/-0)
tomboy/tomboy_basics.xml (+18/-0)
To merge this branch: bzr merge lp:~ara/mago/tomboy_tests
Reviewer Review Type Date Requested Status
Nagappan Alagappan Approve
Review via email: mp+42271@code.launchpad.net

Description of the change

Added some basic tests for Tomboy:

 * Create a note (& deletes it)
 * About dialog

To post a comment you must log in.
Revision history for this message
Nagappan Alagappan (nagappan) wrote :

Nice work :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'mago/application/tomboy.py'
2--- mago/application/tomboy.py 1970-01-01 00:00:00 +0000
3+++ mago/application/tomboy.py 2010-11-30 16:38:53 +0000
4@@ -0,0 +1,199 @@
5+PACKAGE = "mago"
6+
7+#-*- coding:utf-8 -*-
8+"""
9+This is the "tomboy" module.
10+
11+This module provides a wrapper for LDTP to make writing Tomboy tests easier.
12+"""
13+import ooldtp
14+import ldtp
15+import os
16+from .main import Application
17+from ..gconfwrapper import GConf
18+from ..cmd import globals
19+import time
20+import gettext
21+import re
22+
23+gettext.install (True)
24+gettext.bindtextdomain (PACKAGE, globals.LOCALE_SHARE)
25+gettext.textdomain (PACKAGE)
26+t = gettext.translation(PACKAGE, globals.LOCALE_SHARE, fallback = True)
27+_ = t.gettext
28+
29+
30+class Tomboy(Application):
31+ """
32+ tomboy manages the Tomboy application.
33+ """
34+
35+ LAUNCHER = 'tomboy'
36+ LAUNCHER_ARGS = ['--search']
37+ WINDOW = _('frmSearchAllNotes')
38+
39+ BTN_CLEAR = _('btnClear')
40+ CBO_SEARCH = _('cboSearch')
41+ MNU_26 = _('mnu26')
42+ MNU_ABOUT = _('mnuAbout')
43+ MNU_CLOSE = _('mnuClose')
44+ MNU_CONTENTS = _('mnuContents')
45+ MNU_DELETE = _('mnuDelete')
46+ MNU_DELETENOTEBOOK = _('mnuDeleteNotebook')
47+ MNU_EDIT = _('mnuEdit')
48+ MNU_EMPTY = _('mnuEmpty')
49+ MNU_EMPTY1 = _('mnuEmpty1')
50+ MNU_EMPTY2 = _('mnuEmpty2')
51+ MNU_EMPTY3 = _('mnuEmpty3')
52+ MNU_FILE = _('mnuFile')
53+ MNU_GETHELPONLINE = _('mnuGetHelpOnline')
54+ MNU_HELP = _('mnuHelp')
55+ MNU_NEW = _('mnuNew')
56+ MNU_NEW_ARCHIVE_NOTE = _('mnuNew*Archive*Note')
57+ MNU_NEW_ORGANIZATION_NOTE = _('mnuNew*Organization*Note')
58+ MNU_NEW_QA_NOTE = _('mnuNew*QA*Note')
59+ MNU_NEWNOTEBOOK___ = _('mnuNewNotebook***')
60+ MNU_NOTEBOOKS = _('mnuNotebooks')
61+ MNU_OPEN___ = _('mnuOpen***')
62+ MNU_PREFERENCES = _('mnuPreferences')
63+ MNU_QUIT = _('mnuQuit')
64+ MNU_REPORTAPROBLEM = _('mnuReportaProblem')
65+ MNU_SYNCHRONISENOTES = _('mnuSynchroniseNotes')
66+ MNU_TOOLS = _('mnuTools')
67+ MNU_TRANSLATETHISAPPLICATION = _('mnuTranslatethisApplication')
68+ SCB_R0 = _('scbr0')
69+ SCB_R1 = _('scbr1')
70+ TBL_NOTEBOOKS = _('tbl0')
71+ TBL_NOTES = _('tbl1')
72+ TXT_0 = _('txt0')
73+ FRM_NEW_NOTE = _('frmNewNote*')
74+ NEW_NOTE_STARTS = _('NewNote')
75+ CELL_ALL_NOTES = _("All Notes")
76+ BTN_DELETE = _("btnDelete")
77+
78+
79+ def runAboutdialog(self):
80+ """
81+ This basic test simply verifies that the application launches
82+ and that the UI reacts
83+ The About dialog is the only menu that is always present in the UI
84+ """
85+ if self.MNU_ABOUT:
86+ self.main_window.click(self.MNU_ABOUT)
87+
88+ # Wait for the dialog to open
89+ # Name of about dialogs change with the app
90+ timeout=60
91+ dlgAbout=None
92+ while not ( timeout>0 and dlgAbout):
93+ dlgs=[ w for w in ldtp.getwindowlist() if w.startswith('dlgAbout')]
94+ if dlgs:
95+ dlgAbout = dlgs[0]
96+ timeout -= 1
97+ time.sleep(1)
98+
99+ if not dlgAbout:
100+ raise AssertionError('About Dialog not found')
101+
102+
103+ # Looking for a button to close the window
104+ found = None
105+ for btnClose in ('btnClose', 'btnOK', 'btnCancel'):
106+ try:
107+ found = ldtp.getchild(dlgAbout, btnClose, 'push button')
108+ break
109+ except:
110+ pass
111+
112+ if not found:
113+ return
114+
115+ ldtp.click(dlgAbout, btnClose)
116+
117+
118+ def create_new_note(self):
119+ """
120+ Creates a new note in Tomboy
121+ It returns the name of the new note
122+ """
123+
124+ notename = ""
125+
126+ searchNotes = ooldtp.context(self.WINDOW)
127+ searchNotes.getchild(self.MNU_NEW).click()
128+
129+ ldtp.waittillguiexist(self.FRM_NEW_NOTE)
130+
131+ pattern = re.compile("frm(" + self.NEW_NOTE_STARTS + "[0-9]+)")
132+
133+ for note in ldtp.getwindowlist():
134+ if note.find(self.NEW_NOTE_STARTS) >= 0:
135+ notename = re.match(pattern, note).groups(1)[0]
136+ break
137+
138+ pattern = re.compile("(([A-Z])|([0-9]+))")
139+ notename = re.sub(pattern, r" \1", notename)
140+ notename = notename[1:]
141+
142+ return notename
143+
144+ def _get_dialog_list(self):
145+ """
146+ The dialog that warns about the deletion of a note does not have a
147+ proper ATK name. We have this workaround to try to discover which one it
148+ is the new one
149+ """
150+
151+ list_dlg = []
152+
153+ pattern = re.compile("dlg([0-9])+")
154+
155+ for dlg in ldtp.getwindowlist():
156+ if re.match(pattern, dlg):
157+ list_dlg.append(dlg)
158+
159+ return dlg
160+
161+
162+ def delete_note(self, notename):
163+ """
164+ Given a note name, it deletes it
165+ """
166+ searchNotes = ooldtp.context(self.WINDOW)
167+
168+ tbl_notebooks = searchNotes.getchild(self.TBL_NOTEBOOKS)
169+ tbl_notebooks.selectrowpartialmatch(self.CELL_ALL_NOTES)
170+
171+ tbl_notes = searchNotes.getchild(self.TBL_NOTES)
172+ tbl_notes.selectrowpartialmatch(notename)
173+
174+ mnu_delete = searchNotes.getchild(self.MNU_DELETE)
175+
176+ # Get the dialogs without name list
177+ list1 = self._get_dialog_list()
178+
179+ # Delete the note
180+ mnu_delete.click()
181+
182+ # Get the dialogs without name list
183+ list2 = self._get_dialog_list()
184+
185+ new_dlg = ""
186+
187+ # A bit of a hack to get the right dialog
188+ for dlg in list2:
189+ if dlg not in list1:
190+ new_dlg = dlg
191+ return
192+
193+ dlg_delete = ooldtp.context(new_dlg)
194+ btn_delete = dlg_delete.get_child(self.BTN_DELETE)
195+
196+ btn_delete.click()
197+
198+ ldtp.waittillguinotexist(new_dlg)
199+ ldtp.wait(2)
200+
201+ def __init__(self):
202+ Application.__init__(self)
203+ self.main_window = ooldtp.context(self.WINDOW)
204
205=== added file 'mago/test_suite/tomboy.py'
206--- mago/test_suite/tomboy.py 1970-01-01 00:00:00 +0000
207+++ mago/test_suite/tomboy.py 2010-11-30 16:38:53 +0000
208@@ -0,0 +1,20 @@
209+"""
210+This module contains the definition of the test suite for Tomboy testing.
211+"""
212+import ldtp, ooldtp
213+from .main import SingleApplicationTestSuite
214+from ..application.tomboy import Application, Tomboy
215+
216+class TomboyTestSuite(SingleApplicationTestSuite):
217+ """
218+ Default test suite for Tomboy
219+ """
220+ APPLICATION_FACTORY = Tomboy
221+ def setup(self):
222+ self.application.open()
223+
224+ def teardown(self):
225+ self.application.close()
226+
227+ def cleanup(self):
228+ pass
229
230=== added directory 'tomboy'
231=== added file 'tomboy/README'
232--- tomboy/README 1970-01-01 00:00:00 +0000
233+++ tomboy/README 2010-11-30 16:38:53 +0000
234@@ -0,0 +1,18 @@
235+TOMBOY TESTS
236+--------------
237+Tests that verify Tomboy basic functionality.
238+
239+Safety
240+------
241+None of these tests touches any configuration or system files. They are safe to run.
242+
243+Configuration
244+-------------
245+NA
246+
247+Available Tests
248+---------------
249+
250+* Check about dialog
251+* Create a note & delete it
252+
253
254=== added file 'tomboy/tomboy_basics.py'
255--- tomboy/tomboy_basics.py 1970-01-01 00:00:00 +0000
256+++ tomboy/tomboy_basics.py 2010-11-30 16:38:53 +0000
257@@ -0,0 +1,21 @@
258+# -*- coding: utf-8 -*-
259+import os
260+from time import time, gmtime, strftime
261+
262+from mago.test_suite.tomboy import TomboyTestSuite
263+
264+class TomboyBasics(TomboyTestSuite):
265+ def testAboutdialog(self, arg1=None):
266+ self.application.runAboutdialog()
267+
268+ def testCreateNote(self):
269+ notename = self.application.create_new_note()
270+
271+ if notename == "":
272+ raise AssertionError("The note was not created correctly")
273+
274+ self.application.delete_note(notename)
275+
276+if __name__ == "__main__":
277+ tomboy_test = TomboyBasics()
278+ tomboy_test.run()
279
280=== added file 'tomboy/tomboy_basics.xml'
281--- tomboy/tomboy_basics.xml 1970-01-01 00:00:00 +0000
282+++ tomboy/tomboy_basics.xml 2010-11-30 16:38:53 +0000
283@@ -0,0 +1,18 @@
284+<?xml version="1.0"?>
285+<suite name="Tomboy">
286+ <class>tomboy_basics.TomboyBasics</class>
287+ <description>
288+ Tests which verify Tomboy basics functionality.
289+ </description>
290+ <case name="about_dialog">
291+ <method>testAboutdialog</method>
292+ <description>Verify that the about dialog launches</description>
293+ <args>
294+ <arg1>Arg example</arg1>
295+ </args>
296+ </case>
297+ <case name="create note and delete it">
298+ <method>testCreateNote</method>
299+ <description>Creates a new note in tomboy</description>
300+ </case>
301+</suite>

Subscribers

People subscribed via source and target branches

to status/vote changes: