Merge lp:~pedro/mago/gnome-search-tool into lp:~mago-contributors/mago/mago-1.0

Proposed by Pedro Villavicencio
Status: Merged
Merged at revision: 151
Proposed branch: lp:~pedro/mago/gnome-search-tool
Merge into: lp:~mago-contributors/mago/mago-1.0
Diff against target: 283 lines (+242/-0)
8 files modified
gnome_search_tool/README (+21/-0)
gnome_search_tool/data/יהודית (+1/-0)
gnome_search_tool/data/ᏘᏊᎽᎼᏨ (+1/-0)
gnome_search_tool/data/ﯕﯖﯓﴢﻚﻁﻶﻫ (+1/-0)
gnome_search_tool/gnome_search_tool_tests.py (+38/-0)
gnome_search_tool/gnome_search_tool_tests.xml (+46/-0)
mago/application/gnome_search_tool.py (+105/-0)
mago/test_suite/gnome_search_tool.py (+29/-0)
To merge this branch: bzr merge lp:~pedro/mago/gnome-search-tool
Reviewer Review Type Date Requested Status
Nagappan Alagappan Approve
Review via email: mp+42235@code.launchpad.net

Description of the change

tests for Gnome Search Tool, what it does for now:

Available Tests
---------------
 * UTF8 Search
 * RTL Search
   - Hebrew
   - Arabic
 * Search with wildcard
 * Search on Filesystem a file created recently
 * Enable and disable all options available on the UI.

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

Looks fine to me

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'gnome_search_tool'
2=== added file 'gnome_search_tool/README'
3--- gnome_search_tool/README 1970-01-01 00:00:00 +0000
4+++ gnome_search_tool/README 2010-11-30 13:16:32 +0000
5@@ -0,0 +1,21 @@
6+GNOME SEARCH TOOL TESTS
7+=======================
8+
9+Safety
10+------
11+None of these tests touches any configuration or system files. They are safe to run.
12+
13+Configuration
14+-------------
15+A couple of files with utf8 characters are included in this test, they need to be available on the data/ directory.
16+
17+Available Tests
18+---------------
19+ * UTF8 Search
20+ * RTL Search
21+ - Hebrew
22+ - Arabic
23+ * Search with wildcard
24+ * Search on Filesystem a file created recently
25+ * Enable and disable all options available on the UI.
26+
27
28=== added directory 'gnome_search_tool/data'
29=== added file 'gnome_search_tool/data/יהודית'
30--- gnome_search_tool/data/יהודית 1970-01-01 00:00:00 +0000
31+++ gnome_search_tool/data/יהודית 2010-11-30 13:16:32 +0000
32@@ -0,0 +1,1 @@
33+יהודית
34
35=== added file 'gnome_search_tool/data/ᏘᏊᎽᎼᏨ'
36--- gnome_search_tool/data/ᏘᏊᎽᎼᏨ 1970-01-01 00:00:00 +0000
37+++ gnome_search_tool/data/ᏘᏊᎽᎼᏨ 2010-11-30 13:16:32 +0000
38@@ -0,0 +1,1 @@
39+ⲍⲁϤϩϩⲆᏘᏊᎽᎼᏨ
40
41=== added file 'gnome_search_tool/data/ﯕﯖﯓﴢﻚﻁﻶﻫ'
42--- gnome_search_tool/data/ﯕﯖﯓﴢﻚﻁﻶﻫ 1970-01-01 00:00:00 +0000
43+++ gnome_search_tool/data/ﯕﯖﯓﴢﻚﻁﻶﻫ 2010-11-30 13:16:32 +0000
44@@ -0,0 +1,1 @@
45+ﯕﯖﯓﴢﻚﻁﻶﻫ
46
47=== added file 'gnome_search_tool/gnome_search_tool_tests.py'
48--- gnome_search_tool/gnome_search_tool_tests.py 1970-01-01 00:00:00 +0000
49+++ gnome_search_tool/gnome_search_tool_tests.py 2010-11-30 13:16:32 +0000
50@@ -0,0 +1,38 @@
51+# -*- coding: utf-8 -*-
52+import os
53+from time import time, gmtime, strftime
54+
55+from mago.test_suite.gnome_search_tool import Gnome_search_toolTestSuite
56+
57+class Gnome_search_toolTests(Gnome_search_toolTestSuite):
58+
59+ def search_for(self, file_to_search):
60+ data_dir = self.get_test_dir() + '/data/'
61+
62+ if not (self.application.search_for_file(file_to_search, data_dir)):
63+ raise AssertionError, "the search based on the term: %s did not return anything" % file_to_search
64+
65+ def search_on_filesystem(self, file_to_search):
66+
67+ if not (self.application.search_for_file(file_to_search, 'File System')):
68+ raise AssertionError, "the search based on the term: %s did not return anything" % file_to_search
69+
70+ def search_new_file_on_filesystem(self):
71+ filename = strftime("%Y%m%d_%H%M%S" + ".txt", gmtime(time()))
72+ file_path = open(os.getenv('HOME') + '/' + filename, 'w')
73+ file_path.write('1234567890')
74+ file_path.close()
75+
76+ result = self.application.search_for_file(filename, 'File System')
77+ os.unlink(os.getenv('HOME') + '/' + filename)
78+
79+ if not result:
80+ raise AssertionError, "the search based on the term: %s did not return anything" % filename
81+
82+ def enable_all_options(self):
83+ self.application.enable_disable_all_options(True)
84+ self.application.enable_disable_all_options(False)
85+
86+if __name__ == "__main__":
87+ gnome_search_to_test = Gnome_search_toolTests()
88+ gnome_search_to_test.run()
89
90=== added file 'gnome_search_tool/gnome_search_tool_tests.xml'
91--- gnome_search_tool/gnome_search_tool_tests.xml 1970-01-01 00:00:00 +0000
92+++ gnome_search_tool/gnome_search_tool_tests.xml 2010-11-30 13:16:32 +0000
93@@ -0,0 +1,46 @@
94+<?xml version="1.0"?>
95+<suite name="Gnome_search_tool">
96+ <class>gnome_search_tool_tests.Gnome_search_toolTests</class>
97+ <description>
98+ Tests which verify Gnome_search_to basics functionality.
99+ </description>
100+ <case name="UTF8 Search">
101+ <method>search_for</method>
102+ <description>Search for an UTF8 file</description>
103+ <args>
104+ <file_to_search>ᏘᏊᎽᎼᏨ</file_to_search>
105+ </args>
106+ </case>
107+ <case name="Search RTL Hebrew">
108+ <method>search_for</method>
109+ <description>Search for a file with RTL name in Hebrew</description>
110+ <args>
111+ <file_to_search>יהודית</file_to_search>
112+ </args>
113+ </case>
114+ <case name="Search RTL Arabic">
115+ <method>search_for</method>
116+ <description>Search for a file with RTL name in Arabic</description>
117+ <args>
118+ <file_to_search>ﯕﯖﯓﴢﻚﻁﻶﻫ</file_to_search>
119+ </args>
120+ </case>
121+ <case name="Search with wildcard">
122+ <method>search_on_filesystem</method>
123+ <description>Search for files with .ogg extension</description>
124+ <args>
125+ <file_to_search>*.ogg</file_to_search>
126+ </args>
127+ </case>
128+<!-- this is a verification for bug https://bugs.edge.launchpad.net/ubuntu/+source/gnome-utils/+bug/506219
129+it could be disabled until that bug is fixed.
130+-->
131+ <case name="Search on Filesystem">
132+ <method>search_new_file_on_filesystem</method>
133+ <description>Search for a newly created file trough the filesystem</description>
134+ </case>
135+ <case name="Enable all options">
136+ <method>enable_all_options</method>
137+ <description>Enable all the search options</description>
138+ </case>
139+</suite>
140
141=== added file 'mago/application/gnome_search_tool.py'
142--- mago/application/gnome_search_tool.py 1970-01-01 00:00:00 +0000
143+++ mago/application/gnome_search_tool.py 2010-11-30 13:16:32 +0000
144@@ -0,0 +1,105 @@
145+PACKAGE = "mago"
146+
147+#-*- coding:utf-8 -*-
148+"""
149+This is the "gnome_search_to" module.
150+
151+This module provides a wrapper for LDTP to make writing Gnome_search_to tests easier.
152+"""
153+import ooldtp
154+import ldtp
155+import os
156+from .main import Application
157+from ..gconfwrapper import GConf
158+from ..cmd import globals
159+import time
160+import gettext
161+
162+gettext.install (True)
163+gettext.bindtextdomain (PACKAGE, globals.LOCALE_SHARE)
164+gettext.textdomain (PACKAGE)
165+t = gettext.translation(PACKAGE, globals.LOCALE_SHARE, fallback = True)
166+_ = t.gettext
167+
168+
169+class GnomeSearchTool(Application):
170+ """
171+ GnomeSearchTool manages the Gnome Search Tool application.
172+ """
173+ LAUNCHER = 'gnome-search-tool'
174+ LAUNCHER_ARGS = []
175+ WINDOW = 'frm0'
176+ SEARCHING = 'frm*SearchforFiles'
177+
178+ BTN_FIND = _('btnFind')
179+ BTN_OPEN = _('btnOpen')
180+ BTN_STOP = _('btnStop')
181+ BTN_ADDOPTION = _('btnAddsearchoption')
182+ BTN_REMOVEOPTION = _('btnRemove*')
183+ TXT_NAMECONTAINS = _('txtNamecontains')
184+ TBL_SEARCHRESULTS = _('tblSearchresults')
185+ TBTN_MOREOPTIONS = _('tbtnSelectmoreoptions')
186+ CBO_LOOKINFOLDER = _('cboLookinfolder')
187+ DLG_BROWSE = _('dlgBrowse')
188+ TXT_LOCATION = _('txtLocation')
189+
190+ def search_for_file(self, file_name, search_where):
191+
192+ if not ldtp.guiexist(self.WINDOW):
193+ gst = ooldtp.context(self.SEARCHING)
194+ else:
195+ gst = ooldtp.context(self.WINDOW)
196+
197+ if search_where == 'File System':
198+ gst.comboselect(self.CBO_LOOKINFOLDER, search_where)
199+ else:
200+ gst.comboselect(self.CBO_LOOKINFOLDER, 'Other...')
201+ ldtp.wait(2)
202+ browse = ooldtp.context(self.DLG_BROWSE)
203+ if not (browse.getchild(self.TXT_LOCATION)):
204+ ldtp.generatekeyevent('<ctrl>l')
205+ browse.settextvalue(self.TXT_LOCATION, search_where)
206+ ldtp.wait(2)
207+ browse.getchild(self.BTN_OPEN).click()
208+
209+ textFind = gst.getchild(self.TXT_NAMECONTAINS)
210+ textFind.settextvalue(file_name)
211+ gst.getchild(self.BTN_FIND).click()
212+
213+ gst = ooldtp.context(self.SEARCHING)
214+ buttonFind = gst.getchild(self.BTN_FIND)
215+
216+ while not buttonFind.stateenabled():
217+ ldtp.wait()
218+
219+ results = gst.getchild(self.TBL_SEARCHRESULTS)
220+
221+ if results.getrowcount() < 2:
222+ if results.doesrowexist('No files found'):
223+ return False
224+
225+ return True
226+
227+ def enable_disable_all_options(self, enable):
228+ if not ldtp.guiexist(self.WINDOW):
229+ gst = ooldtp.context(self.SEARCHING)
230+ else:
231+ gst = ooldtp.context(self.WINDOW)
232+
233+ moreOptions = gst.getchild(self.TBTN_MOREOPTIONS)
234+
235+ if not moreOptions.verifytoggled():
236+ moreOptions.click()
237+
238+ option = 0
239+ while option < 14:
240+ if (enable):
241+ gst.getchild(self.BTN_ADDOPTION).click()
242+ else:
243+ gst.getchild(self.BTN_REMOVEOPTION).click()
244+ gst.remap()
245+ option+=1
246+
247+ def __init__(self):
248+ Application.__init__(self)
249+ self.main_window = ooldtp.context(self.WINDOW)
250
251=== added file 'mago/test_suite/gnome_search_tool.py'
252--- mago/test_suite/gnome_search_tool.py 1970-01-01 00:00:00 +0000
253+++ mago/test_suite/gnome_search_tool.py 2010-11-30 13:16:32 +0000
254@@ -0,0 +1,29 @@
255+"""
256+This module contains the definition of the test suite for Gnome_search_tool testing.
257+"""
258+import ldtp, ooldtp
259+from .main import SingleApplicationTestSuite
260+from ..application.gnome_search_tool import Application, GnomeSearchTool
261+from ..gconfwrapper import GConf
262+
263+class Gnome_search_toolTestSuite(SingleApplicationTestSuite):
264+ """
265+ Default test suite for Gnome_search_tool
266+ """
267+ APPLICATION_FACTORY = GnomeSearchTool
268+
269+ def setup(self):
270+ self.application.open()
271+
272+ def teardown(self):
273+ if not ldtp.guiexist('frm0'):
274+ self.application.set_name('frm*SearchforFiles')
275+
276+ self.application.set_close_name('btnClose')
277+
278+ #unset the /apps/gnome-search-tool/look_in_folder gconf key.
279+ GConf.set_item('/apps/gnome-search-tool/look_in_folder', '')
280+ self.application.close()
281+
282+ def cleanup(self):
283+ pass

Subscribers

People subscribed via source and target branches

to status/vote changes: