def focus_nth_recipe (self, n=0): dp.focus.application(APPNAME) dp.focus.frame("Gourmet Recipe Manager") dp.focus.table() dp.keyCombo('<Up>') for i in range(n): dp.keyCombo('<Down>')
def do_tearDown (self): print 'tearDown!' # Quit application! print 'Quit app!' dp.focus.application(APPNAME) dp.focus.frame('Gourmet Recipe Manager') dp.keyCombo('<Ctrl>Q') print 'Hit quit!' time.sleep(2) print 'tearDown done!' os.system('killall gourmet_in_place') # Maek sure it's really dead...
def do_tearDown (self): print('tearDown!') # Quit application! print('Quit app!') dp.focus.application(APPNAME) dp.focus.frame('Gourmet Recipe Manager') dp.keyCombo('<Ctrl>Q') print('Hit quit!') time.sleep(2) print('tearDown done!') os.system('killall gourmet_in_place') # Maek sure it's really dead...
def test_keyCombo_on_widget(self): self.runDemo('Builder') focus.button('Copy') keyCombo('<F7>') try: res = focus.dialog('About Builder demo') except: try: res = focus.dialog('About GtkBuilder demo') except: pass self.assertTrue(res)
def test_keyCombo(self): self.runDemo('Builder') keyCombo('<F7>') res = False try: res = focus.dialog('About Builder demo') except: try: res = focus.dialog('About GtkBuilder demo') except: pass self.assertTrue(res)
def do_testWebImport (self, url): shortname = url.split('/')[-1] dp.focus.application(APPNAME) dp.focus.frame('Gourmet Recipe Manager') dp.click("File") dp.click('Import webpage') time.sleep(2) dp.focus.frame('Enter website address') print('TYPING URL!') dp.type(url) dp.keyCombo("Return") time.sleep(1) screenshot('manual_web_import-%s.png'%shortname) dp.click('OK') screenshot('manual_web_import_done-%s.png'%shortname) dp.focus.dialog('Gourmet Import/Export') dp.click('Close')
def do_testWebImport (self, url): shortname = url.split('/')[-1] dp.focus.application(APPNAME) dp.focus.frame('Gourmet Recipe Manager') dp.click("File") dp.click('Import webpage') time.sleep(2) dp.focus.frame('Enter website address') print 'TYPING URL!' dp.type(url) dp.keyCombo("Return") time.sleep(1) screenshot('manual_web_import-%s.png'%shortname) dp.click('OK') screenshot('manual_web_import_done-%s.png'%shortname) dp.focus.dialog('Gourmet Import/Export') dp.click('Close')
def testEditingNewCard (self): dp.focus.application(APPNAME) dp.focus.frame('Gourmet Recipe Manager') #dp.keyCombo('<Ctrl>n') dp.click('File') dp.click('New') dp.focus.frame('New Recipe (Edit)') dp.keyCombo('<Alt>l') dp.focus.widget('Title Entry') time.sleep(1) dp.type('Testing!') dp.focus.widget('Preparation Time Entry') time.sleep(1) dp.type('30 minutes') dp.focus.widget('Rating Entry') time.sleep(1) dp.type('4') screenshot('Edited_recipe.png') #dp.keyCombo('<Ctrl>w') dp.click("Recipe") dp.click("Close") screenshot('save_changes_to_edited_rec.png') dp.focus.dialog('Question') #dp.keyCombo('<Alt>C') dp.click("Cancel") #self.assertEqual(hasattr(rc,'recipe_editor'),True,'Cancelling save-changes did not work') dp.focus.frame('New Recipe (Edit)') time.sleep(3) dp.keyCombo('<Ctrl>w') time.sleep(3) dp.focus.dialog('Question') dp.keyCombo('<Alt>s') screenshot('new_rec_saved.png')
def testEditingNewCard (self): dp.focus.application(APPNAME) dp.focus.frame('Gourmet Recipe Manager') #dp.keyCombo('<Ctrl>n') dp.click('File') dp.click('New') dp.focus.frame(u'New Recipe (Edit)') dp.keyCombo('<Alt>l') dp.focus.widget('Title Entry') time.sleep(1) dp.type('Testing!') dp.focus.widget('Preparation Time Entry') time.sleep(1) dp.type('30 minutes') dp.focus.widget('Rating Entry') time.sleep(1) dp.type('4') screenshot('Edited_recipe.png') #dp.keyCombo('<Ctrl>w') dp.click("Recipe") dp.click("Close") screenshot('save_changes_to_edited_rec.png') dp.focus.dialog('Question') #dp.keyCombo('<Alt>C') dp.click("Cancel") #self.assertEqual(hasattr(rc,'recipe_editor'),True,'Cancelling save-changes did not work') dp.focus.frame(u'New Recipe (Edit)') time.sleep(3) dp.keyCombo('<Ctrl>w') time.sleep(3) dp.focus.dialog('Question') dp.keyCombo('<Alt>s') screenshot('new_rec_saved.png')
def search_and_open (self, txt): dp.focus.frame("Gourmet Recipe Manager") dp.keyCombo('<Alt>S') # Focus search dp.focus.text() dp.type(txt) # Search for our recipe dp.keyCombo('<Alt>L') # Focus recipe list dp.keyCombo('Return') # Open recipe time.sleep(1)
def testShoppingListGenerationFromIndex (self): self.focus_nth_recipe(0) dp.click('Actions') dp.click('Add to Shopping List') screenshot('generate_shopping_list_from_index.png') dp.focus.dialog('') dp.click('OK') screenshot('generated_shopping_list_from_index.png') dp.focus.frame('Shopping List') dp.keyCombo('<Ctrl>w') # Add a second recipe to the list... self.focus_nth_recipe(1) dp.keyCombo('<Ctrl>l') # Add with keycombo... dp.focus.dialog('') dp.focus.text() dp.type('12') dp.keyCombo('<Return>') screenshot('shopping list With two recipes+mult.png') dp.keyCombo('<Ctrl>w')
def do_testFileImport (self, fn): shortname = os.path.split(fn)[1] dp.focus.application(APPNAME) dp.focus.frame('Gourmet Recipe Manager') dp.click("File") dp.click("Import file") dp.focus.dialog('Open recipe...') dp.keyCombo("<Alt>l") dp.type(fn) screenshot('import_dialog-%s-.png'%shortname) dp.keyCombo("Return") time.sleep(5) # wait for import to complete... print('DONE SLEEPING -- IMPORT SHOULD BE DONE!') screenshot('import_done-%s.png'%shortname) dp.keyCombo("<Alt>C") # close dialog dp.focus.frame('Gourmet Recipe Manager') screenshot('with_imported_recs-%s.png'%shortname)
def do_testFileImport (self, fn): shortname = os.path.split(fn)[1] dp.focus.application(APPNAME) dp.focus.frame('Gourmet Recipe Manager') dp.click("File") dp.click("Import file") dp.focus.dialog('Open recipe...') dp.keyCombo("<Alt>l") dp.type(fn) screenshot('import_dialog-%s-.png'%shortname) dp.keyCombo("Return") time.sleep(5) # wait for import to complete... print 'DONE SLEEPING -- IMPORT SHOULD BE DONE!' screenshot('import_done-%s.png'%shortname) dp.keyCombo("<Alt>C") # close dialog dp.focus.frame('Gourmet Recipe Manager') screenshot('with_imported_recs-%s.png'%shortname)
def testShoppingListGenerationFromCard (self): # Test multiplication + no multiplication self.focus_nth_recipe() dp.keyCombo('<Ctrl>o') # open recipe card dp.focus.frame('') dp.click('Actions') dp.click('Shop') # using shop button dp.focus.frame('Shopping List') screenshot('add-to-shopping-list-from-card-w-button.png') dp.keyCombo('<Ctrl>w') dp.focus.frame('') dp.click('Recipe') dp.click("Add to Shopping List") # from menu dp.focus.frame('Shopping List') screenshot('add-to-shopping-list-from-card-w-menu.png') screenshot('Adding Shopping List from Card') dp.keyCombo('<Ctrl>w') dp.focus.frame('') dp.keyCombo('<Alt>y') dp.focus.text() dp.type('12') # double... dp.keyCombo('<Ctrl>l') # from keyboard dp.keyCombo('<Return>') screenshot('add-to-shopping-list-from-card-w-keyboard-multiplied-by-2.png') dp.keyCombo('<Ctrl>w')
def test_keyCombo_on_widget(self): self.runDemo('Builder') focus.button('Copy') keyCombo('<F7>') self.assertTrue(focus.dialog('About GtkBuilder demo'))
def testKeyCombo(self): self.runDemo('Application window') focus.window('Application Window') keyCombo("<ctrl>a") focus.dialog('About GTK+ Code Demos')
def test_keyCombo_on_widget(self): self.runDemo('Application window') focus.window('Application Window') focus.icon('') keyCombo("<ctrl>a") focus.dialog('About GTK+ Code Demos')
def test_keyCombo(self): self.runDemo('Builder') keyCombo('<F7>') self.assertTrue(focus.dialog('About GtkBuilder demo'))
def test_unit_converter(): """Dogtail integration test: Unit converter plugin behaves as intended.""" cmd = "gourmet" pid = run(cmd, timeout=3) gourmet = None for app in tree.root.applications(): if app.get_process_id() == pid: gourmet = app break assert gourmet is not None, "Could not find Gourmet instance!" # Open the unit converter plugin procedural.keyCombo("<Alt>T") procedural.keyCombo("U") procedural.focus.window("Unit Converter") # Enter source amount and unit (5 liters) procedural.keyCombo("<Alt>A") procedural.type("5") procedural.keyCombo("<Alt>U") procedural.keyCombo("<Enter>") procedural.click("liter (l)") # Enter target unit (ml) procedural.keyCombo("<Alt>U") procedural.keyCombo("<Enter>") procedural.keyCombo("Right") for _ in range(7): procedural.keyCombo("Down") procedural.keyCombo("<Enter>") # Check that the result is shown correctly assert procedural.focus.widget(name="5 l = 5000 ml", roleName="label") # There are now two windows, the unit converter, and main window # Close them successively to quit the application procedural.keyCombo("<Alt><F4>") procedural.keyCombo("<Alt><F4>")