def setUpClass(self): libastylewx.print_separator() print("Checking menu sans editor") # close the open pane ldtp.selectmenuitem('frmAStyleWx', 'mnuFile;mnuClose') # linux must open a menu so that OnMenuOpen() in astylewx will be called libastylewx.activate_linux_menus()
def testRmRepository(self): repo_name = "test2" pm_str = "%s/usr/bin/packagemanager" % pkg5unittest.g_proto_area ldtp.launchapp(pm_str,["-R", self.get_img_path()]) ldtp.waittillguiexist('Package Manager', state = ldtp.state.ENABLED) ldtp.selectmenuitem('Package Manager', 'mnuFile;mnuManage Publishers...') ldtp.waittillguiexist('dlgManage Publishers') ldtp.selectrow('dlgManage Publishers', 'Publishers', repo_name) ldtp.click('dlgManage Publishers', 'btnRemove') ldtp.click('dlgManage Publishers', 'btnOK') ldtp.waittillguiexist('dlgManage Publishers Confirmation') ldtp.click('dlgManage Publishers Confirmation', 'btnOK') ldtp.waittillguinotexist('dlgManage Publishers') # Verify result self.pkg('publisher | grep %s' % repo_name, exit=1) # Quit Package Manager ldtp.selectmenuitem('Package Manager', 'mnuFile;mnuQuit')
def testInstallSimplePackage(self): pkgname = 'package1' pm_str = "%s/usr/bin/packagemanager" % pkg5unittest.g_proto_area self.pkgsend_bulk(self.rurl, self.foo10) self.image_create(self.rurl) ldtp.launchapp(pm_str,["-R", self.get_img_path()]) ldtp.waittillguiexist('Package Manager', state = ldtp.state.ENABLED) ldtp.selectindex('Package Manager', 'Publisher', 0) ldtp.selectrow('Package Manager', 'Packages', pkgname) ldtp.selectmenuitem('Package Manager', 'mnuEdit;mnuSelect All') ldtp.click('Package Manager', 'btnInstall/Update') ldtp.waittillguiexist('dlgInstall Confirmation') ldtp.click('dlgInstall Confirmation', 'btnProceed') while (ldtp.objectexist('dlgInstall/Update', 'btnClose') == 0): ldtp.wait(0.1) ldtp.click('dlgInstall/Update', 'btnClose') ldtp.waittillguinotexist('dlgInstall/Update') # Verify result self.pkg('verify') # Quit packagemanager ldtp.selectmenuitem('Package Manager', 'mnuFile;mnuQuit')
def testViews(self): for menu_item in ('mnuAdvanced', 'mnuFinancial', 'mnuScientific', 'mnuProgramming', 'mnuBasic'): ldtp.selectmenuitem('frmCalculator*', menu_item) sleep(1)
def mac_take_finder_combo_box_action(self, window_name, action): try: ldtp.mouseleftclick("frm"+window_name,'cbo0') time.sleep(3) ldtp.selectmenuitem("frm"+window_name,"mnu%s*" % action) except: ldtp.click(window_name,'cbo0') time.sleep(3) ldtp.selectmenuitem(window_name,"mnu%s*" % action)
def testStartPackagemanager(self): pm_str = "%s/usr/bin/packagemanager" % pkg5unittest.g_proto_area self.pkgsend_bulk(self.rurl, self.foo10) self.image_create(self.rurl) ldtp.launchapp(pm_str,["-R", self.get_img_path()]) ldtp.waittillguiexist('Package Manager', state = ldtp.state.ENABLED) ldtp.selectmenuitem('Package Manager', 'mnuFile;mnuQuit')
def activate_linux_menus(): """Linux must open a menu to call OnMenuOpen() in astylewx to activate or deactivate the submenus. """ if not os.name == "nt": ldtp.selectmenuitem('frmAStyleWx', 'mnuFile') ldtp.keypress('<esc>') ldtp.keyrelease('<esc>') ldtp.wait(1)
def tearDown(self): ldtp.selectmenuitem('frmUbuntuSoftwareCent*', 'mnuClose') assert ldtp.waittillguinotexist('frmUbuntuSoftwareCent*') c = "This test took a total of " + str( time.time() - start_time) + " Cpu percentage: " + str( ldtp.getcpustat( 'software-center')) + " Memory usage in MB: " + str( ldtp.getmemorystat('software-center')) self.msgs.append(c) print '\n'.join(self.msgs)
def main(): """Main processing function. """ if os.name == "nt": exepath = "C:/Users/jimp/Projects/AStyleWx/build/vs2013_3.0/debug/AStyleWxd.exe" else: exepath = "../../AStyleWx/build/cb-gcc/wx3.0/bin/astylewxd" exepath = exepath.replace('/', os.sep) #print(sys.path[0]) os.chdir(sys.path[0]) if not os.path.exists(exepath): print("Cannot find executable: " + exepath) print("The script has terminated!") sys.exit(1) print("Launching AStyleWx") try: ldtp.launchapp(exepath) except ldtp.client_exception.LdtpExecutionError as err: print("Error in launchapp: " + exepath) print(err) print("The script has terminated!") sys.exit(1) if not ldtp.waittillguiexist('*AStyleWx'): print("Error in waittillguiexist") print("The script has terminated!") sys.exit(1) print('\nFile') print(ldtp.listsubmenus('frmAStyleWx', 'mnuFile')) print('\nEdit') print(ldtp.listsubmenus('frmAStyleWx', 'mnuEdit')) print('\nSearch') print(ldtp.listsubmenus('frmAStyleWx', 'mnuSearch')) print('\nView') print(ldtp.listsubmenus('frmAStyleWx', 'mnuView')) print('\nTools') print(ldtp.listsubmenus('frmAStyleWx', 'mnuTools')) print('\nHelp') print(ldtp.listsubmenus('frmAStyleWx', 'mnuHelp')) print() print("Closing AStyleWx") ldtp.selectmenuitem('frmAStyleWx', 'mnuFile;mnuExit') if not ldtp.waittillguinotexist('*AStyleWx'): print("Error in waittillguinotexist") print("The script has terminated!") sys.exit(1)
def select_context_click_menu(self,window_name,object_name = None,menu = None): if self.os_family == 'windows': # object_name = "lst"+object_name pane_name = self.get_explorer_main_pane() # self.click_element("Clicking pane", window_name, pane_name) if object_name: time.sleep(4) ldtp.mouserightclick(window_name,object_name) else: try: ldtp.mouserightclick(window_name,'lblThisfolderisempty') except: pass ldtp.mouserightclick(window_name,pane_name) ldtp.selectmenuitem('mnuContext','mnu%s'% menu)
def select_menu_item(self, window_name, object_name): """ [关键字概要] 选择菜单栏, 菜单栏可以以`;`符号表示层级, 如mnuFile;mnuNew :@参数 window_name: 窗口名称 :@参数 object_name: 对象名称 :@返回值: 成功或失败 Examples: | *Test Cases* | *Action* | *Argument* | *Arguments* | | Example_Test | Select Menu Item | ${FRM_NAME} | ${MENU_ITEM_NAME} | """ try: self._info("select menu item ... (%s, %s)" % (window_name, object_name)) # print("*INFO* select menu item ... [%s, %s]\r\n" % (window_name, object_name)) return ldtp.selectmenuitem(window_name, object_name) except LdtpExecutionError: raise LdtpExecutionError( "select menu item failed, please check if the input parameters are correct. " )
def create_new_file(self,window_name): if self.os_family == 'windows': if self.os_check not in ["Win_8"]: ldtp.mouseleftclick(window_name,'paneShellFolderView') ldtp.generatekeyevent('<alt>f') ldtp.keypress('w') ldtp.keypress('t') else: try: ldtp.click(window_name,'uknNewitem') except: ldtp.click(window_name,'btnMinimizetheRibbon') ldtp.click(window_name,'uknNewitem') time.sleep(2) ldtp.selectmenuitem('frmNewitem','mnuTextDocument') time.sleep(2) ldtp.generatekeyevent("%s<enter>" % str(int(time.time())))
def testAddRepository(self): repo_name = "test2" pm_str = "%s/usr/bin/packagemanager" % pkg5unittest.g_proto_area ldtp.launchapp(pm_str,["-R", self.get_img_path()]) ldtp.waittillguiexist('Package Manager', state = ldtp.state.ENABLED) ldtp.selectmenuitem('Package Manager', 'mnuFile;mnuAdd Publisher...') ldtp.waittillguiexist('dlgAdd Publisher') ldtp.settextvalue('dlgAdd Publisher', "txtURI", self.dcs[2].get_depot_url()) ldtp.click('dlgAdd Publisher', 'btnAdd') ldtp.waittillguiexist('dlgAdding Publisher Complete') ldtp.click('dlgAdding Publisher Complete', 'btnClose') # Verify result self.pkg('publisher | grep %s' % repo_name, exit=0) # Quit Package Manager ldtp.selectmenuitem('Package Manager', 'mnuFile;mnuQuit')
def create_new_folder(self,window_name, dir_name = None): if dir_name == None : dir_name = str(int(time.time())) if self.os_family == "mac": ldtp.selectmenuitem(window_name,"mnuFile;mnuNewFolder") self.send_keys_to_current_focused_object("<control_l><c>") self.send_keys_to_current_focused_object("%s<enter>"%dir_name) elif self.os_family == "windows": pane_name = self.get_explorer_main_pane() self.click_element("Clicking pane", window_name, pane_name) if self.os_check not in ["Win_8"]: self.send_keys_to_current_focused_object("<alt><f>") self.send_keys_to_current_focused_object("<w>") self.send_keys_to_current_focused_object("<f>") time.sleep(3) else: try: self.click_element("Clicking on NewFolder Button " ,window_name,"btnNewfolder1") except: self.click_element("Clicking on NewFolder Button " ,window_name,"btnNewfolder") time.sleep(4) self.send_keys_to_current_focused_object("%s<enter>"%dir_name) return dir_name
def click_element(self, msg, window_name, object_name,double = False): ''' Generic call to click any type of element. Tries coordinate based clicking if default does not work. ''' logger.debug(msg) prefix = "img" if self.os_check == "Mac": prefix_of_obj = ["lbl","img","btn","chk","txt", "grp"] if window_name.find("frm") == -1 : window_name = "frm" + window_name if object_name[:3] not in prefix_of_obj: object_name = prefix + object_name try: ldtp.selectmenuitem(window_name,"mnuView;mnuasIcons") time.sleep(2) ldtp.selectmenuitem('frmsample','mnuView;mnuCleanUp') time.sleep(2) except: pass try: if not double: success = ldtp.click(window_name, object_name) else: success = ldtp.doubleclick(window_name, object_name) except Exception, e: try: if not double: ldtp.mouseleftclick(window_name, object_name) else: # on mac first time doubleclick does not work at times ldtp.doubleclick(window_name, object_name) except Exception, e: raise AssertionError("Unable to click element: %s" % traceback.format_exc())
def testPmHelp(self): ldtp.launchapp(self.pm_str,["-R", self.get_img_path()]) ldtp.waittillguiexist('Package Manager', state = ldtp.state.ENABLED) ldtp.selectmenuitem('Package Manager', 'mnuHelp;mnuContents') # Verify result ldtp.waittillguiexist('*Online Help') self.assertEqual(ldtp.guiexist('*Online Help'), 1) ldtp.selectmenuitem('*Online Help', 'mnuCloseWindow') ldtp.selectmenuitem('Package Manager', 'mnuHelp;mnuAbout') # Verify result self.assertEqual(ldtp.guiexist('About Package Manager'), 1) ldtp.waittillguiexist('dlgAboutPackageManager') ldtp.click('dlgAboutPackageManager', 'btnClose') # Quit Package Manager ldtp.selectmenuitem('Package Manager', 'mnuFile;mnuQuit')
def tearDown(self): ldtp.selectmenuitem('frmUbuntuSoftwareCent*', 'mnuClose') assert ldtp.waittillguinotexist('frmUbuntuSoftwareCent*') c = "This test took a total of " + str(time.time() - start_time) + " Cpu percentage: " + str(ldtp.getcpustat('software-center')) + " Memory usage in MB: " + str(ldtp.getmemorystat('software-center')) self.msgs.append(c) print '\n'.join(self.msgs)
def select_menu(self, window_name, object_name): ''' Selects menu item in the window ''' ldtp.selectmenuitem(window_name, object_name)
def tearDown(self): ldtp.selectmenuitem("frmCalculator*", "mnuQuit") ldtp.waittillguinotexist("frmCalculator*")
def exit_glom(): ldtp.selectmenuitem(main_window, 'mnuFile;mnuClose') if ldtp.waittillguinotexist('*Glom*') == 0: raise ldtp.LdtpExecutionError( 'The Glom Window did not disappear after closing the application.')
def testViews(self): for menu_item in ("mnuAdvanced", "mnuFinancial", "mnuScientific", "mnuProgramming", "mnuBasic"): ldtp.selectmenuitem("frmCalculator*", menu_item) sleep(1)
def exit_glom(): ldtp.selectmenuitem(main_window, 'mnuFile;mnuClose') if ldtp.waittillguinotexist('*Glom*') == 0: raise ldtp.LdtpExecutionError('The Glom Window did not disappear after closing the application.')
def tearDown(self): ldtp.selectmenuitem('frmCalculator*', 'mnuQuit') ldtp.waittillguinotexist('frmCalculator*')
def go_to_dir(self, window_name, path): ''' Got to a location in file system via explorer. ''' if self.os_family == "windows": # self.click_element("Go to location: Computer",window_name, 'uknComputer') object_name = "pane3" currWindowName = window_name tempWindowName = window_name if self.os_check == "Win_8": object_name="pane5" try: ldtp.doubleclick(tempWindowName,'tblcFavorites') tempWindowName = 'Favorites' time.sleep(2) ldtp.generatekeyevent("<left>") ldtp.doubleclick(tempWindowName,'tblcLibraries') tempWindowName = 'Libraries' time.sleep(2) ldtp.generatekeyevent("<left>") ldtp.doubleclick(tempWindowName,'tblcComputer') time.sleep(2) except: ldtp.mouseleftclick(tempWindowName,'ptabView') time.sleep(2) ldtp.mouseleftclick(tempWindowName,'uknNavigationpane') time.sleep(2) ldtp.mouseleftclick(tempWindowName,'mnuNavigationpane') time.sleep(2) try: ldtp.doubleclick(tempWindowName,'tblcFavorites') tempWindowName = 'Favorites' ldtp.generatekeyevent("<left>") time.sleep(2) ldtp.doubleclick(tempWindowName,'tblcLibraries') tempWindowName = 'Libraries' ldtp.generatekeyevent("<left>") time.sleep(2) except: pass ldtp.doubleclick(tempWindowName,'tblcComputer') time.sleep(2) tempWindowName = 'Computer' elif self.os_check == "Win_7_Vista_XP": try: ldtp.doubleclick(tempWindowName, "tblcFavorites") tempWindowName = "Favorites" ldtp.generatekeyevent("<left>") time.sleep(2) ldtp.doubleclick(tempWindowName, "tblcLibraries") tempWindowName = 'Libraries' ldtp.generatekeyevent("<left>") time.sleep(2) ldtp.doubleclick(tempWindowName, "tblcComputer") except : ldtp.mouseleftclick(tempWindowName, "btnOrganize") time.sleep(2) ldtp.generatekeyevent("<l>") time.sleep(2) ldtp.generatekeyevent("<n>") time.sleep(2) ldtp.doubleclick(tempWindowName, "tblcFavorites") tempWindowName = "Favorites" ldtp.generatekeyevent("<left>") time.sleep(2) ldtp.doubleclick(tempWindowName, "tblcLibraries") tempWindowName = 'Libraries' ldtp.generatekeyevent("<left>") time.sleep(2) ldtp.doubleclick(tempWindowName, "tblcComputer") time.sleep(2) # self.click_element("Go to location: Computer",window_name, 'tblcComputer', double = True) self.click_element("Click on Address bar pane in explorer","Computer", object_name) ldtp.enterstring("Computer", "txtAddress", r"%s<enter>" % path) if self.os_check == "Win_8": tempWindowName = self.get_window_name_for_path(path) time.sleep(2) ldtp.mouseleftclick(tempWindowName,'ptabHome') time.sleep(2) elif self.os_family == "mac": if window_name.find("frm") == -1 : window_name = "frm" + window_name ldtp.selectmenuitem(window_name,"mnuGo;mnuGotoFolder*" ) path = path.replace("C:","").replace("\\","/") time.sleep(1) self.send_keys_to_current_focused_object("%s<enter>" % path)
def tearDown(self): ldtp.selectmenuitem('frmUbuntuSoftwareCent*', 'mnuClose') assert ldtp.waittillguinotexist('frmUbuntuSoftwareCent*') c = "This test took a total of " + str(time.time() - start_time) self.msgs.append(c) print '\n'.join(self.msgs)