uitests: Add choosecd dialog tests

This commit is contained in:
Cole Robinson 2018-01-19 17:34:32 -05:00
parent a6c3fca7a7
commit 3ccb947ce3
7 changed files with 235 additions and 23 deletions

View File

@ -11,13 +11,7 @@ class AddHardware(uiutils.UITestCase):
# Private helpers #
###################
def _open_details_window(self, vmname="test-clone-simple"):
self.app.root.find_fuzzy(vmname, "table cell").click(button=3)
self.app.root.find("Open", "menu item").click()
win = self.app.root.find("%s on" % vmname, "frame")
win.find("Details", "radio button").click()
return win
_default_vmname = "test-clone-simple"
def _open_addhw_window(self, details):
details.find("add-hardware", "push button").click()

92
tests/uitests/choosecd.py Normal file
View File

@ -0,0 +1,92 @@
from tests.uitests import utils as uiutils
class ChooseCD(uiutils.UITestCase):
"""
UI tests for the choosecd dialog
"""
###################
# Private helpers #
###################
##############
# Test cases #
##############
def testChooseCD(self):
win = self._open_details_window(shutdown=True)
hw = win.find("hw-list")
tab = win.find("disk-tab")
# Floppy + physical
hw.find("Floppy 1", "table cell").click()
tab.find("Disconnect", "push button").click()
tab.find("Connect", "push button").click()
cm = self.app.root.find("Choose Media", "dialog")
cm.find("OK", "push button").click()
self.assertTrue("/dev/fdb" in tab.find("disk-source-path").text)
# Floppy + image
hw.find("Floppy 2", "table cell").click()
tab.find("Disconnect", "push button").click()
tab.find("Connect", "push button").click()
cm = self.app.root.find("Choose Media", "dialog")
cm.find("Image Location", "radio button").click()
cm.find("Location:", "text").text = "/dev/default-pool/bochs-vol"
cm.find("OK", "push button").click()
self.assertTrue("bochs-vol" in tab.find("disk-source-path").text)
# CDROM + physical
hw.find("IDE CDROM 1", "table cell").click()
tab.find("Connect", "push button").click()
cm = self.app.root.find("Choose Media", "dialog")
cm.find("Physical Device", "radio button").click()
cm.find("physical-device-combo").click()
cm.find_fuzzy("/dev/sr1", "menu item").click()
cm.find("OK", "push button").click()
self.assertTrue("/dev/sr1" in tab.find("disk-source-path").text)
# CDROM + image
hw.find("SCSI CDROM 1", "table cell").click()
tab.find("Connect", "push button").click()
cm = self.app.root.find("Choose Media", "dialog")
cm.find("Image Location", "radio button").click()
cm.find("Browse...", "push button").click()
browsewin = self.app.root.find(
"Choose Storage Volume", "frame")
browsewin.find_fuzzy("default-pool", "table cell").click()
browsewin.find_fuzzy("backingl1.img", "table cell").click()
browsewin.find("Choose Volume", "push button").click()
cm.find("OK", "push button").click()
alert = self.app.root.find("vmm dialog", "alert")
alert.find_fuzzy("already in use by", "label")
alert.find("Yes", "push button").click()
self.assertTrue(lambda: not cm.showing)
self.assertTrue("backing" in tab.find("disk-source-path").text)
tab.find("Disconnect", "push button").click()
self.assertTrue("-" in tab.find("disk-source-path").text)
def testChooseCDHotplug(self):
"""
Test in the case of a running VM
"""
win = self._open_details_window()
hw = win.find("hw-list")
tab = win.find("disk-tab")
# CDROM + physical
hw.find("IDE CDROM 1", "table cell").click()
tab.find("Connect", "push button").click()
cm = self.app.root.find("Choose Media", "dialog")
cm.find("OK", "push button").click()
alert = self.app.root.find("vmm dialog", "alert")
alert.find_fuzzy("changes will take effect", "label")
alert.find("OK", "push button").click()
self.assertTrue("-" in tab.find("disk-source-path").text)
# Shutdown the VM, verify change shows up
win.find("Shut Down", "push button").click()
run = win.find("Run", "push button")
uiutils.check_in_loop(lambda: run.sensitive)
self.assertTrue("/dev/sr0" in tab.find("disk-source-path").text)

View File

@ -6,19 +6,6 @@ class Details(uiutils.UITestCase):
UI tests for virt-manager's VM details window
"""
###################
# Private helpers #
###################
def _open_details_window(self, vmname="test-many-devices"):
self.app.root.find_fuzzy(vmname, "table cell").click(button=3)
self.app.root.find("Open", "menu item").click()
win = self.app.root.find("%s on" % vmname, "frame")
win.find("Details", "radio button").click()
return win
##############
# Test cases #
##############

View File

@ -24,6 +24,8 @@ class UITestCase(unittest.TestCase):
def tearDown(self):
self.app.stop()
_default_vmname = "test-many-devices"
# Helpers to save testfile imports
@staticmethod
def sleep(*args, **kwargs):
@ -44,6 +46,23 @@ class UITestCase(unittest.TestCase):
win.find_fuzzy(tab, "page tab").click()
return win
def _open_details_window(self, vmname=None, shutdown=False):
if vmname is None:
vmname = self._default_vmname
self.app.root.find_fuzzy(vmname, "table cell").click(button=3)
self.app.root.find("Open", "menu item").click()
win = self.app.root.find("%s on" % vmname, "frame")
win.find("Details", "radio button").click()
if shutdown:
win.find("Shut Down", "push button").click()
run = win.find("Run", "push button")
check_in_loop(lambda: run.sensitive)
return win
##############
def _walkUIList(self, win, lst, error_cb):
"""
Toggle down through a UI list like addhardware, net/storage/iface

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<!-- Generated with glade 3.20.2 -->
<interface>
<requires lib="gtk+" version="3.14"/>
<object class="GtkDialog" id="vmm-choose-cd">
@ -17,6 +17,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
@ -122,7 +123,7 @@
</child>
<child>
<object class="GtkRadioButton" id="physical-media">
<property name="label" translatable="yes">CD-_ROM or DVD</property>
<property name="label" translatable="yes">P_hysical Device</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@ -145,7 +146,7 @@
<property name="yscale">0</property>
<child>
<object class="GtkRadioButton" id="iso-image">
<property name="label" translatable="yes">_ISO Image Location</property>
<property name="label" translatable="yes">_Image Location</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@ -243,5 +244,8 @@
<action-widget response="-6">Cancel</action-widget>
<action-widget response="-5">OK</action-widget>
</action-widgets>
<child>
<placeholder/>
</child>
</object>
</interface>

View File

@ -1381,6 +1381,11 @@
<property name="position">2</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="vbox6-atkobject">
<property name="AtkObject::accessible-name">overview-tab</property>
</object>
</child>
</object>
</child>
<child type="tab">
@ -1624,6 +1629,11 @@
<property name="position">2</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="box12-atkobject">
<property name="AtkObject::accessible-name">inspection-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
@ -1917,6 +1927,11 @@
<property name="position">0</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="box2-atkobject">
<property name="AtkObject::accessible-name">performance-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">2</property>
@ -2432,6 +2447,11 @@
<property name="position">2</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="vbox14-atkobject">
<property name="AtkObject::accessible-name">cpu-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">3</property>
@ -2643,6 +2663,11 @@
<property name="position">0</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="vbox7-atkobject">
<property name="AtkObject::accessible-name">memory-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">4</property>
@ -3233,6 +3258,11 @@
<property name="top_attach">1</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="vbox4-atkobject">
<property name="AtkObject::accessible-name">boot-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">5</property>
@ -3398,6 +3428,11 @@
<property name="label">path</property>
<property name="selectable">True</property>
<property name="ellipsize">start</property>
<child internal-child="accessible">
<object class="AtkObject" id="disk-source-path-atkobject">
<property name="AtkObject::accessible-name">disk-source-path</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -3810,6 +3845,11 @@
<property name="position">1</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="vbox55-atkobject">
<property name="AtkObject::accessible-name">disk-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">6</property>
@ -3996,6 +4036,11 @@
<property name="position">1</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="vbox54-atkobject">
<property name="AtkObject::accessible-name">network-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">7</property>
@ -4107,6 +4152,11 @@
<property name="position">0</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="vbox56-atkobject">
<property name="AtkObject::accessible-name">input-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">8</property>
@ -4160,6 +4210,11 @@
<property name="position">0</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="vbox57-atkobject">
<property name="AtkObject::accessible-name">graphics-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">9</property>
@ -4251,6 +4306,11 @@
<property name="position">0</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="vbox58-atkobject">
<property name="AtkObject::accessible-name">sound-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">10</property>
@ -4457,6 +4517,11 @@
<property name="position">0</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="vbox59-atkobject">
<property name="AtkObject::accessible-name">char-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">11</property>
@ -4568,6 +4633,11 @@
<property name="position">0</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="vbox8-atkobject">
<property name="AtkObject::accessible-name">host-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">12</property>
@ -4729,6 +4799,11 @@
<property name="position">0</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="vbox9-atkobject">
<property name="AtkObject::accessible-name">video-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">13</property>
@ -4851,6 +4926,11 @@
<property name="position">0</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="vbox12-atkobject">
<property name="AtkObject::accessible-name">watchdog-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">14</property>
@ -5003,6 +5083,11 @@
<property name="use_markup">True</property>
</object>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="frame12-atkobject">
<property name="AtkObject::accessible-name">controller-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">15</property>
@ -5044,6 +5129,11 @@
<property name="use_markup">True</property>
</object>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="frame16-atkobject">
<property name="AtkObject::accessible-name">filesystem-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">16</property>
@ -5137,6 +5227,11 @@
<property name="position">0</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="vbox16-atkobject">
<property name="AtkObject::accessible-name">smartcard-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">17</property>
@ -5232,6 +5327,11 @@
<property name="use_markup">True</property>
</object>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="frame19-atkobject">
<property name="AtkObject::accessible-name">redir-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">18</property>
@ -5340,6 +5440,11 @@
<property name="position">0</property>
</packing>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="vbox17-atkobject">
<property name="AtkObject::accessible-name">tpm-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">19</property>
@ -5627,6 +5732,11 @@
<property name="use_markup">True</property>
</object>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="frame21-atkobject">
<property name="AtkObject::accessible-name">rng-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">20</property>
@ -5698,6 +5808,11 @@
<property name="use_markup">True</property>
</object>
</child>
<child internal-child="accessible">
<object class="AtkObject" id="frame17-atkobject">
<property name="AtkObject::accessible-name">panic-tab</property>
</object>
</child>
</object>
<packing>
<property name="position">21</property>

View File

@ -79,6 +79,7 @@ class vmmMediaCombo(vmmGObjectUI):
text = Gtk.CellRendererText()
self.combo.pack_start(text, True)
self.combo.add_attribute(text, 'text', self.OPTICAL_LABEL)
self.combo.get_accessible().set_name("physical-device-combo")
error = None
if not self.conn.is_nodedev_capable():