コード例 #1
0
        private Task TestIncludeItemAsync(KnownDataGrid grid)
        {
            Func <Task <StackWindow> > setupAsync = async() =>
            {
                await JoinableTaskFactory.SwitchToMainThreadAsync();

                var file = new TimeRangeFile();
                await OpenAsync(JoinableTaskFactory, file, GuiApp.MainWindow, GuiApp.MainWindow.StatusBar).ConfigureAwait(true);

                var stackSource = file.GetStackSource();
                return(stackSource.Viewer);
            };

            Func <StackWindow, Task> cleanupAsync = async stackWindow =>
            {
                await JoinableTaskFactory.SwitchToMainThreadAsync();

                stackWindow.Close();
            };

            Func <StackWindow, Task> testDriverAsync = async stackWindow =>
            {
                await JoinableTaskFactory.SwitchToMainThreadAsync();

                PerfDataGrid dataGrid = await SelectTabAsync(stackWindow, grid, CancellationToken.None).ConfigureAwait(true);

                object selectedItem     = dataGrid.Grid.Items[0];
                var    callTreeNodeBase = selectedItem as CallTreeNodeBase;
                if (callTreeNodeBase == null)
                {
                    callTreeNodeBase = (selectedItem as CallTreeViewNode)?.Data;
                }

                Assert.NotNull(callTreeNodeBase);

                // Keep a copy of the DisplayName since setting focus can clear this information from nodes
                string selectedItemName = callTreeNodeBase.DisplayName;

                var dataGridCell = (DataGridCell)dataGrid.DisplayNameColumn.GetCellContent(selectedItem).Parent;
                dataGridCell.RaiseEvent(new MouseButtonEventArgs(Mouse.PrimaryDevice, Environment.TickCount, MouseButton.Left)
                {
                    RoutedEvent = UIElement.MouseLeftButtonDownEvent
                });
                dataGridCell.RaiseEvent(new MouseButtonEventArgs(Mouse.PrimaryDevice, Environment.TickCount, MouseButton.Left)
                {
                    RoutedEvent = UIElement.MouseLeftButtonUpEvent
                });

                await WaitForUIAsync(stackWindow.Dispatcher, CancellationToken.None);

                StackWindow.IncludeItemCommand.Execute(null, dataGridCell);

                // Wait for any background processing to complete
                await stackWindow.StatusBar.WaitForWorkCompleteAsync().ConfigureAwait(true);

                Assert.Equal("^" + Regex.Escape(selectedItemName), stackWindow.IncludeRegExTextBox.Text);
            };

            return(RunUITestAsync(setupAsync, testDriverAsync, cleanupAsync));
        }
コード例 #2
0
        private Task TestSetTimeRangeInStartTextBoxImplAsync(string initialStartText, string initialEndText, string finalStartText, string finalEndText, string statusText, CultureInfo culture)
        {
            TimeRangeFile file = null;

            Func <Task <StackWindow> > setupAsync = async() =>
            {
                await JoinableTaskFactory.SwitchToMainThreadAsync();

                file = new TimeRangeFile();
                await OpenAsync(JoinableTaskFactory, file, GuiApp.MainWindow, GuiApp.MainWindow.StatusBar).ConfigureAwait(true);

                var stackSource = file.GetStackSource();
                return(stackSource.Viewer);
            };

            Func <StackWindow, Task> cleanupAsync = async stackWindow =>
            {
                await JoinableTaskFactory.SwitchToMainThreadAsync();

                stackWindow.Close();
            };

            Func <StackWindow, Task> testDriverAsync = async stackWindow =>
            {
                await JoinableTaskFactory.SwitchToMainThreadAsync();

                if (initialEndText != null)
                {
                    stackWindow.EndTextBox.Text = initialEndText;
                }

                stackWindow.StartTextBox.Text = initialStartText;

                Keyboard.PrimaryDevice.Focus(stackWindow.StartTextBox);
                InputManager.Current.ProcessInput(
                    new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.Return)
                {
                    RoutedEvent = Keyboard.KeyDownEvent,
                });

                // Wait for any background processing to complete
                await stackWindow.StatusBar.WaitForWorkCompleteAsync().ConfigureAwait(true);

                Assert.Equal(finalStartText, stackWindow.StartTextBox.Text);
                Assert.Equal(finalEndText ?? file.StackSource.Samples[file.StackSource.Samples.Count - 1].TimeRelativeMSec.ToString("n3", culture), stackWindow.EndTextBox.Text);

                if (statusText != null)
                {
                    Assert.Equal(statusText, stackWindow.StatusBar.Status);
                }
            };

            return(RunUITestAsync(setupAsync, testDriverAsync, cleanupAsync));
        }
コード例 #3
0
        private Task TestSetTimeRangeWithSpaceImplAsync(CultureInfo culture)
        {
            Func <Task <StackWindow> > setupAsync = async() =>
            {
                await JoinableTaskFactory.SwitchToMainThreadAsync();

                var file = new TimeRangeFile();
                await OpenAsync(JoinableTaskFactory, file, GuiApp.MainWindow, GuiApp.MainWindow.StatusBar).ConfigureAwait(true);

                var stackSource = file.GetStackSource();
                return(stackSource.Viewer);
            };

            Func <StackWindow, Task> cleanupAsync = async stackWindow =>
            {
                await JoinableTaskFactory.SwitchToMainThreadAsync();

                stackWindow.Close();
            };

            Func <StackWindow, Task> testDriverAsync = async stackWindow =>
            {
                await JoinableTaskFactory.SwitchToMainThreadAsync();

                var byNameView            = stackWindow.m_byNameView;
                var row                   = byNameView.FindIndex(node => node.FirstTimeRelativeMSec > 0 && node.FirstTimeRelativeMSec < node.LastTimeRelativeMSec);
                CallTreeNodeBase selected = byNameView[row];

                var selectedCells = stackWindow.ByNameDataGrid.Grid.SelectedCells;
                selectedCells.Clear();
                selectedCells.Add(new DataGridCellInfo(byNameView[row], stackWindow.ByNameDataGrid.FirstTimeColumn));
                selectedCells.Add(new DataGridCellInfo(byNameView[row], stackWindow.ByNameDataGrid.LastTimeColumn));

                StackWindow.SetTimeRangeCommand.Execute(null, stackWindow.ByNameDataGrid);

                // Wait for any background processing to complete
                await stackWindow.StatusBar.WaitForWorkCompleteAsync().ConfigureAwait(true);

                Assert.Equal(selected.FirstTimeRelativeMSec.ToString("n3", culture), stackWindow.StartTextBox.Text);
                Assert.Equal(selected.LastTimeRelativeMSec.ToString("n3", culture), stackWindow.EndTextBox.Text);
            };

            return(RunUITestAsync(setupAsync, testDriverAsync, cleanupAsync));
        }