CA-216752: Not all wizards progress through to the next page by pressing the Enter key

- Added a new method in XenTabPage which the derived classes can implement to select a default control after the page is loaded.
- Added a new wizard test that runs through the wizard by pressing the Enter key and checks if it has landed on the right page.

Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
Mihaela Stoica 2016-12-08 14:47:58 +00:00
parent e42bc87d17
commit 508f638b3a
18 changed files with 127 additions and 6 deletions

View File

@ -191,6 +191,11 @@ namespace XenAdmin.Controls
/// Check whether this step needs to be disabled. Not always overriden in derived classes
/// </summary>
public virtual void CheckPageDisabled() { }
/// <summary>
/// Select a control on the page. Not always overriden in derived classes
/// </summary>
public virtual void SelectDefaultControl() { }
protected void OnPageUpdated()
{

View File

@ -233,6 +233,12 @@ namespace XenAdmin.SettingsPanels
}
}
public override void SelectDefaultControl()
{
if (comboBoxGpus.CanSelect)
comboBoxGpus.Select();
}
#endregion
private void PopulateComboBox()

View File

@ -173,6 +173,11 @@ namespace XenAdmin.Wizards.GenericPages
restoreGridHomeServerSelection = (direction == PageLoadedDirection.Back);
}
public override void SelectDefaultControl()
{
m_comboBoxConnection.Select();
}
public override bool EnableNext()
{
return m_buttonNextEnabled;

View File

@ -686,6 +686,11 @@ namespace XenAdmin.Wizards.HAWizard_Pages
StartNtolUpdate();
}
public override void SelectDefaultControl()
{
dataGridViewVms.Select();
}
public override void PageLeave(PageLoadedDirection direction, ref bool cancel)
{
StopNtolUpdate();

View File

@ -83,6 +83,11 @@ namespace XenAdmin.Wizards.ImportWizard
m_upDownAddSpace.Value = m_upDownAddSpace.Minimum;
}
public override void SelectDefaultControl()
{
m_textBoxVMName.Select();
}
public override bool EnableNext()
{
return m_buttonNextEnabled;

View File

@ -129,6 +129,11 @@ namespace XenAdmin.Wizards.ImportWizard
}
}
public override void SelectDefaultControl()
{
m_tabControlEULA.Select();
}
public override bool EnableNext()
{
return m_buttonNextEnabled;

View File

@ -126,6 +126,11 @@ namespace XenAdmin.Wizards.NewVMWizard
initialising = false;
}
public override void SelectDefaultControl()
{
comboBoxVCPUs.Select();
}
private void InitialiseVcpuControls()
{
labelVCPUs.Text = isVcpuHotplugSupported

View File

@ -84,7 +84,10 @@ namespace XenAdmin.Wizards.NewVMWizard
var entries = SummaryRetreiver.Invoke();
foreach (KeyValuePair<string, string> pair in entries)
SummaryGridView.Rows.Add(pair.Key, pair.Value);
}
public override void SelectDefaultControl()
{
AutoStartCheckBox.Select();
}

View File

@ -114,6 +114,10 @@ namespace XenAdmin.Wizards.NewVMWizard
affinityPicker1.SetAffinity(Connection, Affinity,
CdAffinity ?? Template.GetStorageHost(false));
}
}
public override void SelectDefaultControl()
{
affinityPicker1.Select();
}

View File

@ -82,6 +82,10 @@ namespace XenAdmin.Wizards.NewVMWizard
Template = SelectedTemplate;
NameTextBox.Text = Helpers.DefaultVMName(Helpers.GetName(Template), Connection);
}
public override void SelectDefaultControl()
{
NameTextBox.Select();
}

View File

@ -98,6 +98,10 @@ namespace XenAdmin.Wizards.NewVMWizard
NetworksGridView.Rows[0].Selected = true;
UpdateEnablement();
}
public override void SelectDefaultControl()
{
NetworksGridView.Select();
}

View File

@ -93,6 +93,10 @@ namespace XenAdmin.Wizards.NewVMWizard
LoadDisks();
UpdateEnablement();
UpdateCloneCheckboxEnablement(true);
}
public override void SelectDefaultControl()
{
DisksGridView.Select();
}

View File

@ -149,6 +149,11 @@ namespace XenAdmin.Wizards.PatchingWizard
}
}
public override void SelectDefaultControl()
{
dataGridView1.Select();
}
protected void RefreshRechecks()
{
buttonResolveAll.Enabled = buttonReCheckProblems.Enabled = checkBoxViewPrecheckFailuresOnly.Enabled = false;

View File

@ -165,6 +165,11 @@ namespace XenAdmin.Wizards.PatchingWizard
}
}
public override void SelectDefaultControl()
{
dataGridViewHosts.Select();
}
public bool IsInAutomaticMode { set; get; }
private void EnabledRow(Host host, UpdateType type, int index)

View File

@ -96,6 +96,11 @@ namespace XenAdmin.Wizards.PatchingWizard
}
}
public override void SelectDefaultControl()
{
flickerFreeListBox1.Select();
}
private void DownloadFile()
{
string patchUri = ((XenServerPatchAlert)SelectedUpdateAlert).Patch.PatchUrl;

View File

@ -189,6 +189,11 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard
BuildServerList();
}
public override void SelectDefaultControl()
{
dataGridView1.Select();
}
private void BuildServerList()
{
IList<Host> masters = SelectedMasters;

View File

@ -166,6 +166,7 @@ namespace XenAdmin.Wizards
xenTabControlBody.SelectedTab = wizardProgress.CurrentStepTabPage;
wizardProgress.CurrentStepTabPage.PageLoaded(e.IsForwardsTransition ? PageLoadedDirection.Forward : PageLoadedDirection.Back);
wizardProgress.CurrentStepTabPage.SelectDefaultControl();
UpdateWizard();
if (wizardProgress.IsLastStep)
@ -325,7 +326,11 @@ namespace XenAdmin.Wizards
private void XenWizardBase_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)Keys.Enter)
{
if (buttonNext.CanSelect)
buttonNext.Select();
buttonNext.PerformClick();
}
}
[Browsable(false)]

View File

@ -30,15 +30,11 @@
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using NUnit.Framework;
using XenAdmin;
using XenAdmin.Controls;
using XenAdmin.Wizards;
using XenAdmin.Commands;
using XenAdmin.Core;
namespace XenAdminTests.WizardTests
{
@ -53,6 +49,8 @@ namespace XenAdminTests.WizardTests
protected Button btnPrevious;
protected Button btnCancel;
private static uint WM_KEYDOWN = 0x100;
protected WizardTest(string[] pageNames, bool canFinish, bool doFinish)
{
this.pageNames = pageNames;
@ -60,6 +58,49 @@ namespace XenAdminTests.WizardTests
this.doFinish = doFinish;
}
[Test]
[Timeout(100 * 1000)]
public void RunWizardKeyboardTests()
{
RunBefore();
wizard = MW<T>(NewWizard);
MW(wizard.Show);
btnNext = TestUtils.GetButton(wizard, "buttonNext");
btnPrevious = TestUtils.GetButton(wizard, "buttonPrevious");
btnCancel = TestUtils.GetButton(wizard, "buttonCancel");
// Test that the Enter key takes us forward through the wizard
for (int i = 0; i < pageNames.Length; ++i)
{
bool lastPage = (i == pageNames.Length - 1);
// Any specific setup or testing for this page defined in derived class
TestPage(pageNames[i]);
if (!lastPage)
{
// send th eenter key to the wizard window
MW(() =>
{
Win32.PostMessage(wizard.Handle, WM_KEYDOWN, new IntPtr((int)Keys.Enter), IntPtr.Zero);
});
// wait for any progress dialog to close
while (wizard.Visible && !wizard.CanFocus)
Thread.Sleep(1000);
// check if the wizard progressed to the next page
Assert.AreEqual(pageNames[i + 1], CurrentPageName(wizard), "Enter key button didn't get from page: " + pageNames[i] + " to page: " + pageNames[i + 1]);
}
else
{
MW(btnCancel.PerformClick);
}
}
MW(() => wizard.Dispose());
}
[Test]
[Timeout(100 * 1000)]
public void RunWizardTests()