Loading WindowsDevicePortalWrapper/MockDataGenerator/Program.cs +3 −0 Original line number Diff line number Diff line Loading @@ -40,8 +40,11 @@ namespace MockDataGenerator new Endpoint(HttpMethods.Get, DevicePortal.IpConfigApi), new Endpoint(HttpMethods.Get, DevicePortal.SystemPerfApi), new Endpoint(HttpMethods.Get, DevicePortal.RunningProcessApi), new Endpoint(HttpMethods.Get, DevicePortal.CustomEtwProvidersApi), new Endpoint(HttpMethods.Get, DevicePortal.EtwProvidersApi), new Endpoint(HttpMethods.WebSocket, DevicePortal.SystemPerfApi), new Endpoint(HttpMethods.WebSocket, DevicePortal.RunningProcessApi), new Endpoint(HttpMethods.WebSocket, DevicePortal.RealtimeEtwSessionApi), // HoloLens specific endpoints new Endpoint(HttpMethods.Get, DevicePortal.HolographicIpdApi), Loading WindowsDevicePortalWrapper/UnitTestProject/Core/EtwTests.cs 0 → 100644 +108 −0 Original line number Diff line number Diff line //---------------------------------------------------------------------------------------------- // <copyright file="EtwTests.cs" company="Microsoft Corporation"> // Licensed under the MIT License. See LICENSE.TXT in the project root license information. // </copyright> //---------------------------------------------------------------------------------------------- using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using static Microsoft.Tools.WindowsDevicePortal.DevicePortal; namespace Microsoft.Tools.WindowsDevicePortal.Tests.Core { /// <summary> /// Test class for ETW APIs. /// </summary> [TestClass] public class EtwTests : BaseTests { /// <summary> /// Basic test of GET method for getting a list of custom registered ETW providers. /// </summary> [TestMethod] public void GetCustomEtwProvidersTest() { TestHelpers.MockHttpResponder.AddMockResponse(DevicePortal.CustomEtwProvidersApi, HttpMethods.Get); Task<EtwProviders> getCustomEtwProvidersTask = TestHelpers.Portal.GetCustomEtwProvidersAsync(); getCustomEtwProvidersTask.Wait(); Assert.AreEqual(TaskStatus.RanToCompletion, getCustomEtwProvidersTask.Status); ValidateEtwProviders(getCustomEtwProvidersTask.Result); } /// <summary> /// Basic test of GET method for getting a list of registered ETW providers. /// </summary> [TestMethod] public void GetEtwProvidersTest() { TestHelpers.MockHttpResponder.AddMockResponse(DevicePortal.EtwProvidersApi, HttpMethods.Get); Task<EtwProviders> getEtwProvidersTask = TestHelpers.Portal.GetEtwProvidersAsync(); getEtwProvidersTask.Wait(); Assert.AreEqual(TaskStatus.RanToCompletion, getEtwProvidersTask.Status); ValidateEtwProviders(getEtwProvidersTask.Result); } [TestMethod] public void GetEtwEventsTest() { TestHelpers.MockHttpResponder.AddMockResponse(DevicePortal.RealtimeEtwSessionApi, HttpMethods.WebSocket); ManualResetEvent etwEventsReceived = new ManualResetEvent(false); EtwEvents etwEvents = null; WindowsDevicePortal.WebSocketMessageReceivedEventHandler<EtwEvents> etwEventsReceivedHandler = delegate (DevicePortal sender, WebSocketMessageReceivedEventArgs<EtwEvents> args) { if (args.Message != null) { etwEvents = args.Message; etwEventsReceived.Set(); } }; TestHelpers.Portal.RealtimeEventsMessageReceived += etwEventsReceivedHandler; Task startListeningForEtwEventsTask = TestHelpers.Portal.StartListeningForEtwEventsAsync(); startListeningForEtwEventsTask.Wait(); Assert.AreEqual(TaskStatus.RanToCompletion, startListeningForEtwEventsTask.Status); etwEventsReceived.WaitOne(); Task stopListeningForEtwEventsTask = TestHelpers.Portal.StopListeningForEtwEventsAsync(); stopListeningForEtwEventsTask.Wait(); Assert.AreEqual(TaskStatus.RanToCompletion, stopListeningForEtwEventsTask.Status); TestHelpers.Portal.RealtimeEventsMessageReceived -= etwEventsReceivedHandler; ValidateEtwEvents(etwEvents); } /// <summary> /// Validate the <see cref="EtwEvents"/> returned from the tests. /// </summary> /// <param name="etwEvents">The <see cref="EtwEvents"/> to validate.</param> private static void ValidateEtwEvents(EtwEvents etwEvents) { Assert.IsNotNull(etwEvents); } /// <summary> /// Validate the <see cref="EtwProviders"/> returned from the tests. /// </summary> /// <param name="etw">The <see cref="EtwProviders"/> to validate.</param> private static void ValidateEtwProviders(EtwProviders etw) { EtwProviderInfo providerInfo = etw?.Providers?.FirstOrDefault(); Assert.IsNotNull(providerInfo); } } } WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/WebSocket_api_etw_session_realtime_Default.dat 0 → 100644 +1 −0 Original line number Diff line number Diff line { } No newline at end of file WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/api_etw_customproviders_Default.dat 0 → 100644 +1 −0 Original line number Diff line number Diff line { "Providers": [ { "GUID": "ProviderGUID", "Name": "ProviderName" } ] } No newline at end of file WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/api_etw_providers_Default.dat 0 → 100644 +1 −0 Original line number Diff line number Diff line { "Providers": [ { "GUID": "ProviderGUID", "Name": "ProviderName" } ] } No newline at end of file Loading
WindowsDevicePortalWrapper/MockDataGenerator/Program.cs +3 −0 Original line number Diff line number Diff line Loading @@ -40,8 +40,11 @@ namespace MockDataGenerator new Endpoint(HttpMethods.Get, DevicePortal.IpConfigApi), new Endpoint(HttpMethods.Get, DevicePortal.SystemPerfApi), new Endpoint(HttpMethods.Get, DevicePortal.RunningProcessApi), new Endpoint(HttpMethods.Get, DevicePortal.CustomEtwProvidersApi), new Endpoint(HttpMethods.Get, DevicePortal.EtwProvidersApi), new Endpoint(HttpMethods.WebSocket, DevicePortal.SystemPerfApi), new Endpoint(HttpMethods.WebSocket, DevicePortal.RunningProcessApi), new Endpoint(HttpMethods.WebSocket, DevicePortal.RealtimeEtwSessionApi), // HoloLens specific endpoints new Endpoint(HttpMethods.Get, DevicePortal.HolographicIpdApi), Loading
WindowsDevicePortalWrapper/UnitTestProject/Core/EtwTests.cs 0 → 100644 +108 −0 Original line number Diff line number Diff line //---------------------------------------------------------------------------------------------- // <copyright file="EtwTests.cs" company="Microsoft Corporation"> // Licensed under the MIT License. See LICENSE.TXT in the project root license information. // </copyright> //---------------------------------------------------------------------------------------------- using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.VisualStudio.TestTools.UnitTesting; using static Microsoft.Tools.WindowsDevicePortal.DevicePortal; namespace Microsoft.Tools.WindowsDevicePortal.Tests.Core { /// <summary> /// Test class for ETW APIs. /// </summary> [TestClass] public class EtwTests : BaseTests { /// <summary> /// Basic test of GET method for getting a list of custom registered ETW providers. /// </summary> [TestMethod] public void GetCustomEtwProvidersTest() { TestHelpers.MockHttpResponder.AddMockResponse(DevicePortal.CustomEtwProvidersApi, HttpMethods.Get); Task<EtwProviders> getCustomEtwProvidersTask = TestHelpers.Portal.GetCustomEtwProvidersAsync(); getCustomEtwProvidersTask.Wait(); Assert.AreEqual(TaskStatus.RanToCompletion, getCustomEtwProvidersTask.Status); ValidateEtwProviders(getCustomEtwProvidersTask.Result); } /// <summary> /// Basic test of GET method for getting a list of registered ETW providers. /// </summary> [TestMethod] public void GetEtwProvidersTest() { TestHelpers.MockHttpResponder.AddMockResponse(DevicePortal.EtwProvidersApi, HttpMethods.Get); Task<EtwProviders> getEtwProvidersTask = TestHelpers.Portal.GetEtwProvidersAsync(); getEtwProvidersTask.Wait(); Assert.AreEqual(TaskStatus.RanToCompletion, getEtwProvidersTask.Status); ValidateEtwProviders(getEtwProvidersTask.Result); } [TestMethod] public void GetEtwEventsTest() { TestHelpers.MockHttpResponder.AddMockResponse(DevicePortal.RealtimeEtwSessionApi, HttpMethods.WebSocket); ManualResetEvent etwEventsReceived = new ManualResetEvent(false); EtwEvents etwEvents = null; WindowsDevicePortal.WebSocketMessageReceivedEventHandler<EtwEvents> etwEventsReceivedHandler = delegate (DevicePortal sender, WebSocketMessageReceivedEventArgs<EtwEvents> args) { if (args.Message != null) { etwEvents = args.Message; etwEventsReceived.Set(); } }; TestHelpers.Portal.RealtimeEventsMessageReceived += etwEventsReceivedHandler; Task startListeningForEtwEventsTask = TestHelpers.Portal.StartListeningForEtwEventsAsync(); startListeningForEtwEventsTask.Wait(); Assert.AreEqual(TaskStatus.RanToCompletion, startListeningForEtwEventsTask.Status); etwEventsReceived.WaitOne(); Task stopListeningForEtwEventsTask = TestHelpers.Portal.StopListeningForEtwEventsAsync(); stopListeningForEtwEventsTask.Wait(); Assert.AreEqual(TaskStatus.RanToCompletion, stopListeningForEtwEventsTask.Status); TestHelpers.Portal.RealtimeEventsMessageReceived -= etwEventsReceivedHandler; ValidateEtwEvents(etwEvents); } /// <summary> /// Validate the <see cref="EtwEvents"/> returned from the tests. /// </summary> /// <param name="etwEvents">The <see cref="EtwEvents"/> to validate.</param> private static void ValidateEtwEvents(EtwEvents etwEvents) { Assert.IsNotNull(etwEvents); } /// <summary> /// Validate the <see cref="EtwProviders"/> returned from the tests. /// </summary> /// <param name="etw">The <see cref="EtwProviders"/> to validate.</param> private static void ValidateEtwProviders(EtwProviders etw) { EtwProviderInfo providerInfo = etw?.Providers?.FirstOrDefault(); Assert.IsNotNull(providerInfo); } } }
WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/WebSocket_api_etw_session_realtime_Default.dat 0 → 100644 +1 −0 Original line number Diff line number Diff line { } No newline at end of file
WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/api_etw_customproviders_Default.dat 0 → 100644 +1 −0 Original line number Diff line number Diff line { "Providers": [ { "GUID": "ProviderGUID", "Name": "ProviderName" } ] } No newline at end of file
WindowsDevicePortalWrapper/UnitTestProject/MockData/Defaults/api_etw_providers_Default.dat 0 → 100644 +1 −0 Original line number Diff line number Diff line { "Providers": [ { "GUID": "ProviderGUID", "Name": "ProviderName" } ] } No newline at end of file