public void TestNpmUIInitialization() { using (var app = new VisualStudioApp()) { // Initialize call is required because NTVS does not autoload its package // We may not be on UI thread, but Dev11 and Dev12 know how to sort that out. UIThread.InitializeAndAlwaysInvokeToCurrentThread(); UIThread.Invoke(() => { NpmPackageInstallWindow npmWindow = OpenNpmWindowAndWaitForReady(); Assert.IsTrue(npmWindow.FilterTextBox.IsKeyboardFocused, "FilterTextBox should be keyboard focused"); Assert.AreEqual(0, npmWindow._packageList.SelectedIndex, "First item in package list should be selected"); }); } }
public void TestNpmUIArrowKeyBehavior() { using (var app = new VisualStudioApp()) { UIThread.InitializeAndAlwaysInvokeToCurrentThread(); UIThread.Invoke(() => { NpmPackageInstallWindow npmWindow = OpenNpmWindowAndWaitForReady(); System.Windows.Input.Keyboard.Focus(npmWindow.FilterTextBox); TestUtilities.UI.Keyboard.PressAndRelease(Key.Down); WaitForUIInputIdle(); var selectedItem = GetSelectedPackageListItemContainer(npmWindow); Assert.IsTrue(selectedItem.IsKeyboardFocused, "Focus should be on newly selected item"); Assert.AreEqual(0, npmWindow._packageList.SelectedIndex); TestUtilities.UI.Keyboard.PressAndRelease(Key.Down); WaitForUIInputIdle(); Assert.AreEqual(1, npmWindow._packageList.SelectedIndex); npmWindow.FilterTextBox.Focus(); TestUtilities.UI.Keyboard.PressAndRelease(Key.Up); WaitForUIInputIdle(); Assert.IsTrue(npmWindow.FilterTextBox.IsKeyboardFocused, "Focus should remain on filter box"); Assert.AreEqual(1, npmWindow._packageList.SelectedIndex, "Pressing up while in filter box should maintain current selection"); selectedItem = GetSelectedPackageListItemContainer(npmWindow); selectedItem.Focus(); TestUtilities.UI.Keyboard.PressAndRelease(Key.Up); TestUtilities.UI.Keyboard.PressAndRelease(Key.Up); WaitForUIInputIdle(); Assert.IsTrue(npmWindow.FilterTextBox.IsKeyboardFocused, "Focus should move to filter textbox after pressing up key while on topmost package is selected"); TestUtilities.UI.Keyboard.PressAndRelease(Key.Up); WaitForUIInputIdle(); Assert.IsTrue(npmWindow.FilterTextBox.IsKeyboardFocused, "Focus should remain on textbox while pressing up when topmost package is selected"); Assert.IsFalse(npmWindow.InstallButton.IsEnabled, "Install button should not be enabled when filter box has focus"); TestUtilities.UI.Keyboard.PressAndRelease(Key.Enter); WaitForUIInputIdle(); selectedItem = GetSelectedPackageListItemContainer(npmWindow); Assert.IsTrue(selectedItem.IsKeyboardFocused, "Focus should be on newly selected item"); Assert.AreEqual(0, npmWindow._packageList.SelectedIndex); }); } }
public void TestNpmUITabKeyBehavior() { using (var app = new VisualStudioApp()) { UIThread.InitializeAndAlwaysInvokeToCurrentThread(); UIThread.Invoke(() => { NpmPackageInstallWindow npmWindow = OpenNpmWindowAndWaitForReady(); npmWindow.FilterTextBox.Focus(); WaitForUIInputIdle(); TestUtilities.UI.Keyboard.PressAndRelease(Key.Tab); WaitForUIInputIdle(); var selectedItem = GetSelectedPackageListItemContainer(npmWindow); Assert.IsTrue(selectedItem.IsKeyboardFocused); // Install button disabled, must key down to select "installable" package TestUtilities.UI.Keyboard.PressAndRelease(Key.Down); TestUtilities.UI.Keyboard.PressAndRelease(Key.Tab); WaitForUIInputIdle(); Assert.IsTrue(npmWindow.DependencyComboBox.IsKeyboardFocused); TestUtilities.UI.Keyboard.PressAndRelease(Key.Tab); WaitForUIInputIdle(); Assert.IsTrue(npmWindow.SaveToPackageJsonCheckbox.IsKeyboardFocused); TestUtilities.UI.Keyboard.PressAndRelease(Key.Tab); WaitForUIInputIdle(); Assert.IsTrue(npmWindow.SelectedVersionComboBox.IsKeyboardFocused); TestUtilities.UI.Keyboard.PressAndRelease(Key.Tab); WaitForUIInputIdle(); Assert.IsTrue(npmWindow.ArgumentsTextBox.IsKeyboardFocused); TestUtilities.UI.Keyboard.PressAndRelease(Key.Tab); WaitForUIInputIdle(); Assert.IsTrue(npmWindow.InstallButton.IsKeyboardFocused); }); } }
/// <summary> /// Default constructor of the package. /// Inside this method you can place any initialization code that does not require /// any Visual Studio service because at this point the package object is created but /// not sited yet inside Visual Studio environment. The place to do all the other /// initialization is the Initialize method. /// </summary> public NodejsProfilingPackage() { UIThread.InitializeAndAlwaysInvokeToCurrentThread(); Instance = this; }