public async Task SelectNavigationBarItemAsync(NavigationBarDropdownKind index, string item, CancellationToken cancellationToken) { await TestServices.Workspace.WaitForAsyncOperationsAsync(FeatureAttribute.NavigationBar, cancellationToken); await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); var itemIndex = await GetNavigationBarItemIndexAsync(index, item, cancellationToken); if (itemIndex < 0) { Assert.Contains(item, await GetNavigationBarItemsAsync(index, cancellationToken)); throw ExceptionUtilities.Unreachable; } await ExpandNavigationBarAsync(index, cancellationToken); await TestServices.Input.SendAsync(VirtualKey.Home); for (var i = 0; i < itemIndex; i++) { await TestServices.Input.SendAsync(VirtualKey.Down); } await TestServices.Input.SendAsync(VirtualKey.Enter); // Navigation and/or code generation following selection is tracked under FeatureAttribute.NavigationBar await TestServices.Workspace.WaitForAsyncOperationsAsync(FeatureAttribute.NavigationBar, cancellationToken); }
public async Task <ImmutableArray <string> > GetNavigationBarItemsAsync(NavigationBarDropdownKind index, CancellationToken cancellationToken) { await TestServices.Workspace.WaitForAsyncOperationsAsync(FeatureAttribute.NavigationBar, cancellationToken); await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); var view = await GetActiveTextViewAsync(cancellationToken); var combobox = (await GetNavigationBarComboBoxesAsync(view, cancellationToken))[(int)index]; return(combobox.Items.OfType <object>().SelectAsArray(i => $"{i}")); }
public async Task <string?> GetNavigationBarSelectionAsync(NavigationBarDropdownKind index, CancellationToken cancellationToken) { await TestServices.Workspace.WaitForAsyncOperationsAsync(FeatureAttribute.NavigationBar, cancellationToken); await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); var view = await GetActiveTextViewAsync(cancellationToken); var combobox = (await GetNavigationBarComboBoxesAsync(view, cancellationToken))[(int)index]; return(combobox.SelectedItem?.ToString()); }
public async Task ExpandNavigationBarAsync(NavigationBarDropdownKind index, CancellationToken cancellationToken) { await TestServices.Workspace.WaitForAsyncOperationsAsync(FeatureAttribute.NavigationBar, cancellationToken); await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); var view = await GetActiveTextViewAsync(cancellationToken); var combobox = (await GetNavigationBarComboBoxesAsync(view, cancellationToken))[(int)index]; FocusManager.SetFocusedElement(FocusManager.GetFocusScope(combobox), combobox); combobox.IsDropDownOpen = true; }
public async Task <int> GetNavigationBarItemIndexAsync(NavigationBarDropdownKind index, string item, CancellationToken cancellationToken) { var items = await GetNavigationBarItemsAsync(index, cancellationToken); return(items.IndexOf(item)); }