Skip to content

Commit 3096114

Browse files
committed
Fix failures in regression test.
1 parent bbe5b0e commit 3096114

File tree

1 file changed

+38
-10
lines changed

1 file changed

+38
-10
lines changed

src/PerfView.Tests/EventViewerTests.cs

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,12 @@
99
using PerfView;
1010
using PerfView.TestUtilities;
1111
using PerfViewTests.Utilities;
12-
using System.Threading;
1312
using System.Windows;
1413
using Xunit;
1514
using Xunit.Abstractions;
1615

1716
namespace PerfViewTests
1817
{
19-
/// <summary>
20-
/// Regression tests for issue #927: XML escaping for EventName when saving to XML
21-
///
22-
/// Tests that use the actual EventViewer UI and SaveDataToXmlFile implementation
23-
/// to ensure proper XML escaping of EventName and other fields.
24-
/// </summary>
2518
public class EventViewerTests : PerfViewTestBase
2619
{
2720
public EventViewerTests(ITestOutputHelper testOutputHelper)
@@ -160,9 +153,13 @@ public XmlEscapeTestFile(XmlEscapeTestEventSource eventSource)
160153

161154
protected override Action<Action> OpenImpl(Window parentWindow, StatusBar worker)
162155
{
163-
m_Children = new List<PerfViewTreeItem>();
164-
m_Children.Add(new TestPerfViewEventSource(this));
165-
return null;
156+
return doAfter =>
157+
{
158+
TestPerfViewEventSource eventSource = new TestPerfViewEventSource(this);
159+
eventSource.Open(parentWindow, worker, doAfter);
160+
m_Children = new List<PerfViewTreeItem>();
161+
m_Children.Add(eventSource);
162+
};
166163
}
167164

168165
protected internal override EventSource OpenEventSourceImpl(TextWriter log)
@@ -187,6 +184,37 @@ public override EventSource GetEventSource()
187184
{
188185
return _dataFile.EventSource;
189186
}
187+
188+
public override void Open(Window parentWindow, StatusBar worker, Action doAfter)
189+
{
190+
if (Viewer == null)
191+
{
192+
worker.StartWork("Opening " + Name, delegate ()
193+
{
194+
if (m_eventSource == null)
195+
{
196+
m_eventSource = DataFile.OpenEventSourceImpl(worker.LogWriter);
197+
}
198+
199+
worker.EndWork(delegate ()
200+
{
201+
if (m_eventSource == null)
202+
{
203+
throw new ApplicationException("Not a file type that supports the EventView.");
204+
}
205+
206+
Viewer = new EventWindow(parentWindow, this);
207+
Viewer.Show();
208+
doAfter?.Invoke();
209+
});
210+
});
211+
}
212+
else
213+
{
214+
Viewer.Focus();
215+
doAfter?.Invoke();
216+
}
217+
}
190218
}
191219

192220
/// <summary>

0 commit comments

Comments
 (0)