2018-04-04 14:35:41 +01:00
# This work is licensed under the GNU GPLv2 or later.
2018-03-20 15:00:02 -04:00
# See the COPYING file in the top-level directory.
2018-01-09 15:21:33 -05:00
from tests . uitests import utils as uiutils
class VMMPrefs ( uiutils . UITestCase ) :
"""
UI tests for the preferences dialog
"""
##############
# Test cases #
##############
def testPrefs ( self ) :
2018-01-19 10:51:33 -05:00
self . app . root . find ( " Edit " , " menu " ) . click ( )
self . app . root . find ( " Preferences " , " menu item " ) . click ( )
2018-01-10 16:42:53 -05:00
2018-01-10 18:57:40 -05:00
win = self . app . root . find_fuzzy ( " Preferences " , " frame " )
2018-01-09 15:21:33 -05:00
2018-01-10 18:57:40 -05:00
win . find_fuzzy ( " Enable system tray " , " check " ) . click ( )
2018-01-09 15:21:33 -05:00
2018-01-19 10:51:33 -05:00
win . find ( " Polling " , " page tab " ) . click ( )
2018-01-10 18:57:40 -05:00
win . find_fuzzy ( None , " check box " ,
2018-01-09 15:21:33 -05:00
labeller_text = " Poll CPU " ) . click ( )
2018-01-19 10:51:33 -05:00
win . find ( " New VM " , " page tab " ) . click ( )
win . find ( " prefs-add-spice-usbredir " ,
2018-01-09 15:21:33 -05:00
" combo box " ) . click ( )
2018-01-19 10:51:33 -05:00
win . find ( " No " , " menu item " ) . click ( )
2018-01-09 15:21:33 -05:00
2018-01-19 10:51:33 -05:00
win . find ( " Console " , " page tab " ) . click ( )
win . find ( " Change... " , " push button " ) . click ( )
2018-01-10 18:57:40 -05:00
keyframe = self . app . root . find_fuzzy ( " Configure grab " , " dialog " )
2018-09-02 01:26:30 +03:00
# On certain environments pressing "Alt_L" and clicking a window starts
# window drag operation. Work around by pushing both Control and Alt.
self . holdKey ( " Control_L " )
2018-01-21 11:58:11 -05:00
self . holdKey ( " Alt_L " )
self . holdKey ( " Z " )
2018-01-09 15:21:33 -05:00
try :
2018-01-10 18:57:40 -05:00
keyframe . find_fuzzy ( " OK " , " push button " ) . click ( )
2018-01-09 15:21:33 -05:00
finally :
2018-01-21 11:58:11 -05:00
self . releaseKey ( " Z " )
self . releaseKey ( " Alt_L " )
2018-09-02 01:26:30 +03:00
self . releaseKey ( " Control_L " )
2018-01-09 15:21:33 -05:00
2018-01-19 10:51:33 -05:00
win . find ( " Feedback " , " page tab " ) . click ( )
2018-01-10 18:57:40 -05:00
win . find_fuzzy ( None , " check box " ,
2018-01-09 15:21:33 -05:00
labeller_text = " Force Poweroff " ) . click ( )
2018-01-19 10:51:33 -05:00
win . find ( " General " , " page tab " ) . click ( )
2018-01-10 18:57:40 -05:00
win . find_fuzzy ( " Enable system tray " , " check " ) . click ( )
2018-01-09 15:21:33 -05:00
2018-01-10 18:57:40 -05:00
win . find_fuzzy ( " Close " , " push button " ) . click ( )
2018-01-09 15:21:33 -05:00
uiutils . check_in_loop ( lambda : win . visible is False )
2019-06-05 17:40:54 -04:00
def testPrefsXMLEditor ( self ) :
managerwin = self . app . topwin
2019-06-13 13:50:13 -04:00
uiutils . drag ( managerwin , 0 , 200 )
2019-06-05 17:40:54 -04:00
detailswin = self . _open_details_window ( vmname = " test-clone-simple " )
finish = detailswin . find ( " config-apply " )
xmleditor = detailswin . find ( " XML editor " )
detailswin . find ( " XML " , " page tab " ) . click ( )
warnlabel = detailswin . find_fuzzy ( " XML editing is disabled " )
self . assertTrue ( warnlabel . visible )
origtext = xmleditor . text
xmleditor . typeText ( " 1234abcd " )
self . assertEqual ( xmleditor . text , origtext )
2019-06-13 13:50:13 -04:00
managerwin . grabFocus ( )
2019-06-05 17:40:54 -04:00
managerwin . click ( )
managerwin . find ( " Edit " , " menu " ) . click ( )
managerwin . find ( " Preferences " , " menu item " ) . click ( )
prefswin = self . app . root . find_fuzzy ( " Preferences " , " frame " )
prefswin . find_fuzzy ( " Enable XML " ) . click ( )
prefswin . find_fuzzy ( " Close " , " push button " ) . click ( )
uiutils . check_in_loop ( lambda : prefswin . visible is False )
managerwin . keyCombo ( " <alt>F4 " )
detailswin . click ( )
xmleditor . text = xmleditor . text . replace ( " > " ,
" ><title>FOOTITLE</title> " , 1 )
finish . click ( )
detailswin . find ( " Details " , " page tab " ) . click ( )
uiutils . check_in_loop ( lambda :
detailswin . find ( " Title: " , " text " ) . text == " FOOTITLE " )