diff options
author | prashmohan <prashmohan> | 2006-06-19 17:32:20 +0000 |
---|---|---|
committer | prashmohan <prashmohan> | 2006-06-19 17:32:20 +0000 |
commit | 81a0f8b6d7bc620ad32d6ce438d26b9516306fb5 (patch) | |
tree | 906879f1948c4035f5b892cf08fa0dc47852c7f4 | |
parent | 1219976aa0aa7ca2c405d20886d2deccf6d72ecf (diff) |
Added new gnome-dictionary test casesgnome-2-14
-rw-r--r-- | gnome-dictionary/README | 18 | ||||
-rw-r--r-- | gnome-dictionary/check_meaning.py | 37 | ||||
-rw-r--r-- | gnome-dictionary/close.py | 38 | ||||
-rw-r--r-- | gnome-dictionary/data.xml | 40 | ||||
-rw-r--r-- | gnome-dictionary/dicti.py | 208 | ||||
-rw-r--r-- | gnome-dictionary/dicti.pyc | bin | 0 -> 5823 bytes | |||
-rw-r--r-- | gnome-dictionary/find.py | 48 | ||||
-rw-r--r-- | gnome-dictionary/find_next.py | 38 | ||||
-rw-r--r-- | gnome-dictionary/new.py | 37 | ||||
-rw-r--r-- | gnome-dictionary/run.xml | 29 | ||||
-rw-r--r-- | gnome-dictionary/save_a_copy.py | 38 |
11 files changed, 531 insertions, 0 deletions
diff --git a/gnome-dictionary/README b/gnome-dictionary/README new file mode 100644 index 0000000..d874e17 --- /dev/null +++ b/gnome-dictionary/README @@ -0,0 +1,18 @@ + +Application: gnome-dictionary 2.14 (part of gnome-utils) +Scripts Author: Prashanth Mohan <prashmohan@gmail.com> +Requirements: ldtp 0.5+ + +The scripts can be run by issuing the command `gldap.py run.xml'. The +running of the scripts might require versions of ldtp (0.5+) + +The following test cases have been automated: +* Check Meaning +* New Window +* Close Window +* Find, Find Next, Find Prev +* Save a Copy + + + + diff --git a/gnome-dictionary/check_meaning.py b/gnome-dictionary/check_meaning.py new file mode 100644 index 0000000..7418940 --- /dev/null +++ b/gnome-dictionary/check_meaning.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +# +# Linux Desktop Testing Project http://ldtp.freedesktop.org +# +# Author: +# Prashanth Mohan <prashmohan at gmail dot com> +# +# Copyright 2004 Novell, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# + +from dicti import * +gd = gnome_dictionary(datafilename) + +try: + log ('Check Meaning','teststart') + gd.check_meaning () +except: + log ('Check Meaning','fail') + log ('Check Meaning','testend') + raise +log ('Check Meaning','pass') +log ('Check Meaning','testend') diff --git a/gnome-dictionary/close.py b/gnome-dictionary/close.py new file mode 100644 index 0000000..9c0174f --- /dev/null +++ b/gnome-dictionary/close.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# +# Linux Desktop Testing Project http://ldtp.freedesktop.org +# +# Author: +# Prashanth Mohan <prashmohan at gmail dot com> +# +# Copyright 2004 Novell, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# + +from dicti import * + +gd = gnome_dictionary(datafilename) + +try: + log ('Close Window','teststart') + gd.close_window () +except: + log ('Close Window','fail') + log ('Close Window','testend') + raise +log ('Close Window','pass') +log ('Close Window','testend') diff --git a/gnome-dictionary/data.xml b/gnome-dictionary/data.xml new file mode 100644 index 0000000..ed4dc14 --- /dev/null +++ b/gnome-dictionary/data.xml @@ -0,0 +1,40 @@ +<?xml version="1.0"?> +<data> + <term>Xenophobia</term> + <meaning>xenophobia + +xenophobia + n : an irrational fear of foreigners or strangers + + -- From WordNet (r) 2.0 + +86 Moby Thesaurus words for "xenophobia": + Anglophobia, Francophobia, Germanophobia, Jim Crow, Jim Crow law, + Russophobia, abhorrence, abomination, agoraphobia, alien, + anti-Semitism, antipathy, apartheid, aversion, bigotry, + black power, black supremacy, chauvinism, class consciousness, + class distinction, class hatred, class prejudice, class war, + color bar, color line, demonophobia, despitefulness, detestation, + discrimination, dislike, division, ethnocentrism, exclusiveness, + execration, fascism, foreigner, hate, hatred, insularity, + insulation, isolation, know-nothingism, loathing, male chauvinist, + malevolence, malice, malignity, minority prejudice, misandry, + misanthropy, misogyny, narrowness, odium, out-group, outcast, + outsider, parochialism, persona non grata, quarantine, race hatred, + race prejudice, race snobbery, racial discrimination, + racial segregation, racialism, racism, red-baiting, repugnance, + seclusion, segregation, separation, sex discrimination, sexism, + snobbishness, social barrier, social discrimination, spite, + spitefulness, stranger, superpatriotism, tightness, + ultranationalism, vials of hate, vials of wrath, white power, + white supremacy + + + + -- From Moby Thesaurus II by Grady Ward, 1.0 + +</meaning> + <NoOfDefenitions>2</NoOfDefenitions> + <filename>/tmp/abc.txt</filename> + <search>pho</search> +</data> diff --git a/gnome-dictionary/dicti.py b/gnome-dictionary/dicti.py new file mode 100644 index 0000000..fdc6596 --- /dev/null +++ b/gnome-dictionary/dicti.py @@ -0,0 +1,208 @@ +#!/usr/bin/env python +# +# Linux Desktop Testing Project http://ldtp.freedesktop.org +# +# Author: +# Prashanth Mohan <prashmohan at gmail dot com> +# +# Copyright 2004 Novell, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# + +from ldtp import * +from ldtputils import * +import time, os + +class gnome_dictionary: + """Class containing functions for testing the functionalities + of gnome-dictionary which is a part of the gnome-utils package""" + + def launch (self): + launchapp ('gnome-dictionary',1) + + + def __init__ (self, datafilename, appmap_file=''): + self.data_object = LdtpDataFileParser (datafilename) + self.term = self.data_object.gettagvalue ('term') + if self.term != []: + self.term = self.term[0] + + self.meaning = self.data_object.gettagvalue ('meaning') + if self.meaning != []: + self.meaning = self.meaning[0] + + self.save_file = self.data_object.gettagvalue ('filename') + if self.save_file != []: + self.save_file = self.save_file[0] + + self.search_term = self.data_object.gettagvalue ('search') + if self.search_term != []: + self.search_term = self.search_term[0] + self.last_search_term = self.search_term + + self.last_find = 0 + if guiexist ('*Dictionary') != 1: + print 'OPENING' + log ('Dictionary not open.. opening','info') + launchapp ('gnome-dictionary',1) + print 'OPENED' + + + def check_meaning (self, term='', meaning=''): + if term == '': + term = self.term + if meaning == '': + meaning = self.meaning + + log ('Searching for term: '+term,'info') + enterstring ('*Dictionary','txtLookup',term+'<return>') + + print 'Sleeping...' + time.sleep (5) # arbitrary time gap for retreiving information from the server + + real_meaning = gettextvalue ('*Dictionary','txt1') + if real_meaning != meaning: + log ('Meanings do not match','cause') + raise LdtpExecutionError ('Meanings do not match') + + + def new_window (self): + while guiexist ('Dictionary') == 1: + enterstring ('Dictionary','txtLookup','test<return>') + time.sleep (5) + selectmenuitem ('*Dictionary','mnuFile;mnuNew') + waittillguiexist ('Dictionary') + if guiexist ('Dictionary') != 1: + log ('New Window not found','cause') + raise LdtpExecutionError ('New Window not found') + + + def save_a_copy (self, file_name=''): + if file_name == '': + file_name = self.save_file + + print 'FILENAME: ',file_name + selectmenuitem ('*Dictionary','mnuFile;mnuSaveaCopy') + os.environ['GUI_EXIST'] = '5' + waittillguiexist ('dlgSaveaCopy') + settextvalue ('dlgSaveaCopy','txtName',file_name) + click ('dlgSaveaCopy','btnSave') + + if waittillguiexist ('Question') == 1: + click ('dlgQuestion','btnReplace') + waittillguinotexist ('Question') + + waittillguinotexist ('Save a Copy') + contents = gettextvalue ('*Dictionary','txt1') + fp = open (file_name,"r") + cont = fp.read()#.strip() + + index1 = 0 + index2 = 0 + while index1 < len (cont) and index2 < len (contents): + if cont[index1] == '\r': + index1 += 1 + continue + if cont[index1] != contents[index2]: + log ('Contents of file differs','cause') + raise LdtpExecutionError ('Contents of file differs') + index1 += 1 + index2 += 1 + + if index1 != len (cont) and index2 != len (contents): + log ('Contents of file differs','cause') + raise LdtpExecutionError ('Contents of file differs') + + + def close_window(self): + selectmenuitem ('*Dictionary','mnuFile;mnuClose') + waittillguinotexist ('*Dictionary') + if guiexist ('*Dictionary') == 1: + log ('Window still open','cause') + raise LdtpExecutionError ('Window still open') + + + def check_find (self, term, position): + meaning = gettextvalue ('*Dictionary', 'txt1') + + if self.last_find == position and position != 0: + return + + if (position == 0 and meaning.find (term) != 0) or position < len (term): + log ('Find pointing to position 0', 'cause') + raise LdtpExecutionError ('Find pointing to position 0') + + if meaning [position - len (term): position] != term: + log ('Find giving wrong results','cause') + raise LdtpExecutionError ('Find giving wrong results') + + print 'LAST FIND :: ', self.last_find + print 'TERM :: ',term + print 'POSITIOn ::', position + print 'LEN(TERM) ::', len (term) + time.sleep (5) + if meaning [self.last_find:].find (term) != position - len(term) - self.last_find: + log ('Skipped results','cause') + raise LdtpExecutionError ('Skipped results') + + self.last_find = position + print 'LAST_FIND :: ',self.last_find + + + def ordinary_find (self,term=''): + if term == '': + term = self.search_term + + self.last_search_term = term + selectmenuitem ('*Dictionary','mnuEdit;mnuFind') + setcursorposition ('*Dictionary','txt1',0) + settextvalue ('*Dictionary','txtFind',term) + position = getcursorposition ('*Dictionary','txt1') + try: + self.check_find (term,position) + except: + raise + + + def find_next (self): + selectmenuitem ('*Dictionary','mnuEdit;mnuFindNext') + print 'INSIDE FIND NEXT' + #abc = raw_input() + time.sleep (5) + position = getcursorposition ('*Dictionary','txt1') + + try: + self.check_find (self.last_search_term, position) + except: + raise + + + def find_prev (self): + + if self.last_find == 0: + log ('Nothing to find','cause') + raise LdtpExecutionError ('Nothing to find') + + meaning = gettextvalue ('*Dictionary','txt1') + term = self.search_term + selectmenuitem ('*Dictionary','mnuEdit;mnuFindPrevious') + time.sleep (1) + position = getcursorposition ('*Dictionary','txt1') + + if meaning [:self.last_find-1].rfind (self.last_search_term) != position - len (term): + log ('Wrong answer','cause') + raise LdtpExecutionError ('Wrong answer') diff --git a/gnome-dictionary/dicti.pyc b/gnome-dictionary/dicti.pyc Binary files differnew file mode 100644 index 0000000..34969e5 --- /dev/null +++ b/gnome-dictionary/dicti.pyc diff --git a/gnome-dictionary/find.py b/gnome-dictionary/find.py new file mode 100644 index 0000000..611010d --- /dev/null +++ b/gnome-dictionary/find.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +# +# Linux Desktop Testing Project http://ldtp.freedesktop.org +# +# Author: +# Prashanth Mohan <prashmohan at gmail dot com> +# +# Copyright 2004 Novell, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# + + +from dicti import * +import time + +while guiexist ('*Dictionary'): + selectmenuitem ('*Dictionary','mnuFile;mnuClose') + time.sleep (2) + +time.sleep (5) +gd = gnome_dictionary(datafilename) + +try: + log ('Find','teststart') + gd.check_meaning () + gd.ordinary_find () + gd.find_next () + gd.find_prev () +except: + log ('Find','fail') + log ('Find','testend') + raise +log ('Find','pass') +log ('Find','testend') diff --git a/gnome-dictionary/find_next.py b/gnome-dictionary/find_next.py new file mode 100644 index 0000000..72c5dc8 --- /dev/null +++ b/gnome-dictionary/find_next.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# +# Linux Desktop Testing Project http://ldtp.freedesktop.org +# +# Author: +# Prashanth Mohan <prashmohan at gmail dot com> +# +# Copyright 2004 Novell, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# + + +from dicti import * +gd = gnome_dictionary(datafilename) + +try: + log ('Find Next','teststart') + gd.find_next () +except: + log ('Find Next','fail') + log ('Find Next','testend') + raise +log ('Find Next','pass') +log ('Find Next','testend') diff --git a/gnome-dictionary/new.py b/gnome-dictionary/new.py new file mode 100644 index 0000000..31db155 --- /dev/null +++ b/gnome-dictionary/new.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python +# +# Linux Desktop Testing Project http://ldtp.freedesktop.org +# +# Author: +# Prashanth Mohan <prashmohan at gmail dot com> +# +# Copyright 2004 Novell, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# + +from dicti import * + +gd = gnome_dictionary(datafilename) +try: + log ('New Window','teststart') + gd.new_window () +except: + log ('New Window','fail') + log ('New Window','testend') + raise +log ('New Window','pass') +log ('New Window','testend') diff --git a/gnome-dictionary/run.xml b/gnome-dictionary/run.xml new file mode 100644 index 0000000..58eff1d --- /dev/null +++ b/gnome-dictionary/run.xml @@ -0,0 +1,29 @@ +<?xml version="1.0"?> +<ldtp> + <logfileoverwrite>1</logfileoverwrite> + <logfile>/home/prash/src/gd/log.xml</logfile> + <group> + <script> + <name>check_meaning.py</name> + <data>data.xml</data> + </script> + <script> + <name>save_a_copy.py</name> + <data>data.xml</data> + </script> + <script> + <name>close.py</name> + <data>data.xml</data> + </script> + <script> + <name>new.py</name> + <data>data.xml</data> + </script> + </group> + <group> + <script> + <name>find.py</name> + <data>data.xml</data> + </script> + </group> +</ldtp> diff --git a/gnome-dictionary/save_a_copy.py b/gnome-dictionary/save_a_copy.py new file mode 100644 index 0000000..39229ba --- /dev/null +++ b/gnome-dictionary/save_a_copy.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# +# Linux Desktop Testing Project http://ldtp.freedesktop.org +# +# Author: +# Prashanth Mohan <prashmohan at gmail dot com> +# +# Copyright 2004 Novell, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. +# + +from dicti import * + +gd = gnome_dictionary (datafilename) + +try: + log ('Save a copy','teststart') + gd.save_a_copy () +except: + log ('Save a copy','fail') + log ('Save a copy','testend') + raise +log ('Save a copy','pass') +log ('Save a copy','testend') |