Merge lp:~roignac/mago/gcalctool into lp:~mago-contributors/mago/mago-testsuite
- gcalctool
- Merge into mago-testsuite
Proposed by
Vadim Rutkovsky
Status: | Needs review |
---|---|
Proposed branch: | lp:~roignac/mago/gcalctool |
Merge into: | lp:~mago-contributors/mago/mago-testsuite |
Diff against target: |
735 lines (+725/-0) 2 files modified
gnome-calculator/mago_gcalctool.py (+171/-0) gnome-calculator/test_gnome-calculator.py (+554/-0) |
To merge this branch: | bzr merge lp:~roignac/mago/gcalctool |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jean-Baptiste Lallement | Pending | ||
Mago Contributors | Pending | ||
Review via email: mp+70711@code.launchpad.net |
Commit message
Description of the change
The branch contains tests for Gnome Calculator (smoke test cases + several regression checks)
To post a comment you must log in.
lp:~roignac/mago/gcalctool
updated
- 41. By Vadim Rutkovsky
-
Added classfile
Unmerged revisions
- 41. By Vadim Rutkovsky
-
Added classfile
- 40. By Vadim Rutkovsky
-
Added test for bug 302115
- 39. By Vadim Rutkovsky
-
Added test for bug 288446
- 38. By Vadim Rutkovsky
-
Added input_from_keyboard function
- 37. By Vadim Rutkovsky
-
Clean up, added more tests
- 36. By Vadim Rutkovsky
-
* Moved object definition to mago_gnome-
calculator. py
* Added cases bug515280 and bug499211 - 35. By Vadim Rutkovsky
-
Refactored cases
- 34. By Vadim Rutkovsky
-
Added case for lp:#204682
- 33. By Vadim Rutkovsky
-
Added case for lp:#32200
- 32. By Vadim Rutkovsky
-
Added case for lp:#28928
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory 'gnome-calculator' | |||
2 | === added file 'gnome-calculator/mago_gcalctool.py' | |||
3 | --- gnome-calculator/mago_gcalctool.py 1970-01-01 00:00:00 +0000 | |||
4 | +++ gnome-calculator/mago_gcalctool.py 2011-08-08 09:54:34 +0000 | |||
5 | @@ -0,0 +1,171 @@ | |||
6 | 1 | #!/usr/bin/ipython | ||
7 | 2 | # -*- coding: utf-8 -*- | ||
8 | 3 | # Copyright (C) 2010 Canonical Ltd | ||
9 | 4 | # | ||
10 | 5 | # This program is free software; you can redistribute it and/or modify | ||
11 | 6 | # it under the terms of the GNU General Public License as published by | ||
12 | 7 | # the Free Software Foundation; either version 2 of the License, or | ||
13 | 8 | # (at your option) any later version. | ||
14 | 9 | # | ||
15 | 10 | # This program is distributed in the hope that it will be useful, | ||
16 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | 13 | # GNU General Public License for more details. | ||
19 | 14 | # | ||
20 | 15 | # You should have received a copy of the GNU General Public License | ||
21 | 16 | # along with this program; if not, write to the Free Software | ||
22 | 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
23 | 18 | |||
24 | 19 | import ldtp, ooldtp | ||
25 | 20 | |||
26 | 21 | class GnomeCalculator(): | ||
27 | 22 | menu = { | ||
28 | 23 | 'Calculator' : { | ||
29 | 24 | 'Menu' : 'mnuCalculator', | ||
30 | 25 | 'Copy' : 'mnuCopy', | ||
31 | 26 | 'Paste' : 'mnuPaste', | ||
32 | 27 | 'Undo' : 'mnuUndo', | ||
33 | 28 | 'Preferences': 'mnuPreferences', | ||
34 | 29 | 'Quit' : 'mnuQuit', | ||
35 | 30 | }, | ||
36 | 31 | 'Mode' : { | ||
37 | 32 | 'Menu' : 'mnuMode', | ||
38 | 33 | 'Basic' : 'mnuBasic', | ||
39 | 34 | 'Advanced' : 'mnuAdvanced', | ||
40 | 35 | 'Financial' : 'mnuFinancial', | ||
41 | 36 | 'Programming': 'mnuProgramming' | ||
42 | 37 | }, | ||
43 | 38 | 'Help' : { | ||
44 | 39 | 'Menu' : 'mnuHelp', | ||
45 | 40 | 'Contents' : 'mnuContents', | ||
46 | 41 | 'Get Help Online' : 'mnuGetHelpOnline', | ||
47 | 42 | 'Translate' : 'mnuTranslateThisApplication', | ||
48 | 43 | 'Report a Problem': 'mnuReportaProblem', | ||
49 | 44 | 'About' : 'mnuAbout' | ||
50 | 45 | } | ||
51 | 46 | } | ||
52 | 47 | |||
53 | 48 | controls = { | ||
54 | 49 | 'Output' : 'txt0', | ||
55 | 50 | 'Error' : 'txt1', | ||
56 | 51 | '1' : 'btn1', | ||
57 | 52 | '2' : 'btn2', | ||
58 | 53 | '3' : 'btn3', | ||
59 | 54 | '4' : 'btn4', | ||
60 | 55 | '5' : 'btn5', | ||
61 | 56 | '6' : 'btn6', | ||
62 | 57 | '7' : 'btn7', | ||
63 | 58 | '8' : 'btn8', | ||
64 | 59 | '9' : 'btn9', | ||
65 | 60 | '0' : 'btn0', | ||
66 | 61 | '.' : 'btnnumericpoint', | ||
67 | 62 | '%' : 'btnpercentage', | ||
68 | 63 | '+' : 'btnadd', | ||
69 | 64 | '-' : 'btnsubtract', | ||
70 | 65 | '*' : 'btnmultiply', | ||
71 | 66 | '/' : 'btndivide', | ||
72 | 67 | '=' : 'btnresult', | ||
73 | 68 | '(' : 'btnstartgroup', | ||
74 | 69 | ')' : 'btnendgroup', | ||
75 | 70 | '^2' : 'btnxsquared', | ||
76 | 71 | 'sqroot' : 'btnsquareroot', | ||
77 | 72 | 'undo' : 'btnundo', | ||
78 | 73 | 'clear' : 'btnclear', | ||
79 | 74 | 'i' : 'btnimaginary', | ||
80 | 75 | 'x' : 'btnmemory', | ||
81 | 76 | 'e' : 'btneulersnumber', | ||
82 | 77 | '!' : 'btnfactorial', | ||
83 | 78 | 'pi' : 'btnpi', | ||
84 | 79 | 're' : 'btnrealportion', | ||
85 | 80 | 'im' : 'btnimaginaryportion', | ||
86 | 81 | 'ln' : 'btnnaturallogarithm', | ||
87 | 82 | 'arg' : 'btnarg', | ||
88 | 83 | 'exp' : 'btnexponential', | ||
89 | 84 | 'mod' : 'btnmodulusdivide', | ||
90 | 85 | 'sup' : 'tbtnsuperscript', | ||
91 | 86 | 'sub' : 'tbtnsubscript', | ||
92 | 87 | 'cos' : 'btncosine', | ||
93 | 88 | 'sin' : 'btnsine', | ||
94 | 89 | 'tan' : 'btntangent', | ||
95 | 90 | 'log' : 'btnlogarithm', | ||
96 | 91 | '|x|' : 'btnabs', | ||
97 | 92 | 'f(x)' : 'btnfunction', | ||
98 | 93 | 'cosh' : 'btnhyperboliccosine', | ||
99 | 94 | 'sinh' : 'btnhyperbolicsine', | ||
100 | 95 | 'tanh' : 'btnhyperbolictangent', | ||
101 | 96 | 'conj' : 'btnconjugate', | ||
102 | 97 | 'root' : 'btnroot', | ||
103 | 98 | 'undo' : 'btnundo', | ||
104 | 99 | 'xpowy' : 'btnxpowy', | ||
105 | 100 | 'clear' : 'btnclear', | ||
106 | 101 | 'factor' : 'btnfactor', | ||
107 | 102 | 'inverse': 'btninverse', | ||
108 | 103 | 'degrees': 'cboDegrees', | ||
109 | 104 | 'radians': 'cboRadians', | ||
110 | 105 | 'convert': u'btn\u21c6', | ||
111 | 106 | |||
112 | 107 | 'ctrm' : 'btnfinccompoundingterm', | ||
113 | 108 | 'gpm' : 'btnfincgrossprofitmargin', | ||
114 | 109 | 'rate' : 'btnfincperiodicinterestrate', | ||
115 | 110 | 'ddb' : 'btnfincperiodicinterestrate', | ||
116 | 111 | 'pmt' : 'btnfincperiodicpayment', | ||
117 | 112 | 'sln' : 'btnfincstraightlinedepreciation', | ||
118 | 113 | 'term' : 'btnfincterm', | ||
119 | 114 | 'fv' : 'btnfincfuturevalue', | ||
120 | 115 | 'pv' : 'btnfincpresentvalue', | ||
121 | 116 | 'syd' : 'btnfincsumoftheyearsdigitsdepreciation', | ||
122 | 117 | |||
123 | 118 | 'Binary' : 'cboBinary', | ||
124 | 119 | 'Octal' : 'cboOctal', | ||
125 | 120 | 'Decimal': 'cboDecimal', | ||
126 | 121 | 'Hex' : 'cboHexadecimal', | ||
127 | 122 | 'A' : 'btnA', | ||
128 | 123 | 'B' : 'btnB', | ||
129 | 124 | 'C' : 'btnC', | ||
130 | 125 | 'D' : 'btnD', | ||
131 | 126 | 'E' : 'btnE', | ||
132 | 127 | 'F' : 'btnF', | ||
133 | 128 | 'AND' : 'btnand', | ||
134 | 129 | 'OR' : 'btnor', | ||
135 | 130 | 'XOR' : 'btnxor', | ||
136 | 131 | '<' : 'btnshiftleft', | ||
137 | 132 | 'ones' : 'btnonescomplement', | ||
138 | 133 | 'NOT' : 'btnnot', | ||
139 | 134 | '>' : 'btnshiftright', | ||
140 | 135 | 'ones' : 'btntwoscomplement', | ||
141 | 136 | 'a' : 'btncharacter', | ||
142 | 137 | 'trunc' : 'btntrunc', | ||
143 | 138 | 'int' : 'btnintegerportion', | ||
144 | 139 | 'frac' : 'btnfractionalportion' | ||
145 | 140 | } | ||
146 | 141 | |||
147 | 142 | a = None | ||
148 | 143 | |||
149 | 144 | def switch_to(self, mode): | ||
150 | 145 | """ Switch to mode """ | ||
151 | 146 | self.a.click(self.menu['Mode'][mode]) | ||
152 | 147 | |||
153 | 148 | def input(self, expression): | ||
154 | 149 | """ Input expression (each char = one button) """ | ||
155 | 150 | for char in expression: | ||
156 | 151 | self.a.click(self.controls[char]) | ||
157 | 152 | |||
158 | 153 | def click(self, button): | ||
159 | 154 | """ Click some button (for complex expressions) """ | ||
160 | 155 | self.a.click(self.controls[button]) | ||
161 | 156 | |||
162 | 157 | def input_from_keyboard(self, string): | ||
163 | 158 | """ Input string from keyboard """ | ||
164 | 159 | self.a.enterstring(self.controls['Output'], string) | ||
165 | 160 | |||
166 | 161 | def get_result(self): | ||
167 | 162 | """ Get calculation result """ | ||
168 | 163 | # A pause for calculation | ||
169 | 164 | ldtp.wait(2) | ||
170 | 165 | return self.a.gettextvalue(self.controls['Output']) | ||
171 | 166 | |||
172 | 167 | def get_error_message(self): | ||
173 | 168 | """ Get error message for calculation """ | ||
174 | 169 | # A pause for calculation | ||
175 | 170 | ldtp.wait(2) | ||
176 | 171 | return self.a.gettextvalue(self.controls['Error']) | ||
177 | 0 | 172 | ||
178 | === added file 'gnome-calculator/test_gnome-calculator.py' | |||
179 | --- gnome-calculator/test_gnome-calculator.py 1970-01-01 00:00:00 +0000 | |||
180 | +++ gnome-calculator/test_gnome-calculator.py 2011-08-08 09:54:34 +0000 | |||
181 | @@ -0,0 +1,554 @@ | |||
182 | 1 | #!/usr/bin/python | ||
183 | 2 | # -*- coding: utf-8 -*- | ||
184 | 3 | # Copyright (C) 2010 Canonical Ltd | ||
185 | 4 | # | ||
186 | 5 | # This program is free software; you can redistribute it and/or modify | ||
187 | 6 | # it under the terms of the GNU General Public License as published by | ||
188 | 7 | # the Free Software Foundation; either version 2 of the License, or | ||
189 | 8 | # (at your option) any later version. | ||
190 | 9 | # | ||
191 | 10 | # This program is distributed in the hope that it will be useful, | ||
192 | 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
193 | 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
194 | 13 | # GNU General Public License for more details. | ||
195 | 14 | # | ||
196 | 15 | # You should have received a copy of the GNU General Public License | ||
197 | 16 | # along with this program; if not, write to the Free Software | ||
198 | 17 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
199 | 18 | |||
200 | 19 | """Template Test | ||
201 | 20 | |||
202 | 21 | This is a template to create tests for Mago | ||
203 | 22 | |||
204 | 23 | To run it with: | ||
205 | 24 | $ mago <path_to_this_file> | ||
206 | 25 | |||
207 | 26 | The only mandatory element is 'launcher' | ||
208 | 27 | If no 'window_name' property is set, then mago will try to guess it from the | ||
209 | 28 | XID of the window | ||
210 | 29 | |||
211 | 30 | set setupOnce to False to launch/close the app for each test | ||
212 | 31 | |||
213 | 32 | """ | ||
214 | 33 | |||
215 | 34 | from mago import TestCase | ||
216 | 35 | import unittest | ||
217 | 36 | import ldtp, ooldtp | ||
218 | 37 | from mago_gcalctool import GnomeCalculator | ||
219 | 38 | |||
220 | 39 | class TestGCalcTool(TestCase): | ||
221 | 40 | """ | ||
222 | 41 | Tests for gcalctool (Gnome Calculator) | ||
223 | 42 | """ | ||
224 | 43 | launcher = 'gnome-calculator' | ||
225 | 44 | window = 'frmCalculator' | ||
226 | 45 | gcalctool = None | ||
227 | 46 | setupOnce = False | ||
228 | 47 | gcalctool = GnomeCalculator() | ||
229 | 48 | gcalctool.a = ooldtp.context(window) | ||
230 | 49 | |||
231 | 50 | def test_cal002_1(self): | ||
232 | 51 | """ | ||
233 | 52 | cal-002-1: Basic Mode: 1+1 | ||
234 | 53 | requires: gcalctool | ||
235 | 54 | command: gnome-calculator | ||
236 | 55 | _description: | ||
237 | 56 | PURPOSE: | ||
238 | 57 | Switch to Basic mode and calculate 1+1 | ||
239 | 58 | STEPS: | ||
240 | 59 | 1. 1+1 = 2 | ||
241 | 60 | VERIFICATION: | ||
242 | 61 | 1. Check that the calculator is calculating expression correctly | ||
243 | 62 | """ | ||
244 | 63 | |||
245 | 64 | self.gcalctool.switch_to('Basic') | ||
246 | 65 | |||
247 | 66 | self.gcalctool.input('1+1=') | ||
248 | 67 | self.assertEquals(self.gcalctool.get_result(), '2') | ||
249 | 68 | |||
250 | 69 | def test_cal002_2(self): | ||
251 | 70 | """ cal-002-2 | ||
252 | 71 | cal-002-2: Basic Mode: 3*4 | ||
253 | 72 | requires: gcalctool | ||
254 | 73 | command: gnome-calculator | ||
255 | 74 | _description: | ||
256 | 75 | PURPOSE: | ||
257 | 76 | Switch to Basic mode and calculate 3*4 | ||
258 | 77 | STEPS: | ||
259 | 78 | 1. 3*4 = 12 | ||
260 | 79 | VERIFICATION: | ||
261 | 80 | 1. Check that the calculator is calculating expression correctly | ||
262 | 81 | """ | ||
263 | 82 | self.gcalctool.switch_to('Basic') | ||
264 | 83 | |||
265 | 84 | self.gcalctool.input('3*4=') | ||
266 | 85 | self.assertEquals(self.gcalctool.get_result(), '12') | ||
267 | 86 | |||
268 | 87 | def test_cal002_3(self): | ||
269 | 88 | """ | ||
270 | 89 | cal-002-3: Basic Mode: √9 | ||
271 | 90 | requires: gcalctool | ||
272 | 91 | command: gnome-calculator | ||
273 | 92 | _description: | ||
274 | 93 | PURPOSE: | ||
275 | 94 | Switch to Basic mode and calculate √9 | ||
276 | 95 | STEPS: | ||
277 | 96 | 1. √9 = 3 | ||
278 | 97 | VERIFICATION: | ||
279 | 98 | 1. Check that the calculator is calculating expression correctly | ||
280 | 99 | """ | ||
281 | 100 | self.gcalctool.switch_to('Basic') | ||
282 | 101 | |||
283 | 102 | self.gcalctool.click('sqroot') | ||
284 | 103 | self.gcalctool.input('9=') | ||
285 | 104 | self.assertEquals(self.gcalctool.get_result(), '3') | ||
286 | 105 | |||
287 | 106 | def test_cal003_1(self): | ||
288 | 107 | """ | ||
289 | 108 | cal-003-1: Advanced Mode: log 100 | ||
290 | 109 | requires: gcalctool | ||
291 | 110 | command: gnome-calculator | ||
292 | 111 | _description: | ||
293 | 112 | PURPOSE: | ||
294 | 113 | Switch to Advanced mode and calculate log 100 | ||
295 | 114 | STEPS: | ||
296 | 115 | 1. log 100 = 2 | ||
297 | 116 | VERIFICATION: | ||
298 | 117 | 1. Check that the calculator is calculating expression correctly | ||
299 | 118 | """ | ||
300 | 119 | |||
301 | 120 | self.gcalctool.switch_to('Advanced') | ||
302 | 121 | |||
303 | 122 | self.gcalctool.click('log') | ||
304 | 123 | self.gcalctool.input('100=') | ||
305 | 124 | self.assertEquals(self.gcalctool.get_result(), '2') | ||
306 | 125 | |||
307 | 126 | def test_cal003_2(self): | ||
308 | 127 | """ | ||
309 | 128 | ccal-003-2: Advanced Mode: sin 45 = 0.707106781 | ||
310 | 129 | requires: gcalctool | ||
311 | 130 | command: gnome-calculator | ||
312 | 131 | _description: | ||
313 | 132 | PURPOSE: | ||
314 | 133 | Switch to Advanced mode and calculate sin 45 | ||
315 | 134 | STEPS: | ||
316 | 135 | 1. sin 45 = 0.707106781 | ||
317 | 136 | VERIFICATION: | ||
318 | 137 | 1. Check that the calculator is calculating expression correctly | ||
319 | 138 | """ | ||
320 | 139 | self.gcalctool.switch_to('Advanced') | ||
321 | 140 | |||
322 | 141 | self.gcalctool.click('sin') | ||
323 | 142 | self.gcalctool.input('45=') | ||
324 | 143 | self.assertEquals(self.gcalctool.get_result(), '0.707106781') | ||
325 | 144 | |||
326 | 145 | def test_cal003_3(self): | ||
327 | 146 | """ | ||
328 | 147 | cal-003-3: Advanced Mode: 6! | ||
329 | 148 | requires: gcalctool | ||
330 | 149 | command: gnome-calculator | ||
331 | 150 | _description: | ||
332 | 151 | PURPOSE: | ||
333 | 152 | Switch to Advanced mode and calculate 6! | ||
334 | 153 | STEPS: | ||
335 | 154 | 1. 6! = 720 | ||
336 | 155 | VERIFICATION: | ||
337 | 156 | 1. Check that the calculator is calculating expression correctly | ||
338 | 157 | """ | ||
339 | 158 | self.gcalctool.switch_to('Advanced') | ||
340 | 159 | |||
341 | 160 | self.gcalctool.input('6!=') | ||
342 | 161 | self.assertEquals(self.gcalctool.get_result(), '720') | ||
343 | 162 | |||
344 | 163 | def test_cal004_1(self): | ||
345 | 164 | """ | ||
346 | 165 | cal-004-1: Financial Mode: 140+15% | ||
347 | 166 | requires: gcalctool | ||
348 | 167 | command: gnome-calculator | ||
349 | 168 | _description: | ||
350 | 169 | PURPOSE: | ||
351 | 170 | Switch to Financial mode and calculate 140+15% | ||
352 | 171 | STEPS: | ||
353 | 172 | 1. 140+15% = 161 | ||
354 | 173 | VERIFICATION: | ||
355 | 174 | 1. Check that the calculator is calculating expression correctly | ||
356 | 175 | """ | ||
357 | 176 | self.gcalctool.switch_to('Financial') | ||
358 | 177 | |||
359 | 178 | self.gcalctool.input('140+15%=') | ||
360 | 179 | self.assertEquals(self.gcalctool.get_result(), '161') | ||
361 | 180 | |||
362 | 181 | def test_cal004_2(self): | ||
363 | 182 | """ | ||
364 | 183 | cal-004-2: Financial Mode: 100-20% | ||
365 | 184 | requires: gcalctool | ||
366 | 185 | command: gnome-calculator | ||
367 | 186 | _description: | ||
368 | 187 | PURPOSE: | ||
369 | 188 | Switch to Financial mode and calculate 100-20% | ||
370 | 189 | STEPS: | ||
371 | 190 | 1. 100-20% = 80 | ||
372 | 191 | VERIFICATION: | ||
373 | 192 | 1. Check that the calculator is calculating expression correctly | ||
374 | 193 | """ | ||
375 | 194 | self.gcalctool.switch_to('Financial') | ||
376 | 195 | |||
377 | 196 | self.gcalctool.input('100-20%=') | ||
378 | 197 | self.assertEquals(self.gcalctool.get_result(), '80') | ||
379 | 198 | |||
380 | 199 | def test_cal005_1(self): | ||
381 | 200 | """ | ||
382 | 201 | cal-005-1: Programming Mode: 0 AND 1 = 0 | ||
383 | 202 | requires: gcalctool | ||
384 | 203 | command: gnome-calculator | ||
385 | 204 | _description: | ||
386 | 205 | PURPOSE: | ||
387 | 206 | Switch to Programming mode and calculate 0 AND 1 | ||
388 | 207 | STEPS: | ||
389 | 208 | 1. 0 AND 1 = 0 | ||
390 | 209 | VERIFICATION: | ||
391 | 210 | 1. Check that the calculator is calculating expression correctly | ||
392 | 211 | """ | ||
393 | 212 | self.a = ooldtp.context(self.window) | ||
394 | 213 | self.gcalctool.switch_to('Programming') | ||
395 | 214 | |||
396 | 215 | self.gcalctool.input('0') | ||
397 | 216 | self.gcalctool.click('AND') | ||
398 | 217 | self.gcalctool.input('1') | ||
399 | 218 | self.gcalctool.input('=') | ||
400 | 219 | |||
401 | 220 | self.assertEquals(self.gcalctool.get_result(), '0') | ||
402 | 221 | |||
403 | 222 | def test_cal005_2(self): | ||
404 | 223 | """ | ||
405 | 224 | cal-005-2: Programming Mode: 0 OR 1 = 1 | ||
406 | 225 | requires: gcalctool | ||
407 | 226 | command: gnome-calculator | ||
408 | 227 | _description: | ||
409 | 228 | PURPOSE: | ||
410 | 229 | Switch to Programming mode and calculate 0 OR 1 | ||
411 | 230 | STEPS: | ||
412 | 231 | 1. 0 OR 1 = 1 | ||
413 | 232 | VERIFICATION: | ||
414 | 233 | 1. Check that the calculator is calculating expression correctly | ||
415 | 234 | """ | ||
416 | 235 | self.gcalctool.switch_to('Programming') | ||
417 | 236 | |||
418 | 237 | self.gcalctool.input('0') | ||
419 | 238 | self.gcalctool.click('OR') | ||
420 | 239 | self.gcalctool.input('1') | ||
421 | 240 | self.gcalctool.input('=') | ||
422 | 241 | |||
423 | 242 | self.assertEquals(self.gcalctool.get_result(), '1') | ||
424 | 243 | |||
425 | 244 | def test_cal007(self): | ||
426 | 245 | """ | ||
427 | 246 | cal-007: Advanced Mode: 7921 mod 14 | ||
428 | 247 | requires: gcalctool | ||
429 | 248 | command: gnome-calculator | ||
430 | 249 | _description: | ||
431 | 250 | PURPOSE: | ||
432 | 251 | Switch to Advanced mode and calculate 7921 mod 14 | ||
433 | 252 | STEPS: | ||
434 | 253 | 1. 7921 mod 14 = 11 | ||
435 | 254 | VERIFICATION: | ||
436 | 255 | 1. Check that the calculator is calculating expression correctly | ||
437 | 256 | """ | ||
438 | 257 | self.gcalctool.switch_to('Advanced') | ||
439 | 258 | |||
440 | 259 | self.gcalctool.input('7921') | ||
441 | 260 | self.gcalctool.click('mod') | ||
442 | 261 | self.gcalctool.input('14=') | ||
443 | 262 | self.assertEquals(self.gcalctool.get_result(), '11') | ||
444 | 263 | |||
445 | 264 | def test_cal008(self): | ||
446 | 265 | """ | ||
447 | 266 | cal-008: Programming Mode: 4 AND B | ||
448 | 267 | requires: gcalctool | ||
449 | 268 | command: gnome-calculator | ||
450 | 269 | _description: | ||
451 | 270 | PURPOSE: | ||
452 | 271 | Switch to Programming mode and calculate 4 AND B | ||
453 | 272 | STEPS: | ||
454 | 273 | 1. 4 AND B | ||
455 | 274 | VERIFICATION: | ||
456 | 275 | 1. Error occurs. Invalid variable 'B' | ||
457 | 276 | """ | ||
458 | 277 | self.gcalctool.switch_to('Programming') | ||
459 | 278 | |||
460 | 279 | self.gcalctool.input('4') | ||
461 | 280 | self.gcalctool.click('AND') | ||
462 | 281 | self.gcalctool.input('B') | ||
463 | 282 | self.gcalctool.input('=') | ||
464 | 283 | |||
465 | 284 | self.assertEquals(self.gcalctool.get_result(), u'4\u2227B') | ||
466 | 285 | self.assertEquals(self.gcalctool.get_error_message(), "Unknown variable 'B'") | ||
467 | 286 | |||
468 | 287 | def test_bug756277(self): | ||
469 | 288 | """ | ||
470 | 289 | bug756277: Incorrect Evaluation Order for Implied Multiplication | ||
471 | 290 | requires: gcalctool | ||
472 | 291 | command: gnome-calculator | ||
473 | 292 | _description: | ||
474 | 293 | PURPOSE: | ||
475 | 294 | Check calculation of evalution order, when multiplication is implied | ||
476 | 295 | LP:#756277 | ||
477 | 296 | STEPS: | ||
478 | 297 | 1. Input expression "48/2(9+3)" | ||
479 | 298 | VERIFICATION: | ||
480 | 299 | 1. Result is 288 | ||
481 | 300 | """ | ||
482 | 301 | self.gcalctool.switch_to('Basic') | ||
483 | 302 | |||
484 | 303 | self.gcalctool.input('48/2(9+3)=') | ||
485 | 304 | self.assertEquals(self.gcalctool.get_result(), '288') | ||
486 | 305 | |||
487 | 306 | def test_bug28928(self): | ||
488 | 307 | """ | ||
489 | 308 | bug28928: Sqrt function for expression with brackets | ||
490 | 309 | requires: gcalctool | ||
491 | 310 | command: gnome-calculator | ||
492 | 311 | _description: | ||
493 | 312 | PURPOSE: | ||
494 | 313 | Check sqrt function for expressions with brackets | ||
495 | 314 | LP:#28928 | ||
496 | 315 | STEPS: | ||
497 | 316 | 1. Input expression "root((9))" | ||
498 | 317 | VERIFICATION: | ||
499 | 318 | 1. Result is 3 | ||
500 | 319 | """ | ||
501 | 320 | self.gcalctool.switch_to('Basic') | ||
502 | 321 | |||
503 | 322 | self.gcalctool.click('sqroot') | ||
504 | 323 | self.gcalctool.input('(9)=') | ||
505 | 324 | |||
506 | 325 | self.assertEquals(self.gcalctool.get_result(), '3') | ||
507 | 326 | |||
508 | 327 | def test_bug32200(self): | ||
509 | 328 | """ | ||
510 | 329 | bug32200: Bitwise operations on results | ||
511 | 330 | requires: gcalctool | ||
512 | 331 | command: gnome-calculator | ||
513 | 332 | _description: | ||
514 | 333 | PURPOSE: | ||
515 | 334 | Check bitwise operations on results | ||
516 | 335 | LP:#32200 | ||
517 | 336 | STEPS: | ||
518 | 337 | 1. Input expression "2 AND 3" | ||
519 | 338 | 2. Click "=" | ||
520 | 339 | 3. Input expression "OR 5" | ||
521 | 340 | 4. Click "=" | ||
522 | 341 | VERIFICATION: | ||
523 | 342 | 1. Result is 7 | ||
524 | 343 | """ | ||
525 | 344 | self.gcalctool.switch_to('Programming') | ||
526 | 345 | |||
527 | 346 | self.gcalctool.input('2') | ||
528 | 347 | self.gcalctool.click('AND') | ||
529 | 348 | self.gcalctool.input('3') | ||
530 | 349 | self.gcalctool.input('=') | ||
531 | 350 | |||
532 | 351 | ldtp.wait(2) | ||
533 | 352 | |||
534 | 353 | self.gcalctool.click('OR') | ||
535 | 354 | self.gcalctool.input('5') | ||
536 | 355 | self.gcalctool.input('=') | ||
537 | 356 | |||
538 | 357 | self.assertEquals(self.gcalctool.get_result(), '7') | ||
539 | 358 | |||
540 | 359 | def test_bug204682(self): | ||
541 | 360 | """ | ||
542 | 361 | bug204682: Powering negative numbers | ||
543 | 362 | requires: gcalctool | ||
544 | 363 | command: gnome-calculator | ||
545 | 364 | _description: | ||
546 | 365 | PURPOSE: | ||
547 | 366 | Check powering of negative numbers | ||
548 | 367 | LP:#204682 | ||
549 | 368 | STEPS: | ||
550 | 369 | 1. Calculate expression "-10^2" | ||
551 | 370 | 2. Calculate expression "-(10)^2" | ||
552 | 371 | 3. Calculate expression "(-10)^2" | ||
553 | 372 | VERIFICATION: | ||
554 | 373 | 1. Result is -100 | ||
555 | 374 | 2. Result is -100 | ||
556 | 375 | 3. Result is 100 | ||
557 | 376 | """ | ||
558 | 377 | self.gcalctool.switch_to('Advanced') | ||
559 | 378 | |||
560 | 379 | self.gcalctool.input('-10') | ||
561 | 380 | self.gcalctool.click('xpowy') | ||
562 | 381 | self.gcalctool.input('2=') | ||
563 | 382 | self.assertEquals(self.gcalctool.get_result(), u'\u2212100') # -100 | ||
564 | 383 | |||
565 | 384 | self.gcalctool.click('clear') | ||
566 | 385 | self.gcalctool.input('-(10)') | ||
567 | 386 | self.gcalctool.click('xpowy') | ||
568 | 387 | self.gcalctool.input('2=') | ||
569 | 388 | self.assertEquals(self.gcalctool.get_result(), u'\u2212100') # -100 | ||
570 | 389 | |||
571 | 390 | self.gcalctool.click('clear') | ||
572 | 391 | self.gcalctool.input('(-10)') | ||
573 | 392 | self.gcalctool.click('xpowy') | ||
574 | 393 | self.gcalctool.input('2=') | ||
575 | 394 | self.assertEquals(self.gcalctool.get_result(), '100') | ||
576 | 395 | |||
577 | 396 | def test_bug499211(self): | ||
578 | 397 | """ | ||
579 | 398 | bug499211: Type < and > from keyboard | ||
580 | 399 | requires: gcalctool | ||
581 | 400 | command: gnome-calculator | ||
582 | 401 | _description: | ||
583 | 402 | PURPOSE: | ||
584 | 403 | Check typing of < and > symbols from keyboard | ||
585 | 404 | LP:#499211 | ||
586 | 405 | STEPS: | ||
587 | 406 | 1. Type ">" | ||
588 | 407 | 2. Type "<" | ||
589 | 408 | VERIFICATION: | ||
590 | 409 | 1. The app doesn't crash | ||
591 | 410 | """ | ||
592 | 411 | self.gcalctool.switch_to('Programming') | ||
593 | 412 | |||
594 | 413 | # Press > and < from keyboard, check that the app doesn't crash | ||
595 | 414 | self.gcalctool.input_from_keyboard('>') | ||
596 | 415 | self.gcalctool.input_from_keyboard('<') | ||
597 | 416 | |||
598 | 417 | def test_bug515280(self): | ||
599 | 418 | """ | ||
600 | 419 | bug515280: Twice root out of -1 | ||
601 | 420 | requires: gcalctool | ||
602 | 421 | command: gnome-calculator | ||
603 | 422 | _description: | ||
604 | 423 | PURPOSE: | ||
605 | 424 | LP:#515280 | ||
606 | 425 | STEPS: | ||
607 | 426 | 1. Calculate expression "root(root(-1))" | ||
608 | 427 | VERIFICATION: | ||
609 | 428 | 1. Result is 7,071067812×10⁻¹7,071067812i×10⁻¹ | ||
610 | 429 | """ | ||
611 | 430 | self.gcalctool.switch_to('Advanced') | ||
612 | 431 | |||
613 | 432 | self.gcalctool.click('sqroot') | ||
614 | 433 | self.gcalctool.click('sqroot') | ||
615 | 434 | self.gcalctool.input('-1') | ||
616 | 435 | self.gcalctool.input('=') | ||
617 | 436 | self.assertEquals(self.gcalctool.get_result(), u'7,071067812\xd710\u207b\xb97,071067812i\xd710\u207b\xb9') | ||
618 | 437 | #'7,071067812×10⁻¹7,071067812i×10⁻¹' = root(i) | ||
619 | 438 | |||
620 | 439 | def test_bug215663(self): | ||
621 | 440 | """ | ||
622 | 441 | bug215663: Zero result instead of -0 | ||
623 | 442 | requires: gcalctool | ||
624 | 443 | command: gnome-calculator | ||
625 | 444 | _description: | ||
626 | 445 | PURPOSE: | ||
627 | 446 | Check that 0 is displayed instead of -0 | ||
628 | 447 | LP:#215663 | ||
629 | 448 | STEPS: | ||
630 | 449 | 1. Calculate expression "4^2-16" | ||
631 | 450 | VERIFICATION: | ||
632 | 451 | 1. Result is 0 | ||
633 | 452 | """ | ||
634 | 453 | self.gcalctool.switch_to('Advanced') | ||
635 | 454 | |||
636 | 455 | self.gcalctool.input('4') | ||
637 | 456 | self.gcalctool.click('xpowy') | ||
638 | 457 | self.gcalctool.input('2') | ||
639 | 458 | self.gcalctool.input('-16') | ||
640 | 459 | self.gcalctool.input('=') | ||
641 | 460 | self.assertEquals(self.gcalctool.get_result(), '0') | ||
642 | 461 | |||
643 | 462 | def test_bug215663(self): | ||
644 | 463 | """ | ||
645 | 464 | bug215663: mod operation after x^y | ||
646 | 465 | requires: gcalctool | ||
647 | 466 | command: gnome-calculator | ||
648 | 467 | _description: | ||
649 | 468 | PURPOSE: | ||
650 | 469 | Check that 2^2 MOD 2 is calculated correctly | ||
651 | 470 | LP:#215663 | ||
652 | 471 | STEPS: | ||
653 | 472 | 1. Calculate expression "2^2 MOD 2" | ||
654 | 473 | VERIFICATION: | ||
655 | 474 | 1. Result is 0 | ||
656 | 475 | """ | ||
657 | 476 | self.gcalctool.switch_to('Advanced') | ||
658 | 477 | |||
659 | 478 | self.gcalctool.input('2') | ||
660 | 479 | self.gcalctool.click('xpowy') | ||
661 | 480 | self.gcalctool.input('2') | ||
662 | 481 | self.gcalctool.click('mod') | ||
663 | 482 | self.gcalctool.input('2') | ||
664 | 483 | self.gcalctool.input('=') | ||
665 | 484 | self.assertEquals(self.gcalctool.get_result(), '0') | ||
666 | 485 | |||
667 | 486 | def test_bug446939(self): | ||
668 | 487 | """ | ||
669 | 488 | bug446939: rand function | ||
670 | 489 | requires: gcalctool | ||
671 | 490 | command: gnome-calculator | ||
672 | 491 | _description: | ||
673 | 492 | PURPOSE: | ||
674 | 493 | Check that rand function works correctly | ||
675 | 494 | LP:#446939 | ||
676 | 495 | STEPS: | ||
677 | 496 | 1. Calculate expression "rand = " | ||
678 | 497 | VERIFICATION: | ||
679 | 498 | 1. Result is a random number, error message is empty | ||
680 | 499 | """ | ||
681 | 500 | self.gcalctool.switch_to('Advanced') | ||
682 | 501 | |||
683 | 502 | self.gcalctool.input_from_keyboard('rand') | ||
684 | 503 | self.gcalctool.input('=') | ||
685 | 504 | self.assertNotEquals(self.gcalctool.get_result(), '') | ||
686 | 505 | self.assertEquals(self.gcalctool.get_error_message(), '') | ||
687 | 506 | |||
688 | 507 | def test_bug288446(self): | ||
689 | 508 | """ | ||
690 | 509 | bug288446: powering negative number in fractional number | ||
691 | 510 | requires: gcalctool | ||
692 | 511 | command: gnome-calculator | ||
693 | 512 | _description: | ||
694 | 513 | PURPOSE: | ||
695 | 514 | Check that (-4)^(1/7) is calculated correctly | ||
696 | 515 | LP:#288446 | ||
697 | 516 | STEPS: | ||
698 | 517 | 1. Calculate expression "(-4)^(1/7)" | ||
699 | 518 | VERIFICATION: | ||
700 | 519 | 1. Result is −1,219013654 | ||
701 | 520 | """ | ||
702 | 521 | self.gcalctool.switch_to('Advanced') | ||
703 | 522 | |||
704 | 523 | self.gcalctool.input('(-4)') | ||
705 | 524 | self.gcalctool.click('xpowy') | ||
706 | 525 | self.gcalctool.input('(1/7)') | ||
707 | 526 | self.gcalctool.input('=') | ||
708 | 527 | self.assertEquals(self.gcalctool.get_result(), u'\u22121,219013654') #−1,219013654 | ||
709 | 528 | |||
710 | 529 | def test_bug302115(self): | ||
711 | 530 | """ | ||
712 | 531 | bug302115: Bitwise operations precedence | ||
713 | 532 | requires: gcalctool | ||
714 | 533 | command: gnome-calculator | ||
715 | 534 | _description: | ||
716 | 535 | PURPOSE: | ||
717 | 536 | Check bitwise operations on results | ||
718 | 537 | LP:#302115 | ||
719 | 538 | STEPS: | ||
720 | 539 | 1. Input expression "~1 AND 1" | ||
721 | 540 | VERIFICATION: | ||
722 | 541 | 1. Result is 0 | ||
723 | 542 | """ | ||
724 | 543 | self.gcalctool.switch_to('Programming') | ||
725 | 544 | |||
726 | 545 | self.gcalctool.input_from_keyboard('~') | ||
727 | 546 | self.gcalctool.input('1') | ||
728 | 547 | self.gcalctool.click('AND') | ||
729 | 548 | self.gcalctool.input('1') | ||
730 | 549 | self.gcalctool.input('=') | ||
731 | 550 | |||
732 | 551 | self.assertEquals(self.gcalctool.get_result(), '0') | ||
733 | 552 | |||
734 | 553 | if __name__ == "__main__": | ||
735 | 554 | unittest.main() |