Ejemplo n.º 1
0
        public async Task CanMaintainLiveLogProperties(TestAppInstance app)
        {
            EmulateShowTimeMenu();

            app.ViewModel.LoadedMessagesLogViewer.OnKeyPressed(UI.Presenters.LogViewer.Key.BeginOfDocument);
            await app.WaitFor(() => (DialogState.FirstMessageLinkLabel.Text ?? "").EndsWith(":37:25.985"));

            app.ViewModel.LoadedMessages.OnToggleViewTail();
            await app.WaitFor(() => DialogState.LastMessageLinkLabel.Text.EndsWith(":37:45.475"));

            var log = File.ReadAllText(tempLogFileName);

            log += "<E2ETraceEvent xmlns=\"http://schemas.microsoft.com/2004/06/E2ETraceEvent\">" +
                   "  <System xmlns=\"http://schemas.microsoft.com/2004/06/windows/eventlog/system\">" +
                   "    <EventID>0</EventID>" +
                   "    <Type>3</Type>" +
                   "    <SubType Name=\"Start\">0</SubType>" +
                   "    <Level>255</Level>" +
                   "    <TimeCreated SystemTime=\"2011-07-24T10:50:01.1000000Z\" />" +
                   "    <Source Name=\"SampleApp\" />" +
                   "    <Correlation ActivityID=\"{00000000-0000-0000-0000-000000000000}\" />" +
                   "    <Execution ProcessName=\"SampleLoggingApp\" ProcessID=\"1956\" ThreadID=\"1\" />" +
                   "    <Channel/>" +
                   "    <Computer>SERGEYS-PC</Computer>" +
                   "  </System>" +
                   "  <ApplicationData>new line</ApplicationData>" +
                   "</E2ETraceEvent>";
            File.WriteAllText(tempLogFileName, log);
            await app.WaitFor(() => DialogState.LastMessageLinkLabel.Text.EndsWith(":50:01.100"));
        }
Ejemplo n.º 2
0
        public async Task CanRemoveBothLogsFromContainer(TestAppInstance app)
        {
            await ExpandContainer();

            app.ViewModel.SourcesList.OnSelectionChange(new[] {
                (IViewItem)ListRoot.Children[0].Children[0],
                (IViewItem)ListRoot.Children[0].Children[1]
            });
            await app.WaitFor(() =>
                              ListRoot.Children[0].Children[0].IsSelected &&
                              ListRoot.Children[0].Children[1].IsSelected
                              );

            Check.That(app.ViewModel.SourcesManager.DeleteSelectedSourcesButtonEnabled).IsTrue();
            Check.That(app.ViewModel.SourcesManager.PropertiesButtonEnabled).IsFalse();

            app.PresentationObjects.AlertPopup.ShowPopupAsync(null, null, UI.Presenters.AlertFlags.None).ReturnsForAnyArgs(UI.Presenters.AlertFlags.Yes);
            app.ViewModel.SourcesManager.OnDeleteSelectedLogSourcesButtonClicked();

            await app.PresentationObjects.AlertPopup.Received(1).ShowPopupAsync("Delete", "Are you sure you want to close 2 log (s)", UI.Presenters.AlertFlags.YesNoCancel);

            await app.WaitFor(() => ListRoot.Children.Count == 0);

            Check.That(app.ViewModel.SourcesManager.DeleteSelectedSourcesButtonEnabled).IsFalse();
            Check.That(app.ViewModel.SourcesManager.PropertiesButtonEnabled).IsFalse();

            await app.WaitForLogDisplayed("");
        }
Ejemplo n.º 3
0
        public async Task CanRemoveOneLogFromContainer(TestAppInstance app)
        {
            await ExpandContainer();

            app.ViewModel.SourcesList.OnSelectionChange(
                new[] { (IViewItem)ListRoot.Children[0].Children[0] });
            await app.WaitFor(() => ListRoot.Children[0].Children[0].IsSelected);

            Check.That(app.ViewModel.SourcesManager.DeleteSelectedSourcesButtonEnabled).IsTrue();
            Check.That(app.ViewModel.SourcesManager.PropertiesButtonEnabled).IsTrue();

            app.PresentationObjects.AlertPopup.ShowPopupAsync(null, null, UI.Presenters.AlertFlags.None).ReturnsForAnyArgs(UI.Presenters.AlertFlags.Yes);
            app.ViewModel.SourcesManager.OnDeleteSelectedLogSourcesButtonClicked();

            await app.PresentationObjects.AlertPopup.Received(1).ShowPopupAsync("Delete", "Are you sure you want to close 1 log (s)", UI.Presenters.AlertFlags.YesNoCancel);

            await app.WaitFor(() =>
                              ListRoot.Children.Count == 1 &&
                              ListRoot.Children[0].Children.Count == 0 &&
                              ListRoot.Children[0].IsSelected == false);

            Check.That(app.ViewModel.SourcesManager.DeleteSelectedSourcesButtonEnabled).IsFalse();
            Check.That(app.ViewModel.SourcesManager.PropertiesButtonEnabled).IsFalse();

            await app.WaitForLogDisplayed(
                @"No free data file found. Going sleep.
Searching for data files
No free data file found. Going sleep.
File cannot be open which means that it was handled
Timestamp parsed and ignored
Test frame
"
                );
        }
Ejemplo n.º 4
0
        async Task OpenDialog()
        {
            await appInstance.WaitFor(() => appInstance.ViewModel.SourcesManager.PropertiesButtonEnabled);

            dialogTask = new TaskCompletionSource <int>();
            appInstance.Mocks.Views.CreateSourcePropertiesWindowView().CreateWindow().ShowModalDialog().Returns(dialogTask.Task);
            appInstance.ViewModel.SourcesList.OnSourceProprtiesMenuItemClicked();
            await appInstance.WaitFor(() => DialogState.NameEditbox.Text != null);
        }
Ejemplo n.º 5
0
        public async Task BeforeEach(TestAppInstance app)
        {
            this.appInstance = app;

            var preprocTask = app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("XmlWriterTraceListenerAndTextWriterTraceListener.zip"));

            await app.WaitFor(() => app.ViewModel.PreprocessingUserInteractions.DialogData != null);

            app.ViewModel.PreprocessingUserInteractions.OnCloseDialog(accept: true);

            await preprocTask;

            await app.WaitFor(() => app.ViewModel.SourcesList.RootItem.Children.Count == 1);
        }
Ejemplo n.º 6
0
        public async Task CanSaveAsLogFromZipContainer(TestAppInstance app)
        {
            CloseDialog();
            app.PresentationObjects.AlertPopup.ShowPopup(null, null, UI.Presenters.AlertFlags.None).ReturnsForAnyArgs(UI.Presenters.AlertFlags.Yes);
            app.ViewModel.SourcesManager.OnDeleteAllLogSourcesButtonClicked();
            await app.EmulateFileDragAndDrop(await samples.GetSampleAsLocalFile("XmlWriterTraceListener1AndImage.zip"));

            await app.WaitFor(() => app.ViewModel.SourcesList.RootItem.Children.Count == 1);

            app.ViewModel.SourcesList.OnSelectionChange(new[] {
                (SrcListItem)app.ViewModel.SourcesList.RootItem.Children[0]
            });
            await OpenDialog();

            Check.That(DialogState.SaveAsButton.Disabled).IsFalse();
            Check.That(DialogState.SaveAsButton.Hidden).IsFalse();

            var destinationFileName = app.ModelObjects.TempFilesManager.GenerateNewName();

            app.Mocks.FileDialogs.SaveFileDialog(Arg.Any <UI.Presenters.SaveFileDialogParams>()).ReturnsForAnyArgs(destinationFileName);
            ViewModel.OnSaveAsButtonClicked();
            app.Mocks.FileDialogs.Received(1).SaveFileDialog(Arg.Any <UI.Presenters.SaveFileDialogParams>());

            var savedLog = File.ReadAllText(destinationFileName);

            var head = "<E2ETraceEvent xmlns=\"http://schemas.microsoft.com/2004/06/E2ETraceEvent\"><System xmlns=\"http://schemas.microsoft.com/2004/06/windows/eventlog/system\"><EventID>0</EventID><Type>3</Type><SubType Name=\"Start\">0</SubType><Level>255</Level><TimeCreated SystemTime=\"2011-07-24T10:37:25.9854589Z\" /><Source Name=\"SampleApp\" />";

            Check.That(head).IsEqualTo(savedLog.Substring(0, head.Length));
        }
Ejemplo n.º 7
0
        public async Task BeforeEach()
        {
            app = await TestAppInstance.Create();

            await app.SynchronizationContext.InvokeAndAwait(async() =>
            {
                var preprocTask = app.EmulateFileDragAndDrop(await samples.GetSampleAsLocalFile("XmlWriterTraceListenerAndTextWriterTraceListener.zip"));

                await app.WaitFor(() => app.ViewModel.PreprocessingUserInteractions.DialogData != null);
                app.ViewModel.PreprocessingUserInteractions.OnCloseDialog(accept: true);

                await preprocTask;

                await app.WaitFor(() => app.ViewModel.SourcesList.RootItem.Children.Count == 1);
            });
        }
Ejemplo n.º 8
0
 async Task ExpandContainer()
 {
     await app.SynchronizationContext.InvokeAndAwait(async() =>
     {
         app.ViewModel.SourcesList.OnItemExpand(
             (IViewItem)ListRoot.Children[0]);
         await app.WaitFor(() => ListRoot.Children[0].IsExpanded);
     });
 }
Ejemplo n.º 9
0
        public async Task UnzippingCanBeCancelled(TestAppInstance app)
        {
            var preprocessorTask = app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("network_trace_with_keys_1.as_pdml.zip"));
            await app.WaitFor(() => (app.ViewModel.SourcesList.RootItem.Children.ElementAtOrDefault(0)?.ToString() ?? "").Contains("Unpacking"));

            app.ViewModel.SourcesList.OnSelectAllShortcutPressed();
            app.Mocks.AlertPopup.ShowPopup(null, null, UI.Presenters.AlertFlags.None).ReturnsForAnyArgs(
                UI.Presenters.AlertFlags.Yes);
            var stopwatch = Stopwatch.StartNew();

            app.ViewModel.SourcesList.OnDeleteButtonPressed();
            await app.WaitFor(() => app.ViewModel.SourcesList.RootItem.Children.Count == 0);

            stopwatch.Stop();
            Check.That(stopwatch.ElapsedMilliseconds).IsStrictlyLessThan(1000);
            Check.That(preprocessorTask.IsCanceled).IsTrue();
        }
Ejemplo n.º 10
0
        public async Task BeforeEach(TestAppInstance app)
        {
            await app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml"));

            await app.WaitFor(() => !app.ViewModel.LoadedMessagesLogViewer.ViewLines.IsEmpty);

            // todo: emulate UI clicks for search
            var filters = app.ModelObjects.FiltersFactory.CreateFiltersList(FilterAction.Exclude, FiltersListPurpose.Search);

            filters.Insert(0, app.ModelObjects.FiltersFactory.CreateFilter(FilterAction.Include, "", true, new Search.Options {
                Template = "file"
            }));
            app.ModelObjects.SearchManager.SubmitSearch(new SearchAllOptions {
                Filters = filters
            });
            await app.WaitFor(() => !app.ViewModel.SearchResultLogViewer.ViewLines.IsEmpty && app.ModelObjects.SearchManager.Results[0].Status == SearchResultStatus.Finished);
        }
Ejemplo n.º 11
0
        public async Task BeforeEach(TestAppInstance app)
        {
            appInstance = app;
            samples     = app.Samples;

            tempLogFileName = Path.Combine(app.AppDataDirectory, "XmlWriterTraceListener1.xml");
            File.Copy(await samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml"), tempLogFileName, overwrite: true);
            await app.EmulateFileDragAndDrop(tempLogFileName);

            await app.WaitFor(() => app.ViewModel.LoadedMessagesLogViewer.ViewLines.Length > 0);

            await app.WaitFor(() => app.ViewModel.SourcesList.RootItem.Children.Count == 1);

            app.ViewModel.SourcesList.OnSelectionChange(new[] {
                (SrcListItem)app.ViewModel.SourcesList.RootItem.Children[0]
            });
            await OpenDialog();
        }
Ejemplo n.º 12
0
        public async Task CanChangeLogSourceColor(TestAppInstance app)
        {
            ViewModel.OnChangeColorLinkClicked();
            var menuColors = (Drawing.Color[])
                             app.Mocks.Views.CreateSourcePropertiesWindowView().CreateWindow().ReceivedCalls().Last().GetArguments()[0];

            Check.That(menuColors).IsNotNull();
            Check.That(menuColors.Length).IsStrictlyGreaterThan(10);
            var newColor = menuColors[7];

            ViewModel.OnColorSelected(newColor);
            await app.WaitFor(() => DialogState.ColorPanel.BackColor.Value == newColor);

            var sourcesColoringMode = app.ViewModel.LoadedMessages.ViewState.Coloring.Options.IndexOf(
                i => i.Text.ToLower().Contains("source"));

            app.ViewModel.LoadedMessages.OnColoringButtonClicked(sourcesColoringMode.Value);
            await app.WaitFor(() => app.ViewModel.LoadedMessagesLogViewer.ViewLines.ElementAtOrDefault(0).ContextColor == newColor);
        }
Ejemplo n.º 13
0
        public async Task CanQuitAppWhileHavingActivePreprocessingUserInteraction(TestAppInstance app)
        {
            var preprocTask = app.EmulateUrlDragAndDrop(app.Samples.GetSampleAsUri("XmlWriterTraceListenerAndTextWriterTraceListener.zip"));

            await app.WaitFor(() => app.ViewModel.PreprocessingUserInteractions.DialogData != null);

            Check.That(app.ViewModel.PreprocessingUserInteractions.DialogData.Items.Count).IsEqualTo(2);

            await app.Dispose();
        }
Ejemplo n.º 14
0
        public async Task CanToggleSourceVisibitity(TestAppInstance app)
        {
            Check.That(DialogState.VisibleCheckBox.Checked).IsEqualTo(true);
            ViewModel.OnVisibleCheckBoxChange(false);
            await app.WaitFor(() => DialogState.VisibleCheckBox.Checked == false);

            await app.WaitForLogDisplayed("");

            Check.That(((SrcListItem)app.ViewModel.SourcesList.RootItem.Children[0]).Checked).IsEqualTo(false);
        }
Ejemplo n.º 15
0
        public async Task CanChangeAnnotation(TestAppInstance app)
        {
            Check.That(DialogState.AnnotationTextBox.Text).IsEqualTo("");
            Check.That(DialogState.AnnotationTextBox.Disabled).IsFalse();
            Check.That(DialogState.AnnotationTextBox.Hidden).IsFalse();

            ViewModel.OnChangeAnnotation("annotation 123");
            await app.WaitFor(() => DialogState.AnnotationTextBox.Text == "annotation 123");

            CloseDialog();

            await app.WaitFor(() => app.ViewModel.SourcesList.RootItem.Children[0].ToString().Contains(
                                  "annotation 123"));

            await OpenDialog();

            Check.That(DialogState.AnnotationTextBox.Text).IsEqualTo("annotation 123");
            Check.That(DialogState.AnnotationTextBox.Disabled).IsFalse();
            Check.That(DialogState.AnnotationTextBox.Hidden).IsFalse();
        }
Ejemplo n.º 16
0
 public async Task CanOpenPasswordProtectedZipExtractAndFindKnownLogFormatInArchive(TestAppInstance app)
 {
     app.Mocks.CredentialsCache.QueryCredentials(
         Arg.Is <Uri>(v => v.ToString().Contains("XmlWriterTraceListener1AndImage.PasswordProtected.zip")), null)
     .ReturnsForAnyArgs(new System.Net.NetworkCredential("", "Pa$$w0rd"));
     await app.SynchronizationContext.InvokeAndAwait(async() =>
     {
         await app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("XmlWriterTraceListener1AndImage.PasswordProtected.zip"));
         await app.WaitFor(() => IsXmlWriterTraceListenerLogIsLoaded(app));
     });
 }
Ejemplo n.º 17
0
        public async Task OpeningTheSameLogTwiceHasNoEffect(TestAppInstance app)
        {
            await app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml"));

            await app.WaitFor(() => IsXmlWriterTraceListenerLogIsLoaded(app));

            Check.That(app.ModelObjects.LogSourcesManager.Items.Count()).IsEqualTo(1);

            await app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml"));

            Check.That(app.ModelObjects.LogSourcesManager.Items.Count()).IsEqualTo(1);
        }
Ejemplo n.º 18
0
        public async Task CanChangeTimeShift(TestAppInstance app)
        {
            EmulateShowTimeMenu();
            await app.WaitFor(() => (app.ViewModel.LoadedMessagesLogViewer.ViewLines.LastOrDefault().Time ?? "").EndsWith(":37:45.475"));

            Check.That(DialogState.TimeOffsetTextBox.Text).IsEqualTo("00:00:00");
            Check.That(DialogState.TimeOffsetTextBox.Disabled).IsFalse();
            Check.That(DialogState.TimeOffsetTextBox.Hidden).IsFalse();

            ViewModel.OnChangeChangeTimeOffset("-00:00:05");
            await app.WaitFor(() => DialogState.TimeOffsetTextBox.Text == "-00:00:05");

            CloseDialog();

            await app.WaitFor(() => app.ViewModel.LoadedMessagesLogViewer.ViewLines.Last().Time.EndsWith(":37:40.475"));

            await OpenDialog();

            Check.That(DialogState.TimeOffsetTextBox.Text).IsEqualTo("-00:00:05");
            Check.That(DialogState.AnnotationTextBox.Disabled).IsFalse();
            Check.That(DialogState.AnnotationTextBox.Hidden).IsFalse();
        }
Ejemplo n.º 19
0
 public async Task CanLoadAndDetectFormatOfLocalLog()
 {
     await app.SynchronizationContext.InvokeAndAwait(async() =>
     {
         await app.EmulateFileDragAndDrop(await samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml"));
         await app.WaitFor(IsXmlWriterTraceListenerLogIsLoaded);
     });
 }
Ejemplo n.º 20
0
 public static async Task WaitForLogDisplayed(this TestAppInstance app, string expectedLog, string operationName = null, TimeSpan?timeout = null)
 {
     try
     {
         await app.WaitFor(
             () => app.IsLogDisplayed(expectedLog),
             operationName : operationName,
             timeout : timeout
             );
     }
     catch (TimeoutException)
     {
         Console.WriteLine("Actually displayed log: '{0}'", app.GetDisplayedLog());
         throw;
     }
 }
Ejemplo n.º 21
0
        public async Task BeforeEach()
        {
            app = await TestAppInstance.Create();

            await app.SynchronizationContext.InvokeAndAwait(async() =>
            {
                tempLogFileName = Path.Combine(app.AppDataDirectory, "XmlWriterTraceListener1.xml");
                File.Copy(await samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml"), tempLogFileName, overwrite: true);
                await app.EmulateFileDragAndDrop(tempLogFileName);
                await app.WaitFor(() => app.ViewModel.SourcesList.RootItem.Children.Count == 1);
                app.ViewModel.SourcesList.OnSelectionChange(new[] {
                    (SrcListItem)app.ViewModel.SourcesList.RootItem.Children[0]
                });
                await OpenDialog();
            });
        }
Ejemplo n.º 22
0
        public async Task CanDownloadZipExtractFindManyKnownLogsAndAskUserWhatToOpen(TestAppInstance app)
        {
            var preprocTask = app.EmulateUrlDragAndDrop(app.Samples.GetSampleAsUri("XmlWriterTraceListenerAndTextWriterTraceListener.zip"));

            await app.WaitFor(() => app.ViewModel.PreprocessingUserInteractions.DialogData != null);

            var userQueryItems = app.ViewModel.PreprocessingUserInteractions.DialogData.Items;

            Check.That(userQueryItems.Count).IsEqualTo(2);
            Check.That(userQueryItems.Any(x => x.Title.Contains("Microsoft\\XmlWriterTraceListener") && x.Title.Contains("XmlWriterTraceListenerAndTextWriterTraceListener.zip\\XmlWriterTraceListener1.xml"))).IsTrue();
            Check.That(userQueryItems.Any(x => x.Title.Contains("Microsoft\\TextWriterTraceListener") && x.Title.Contains("XmlWriterTraceListenerAndTextWriterTraceListener.zip\\TextWriterTraceListener.log"))).IsTrue();
            Check.That(preprocTask.IsCompleted).IsFalse();

            app.ViewModel.PreprocessingUserInteractions.OnCloseDialog(accept: true);
            await preprocTask;
        }
Ejemplo n.º 23
0
        public async Task CanHideOneLogInContainer(TestAppInstance app)
        {
            await ExpandContainer();

            app.ViewModel.SourcesList.OnItemCheck(
                (IViewItem)ListRoot.Children[0].Children[0], false);
            await app.WaitFor(() => ((IViewItem)ListRoot.Children[0].Children[0]).Checked == false);

            await app.WaitForLogDisplayed(
                @"No free data file found. Going sleep.
Searching for data files
No free data file found. Going sleep.
File cannot be open which means that it was handled
Timestamp parsed and ignored
Test frame
"
                );

            Check.WithCustomMessage("Container must be unchecked").That(((IViewItem)ListRoot.Children[0]).Checked).IsEqualTo(false);
        }
Ejemplo n.º 24
0
        public async Task DisplaysProgressDuringUnzipping(TestAppInstance app)
        {
            var preprocessorTask = app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("network_trace_with_keys_1.as_pdml.zip"));
            int lastPercent      = 0;

            for (int iter = 0; iter < 3; ++iter)
            {
                await app.WaitFor(() =>
                {
                    var displayText = app.ViewModel.SourcesList.RootItem.Children.ElementAtOrDefault(0)?.ToString() ?? "";
                    var m           = Regex.Match(displayText, @"Unpacking (\d+)\%");
                    if (m.Success)
                    {
                        var percent = int.Parse(m.Groups[1].Value);
                        if (percent > lastPercent && percent < 100)
                        {
                            lastPercent = percent;
                            return(true);
                        }
                    }
                    return(false);
                });
            }
        }
Ejemplo n.º 25
0
 async Task ExpandContainer()
 {
     appInstance.ViewModel.SourcesList.OnItemExpand(
         (IViewItem)ListRoot.Children[0]);
     await appInstance.WaitFor(() => ListRoot.Children[0].IsExpanded);
 }
Ejemplo n.º 26
0
        public async Task CanDownloadZipExtractAndFindKnownLogFormatInArchive(TestAppInstance app)
        {
            await app.EmulateUrlDragAndDrop(app.Samples.GetSampleAsUri("XmlWriterTraceListener1AndImage.zip"));

            await app.WaitFor(() => IsXmlWriterTraceListenerLogIsLoaded(app));
        }
Ejemplo n.º 27
0
        public async Task CanDownloadAndDetectFormatOfLogFromTheWeb(TestAppInstance app)
        {
            await app.EmulateUrlDragAndDrop(app.Samples.GetSampleAsUri("XmlWriterTraceListener1.xml"));

            await app.WaitFor(() => IsXmlWriterTraceListenerLogIsLoaded(app));
        }
Ejemplo n.º 28
0
        public async Task CanLoadAndDetectFormatOfLocalLog(TestAppInstance app)
        {
            await app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml"));

            await app.WaitFor(() => IsXmlWriterTraceListenerLogIsLoaded(app));
        }
Ejemplo n.º 29
0
 Task IUtils.WaitFor(Func <bool> condition, string operationName, TimeSpan?timeout) => app.WaitFor(condition, operationName, timeout);
Ejemplo n.º 30
0
        public async Task CanExtractGZippedLog(TestAppInstance app)
        {
            await app.EmulateFileDragAndDrop(await app.Samples.GetSampleAsLocalFile("XmlWriterTraceListener1.xml.gz"));

            await app.WaitFor(() => IsXmlWriterTraceListenerLogIsLoaded(app));
        }