Merge lp:~roignac/mago/gcalctool into lp:~mago-contributors/mago/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
Reviewer Review Type Date Requested Status
Jean-Baptiste Lallement Pending
Mago Contributors Pending
Review via email: mp+70711@code.launchpad.net

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

Subscribers

People subscribed via source and target branches