Merge lp:~dpniel/ubuntu-autopilot-tests/gedit into lp:ubuntu-autopilot-tests
- gedit
- Merge into trunk
Status: | Merged | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 59 | ||||||||||||||||
Proposed branch: | lp:~dpniel/ubuntu-autopilot-tests/gedit | ||||||||||||||||
Merge into: | lp:ubuntu-autopilot-tests | ||||||||||||||||
Diff against target: |
1347 lines (+936/-357) 9 files modified
ubuntu_autopilot_tests/gedit/__init__.py (+154/-0) ubuntu_autopilot_tests/gedit/samples/gedit.c (+8/-0) ubuntu_autopilot_tests/gedit/samples/gedit.cpp (+8/-0) ubuntu_autopilot_tests/gedit/samples/gedit.py (+6/-0) ubuntu_autopilot_tests/gedit/samples/gedit.vala (+9/-0) ubuntu_autopilot_tests/gedit/samples/gedit.xml (+21/-0) ubuntu_autopilot_tests/gedit/samples/gedit1.c (+8/-0) ubuntu_autopilot_tests/gedit/samples/test (+1/-0) ubuntu_autopilot_tests/gedit/test_gedit.py (+721/-357) |
||||||||||||||||
To merge this branch: | bzr merge lp:~dpniel/ubuntu-autopilot-tests/gedit | ||||||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Nicholas Skaggs (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
I have implemented the requirements of the two bug reports but on firther inspection I have seen many flaws in this test. If you read through I have made comments about each test which i will file a bug for these changes to be made. If you can see anymore let me know and will file more bugs :-)

Nicholas Skaggs (nskaggs) wrote : | # |

Nicholas Skaggs (nskaggs) wrote : | # |
On this comment, can't we use an eventually looking at the recent docs label instead?
#inserted sleep to see the recent files otherwise window closes too quicly
sleep(2)
Let's just comment these out;
test_highlight_
test_shortcuts
I think you could uncomment this; even add to it easily
test_insert_
Comment or implement;
test_tab_
This could be an easy assert fix; test_display_

Dan Chapman (dpniel) wrote : | # |
I totally agree,
Looking through the test i can't see an area where sleeps will be required, so i will lose all of them as we can just wait on the visible property to change.
I will work on all those changes tomorrow and take it further as I can see areas that can now be tested. With whats available now to introspect we can definately make a very solid test for gedit.
I did file a bug for higlight test which is possible although we can't see the highlighted text we can introspect the search box and from there when entering a search query if you hit enter twice the word you queried dissapears and then test the textview buffer that it has gone. So as long as before the search we can assert the buffer text then assert the search query box entry was typed correctly and then assert that the word dissapears from the textview buffer we can safely say it highlighted it.
anyway i will re-work it and see how we go :-)

Nicholas Skaggs (nskaggs) wrote : | # |
> I did file a bug for higlight test which is possible although we can't see the
> highlighted text we can introspect the search box and from there when entering
> a search query if you hit enter twice the word you queried dissapears and then
> test the textview buffer that it has gone. So as long as before the search we
> can assert the buffer text then assert the search query box entry was typed
> correctly and then assert that the word dissapears from the textview buffer we
> can safely say it highlighted it.
This is really clever! I can see this working!
- 62. By Dan Chapman <email address hidden>
-
commit for some keyboard shortcut tests
- 63. By Dan Chapman <email address hidden>
-
removed the old tests
- 64. By Dan Chapman <email address hidden>
-
some more
- 65. By Dan Chapman <email address hidden>
-
hmmmm
- 66. By Dan Chapman <email address hidden>
-
some notes
- 67. By Dan Chapman <email address hidden>
-
Finished toolbar button tests
- 68. By Dan Chapman <email address hidden>
-
save diff file types
- 69. By Dan Chapman <email address hidden>
-
now saves file types of various different extensions
- 70. By Dan Chapman <email address hidden>
-
added some save dialog tests
- 71. By Dan Chapman <email address hidden>
-
created tests to open files in gedit from terminal
- 72. By Dan Chapman <email address hidden>
-
Tests to load files in gedit from terminal complete
- 73. By Dan Chapman <email address hidden>
-
added test for opening various different file types
- 74. By Dan Chapman <email address hidden>
-
open file type tests now passing
gedit.c file seemed to stop it working so
copied and renamed to gedit1.c - 75. By Dan Chapman <email address hidden>
-
added tests for the open dialog
- 76. By Dan Chapman <email address hidden>
-
created tests for replace dialog
- 77. By Dan Chapman <email address hidden>
-
added some comments
- 78. By Dan Chapman <email address hidden>
-
mods

Dan Chapman (dpniel) wrote : | # |
Ok so now I have expanded this test quite significantly. Running 63 tests lasts like 15 mins atm :-O there is still plenty more tests to be written e.g print preview window and print dialog. We could also do some more save file tests but i think as it stands right now we can push this into production and get some meaningful test output.

Dan Chapman (dpniel) wrote : | # |
just looked further into the print dialog and it seems we can't see as much in that and it will require alot of walking the tree to find the right objects. so will take a while to do and not sure how we can test print preview with zoom etc as there seems to be no visual of zoom level, maybe we can see it in the properties though. There is already test for opening print preview so we know it opens. i will add ones for close using button and esc key and see from there.

Nicholas Skaggs (nskaggs) wrote : | # |
Just repeating a bit of the IRC conversation. I'd like to see some focus asserts before typing text if possible, provided there exists such a property in the gedit object. In addition, I would move the command line tests to use a true command line call and skip using terminal. In addition, add --new-document and --new-window as tests.
Overall, this look great and is a new benchmark for gtk tests moving forward. Kudos Dan!
- 79. By Dan Chapman <email address hidden>
-
added is_focus tests to all objects with the property available
also seperated Terminal tests to launch single and multi file
using raw cmd line and not use terminal - 80. By Dan Chapman <email address hidden>
-
added tests for using --new-document and --new-window cmd line args
ready for review

Dan Chapman (dpniel) wrote : | # |
So i have used the is_focus property where ever possible when entering text. I have also seperated the command line tests to load documents not using the terminal. And finally 2 tests for --new-document and --new-window. If you can think of more let me know :-)

Nicholas Skaggs (nskaggs) wrote : | # |
Not as many is focus as we could have hoped for. Still, excellent work, let's get this in prod
Preview Diff
1 | === modified file 'ubuntu_autopilot_tests/gedit/__init__.py' |
2 | --- ubuntu_autopilot_tests/gedit/__init__.py 2012-12-28 14:02:50 +0000 |
3 | +++ ubuntu_autopilot_tests/gedit/__init__.py 2013-08-14 17:04:33 +0000 |
4 | @@ -0,0 +1,154 @@ |
5 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
6 | +# |
7 | +# Copyright (C) 2013 |
8 | +# |
9 | +# Author: Daniel Chapman daniel@chapman-mail.com |
10 | +# |
11 | +# This program is free software; you can redistribute it and/or modify |
12 | +# it under the terms of the GNU Lesser General Public License as published by |
13 | +# the Free Software Foundation; version 3. |
14 | +# |
15 | +# This program is distributed in the hope that it will be useful, |
16 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | +# GNU Lesser General Public License for more details. |
19 | +# |
20 | +# You should have received a copy of the GNU Lesser General Public License |
21 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | +from autopilot.testcase import AutopilotTestCase |
23 | +from autopilot.matchers import Eventually |
24 | +from testtools.matchers import Equals, NotEquals, Contains, FileExists, FileContains |
25 | +from autopilot.input import Pointer, Mouse |
26 | +import tempfile |
27 | +import os |
28 | + |
29 | + |
30 | +class GeditAutopilotTestCase(AutopilotTestCase): |
31 | + |
32 | + def setUp(self): |
33 | + super(GeditAutopilotTestCase, self).setUp() |
34 | + self.app = self.launch_test_application("gedit") |
35 | + self.pointing_device = Pointer(Mouse.create()) |
36 | + |
37 | + def setup_test_docs(self,num_of_docs,text=False, |
38 | + tab_num=1,save_dlg=False, |
39 | + opn_dlg=False,replace_dlg=False, |
40 | + print_dlg=False,print_preview=False): |
41 | + """ This function sets up the pre-reqs for a test |
42 | + |
43 | + Using a combination of these params you can set up different |
44 | + situations for testing |
45 | + |
46 | + params: |
47 | + num_of_docs: *Required* an int value of the number of docs |
48 | + needed for the test |
49 | + text=: Set to False by default if set to true will add text |
50 | + to each document. |
51 | + tab_num=: Sets the tab focus to the given tab number on setup. |
52 | + Set to 1 by default |
53 | + save_dlg=: If set to True Sets the save dialog up in the |
54 | + gedit/samples directory for the test |
55 | + opn_dlg=: If set to True sets the open dialog up for test |
56 | + print_dlg=: If set to True sets the print dialog up for printing to a file |
57 | + print_preview=: If set to True sets the Print preview dialog up for testing |
58 | + """ |
59 | + # gedit by default loads a blank document |
60 | + # so start num at 1 |
61 | + num = 1 |
62 | + txt = text |
63 | + |
64 | + if txt == True: |
65 | + view = self.app.select_single('GeditView') |
66 | + self.assertThat(view.is_focus, Equals(1)) |
67 | + self.keyboard.type('Document %s: The quick brown fox jumps over the lazy dog' % str(num)) |
68 | + |
69 | + self.assertThat(view.buffer, |
70 | + Equals('Document %s: The quick brown fox jumps over the lazy dog' % str(num)), |
71 | + "Autopilot mis-typed the phrase") |
72 | + |
73 | + while num < num_of_docs: |
74 | + self.keyboard.press_and_release('Ctrl+n') |
75 | + num +=1 |
76 | + if txt == True: |
77 | + view = self.app.select_many('GeditView')[num - 1] |
78 | + self.assertThat(view.is_focus, Equals(1)) |
79 | + self.keyboard.type('Document %s: The quick brown fox jumps over the lazy dog' % str(num)) |
80 | + |
81 | + self.assertThat(view.buffer, |
82 | + Equals('Document %s: The quick brown fox jumps over the lazy dog' % str(num)), |
83 | + "Autopilot mis-typed the phrase") |
84 | + |
85 | + |
86 | + # lets just check we have the right amount of tabs |
87 | + num_of_tabs = len(self.app.select_many('GeditView')) |
88 | + self.assertTrue(num_of_tabs, Equals(num_of_docs)) |
89 | + |
90 | + # focus the required tab window |
91 | + tab = str(tab_num) |
92 | + self.keyboard.press_and_release('Alt+%s' % tab) |
93 | + # check we are on the correct tab |
94 | + view = self.app.select_many('GeditView')[tab_num - 1] |
95 | + self.assertThat(view.is_focus, Eventually(Equals(1)), |
96 | + "We are not on the correct tab") |
97 | + if save_dlg == True: |
98 | + self.pointing_device.click_object( |
99 | + self.app.select_single('GtkToolButton', |
100 | + name='FileSave')) |
101 | + self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
102 | + Eventually(Equals(1)), "The save dialog did not open") |
103 | + dlg = self.app.select_single('GeditFileChooserDialog') |
104 | + |
105 | + self.pointing_device.click_object(dlg.select_single('GtkFileChooserEntry')) |
106 | + self.assertThat(lambda: dlg.select_single('GtkFileChooserEntry').is_focus, |
107 | + Eventually(Equals(1)), |
108 | + "Entry did not get focus after being clicked") |
109 | + self.keyboard.press_and_release('Ctrl+a') |
110 | + self.keyboard.press_and_release('Delete') |
111 | + #lets make sure we always save in /tmp |
112 | + self.keyboard.type('/tmp/') |
113 | + self.keyboard.press_and_release('Enter') |
114 | + |
115 | + if opn_dlg == True: |
116 | + self.pointing_device.click_object( |
117 | + self.app.select_single('GeditOpenToolButton')) |
118 | + self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
119 | + Eventually(Equals(1)), "file chooser dialog did not open") |
120 | + dlg = self.app.select_single('GeditFileChooserDialog') |
121 | + self.keyboard.press_and_release('/') |
122 | + self.assertThat(lambda: dlg.select_single('GtkFileChooserEntry').is_focus, |
123 | + Eventually(Equals(1)), |
124 | + "Entry did not get focus after being clicked") |
125 | + #lets make sure we are in our samples dir |
126 | + sample_dir = 'samples' |
127 | + for root, dirs, files in os.walk(os.getcwd()): |
128 | + for name in dirs: |
129 | + if name == sample_dir: |
130 | + dir_path = os.path.abspath(os.path.join(root, name)) |
131 | + self.keyboard.type(dir_path+"/") |
132 | + |
133 | + if replace_dlg == True: |
134 | + self.pointing_device.click_object( |
135 | + self.app.select_single('GtkToolButton', |
136 | + name='SearchReplace')) |
137 | + self.assertThat(lambda: self.app.select_single('GeditReplaceDialog').visible, |
138 | + Eventually(Equals(1)), |
139 | + "Replace dialog did not open") |
140 | + #lets grab all the objects we might need in the test |
141 | + self.rep_dialog = self.app.select_single('GeditReplaceDialog') |
142 | + self.mtch_chkbtn = self.rep_dialog.select_single(BuilderName='match_case_checkbutton') |
143 | + self.entire_chkbtn = self.rep_dialog.select_single(BuilderName='entire_word_checkbutton') |
144 | + self.srch_bk_chkbtn = self.rep_dialog.select_single(BuilderName='search_backwards_checkbutton') |
145 | + self.wrp_chkbtn = self.rep_dialog.select_single(BuilderName='wrap_around_checkbutton') |
146 | + self.find_button = self.rep_dialog.select_single('GtkLabel', label='_Find') |
147 | + self.replace_button = self.rep_dialog.select_single('GtkLabel', label='_Replace') |
148 | + self.replace_all_button = self.rep_dialog.select_single('GtkLabel', label='Replace _All') |
149 | + self.close_button = self.rep_dialog.select_single('GtkLabel', label='_Close') |
150 | + self.search_entry = self.rep_dialog.select_single('GeditHistoryEntry', history_id='search-for-entry') |
151 | + self.search_entry_text = self.search_entry.select_single('GtkEntry') |
152 | + self.replace_entry = self.rep_dialog.select_single('GeditHistoryEntry', history_id='replace-with-entry') |
153 | + self.replace_entry_text = self.replace_entry.select_single('GtkEntry') |
154 | + #now lets select the search entry |
155 | + self.pointing_device.click_object(self.search_entry) |
156 | + #we are all set for the test now |
157 | + |
158 | + |
159 | \ No newline at end of file |
160 | |
161 | === added directory 'ubuntu_autopilot_tests/gedit/samples' |
162 | === added file 'ubuntu_autopilot_tests/gedit/samples/gedit.c' |
163 | --- ubuntu_autopilot_tests/gedit/samples/gedit.c 1970-01-01 00:00:00 +0000 |
164 | +++ ubuntu_autopilot_tests/gedit/samples/gedit.c 2013-08-14 17:04:33 +0000 |
165 | @@ -0,0 +1,8 @@ |
166 | +#include<stdio.h> |
167 | + |
168 | +main() |
169 | +{ |
170 | + printf("Hello Autopilot"); |
171 | + |
172 | + |
173 | +} |
174 | |
175 | === added file 'ubuntu_autopilot_tests/gedit/samples/gedit.cpp' |
176 | --- ubuntu_autopilot_tests/gedit/samples/gedit.cpp 1970-01-01 00:00:00 +0000 |
177 | +++ ubuntu_autopilot_tests/gedit/samples/gedit.cpp 2013-08-14 17:04:33 +0000 |
178 | @@ -0,0 +1,8 @@ |
179 | +#include <iostream> |
180 | +using namespace std; |
181 | + |
182 | +int main () |
183 | +{ |
184 | + cout << "Hello Autopilot!"; |
185 | + return 0; |
186 | +} |
187 | \ No newline at end of file |
188 | |
189 | === added file 'ubuntu_autopilot_tests/gedit/samples/gedit.py' |
190 | --- ubuntu_autopilot_tests/gedit/samples/gedit.py 1970-01-01 00:00:00 +0000 |
191 | +++ ubuntu_autopilot_tests/gedit/samples/gedit.py 2013-08-14 17:04:33 +0000 |
192 | @@ -0,0 +1,6 @@ |
193 | +import re |
194 | + |
195 | +string = "Hello Autopilot\n" |
196 | +if re.search(r"[^abc]", string): |
197 | + print (string + " contains a character other than " +\ |
198 | + "a, b, and c") |
199 | \ No newline at end of file |
200 | |
201 | === added file 'ubuntu_autopilot_tests/gedit/samples/gedit.vala' |
202 | --- ubuntu_autopilot_tests/gedit/samples/gedit.vala 1970-01-01 00:00:00 +0000 |
203 | +++ ubuntu_autopilot_tests/gedit/samples/gedit.vala 2013-08-14 17:04:33 +0000 |
204 | @@ -0,0 +1,9 @@ |
205 | +class gedittest.HelloAutopilot : GLib.Object { |
206 | + |
207 | + public static int main(string[] args) { |
208 | + |
209 | + stdout.printf("Hello, Autopilot\n"); |
210 | + |
211 | + return 0; |
212 | + } |
213 | +} |
214 | \ No newline at end of file |
215 | |
216 | === added file 'ubuntu_autopilot_tests/gedit/samples/gedit.xml' |
217 | --- ubuntu_autopilot_tests/gedit/samples/gedit.xml 1970-01-01 00:00:00 +0000 |
218 | +++ ubuntu_autopilot_tests/gedit/samples/gedit.xml 2013-08-14 17:04:33 +0000 |
219 | @@ -0,0 +1,21 @@ |
220 | +<?xml version="1.0" encoding="UTF-8"?> |
221 | + |
222 | +<root> |
223 | + <title> |
224 | + Hello Autopilot |
225 | + </title> |
226 | + <para> |
227 | + THis is just a sample paragraph |
228 | + </para> |
229 | + <note> |
230 | + and a sample note |
231 | + </note> |
232 | + |
233 | + <para> |
234 | + This page written by: |
235 | + <ital>Dan Chapman</ital> |
236 | + </para> |
237 | + <para> |
238 | + Copyright 2013 |
239 | + </para> |
240 | +</root> |
241 | \ No newline at end of file |
242 | |
243 | === added file 'ubuntu_autopilot_tests/gedit/samples/gedit1.c' |
244 | --- ubuntu_autopilot_tests/gedit/samples/gedit1.c 1970-01-01 00:00:00 +0000 |
245 | +++ ubuntu_autopilot_tests/gedit/samples/gedit1.c 2013-08-14 17:04:33 +0000 |
246 | @@ -0,0 +1,8 @@ |
247 | +#include<stdio.h> |
248 | + |
249 | +main() |
250 | +{ |
251 | + printf("Hello Autopilot"); |
252 | + |
253 | + |
254 | +} |
255 | |
256 | === added file 'ubuntu_autopilot_tests/gedit/samples/test' |
257 | --- ubuntu_autopilot_tests/gedit/samples/test 1970-01-01 00:00:00 +0000 |
258 | +++ ubuntu_autopilot_tests/gedit/samples/test 2013-08-14 17:04:33 +0000 |
259 | @@ -0,0 +1,1 @@ |
260 | +Hello Autopilot |
261 | \ No newline at end of file |
262 | |
263 | === modified file 'ubuntu_autopilot_tests/gedit/test_gedit.py' |
264 | --- ubuntu_autopilot_tests/gedit/test_gedit.py 2013-05-29 19:37:09 +0000 |
265 | +++ ubuntu_autopilot_tests/gedit/test_gedit.py 2013-08-14 17:04:33 +0000 |
266 | @@ -1,360 +1,724 @@ |
267 | +# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
268 | +# |
269 | +# Copyright (C) 2013 |
270 | +# |
271 | +# Author: Daniel Chapman daniel@chapman-mail.com |
272 | +# |
273 | +# This program is free software; you can redistribute it and/or modify |
274 | +# it under the terms of the GNU Lesser General Public License as published by |
275 | +# the Free Software Foundation; version 3. |
276 | +# |
277 | +# This program is distributed in the hope that it will be useful, |
278 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
279 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
280 | +# GNU Lesser General Public License for more details. |
281 | +# |
282 | +# You should have received a copy of the GNU Lesser General Public License |
283 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
284 | +from autopilot.matchers import Eventually |
285 | +from testtools import ExpectedException |
286 | +from testtools.content import Content, ContentType |
287 | +from testtools.matchers import Equals, NotEquals, Contains, FileExists, FileContains, LessThan, DirExists |
288 | +from gedit import GeditAutopilotTestCase |
289 | from autopilot.testcase import AutopilotTestCase |
290 | -from autopilot.matchers import Eventually |
291 | -from testtools.matchers import Equals, NotEquals, Contains |
292 | -from autopilot.process import ProcessManager |
293 | - |
294 | -from time import sleep |
295 | -import tempfile |
296 | +import subprocess |
297 | +import testscenarios |
298 | import os |
299 | - |
300 | - |
301 | -class GeditTests(AutopilotTestCase): |
302 | - |
303 | - def setUp(self): |
304 | - super(GeditTests, self).setUp() |
305 | +import time |
306 | +import shutil |
307 | + |
308 | +class GeditKeyboardShortcutTests(GeditAutopilotTestCase): |
309 | + |
310 | + def test_close_tab(self, ): |
311 | + """ Using shortcut Ctrl+W """ |
312 | + # setup 2 blank documents |
313 | + self.setup_test_docs(2) |
314 | + num_before = len(self.app.select_many('GeditView')) |
315 | + #close tab |
316 | + self.keyboard.press_and_release('Ctrl+w') |
317 | + #did it close? |
318 | + num_after = len(self.app.select_many('GeditView')) |
319 | + self.assertThat(num_after, |
320 | + Equals(num_before - 1), |
321 | + "Tab did not close correctly: %s tabs were still open"\ |
322 | + %str(num_after)) |
323 | + |
324 | + def test_save_all_document_shortcut(self, ): |
325 | + """ Using shortcut Ctrl+Shift+l, test the save dialog appears """ |
326 | + # create a 3 docs with some text so we can save |
327 | + self.setup_test_docs(3, text=True) |
328 | + self.keyboard.press_and_release('Ctrl+s') |
329 | + self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
330 | + Eventually(Equals(1)), |
331 | + "Save dialog did not open") |
332 | + |
333 | + def test_close_all_tabs_shortcut(self, ): |
334 | + """ Using shortcut Ctrl+Shift+W """ |
335 | + self.setup_test_docs(3) |
336 | + # close all windows |
337 | + self.keyboard.press_and_release('Ctrl+Shift+w') |
338 | + #check there are no tabs |
339 | + tabs = len(self.app.select_many('GeditTab')) |
340 | + self.assertThat(tabs, Equals(0), |
341 | + "Not all tabs closed: %s tabs were still open"%str(tabs)) |
342 | + |
343 | + def test_jump_to_nth_tab_shortcut(self, ): |
344 | + """ Using shortcut Alt+n """ |
345 | + self.setup_test_docs(3) |
346 | + # jump to tab 3 |
347 | + self.keyboard.press_and_release('Alt+3') |
348 | + #check we are on tab 3 (index 2) |
349 | + self.assertThat(lambda: self.app.select_many('GeditView')[2].is_focus, |
350 | + Eventually(Equals(1)), "Tab 3 did not get focus") |
351 | + |
352 | + def test_create_new_document_shortcut(self, ): |
353 | + """ Using shortcut Ctrl+N """ |
354 | + #check that only the default tab is there |
355 | + num_tabs = len(self.app.select_many('GeditView')) |
356 | + self.assertThat(num_tabs, Equals(1)) |
357 | + # create new document |
358 | + self.keyboard.press_and_release('Ctrl+n') |
359 | + #test new document is there and visible |
360 | + self.assertThat(num_tabs, Equals(1)) |
361 | + self.assertThat(lambda: self.app.select_many('GeditView')[1].is_focus, |
362 | + Eventually(Equals(1)), "New document was not created") |
363 | + |
364 | + def test_open_file_shortcut(self, ): |
365 | + """ Using shortcut Ctrl+o, test the file chooser dialog appears """ |
366 | + self.keyboard.press_and_release('Ctrl+o') |
367 | + self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
368 | + Eventually(Equals(1)), "file chooser dialog did not open") |
369 | + |
370 | + def test_save_document_shortcut(self, ): |
371 | + """ Using shortcut Ctrl+s, test the save dialog appears """ |
372 | + # create a doc with some text so we can save |
373 | + self.setup_test_docs(1, text=True) |
374 | + self.keyboard.press_and_release('Ctrl+s') |
375 | + self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
376 | + Eventually(Equals(1)), "The save dialog did not open") |
377 | + |
378 | + def test_save_as_shortcut(self, ): |
379 | + """ Using shortcut Ctrl+Shift+s, test the save as dialog appears """ |
380 | + self.setup_test_docs(1, text=True) |
381 | + self.keyboard.press_and_release('Ctrl+Shift+s') |
382 | + self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
383 | + Eventually(Equals(1)), "The save dialog did not open") |
384 | + |
385 | + def test_print_document_shortcut(self, ): |
386 | + """ Using shortcut Ctrl+p, test the print dialog appears """ |
387 | + self.setup_test_docs(1, text=True) |
388 | + self.keyboard.press_and_release('Ctrl+p') |
389 | + self.assertThat(lambda: self.app.select_single('GtkPrintUnixDialog').visible, |
390 | + Eventually(Equals(1)), "The print dialog did not open") |
391 | + |
392 | + def test_print_preview_shortcut(self, ): |
393 | + """ Using shortcut Ctrl+Shift+p, test the print preview appears """ |
394 | + self.setup_test_docs(1, text=True) |
395 | + self.keyboard.press_and_release('Ctrl+Shift+p') |
396 | + self.assertThat(lambda: self.app.select_single('GeditPrintPreview').visible, |
397 | + Eventually(Equals(1)), "The print preview window did not open") |
398 | + |
399 | + def test_home_key_moves_to_beginning_of_line(self, ): |
400 | + """ Using the 'Home' Key test we go to beginning of line """ |
401 | + self.setup_test_docs(1, text=True) |
402 | + self.keyboard.press_and_release('Home') |
403 | + #lets delete the first letter in the buffer |
404 | + self.keyboard.press_and_release('Delete') |
405 | + #Lets check we went to beginning and deleted 'D' |
406 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
407 | + Eventually( |
408 | + Equals('ocument 1: The quick brown fox jumps over the lazy dog')), |
409 | + "Home key did not go to beginning of line") |
410 | + |
411 | + def test_end_key_goes_to_end_of_line(self, ): |
412 | + """ Using the 'End' Key test we go to end of line """ |
413 | + self.setup_test_docs(1, text=True) |
414 | + self.keyboard.press_and_release('Home') |
415 | + #lets delete the first letter in the buffer |
416 | + self.keyboard.press_and_release('Delete') |
417 | + #Lets check we went to beginning and deleted 'T' |
418 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
419 | + Eventually( |
420 | + Equals('ocument 1: The quick brown fox jumps over the lazy dog'))) |
421 | + self.keyboard.press_and_release('End') |
422 | + self.keyboard.type('s') |
423 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
424 | + Eventually( |
425 | + Equals('ocument 1: The quick brown fox jumps over the lazy dogs')), |
426 | + "Either the 'End' key did not work or autopilot \ |
427 | + mis-typed 's': manual compare needed") |
428 | + |
429 | + def test_undo_shortcut(self, ): |
430 | + """ Using shortcut Ctrl+z, test that we undo last action """ |
431 | + self.setup_test_docs(1, text=True) |
432 | + self.keyboard.press_and_release('Ctrl+z') |
433 | + #Lets check we were able to undo the last word |
434 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
435 | + Eventually(Equals('Document 1: The quick brown fox jumps over the lazy ')), |
436 | + "Last word in phrase was not undone") |
437 | + |
438 | + def test_redo_shortcut(self, ): |
439 | + """ Using shortcut Ctrl+Shift+z, test we can redo last undone action """ |
440 | + self.setup_test_docs(1, text=True) |
441 | + self.keyboard.press_and_release('Ctrl+z') |
442 | + #Lets undo the last word |
443 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
444 | + Eventually( |
445 | + Equals('Document 1: The quick brown fox jumps over the lazy ')), |
446 | + "Last word in phrase was not undone") |
447 | + self.keyboard.press_and_release('Ctrl+Shift+z') |
448 | + #Lets check we were able to redo the last word |
449 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
450 | + Eventually( |
451 | + Equals('Document 1: The quick brown fox jumps over the lazy dog')), |
452 | + "Redo shortcut did not redo the last word in phrase") |
453 | + |
454 | + def test_copy_and_paste_shortcuts(self, ): |
455 | + """ Using shortcuts Ctrl+c & Ctrl+v test we can copy and paste text """ |
456 | + self.setup_test_docs(1, text=True) |
457 | + self.keyboard.press_and_release('Ctrl+a') |
458 | + #copy text |
459 | + self.keyboard.press_and_release('Ctrl+c') |
460 | + self.keyboard.press_and_release('Right') |
461 | + # now paste |
462 | + self.keyboard.press_and_release('Ctrl+v') |
463 | + # did it copy and paste correctly? |
464 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
465 | + Eventually( |
466 | + Equals( |
467 | + 'Document 1: The quick brown fox jumps over the lazy dogDocument 1: The quick brown fox jumps over the lazy dog' |
468 | + )), |
469 | + "Three possible reasons for fail: \ |
470 | + 1) Ctrl+a did not select text, \ |
471 | + 2) Ctrl+c did not copy text or \ |
472 | + 3) Ctrl+v did not paste text") |
473 | + |
474 | + def test_cut_shortcut(self, ): |
475 | + """ Using shortcut Ctrl+x test we can cut text """ |
476 | + self.setup_test_docs(1, text=True) |
477 | + self.keyboard.press_and_release('Ctrl+a') |
478 | + self.keyboard.press_and_release('Ctrl+x') |
479 | + #test it cut the selected text |
480 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
481 | + Eventually(Equals('')), |
482 | + "Two possible reasons for fail: \ |
483 | + 1) Ctrl+a did not select text, \ |
484 | + 2) Ctrl+x did not cut text.") |
485 | + |
486 | + def test_quit_gedit_shortcut(self, ): |
487 | + """ Using shortcut Ctrl+q, test gedit quits """ |
488 | + self.keyboard.press_and_release('Ctrl+q') |
489 | + # Since this closes the application and we lose the proxy |
490 | + # before we can test its gone, we can expect the exception to |
491 | + # assert gedit quit |
492 | + with ExpectedException(RuntimeError, |
493 | + "Application under test exited before the test finished!"): |
494 | + gedit = self.app.select_single('GeditWindow') |
495 | + self.assertTrue(gedit, Equals(None)) |
496 | + |
497 | + def test_sidebar_shortcut(self, ): |
498 | + """ Using F9 key test side panel opens/closes """ |
499 | + #test opening panel |
500 | + self.keyboard.press_and_release('F9') |
501 | + self.assertThat(lambda: self.app.select_many('GeditPanel')[0].visible, |
502 | + Eventually(Equals(1)), |
503 | + "Side panel did not open after pressing F9") |
504 | + #and close panel |
505 | + self.keyboard.press_and_release('F9') |
506 | + self.assertThat(lambda: self.app.select_many('GeditPanel')[0].visible, |
507 | + Eventually(Equals(0)), |
508 | + "Side panel did not close after pressing F9") |
509 | + |
510 | + def test_find_a_string_shortcut(self, ): |
511 | + """ Using shortcut Ctrl+f test we can search for string """ |
512 | + #Ctrl+f |
513 | + self.setup_test_docs(1, text=True) |
514 | + self.keyboard.press_and_release('Ctrl+f') |
515 | + self.keyboard.type('fox\n') |
516 | + #lets delete the highlighted word |
517 | + self.keyboard.press_and_release('Delete') |
518 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
519 | + Eventually( |
520 | + Equals('Document 1: The quick brown jumps over the lazy dog')), |
521 | + "fox was not highlighted and removed from phrase") |
522 | + |
523 | + #TODO: |
524 | + #def test_find_next_instance_of_string_shortcut(self, ): |
525 | + # pass |
526 | + # |
527 | + #def test_find_previous_instance_of_string_shortcut(self, ): |
528 | + # pass |
529 | + |
530 | + def test_search_and_replace_shortcut(self, ): |
531 | + """ Using shortcut Ctrl+h test the replace dialog opens """ |
532 | + self.keyboard.press_and_release('Ctrl+h') |
533 | + self.assertThat(lambda: self.app.select_single('GeditReplaceDialog').visible, |
534 | + Eventually(Equals(1)), |
535 | + "Replace dialog did not open") |
536 | + #TODO: |
537 | + #def test_clear_highlighted_text_shortcut(self, ): |
538 | + # #Ctrl+Shift+k |
539 | + # pass |
540 | + # |
541 | + #def test_go_to_line_shortcut(self, ): |
542 | + # #Ctrl+i |
543 | + # pass |
544 | + |
545 | +class GeditWindowTests(GeditAutopilotTestCase): |
546 | + |
547 | + def test_new_document_button(self, ): |
548 | + """ Test new doc button creates a new document """ |
549 | + #check that only the default tab is there |
550 | + num_tabs = len(self.app.select_many('GeditView')) |
551 | + self.assertThat(num_tabs, Equals(1)) |
552 | + # create new document |
553 | + self.pointing_device.click_object( |
554 | + self.app.select_single('GtkToolButton', |
555 | + name='FileNew')) |
556 | + #test new document is there and visible |
557 | + self.assertThat(num_tabs, Equals(1)) |
558 | + self.assertThat(lambda: self.app.select_many('GeditView')[1].is_focus, |
559 | + Eventually(Equals(1)), "New document was not created") |
560 | + |
561 | + def test_open_file_button(self, ): |
562 | + """ Using open button, test the file chooser dialog appears """ |
563 | + self.pointing_device.click_object( |
564 | + self.app.select_single('GeditOpenToolButton')) |
565 | + self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
566 | + Eventually(Equals(1)), "file chooser dialog did not open") |
567 | + |
568 | + def test_save_document_button(self, ): |
569 | + """ Using save button, test the save dialog appears """ |
570 | + # create a doc with some text so we can save |
571 | + self.setup_test_docs(1, text=True) |
572 | + self.pointing_device.click_object( |
573 | + self.app.select_single('GtkToolButton', |
574 | + name='FileSave')) |
575 | + self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
576 | + Eventually(Equals(1)), "The save dialog did not open") |
577 | + |
578 | + def test_print_document_button(self, ): |
579 | + """ Using print button, test the print dialog opens """ |
580 | + self.setup_test_docs(1) |
581 | + self.pointing_device.click_object( |
582 | + self.app.select_single('GtkToolButton', |
583 | + name='FilePrint')) |
584 | + self.assertThat(lambda: self.app.select_single('GtkPrintUnixDialog').visible, |
585 | + Eventually(Equals(1)), "The print dialog did not open") |
586 | + |
587 | + def test_undo_button(self, ): |
588 | + """ Test undo button, undoes last action """ |
589 | + self.setup_test_docs(1, text=True) |
590 | + self.pointing_device.click_object( |
591 | + self.app.select_single('GtkToolButton', |
592 | + name='EditUndo')) |
593 | + #Lets check we were able to undo the last word |
594 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
595 | + Eventually(Equals('Document 1: The quick brown fox jumps over the lazy ')), |
596 | + "Last word in phrase was not undone") |
597 | + |
598 | + def test_redo_button(self, ): |
599 | + """ Test redo button, redoes the last undo action """ |
600 | + self.setup_test_docs(1, text=True) |
601 | + self.pointing_device.click_object( |
602 | + self.app.select_single('GtkToolButton', |
603 | + name='EditUndo')) |
604 | + #Lets check we were able to undo the last word |
605 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
606 | + Eventually(Equals('Document 1: The quick brown fox jumps over the lazy ')), |
607 | + "Last word in phrase was not undone") |
608 | + self.pointing_device.click_object(self.app.select_single('GtkToolButton', |
609 | + name='EditRedo')) |
610 | + #Lets check we were able to redo the last word |
611 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
612 | + Eventually( |
613 | + Equals('Document 1: The quick brown fox jumps over the lazy dog')), |
614 | + "Redo shortcut did not redo the last word in phrase") |
615 | + |
616 | + def test_cut_button(self, ): |
617 | + """ Test the cut button cuts the selected text """ |
618 | + self.setup_test_docs(1, text=True) |
619 | + self.keyboard.press_and_release('Ctrl+a') |
620 | + self.pointing_device.click_object( |
621 | + self.app.select_single('GtkToolButton', |
622 | + name='EditCut')) |
623 | + #test it cut the selected text |
624 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
625 | + Eventually(Equals('')), |
626 | + "Two possible reasons for fail: \ |
627 | + 1) Ctrl+a did not select text, or \ |
628 | + 2) Cut button did not cut text.") |
629 | + |
630 | + def test_copy_and_paste_buttons(self, ): |
631 | + """ test we can copy and paste using buttons """ |
632 | + self.setup_test_docs(1, text=True) |
633 | + self.keyboard.press_and_release('Ctrl+a') |
634 | + #copy text |
635 | + self.pointing_device.click_object( |
636 | + self.app.select_single('GtkToolButton', |
637 | + name='EditCopy')) |
638 | + self.keyboard.press_and_release('Right') |
639 | + # now paste |
640 | + self.pointing_device.click_object( |
641 | + self.app.select_single('GtkToolButton', |
642 | + name='EditPaste')) |
643 | + # did it copy and paste correctly? |
644 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
645 | + Eventually( |
646 | + Equals( |
647 | + 'Document 1: The quick brown fox jumps over the lazy dogDocument 1: The quick brown fox jumps over the lazy dog' |
648 | + )), |
649 | + "Three possible reasons for fail: \ |
650 | + 1) Ctrl+a did not select text, \ |
651 | + 2) Copy button did not work or \ |
652 | + 3) Paste button did not work") |
653 | + |
654 | + def test_search_button(self, ): |
655 | + """ Test the search button opens the search box """ |
656 | + self.setup_test_docs(1, text=True) |
657 | + self.pointing_device.click_object( |
658 | + self.app.select_single('GtkToolButton', |
659 | + name='SearchFind')) |
660 | + self.keyboard.type('fox\n') |
661 | + #lets delete the highlighted word |
662 | + self.keyboard.press_and_release('Delete') |
663 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
664 | + Eventually( |
665 | + Equals('Document 1: The quick brown jumps over the lazy dog')), |
666 | + "fox was not highlighted and removed from phrase") |
667 | + |
668 | + def test_search_and_replace_button(self, ): |
669 | + """ Test the replace button opens the replace dialog """ |
670 | + self.pointing_device.click_object( |
671 | + self.app.select_single('GtkToolButton', |
672 | + name='SearchReplace')) |
673 | + self.assertThat(lambda: self.app.select_single('GeditReplaceDialog').visible, |
674 | + Eventually(Equals(1)), |
675 | + "Replace dialog did not open") |
676 | + |
677 | + def test_window_visible(self, ): |
678 | + """ Test the window loads """ |
679 | + self.assertThat(lambda: self.app.select_single('GeditWindow').visible, |
680 | + Eventually(Equals(1)), |
681 | + "Gedit window did not open") |
682 | + |
683 | + def test_window_title(self, ): |
684 | + """ Test the window title is correct """ |
685 | + self.assertThat(lambda: self.app.select_single('GeditWindow').title, |
686 | + Eventually(Equals("Untitled Document 1 - gedit")), |
687 | + "Gedit window did not match") |
688 | + |
689 | + def test_tab_name(self, ): |
690 | + """ Test the tab displays name """ |
691 | + self.assertThat(lambda: self.app.select_many('GeditTab')[0].name, |
692 | + Eventually(Equals("Untitled Document 1"))) |
693 | + |
694 | + # CAN WE ACCESS THE BOTTOM COMBOBOX'S???????????? |
695 | + |
696 | +class GeditSidebarTests(GeditAutopilotTestCase): |
697 | + |
698 | + def test_close_sidebar_button(self, ): |
699 | + #open panel |
700 | + self.keyboard.press_and_release('F9') |
701 | + self.assertThat(lambda: self.app.select_many('GeditPanel')[0].visible, |
702 | + Eventually(Equals(1)), |
703 | + "Side panel did not open after pressing F9") |
704 | + #and close panel using button |
705 | + self.pointing_device.click_object( |
706 | + self.app.select_many('GeditCloseButton')[0]) |
707 | + self.assertThat(lambda: self.app.select_many('GeditPanel')[0].visible, |
708 | + Eventually(Equals(0)), |
709 | + "Side panel did not close after clicking close button") |
710 | + |
711 | + #TODO: add more maybe test file browser tab and its button objects |
712 | + |
713 | + |
714 | +class GeditSaveFileTypeTests(GeditAutopilotTestCase): |
715 | + |
716 | + scenarios = [ |
717 | + ('single_char', {'input': "a"}), |
718 | + ('short_name', {'input': "test"}), |
719 | + ('long_name', {'input': "testfilenameforgedit"}), |
720 | + ('extra_long_name', {'input': "autopilotlongfilenamefortesting"}), |
721 | + ('python_file', {'input': "gedit.py"}), |
722 | + ('C_file', {'input': "gedit.c"}), |
723 | + ('cpp_file', {'input': "gedit.cpp"}), |
724 | + ('xml_file', {'input': "gedit.xml"}), |
725 | + ('vala_file', {'input': "gedit.vala"}), |
726 | + ('html_file', {'input': "gedit.html"}), |
727 | + ] |
728 | + |
729 | + def test_save_file_type_tests(self, ): |
730 | + #setup test with empty doc and save dialog opened |
731 | + self.setup_test_docs(1, save_dlg=True) |
732 | + save_dlg = self.app.select_single('GeditFileChooserDialog') |
733 | + self.pointing_device.move_to_object( |
734 | + save_dlg.select_single('GtkLabel', |
735 | + label='_Cancel')) |
736 | + #for each scenario enter filename |
737 | + self.keyboard.type(self.input) |
738 | + #click save |
739 | + |
740 | + self.pointing_device.click_object( |
741 | + save_dlg.select_single('GtkLabel', label='_Save')) |
742 | + #check dialog closed before checking for file |
743 | + self.assertThat(lambda: self.app.select_many('GeditTab')[0].name, |
744 | + Eventually(Equals(self.input)), |
745 | + "Tab did not contain filename "+self.input) |
746 | + filename = self.input |
747 | + |
748 | + self.assertThat('/tmp/'+filename, FileExists()) |
749 | + #add cleanup |
750 | + self.addCleanup(os.remove, '/tmp/%s' % self.input) |
751 | + |
752 | + |
753 | +class GeditSaveDialogTests(GeditAutopilotTestCase): |
754 | + |
755 | + def test_esc_key_closes_dialog(self, ): |
756 | + self.setup_test_docs(1, save_dlg=True) |
757 | + self.keyboard.press_and_release('Escape') |
758 | + # THe fact we can't select dialog shows it closed |
759 | + with ExpectedException(AttributeError, |
760 | + "'NoneType' object has no attribute 'visible'"): |
761 | + self.assertThat(lambda: self.app.select_single( |
762 | + 'GeditFileChooserDialog').visible, |
763 | + Eventually(Equals(0)), |
764 | + "Dialog didn't close") |
765 | + |
766 | + def test_cancel_button_closes_dialog(self, ): |
767 | + self.setup_test_docs(1, save_dlg=True) |
768 | + save_dialog = self.app.select_single('GeditFileChooserDialog') |
769 | + self.pointing_device.click_object( |
770 | + save_dialog.select_single('GtkLabel', |
771 | + label='_Cancel')) |
772 | + # The fact we can't select dialog shows it closed |
773 | + with ExpectedException(AttributeError, |
774 | + "'NoneType' object has no attribute 'visible'"): |
775 | + self.assertThat(lambda: self.app.select_single( |
776 | + 'GeditFileChooserDialog').visible, |
777 | + Eventually(Equals(0)), |
778 | + "Dialog didn't close") |
779 | + |
780 | + def test_new_folder_button(self, ): |
781 | + self.setup_test_docs(1, save_dlg=True) |
782 | + save_dialog = self.app.select_single('GeditFileChooserDialog') |
783 | + self.pointing_device.click_object( |
784 | + save_dialog.select_single('GtkButton', |
785 | + label='Create Fo_lder')) |
786 | + self.keyboard.type('test_folder\n') |
787 | + self.assertThat('/tmp/test_folder', DirExists()) |
788 | + self.addCleanup(os.rmdir, '/tmp/test_folder') |
789 | + |
790 | +class GeditOpenFileTypesTests(GeditAutopilotTestCase): |
791 | + scenarios = [ |
792 | + ('test_file', {'input': "test"}), |
793 | + ('py_file', {'input': "gedit.py"}), |
794 | + ('c_file', {'input': "gedit1.c"}), |
795 | + ('cpp_file', {'input': "gedit.cpp"}), |
796 | + ('vala_file', {'input': "gedit.vala"}), |
797 | + ('xml_file', {'input': "gedit.xml"}), |
798 | + ] |
799 | + |
800 | + def test_open_file_type_tests(self, ): |
801 | + self.setup_test_docs(1, opn_dlg=True) |
802 | + self.keyboard.type(self.input) |
803 | + dialog = self.app.select_single('GeditFileChooserDialog') |
804 | + self.pointing_device.click_object(dialog.select_single('GtkLabel', |
805 | + label='_Open')) |
806 | + self.assertThat(lambda: self.app.select_single('GeditWindow').title, |
807 | + Eventually(Contains(self.input))) |
808 | + |
809 | + |
810 | +class GeditOpenDialogTests(GeditAutopilotTestCase): |
811 | + |
812 | + def test_esc_key_closes_dialog(self, ): |
813 | + self.pointing_device.click_object( |
814 | + self.app.select_single('GeditOpenToolButton')) |
815 | + self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
816 | + Eventually(Equals(1)), "file chooser dialog did not open") |
817 | + self.keyboard.press_and_release('Escape') |
818 | + # The fact we can't select dialog shows it closed |
819 | + with ExpectedException(AttributeError, |
820 | + "'NoneType' object has no attribute 'visible'"): |
821 | + self.assertThat(lambda: self.app.select_single( |
822 | + 'GeditFileChooserDialog').visible, |
823 | + Eventually(Equals(0)), |
824 | + "Dialog didn't close") |
825 | + |
826 | + def test_cancel_button_closes_dialog(self, ): |
827 | + self.pointing_device.click_object( |
828 | + self.app.select_single('GeditOpenToolButton')) |
829 | + self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
830 | + Eventually(Equals(1)), "file chooser dialog did not open") |
831 | + open_dialog = self.app.select_single('GeditFileChooserDialog') |
832 | + self.pointing_device.click_object( |
833 | + open_dialog.select_single('GtkLabel', |
834 | + label='_Cancel')) |
835 | + # The fact we can't select dialog shows it closed |
836 | + with ExpectedException(AttributeError, |
837 | + "'NoneType' object has no attribute 'visible'"): |
838 | + self.assertThat(lambda: self.app.select_single( |
839 | + 'GeditFileChooserDialog').visible, |
840 | + Eventually(Equals(0)), |
841 | + "Dialog didn't close") |
842 | + |
843 | + def test_recent_docs_displayed_on_load(self, ): |
844 | + self.pointing_device.click_object( |
845 | + self.app.select_single('GeditOpenToolButton')) |
846 | + self.assertThat(lambda: self.app.select_single('GeditFileChooserDialog').visible, |
847 | + Eventually(Equals(1)), "file chooser dialog did not open") |
848 | + open_dialog = self.app.select_single('GeditFileChooserDialog') |
849 | + self.assertThat(lambda: open_dialog.select_single('GtkLabel', |
850 | + label='<b>Recently Used</b>').visible, |
851 | + Eventually(Equals(1)), "Recently used not visible") |
852 | + |
853 | + |
854 | +class GeditReplaceDialogTests(GeditAutopilotTestCase): |
855 | + |
856 | + def test_find_and_replace_buttons(self, ): |
857 | + self.setup_test_docs(1, text=True, replace_dlg=True) |
858 | + self.keyboard.type('fox') |
859 | + self.assertTrue(self.search_entry_text.text, Equals('fox')) |
860 | + self.pointing_device.click_object(self.replace_entry) |
861 | + self.keyboard.type('foxes') |
862 | + self.assertTrue(self.replace_entry_text.text, Equals('foxes')) |
863 | + self.pointing_device.click_object(self.find_button) |
864 | + #lets check replace button is now clickable |
865 | + self.assertThat(self.replace_button.sensitive, Eventually(Equals(1))) |
866 | + self.pointing_device.click_object(self.replace_button) |
867 | + #test text was replaced |
868 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
869 | + Eventually(Equals('Document 1: The quick brown foxes jumps over the lazy dog'))) |
870 | + |
871 | + def test_match_case_option(self, ): |
872 | + # test doesnt match |
873 | + self.setup_test_docs(1, text=True, replace_dlg=True) |
874 | + self.keyboard.type('Fox') |
875 | + self.assertTrue(self.search_entry_text.text, Equals('Fox')) |
876 | + self.pointing_device.click_object(self.mtch_chkbtn) |
877 | + #check its selected |
878 | + self.assertTrue(self.mtch_chkbtn.active, Equals(1)) |
879 | + self.pointing_device.click_object(self.replace_all_button) |
880 | + #FIXME: |
881 | + #the replace button should stay inactive as it doesn't match case |
882 | + #for some reason it says the sensitive property is 1 but in vis shows 0 |
883 | + #self.assertThat(self.replace_button.sensitive, Equals(0)) |
884 | + #instead click replace all and check fox was not replaced in the buffer |
885 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
886 | + Eventually(Equals('Document 1: The quick brown fox jumps over the lazy dog'))) |
887 | + #test does match |
888 | + self.pointing_device.click_object(self.search_entry) |
889 | + self.keyboard.press_and_release('Ctrl+a') |
890 | + self.keyboard.type('fox') |
891 | + self.pointing_device.click_object(self.replace_all_button) |
892 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
893 | + Eventually(Equals('Document 1: The quick brown jumps over the lazy dog'))) |
894 | + |
895 | + def test_match_entire_word_option(self, ): |
896 | + self.setup_test_docs(1, text=True, replace_dlg=True) |
897 | + self.keyboard.type('fo') |
898 | + self.assertTrue(self.search_entry_text.text, Equals('fo')) |
899 | + self.pointing_device.click_object(self.entire_chkbtn) |
900 | + #check its selected |
901 | + self.assertTrue(self.entire_chkbtn.active, Equals(1)) |
902 | + #FIXME: |
903 | + #the replace button should stay inactive as it doesn't match entire word |
904 | + #for some reason it says the sensitive property is 1 but in vis shows 0 |
905 | + #self.pointing_device.click_object(self.find_button) |
906 | + #self.assertThat(self.replace_button.sensitive, Equals(0)) |
907 | + #instead click replace all and check fox was not replaced in the buffer |
908 | + self.pointing_device.click_object(self.replace_all_button) |
909 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
910 | + Eventually(Equals('Document 1: The quick brown fox jumps over the lazy dog'))) |
911 | + #test does match |
912 | + self.pointing_device.click_object(self.search_entry) |
913 | + self.keyboard.press_and_release('Ctrl+a') |
914 | + self.keyboard.type('fox') |
915 | + self.pointing_device.click_object(self.replace_all_button) |
916 | + self.assertThat(lambda: self.app.select_many('GeditView')[0].buffer, |
917 | + Eventually(Equals('Document 1: The quick brown jumps over the lazy dog'))) |
918 | + |
919 | + def test_esc_key_closes_dialog(self, ): |
920 | + self.setup_test_docs(1, replace_dlg=True) |
921 | + self.keyboard.press_and_release('Escape') |
922 | + self.assertThat(lambda: self.app.select_single( |
923 | + 'GeditReplaceDialog').visible, |
924 | + Eventually(Equals(0)),"Dialog didn't close") |
925 | + |
926 | + def test_close_button_closes_dialog(self, ): |
927 | + self.setup_test_docs(1, replace_dlg=True) |
928 | + self.pointing_device.click_object(self.close_button) |
929 | + self.assertThat(lambda: self.app.select_single( |
930 | + 'GeditReplaceDialog').visible, |
931 | + Eventually(Equals(0)),"Dialog didn't close") |
932 | + |
933 | + |
934 | +class GeditSingleFileCommandLineTest(AutopilotTestCase): |
935 | + |
936 | + def setUp(self): |
937 | + super(GeditSingleFileCommandLineTest, self).setUp() |
938 | + sample_file = 'test' |
939 | + for root, dirs, files in os.walk(os.getcwd()): |
940 | + for name in files: |
941 | + if name == sample_file: |
942 | + file_path = os.path.abspath(os.path.join(root, name)) |
943 | + self.gedit = self.launch_test_application("gedit", file_path) |
944 | + |
945 | + #can we open files in gedit from terminal |
946 | + def test_open_single_file(self, ): |
947 | + self.assertThat(lambda: self.gedit.select_single('GeditWindow').title, |
948 | + Eventually(Contains('test'))) |
949 | + |
950 | + |
951 | +class GeditMultiFileCommandLineTest(AutopilotTestCase): |
952 | + |
953 | + def setUp(self): |
954 | + super(GeditMultiFileCommandLineTest, self).setUp() |
955 | + sample_dir = 'samples' |
956 | + for root, dirs, files in os.walk(os.getcwd()): |
957 | + for name in dirs: |
958 | + if name == sample_dir: |
959 | + file_path = os.path.abspath(os.path.join(root, name)) |
960 | + self.gedit = self.launch_test_application("gedit", |
961 | + file_path+'/test', |
962 | + file_path+'/gedit.py', |
963 | + file_path+'/gedit.c', |
964 | + file_path+'/gedit.vala') |
965 | + |
966 | + def test_open_multi_files(self, ): |
967 | + |
968 | + #the first opened doc 'tab 1' should be in the title |
969 | + self.assertThat(lambda: self.gedit.select_single('GeditWindow').title, |
970 | + Eventually(Contains('test'))) |
971 | + #check 4 tabs are there |
972 | + self.assertThat(len(self.gedit.select_many('GeditTab')), Equals(4)) |
973 | + #TODO: test the contents of the files are diplayed |
974 | + # but is this needed? as tab title is covered by |
975 | + # another test and so is file contents displayed |
976 | + |
977 | +class GeditCommandLineTests(AutopilotTestCase): |
978 | + |
979 | + def setUp(self): |
980 | + super(GeditCommandLineTests, self).setUp() |
981 | self.app = self.launch_test_application("gedit") |
982 | - |
983 | - def test_save_and_open_a_file(self): |
984 | - #Test-case name: gedit/ged-001 |
985 | - #This test will check that GEdit can save and open saved files |
986 | - #close the original blank document |
987 | - self.keyboard.press_and_release("Ctrl+w") |
988 | - |
989 | - #documents = self.app.select_single('GeditTab') |
990 | - #self.assertThat(lambda: self.app.select_single('GeditTab').name, Eventually(Contains(fileName))) |
991 | - |
992 | - documents = self.app.select_many('GeditTab') |
993 | - self.assertThat(lambda: len(documents), Eventually(Equals(0))) |
994 | - |
995 | - #open a new blank document |
996 | - btn = self.app.select_single('GtkToolButton', label='_New') |
997 | - self.assertThat(btn, NotEquals(None)) |
998 | - self.mouse.move_to_object(btn) |
999 | - self.mouse.click() |
1000 | - |
1001 | - #hacky delay to wait |
1002 | - sleep(1) |
1003 | - |
1004 | - self.keyboard.type("The quick brown foxes jump over the lazy dog") |
1005 | - |
1006 | - #save file |
1007 | - tempFile = _generateTempFileName() |
1008 | - self._saveFile(tempFile) |
1009 | - |
1010 | - #Close the open file |
1011 | - self.keyboard.press_and_release("Ctrl+w") |
1012 | - |
1013 | - #Make sure it closed |
1014 | - documents = self.app.select_many('GeditTab') |
1015 | - self.assertThat(lambda: len(documents), Eventually(Equals(0))) |
1016 | - |
1017 | - #Open the file we made |
1018 | - btn = self.app.select_single('GeditOpenToolButton', label='Open') |
1019 | - self.assertThat(btn, NotEquals(None)) |
1020 | - self.mouse.move_to_object(btn) |
1021 | - self.mouse.click() |
1022 | - |
1023 | - #hacky delay wait for window to appear :-( |
1024 | - sleep(3) |
1025 | - |
1026 | - #Manually type location |
1027 | - self.keyboard.type(tempFile + "\n") |
1028 | - |
1029 | - #Check to see that the title reflects our filename |
1030 | - #(dirName, fileName) = os.path.split(tempFile) |
1031 | - #documents = self.app.select_single('GeditTab') |
1032 | - #self.assertThat(lambda: documents[0].name, Eventually(Contains(fileName))) |
1033 | - |
1034 | - #Check that the file contains the phrase "The quick brown foxes jump over the lazy dog" |
1035 | - filePhrase = open(tempFile, 'r') |
1036 | - self.assertThat(filePhrase, Contains("The quick brown foxes jump over the lazy dog\n")) |
1037 | - |
1038 | - #Close the open file |
1039 | - self.keyboard.press_and_release("Ctrl+w") |
1040 | - |
1041 | - #Delete the file we made |
1042 | - #Added sleep so file does not get removed too soon |
1043 | - sleep(1) |
1044 | - self.addCleanup(os.remove, tempFile) |
1045 | - |
1046 | - def test_replace_test(self): |
1047 | - #Test-case name: gedit/ged-003 |
1048 | - #This test will check that GEdit can replace text |
1049 | - |
1050 | - #Type in phrase |
1051 | - self.keyboard.type("The quick brown foxes jump over the lazy dog") |
1052 | - |
1053 | - #Press ctrl+h to open replace dialog |
1054 | - self.keyboard.press_and_release("Ctrl+h") |
1055 | - |
1056 | - #Verify replace dialog appears |
1057 | - #TODO |
1058 | - |
1059 | - #Replace foxes with fox |
1060 | - self.keyboard.type("foxes\t\tfox") |
1061 | - self.keyboard.press_and_release("Alt+a") |
1062 | - |
1063 | - #Verify replace dialog stays open |
1064 | - #TODO |
1065 | - |
1066 | - #Close replace dialog |
1067 | - self.keyboard.press_and_release("Escape") |
1068 | - |
1069 | - #Save file |
1070 | - tempFile = _generateTempFileName() |
1071 | - print "tempFile " + tempFile |
1072 | - self._saveFile(tempFile) |
1073 | - |
1074 | - #Verify text now reads 'The quick brown fox jump over the lazy dog' |
1075 | - savedFile = open(tempFile, "r") |
1076 | - filePhrase = savedFile.read() |
1077 | - self.assertThat(filePhrase, Contains("The quick brown fox jump over the lazy dog\n")) |
1078 | - |
1079 | - #Close the open file |
1080 | - self.keyboard.press_and_release("Ctrl+w") |
1081 | - |
1082 | - #Delete the file we made |
1083 | - sleep(3) |
1084 | - self.addCleanup(os.remove, tempFile) |
1085 | - |
1086 | - def test_recent_documents(self): |
1087 | - #GeditOpenToolButton tooltip_text Open '/tmp/' |
1088 | - recentBtn = self.app.select_single('GeditOpenToolButton', label='Open') |
1089 | - self.assertThat(recentBtn, NotEquals(None)) |
1090 | - self.mouse.move_to_object(recentBtn) |
1091 | - self.mouse.click() |
1092 | - #inserted sleep to see the recent files otherwise window closes too quicly |
1093 | - sleep(2) |
1094 | - |
1095 | - def test_highlight_searched_text(self): |
1096 | - #Test-case name: gedit/ged-004 |
1097 | - #This test will check that GEdit can find and highlight searched text |
1098 | - |
1099 | - #Type in phrase |
1100 | - self.keyboard.type("The quick brown foxes jump over the lazy dog") |
1101 | - |
1102 | - #Press Ctrl+f to open search box |
1103 | - self.keyboard.press_and_release("Ctrl+f") |
1104 | - |
1105 | - #Verify search box appears |
1106 | - #TODO |
1107 | - |
1108 | - #Type in "T" |
1109 | - self.keyboard.type("T") |
1110 | - sleep(3) |
1111 | - |
1112 | - #Verify all the "T" letters in the document are highlighted |
1113 | - #TODO |
1114 | - |
1115 | - #Type in "he" |
1116 | - self.keyboard.type("he") |
1117 | - |
1118 | - #Verify all the "The" words in the document are highlighted |
1119 | - #TODO |
1120 | - |
1121 | - #Press Ctrl+g to go to the next searched word |
1122 | - self.keyboard.press_and_release("Ctrl+g") |
1123 | - |
1124 | - #Verify that text cursor moves to grey-highlighted 'the' in 'over the lazy dog' |
1125 | - #TODO |
1126 | - |
1127 | - #Press Shift+Ctrl+g to go to the previous searched word |
1128 | - self.keyboard.press_and_release("Shift+Ctrl+g") |
1129 | - |
1130 | - #Verify that text cursor moves to grey-highlighted 'The' in 'The quick brown' |
1131 | - #TODO |
1132 | - |
1133 | - #Close search box |
1134 | - self.keyboard.press_and_release("Escape") |
1135 | - |
1136 | - #Verify that the seach box is closed |
1137 | - #TODO |
1138 | - |
1139 | - #Verify all the "The" words in the document are highlighted |
1140 | - #TODO |
1141 | - |
1142 | - #Close the open file |
1143 | - self.keyboard.press_and_release("Ctrl+w") |
1144 | - |
1145 | - #Don't save |
1146 | - sleep(3) |
1147 | - self.keyboard.press_and_release("Alt+w") |
1148 | - |
1149 | - def test_display_file_browser_panel(self): |
1150 | - #Test-case name: gedit/ged-005 |
1151 | - #This test will check that GEdit can display File Browser panel |
1152 | - |
1153 | - #These property's exist |
1154 | - #GeditCloseButton tooltip_text "Hide panel" |
1155 | - #GtkPaned GtkBox GtkBox GtkBox GtkLabel label "Documents" |
1156 | - #GtkPaned GtkBox GtkBox GtkBox GtkLabel label "File Browser" |
1157 | - #GtkFileBrowserWidget |
1158 | - #GeditDocumentsPanel |
1159 | - #GtkWindow GtkMenu GtkLabel label "Documents" |
1160 | - #GtkWindow GtkMenu GtkLabel label "File Browser" |
1161 | - |
1162 | - #Press Alt+e to open "Edit" menu |
1163 | - self.keyboard.press_and_release("Alt+e", delay=0.5) |
1164 | - |
1165 | - #Press "e" to open "Preferences" |
1166 | - self.keyboard.press_and_release("e") |
1167 | - |
1168 | - #combo_box_widget = self.app.select_single('ComboBox', name='foobar', someOtherProperty=123) |
1169 | - |
1170 | - #Press left arrow "Plugins" tab |
1171 | - self.keyboard.press_and_release("Left") |
1172 | - |
1173 | - #Verify the "File Browser Panel" plugin is checked |
1174 | - #TODO |
1175 | - |
1176 | - #Press Escape to close preferences window |
1177 | - self.keyboard.press_and_release("Escape") |
1178 | - |
1179 | - #Press F9 |
1180 | - self.keyboard.press_and_release("F9") |
1181 | - |
1182 | - #Verify the The side panel appears with the file browser panel included |
1183 | - #should spawn "Documents" |
1184 | - #introspection |
1185 | - #self.assertThat(self.app.select_many('GtkLabel', label='Documents'), NotEquals(None)) |
1186 | - |
1187 | - #Press F9 |
1188 | - self.keyboard.press_and_release("F9") |
1189 | - |
1190 | - #Verify the The side panel close properly |
1191 | - #this seems to stick around the tree -- look for visible property? |
1192 | - #self.assertThat(self.app.select_many('GtkLabel', label='Documents'), Equals(None)) |
1193 | - #self.assertThat(self.app.select_many('GeditCloseButton', tooltip_text='Hide panel'), Equals(None)) |
1194 | - |
1195 | - def test_tab_manipulation(self): |
1196 | - return |
1197 | - #test using alt keys to move between docus |
1198 | - #test using ctrl+w to close tabs |
1199 | - #test ctrl+t for new tabs |
1200 | - #test button for new tab |
1201 | - #test creating tab group |
1202 | - #test moving tab group to new window |
1203 | - |
1204 | - #def test_insert_overwrite_mode(self): |
1205 | - #verify we are in insert mode |
1206 | - #GeditWindow GtkBox GeditStatusbar GtkLabel |
1207 | - #typeMode = self.app.select_single('GtkLabel', label=' INS ') |
1208 | - #typeMode = self.app.select_many('GtkLabel', label=' INS ') |
1209 | - #self.assertThat(typeMode, NotEquals(None)) |
1210 | - |
1211 | - |
1212 | - #type out some words |
1213 | - |
1214 | - #turn on overwrite, and press home |
1215 | - #self.keyboard.press_and_release("Home") |
1216 | - #self.keyboard.press_and_release("Insert") |
1217 | - #self.assertThat(typeMode.label, Equals(' OVR ')) |
1218 | - |
1219 | - |
1220 | - #type over the first word |
1221 | - #turn on insert |
1222 | - #add a word in the middle |
1223 | - #save file and check result matches |
1224 | - |
1225 | - def test_shortcuts(self): |
1226 | - return |
1227 | - #test search, go to line |
1228 | - #plugin! test edit, insert date and time |
1229 | - #test copy and paste into doc |
1230 | - #test save all |
1231 | - #test close all |
1232 | - #test revert |
1233 | - #test undo and redo |
1234 | - |
1235 | - def test_toolbar(self): |
1236 | - #test new |
1237 | - #GeditWindow GtkBox GtkToolbar GtkToolButton |
1238 | - #grab the file new button |
1239 | - btn = self.app.select_single('GtkToolButton', label='_New') |
1240 | - |
1241 | - #does it exist? |
1242 | - self.assertThat(btn, NotEquals(None)) |
1243 | - |
1244 | - #let's click it to open a new document |
1245 | - documents = self.app.select_many('GeditTab') |
1246 | - orginalNumDocuments = len(documents) |
1247 | - self.mouse.move_to_object(btn) |
1248 | - self.mouse.click() |
1249 | - |
1250 | - #let's re-grab the open documents |
1251 | - documents = self.app.select_many('GeditTab') |
1252 | - |
1253 | - #do we have another document now? |
1254 | - self.assertThat(lambda: len(documents), Eventually(Equals(orginalNumDocuments + 1))) |
1255 | - |
1256 | - #is it a new untitled document? |
1257 | - #This will grab the current window title, 'Untitled Document # - gedit', but the untitled document is translated. For now, we'll ignore the translatable text to ensure compatibility |
1258 | - documents = self.app.select_many('GeditTab') |
1259 | - #note index starts at 0 |
1260 | - self.assertThat(documents[orginalNumDocuments].name, Contains(str(orginalNumDocuments + 1))) |
1261 | - |
1262 | - #test open |
1263 | - btn = self.app.select_single('GeditOpenToolButton', label='Open') |
1264 | - self.assertThat(btn, NotEquals(None)) |
1265 | - |
1266 | - #test save |
1267 | - btn = self.app.select_single('GtkToolButton', label='Save') |
1268 | - self.assertThat(btn, NotEquals(None)) |
1269 | - |
1270 | - #test print |
1271 | - btn = self.app.select_single('GtkToolButton', label='Print') |
1272 | - self.assertThat(btn, NotEquals(None)) |
1273 | - |
1274 | - #test undo |
1275 | - btn = self.app.select_single('GtkToolButton', label='_Undo') |
1276 | - self.assertThat(btn, NotEquals(None)) |
1277 | - |
1278 | - #test redo |
1279 | - btn = self.app.select_single('GtkToolButton', label='_Redo') |
1280 | - self.assertThat(btn, NotEquals(None)) |
1281 | - |
1282 | - #test cut |
1283 | - btn = self.app.select_single('GtkToolButton', label='Cu_t') |
1284 | - self.assertThat(btn, NotEquals(None)) |
1285 | - |
1286 | - #test copy |
1287 | - btn = self.app.select_single('GtkToolButton', label='_Copy') |
1288 | - self.assertThat(btn, NotEquals(None)) |
1289 | - |
1290 | - #test paste |
1291 | - btn = self.app.select_single('GtkToolButton', label='_Paste') |
1292 | - self.assertThat(btn, NotEquals(None)) |
1293 | - |
1294 | - #test search |
1295 | - btn = self.app.select_single('GtkToolButton', label='Find') |
1296 | - self.assertThat(btn, NotEquals(None)) |
1297 | - |
1298 | - #test replace |
1299 | - btn = self.app.select_single('GtkToolButton', label='Replace') |
1300 | - self.assertThat(btn, NotEquals(None)) |
1301 | - |
1302 | - def _saveFile(self, saveName): |
1303 | - saveBtn = self.app.select_single('GtkToolButton', label='Save') |
1304 | - self.assertThat(saveBtn, NotEquals(None)) |
1305 | - self.mouse.move_to_object(saveBtn) |
1306 | - self.mouse.click() |
1307 | - |
1308 | - #hacky delay wait for window to appear :-( |
1309 | - sleep(3) |
1310 | - |
1311 | - self.keyboard.type(saveName) |
1312 | - self.keyboard.press_and_release("Alt+s") |
1313 | - |
1314 | - #Check to see that the title reflects our filename |
1315 | - (dirName, fileName) = os.path.split(saveName) |
1316 | - documents = self.app.select_many('GeditTab') |
1317 | - self.assertThat(documents[len(documents) - 1].name, Eventually(Contains(fileName))) |
1318 | - |
1319 | - #An asterisk in a gedit title means an unsaved document |
1320 | - self.assertNotIn(documents[len(documents) - 1].name, "*") |
1321 | - |
1322 | -def _generateTempFileName(): |
1323 | - #Create temporary file, then close it, so we can re-use the file name |
1324 | - sFile = tempfile.NamedTemporaryFile() |
1325 | - sFile.close() |
1326 | - return sFile.name |
1327 | + |
1328 | + |
1329 | + def test_new_doc_arg(self, ): |
1330 | + #check window open with one tab |
1331 | + self.assertThat(lambda: self.app.select_single('GeditWindow').visible, |
1332 | + Eventually(Equals(1))) |
1333 | + self.assertThat(len(self.app.select_many('GeditTab')), Equals(1)) |
1334 | + #now lets use the --new-document argument and we should get another tab |
1335 | + subprocess.check_call(["gedit", "--new-document"]) |
1336 | + self.assertThat(lambda: self.app.select_many('GeditTab')[1].visible, Eventually(Equals(1))) |
1337 | + |
1338 | + def test_new_window_arg(self, ): |
1339 | + self.assertThat(lambda: self.app.select_single('GeditWindow').visible, |
1340 | + Eventually(Equals(1))) |
1341 | + #now lets use the --new-window argument and we should get another window |
1342 | + |
1343 | + subprocess.check_call(["gedit", "--new-window"]) |
1344 | + self.assertThat(lambda: self.app.select_many('GeditWindow')[1].visible, |
1345 | + Eventually(Equals(1))) |
1346 | + #lets just confirm we have 2 windows |
1347 | + self.assertThat(len(self.app.select_many('GeditWindow')), Equals(2)) |
Ok, I would do a few things here. This testcase looks like we can really test the app so much more with the new introspection bits. Good stuff!
Things we should do before pushing this:
-- Let's try and remove the basic sleeps
1) Remove this by checking for a new tab -- #Why not just check there is eventually a new tab??????? select_ many('GeditTab' )
self.assertTha t(documents[ orginalNumDocum ents].name, Contains( str(orginalNumD ocuments + 1)))
I see this logic in the code that could work
documents = self.app.
#note index starts at 0
2) The sleep(3) occurences. They occur waiting for subwindows like open/save/close dialogs. Can we check properly for these to appear? If not, we should think carefully about pushing anyway, if we want this to go to prod.
-- Let's comment out completely the tests that have no asserts, or add a simple assert. Every test needs a assert or there's no reason to even run it.
Things still needing work for later:
-- We should stop using keyboard shortcuts for everything and convert to mouse movements where it makes sense. Click the save button, don't use alt+s, etc
-- We should finish out some of the stubbed testcases; anything we've commented out above, along with expanding the testcases using objects since we can access them now.