uitests: addhardware storage/disk testing

This commit is contained in:
Cole Robinson 2018-01-19 13:14:01 -05:00
parent c620e7405c
commit dc3c0b29f7
4 changed files with 119 additions and 3 deletions

View File

@ -2,9 +2,9 @@ import tests
from tests.uitests import utils as uiutils
class Details(uiutils.UITestCase):
class AddHardware(uiutils.UITestCase):
"""
UI tests for virt-manager's VM details window
UI tests for virt-manager's VM addhardware window
"""
###################
@ -35,6 +35,105 @@ class Details(uiutils.UITestCase):
# Test cases #
##############
def testAddDisks(self):
"""
Add various disk configs and test storage browser
"""
details = self._open_details_window()
addhw = self._open_addhw_window(details)
finish = addhw.find("Finish", "push button")
# Default disk
tab = self._select_hw(addhw, "Storage", "storage-tab")
finish.click()
uiutils.check_in_loop(lambda: details.active)
# Disk with some tweaks
addhw = self._open_addhw_window(details)
tab = self._select_hw(addhw, "Storage", "storage-tab")
tab.find("GiB", "spin button").text = "1.5"
tab.find("Bus type:", "combo box").click()
tab.find("VirtIO", "menu item").click()
tab.find("Advanced options", "toggle button").click_expander()
tab.find("Cache mode:", "combo box").click()
tab.find("none", "menu item").click()
finish.click()
uiutils.check_in_loop(lambda: details.active)
# Managed storage tests
addhw = self._open_addhw_window(details)
tab = self._select_hw(addhw, "Storage", "storage-tab")
tab.find_fuzzy("Select or create", "radio").click()
tab.find("storage-browse", "push button").click()
browse = self.app.root.find("Choose Storage Volume", "frame")
# Create a vol, refresh, then delete it
browse.find_fuzzy("default-pool", "table cell").click()
browse.find("vol-new", "push button").click()
newvol = self.app.root.find("Add a Storage Volume", "frame")
newname = "a-newvol"
newvol.find("Name:", "text").text = newname
newvol.find("Finish", "push button").click()
uiutils.check_in_loop(lambda: not newvol.showing)
volcell = browse.find(newname, "table cell")
self.assertTrue(volcell.selected)
browse.find("vol-refresh", "push button").click()
volcell = browse.find(newname, "table cell")
self.assertTrue(volcell.selected)
browse.find("vol-delete", "push button").click()
alert = self.app.root.find("vmm dialog", "alert")
alert.find_fuzzy("permanently delete the volume", "label")
alert.find("Yes", "push button").click()
uiutils.check_in_loop(lambda: volcell.dead)
# Test browse local
browse.find("Browse Local", "push button").click()
chooser = self.app.root.find(
"Locate existing storage", "file chooser")
fname = "virt-manager.spec.in"
chooser.find(fname, "table cell").click()
chooser.find("Open", "push button").click()
uiutils.check_in_loop(lambda: not chooser.showing)
uiutils.check_in_loop(lambda: addhw.active)
self.assertTrue(("/" + fname) in tab.find("storage-entry").text)
# Reopen dialog, select a volume, etic
tab.find("storage-browse", "push button").click()
browse = self.app.root.find("Choose Storage Volume", "frame")
browse.find_fuzzy("disk-pool", "table cell").click()
browse.find("diskvol1", "table cell").click()
browse.find("Choose Volume", "push button").click()
self.assertTrue("/diskvol1" in tab.find("storage-entry").text)
finish.click()
alert = self.app.root.find("vmm dialog", "alert")
alert.find_fuzzy("already in use by", "label")
alert.find("Yes", "push button").click()
uiutils.check_in_loop(lambda: details.active)
# choose file for floppy
addhw = self._open_addhw_window(details)
tab = self._select_hw(addhw, "Storage", "storage-tab")
tab.find("Device type:", "combo box").click()
tab.find("Floppy device", "menu item").click()
self.assertFalse(
tab.find_fuzzy("Create a disk image", "radio").sensitive)
tab.find("storage-entry").text = "/dev/default-pool/bochs-vol"
finish.click()
uiutils.check_in_loop(lambda: details.active)
# empty cdrom
addhw = self._open_addhw_window(details)
tab = self._select_hw(addhw, "Storage", "storage-tab")
tab.find("Device type:", "combo box").click()
tab.find("CDROM device", "menu item").click()
tab.find("Bus type:", "combo box").click()
tab.find("SCSI", "menu item").click()
finish.click()
uiutils.check_in_loop(lambda: details.active)
def testAddNetworks(self):
"""
Test various network configs

View File

@ -185,6 +185,16 @@ class VMMDogtailNode(dogtail.tree.Node):
clickY = self.position[1] + self.size[1] / 2
dogtail.rawinput.click(clickX, clickY, button)
def click_expander(self):
"""
Helper for clicking expander, hitting the text part to actually
open it. Basically clicks top left corner with some indent
"""
button = 1
clickX = self.position[0] + 10
clickY = self.position[1] + 5
dogtail.rawinput.click(clickX, clickY, button)
#########################
# Widget search helpers #

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="GtkAdjustment" id="adjustment1">
@ -207,6 +207,11 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="width_chars">25</property>
<child internal-child="accessible">
<object class="AtkObject" id="storage-entry-atkobject">
<property name="AtkObject::accessible-name">storage-entry</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>

View File

@ -411,6 +411,8 @@ class vmmAddHardware(vmmGObjectUI):
# Storage init
self.widget("storage-devtype").set_active(0)
self.widget("storage-devtype").emit("changed")
self.widget("storage-cache").set_active(0)
self.widget("disk-advanced-expander").set_expanded(False)
self.addstorage.reset_state()
# Network init