Commit 42da6dc3 authored by David Kline's avatar David Kline Committed by GitHub
Browse files

Merge pull request #128 from davidkline-ms/master

add additional HoloLens tests
parents 183c6a1c 6b6da796
Loading
Loading
Loading
Loading
+37 −1
Original line number Diff line number Diff line
@@ -15,12 +15,48 @@ namespace Microsoft.Tools.WindowsDevicePortal.Tests
    /// </summary>
    public static class HoloLensHelpers
    {
        /// <summary>
        /// Validate the <see cref="SystemPerformanceInformation" /> returned from the HoloLens tests.
        /// </summary>
        /// <param name="systemPerfInfo">The <see cref="SystemPerformanceInformation" /> to validate.</param>
        internal static void ValidateSystemPerf(SystemPerformanceInformation systemPerfInfo)
        {
            // Check some known things about this response.
            Assert.AreEqual(275897, systemPerfInfo.AvailablePages);
            Assert.AreEqual(764290, systemPerfInfo.CommitLimit);
            Assert.AreEqual(225486, systemPerfInfo.CommittedPages);
            Assert.AreEqual(20, systemPerfInfo.CpuLoad);
            Assert.AreEqual(4337544, systemPerfInfo.IoOtherSpeed);
            Assert.AreEqual(1717438, systemPerfInfo.IoReadSpeed);
            Assert.AreEqual(788621, systemPerfInfo.IoWriteSpeed);
            Assert.AreEqual(15470, systemPerfInfo.NonPagedPoolPages);
            Assert.AreEqual(4096, systemPerfInfo.PageSize);
            Assert.AreEqual(18894, systemPerfInfo.PagedPoolPages);
            Assert.AreEqual(2097152, systemPerfInfo.TotalInstalledKb);
            Assert.AreEqual(502146, systemPerfInfo.TotalPages);

            Assert.AreEqual(systemPerfInfo.GpuData.Adapters.Count, 1);
            GpuAdapter gpuAdapter = systemPerfInfo.GpuData.Adapters[0];
            Assert.AreEqual((uint)119537664, gpuAdapter.DedicatedMemory);
            Assert.AreEqual((uint)65536, gpuAdapter.DedicatedMemoryUsed);
            Assert.AreEqual("HoloLens Graphics", gpuAdapter.Description);
            Assert.AreEqual((uint)1028395008, gpuAdapter.SystemMemory);
            Assert.AreEqual((uint)48513024, gpuAdapter.SystemMemoryUsed);

            Assert.AreEqual(9, gpuAdapter.EnginesUtilization.Count);
            Assert.AreEqual("7.098184", gpuAdapter.EnginesUtilization[0].ToString("n6"));

            NetworkPerformanceData networkPerformanceData = systemPerfInfo.NetworkData;
            Assert.AreEqual(0, networkPerformanceData.BytesIn);
            Assert.AreEqual(0, networkPerformanceData.BytesOut);
        }
        
        /// <summary>
        /// Helper method for verifying OS info based on a given version.
        /// </summary>
        /// <param name="friendlyOperatingSystemVersion">The friendly version of the OS we are targeting.</param>
        /// <param name="operatingSystemVersion">The version of the OS we are targeting.</param>
        public static void VerifyOsInformation(
        internal static void VerifyOsInformation(
            string friendlyOperatingSystemVersion, 
            string operatingSystemVersion)
        {
+40 −13
Original line number Diff line number Diff line
@@ -4,15 +4,11 @@
// </copyright>
//----------------------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using static Microsoft.Tools.WindowsDevicePortal.DevicePortal;
using System;

namespace Microsoft.Tools.WindowsDevicePortal.Tests
{
@@ -102,6 +98,38 @@ namespace Microsoft.Tools.WindowsDevicePortal.Tests
            Assert.AreEqual("MyHoloLens", getTask.Result);
        }

        /// <summary>
        /// Gets the IP configuration using a mock generated on a HoloLens.
        /// </summary>
        [TestMethod]
        public void GetIpConfig_HoloLens_1607()
        {
            TestHelpers.MockHttpResponder.AddMockResponse(
                DevicePortal.IpConfigApi, 
                this.PlatformType, 
                this.FriendlyOperatingSystemVersion, 
                HttpMethods.Get);

            Task<IpConfiguration> getTask  = TestHelpers.Portal.GetIpConfig();
            getTask.Wait();;

            Assert.AreEqual(TaskStatus.RanToCompletion, getTask.Status);

            IpConfiguration ipconfig = getTask.Result;

            // Check some known things about this response.
            Assert.AreEqual(2, ipconfig.Adapters.Count);
            NetworkAdapterInfo adapter = ipconfig.Adapters[0];
            Assert.AreEqual("Bluetooth Device (Personal Area Network)", adapter.Description);
            Assert.AreEqual("4c-0b-be-ff-bd-64", adapter.MacAddress);
            Assert.AreEqual(7, adapter.Index);
            Assert.AreEqual(Guid.Parse("{765C05C8-7B46-4CE6-BEC9-33C6112234B4}"), adapter.Id);
            Assert.AreEqual("Ethernet", adapter.AdapterType);
            IpAddressInfo ipAddress = adapter.IpAddresses[0];
            Assert.AreEqual("0.0.0.0", ipAddress.Address);
            Assert.AreEqual("0.0.0.0", ipAddress.SubnetMask);
        }

        /// <summary>
        /// Gets the user's interpupilary distance using a mock generated on a HoloLens.
        /// </summary>
@@ -194,24 +222,23 @@ namespace Microsoft.Tools.WindowsDevicePortal.Tests
        }

        /// <summary>
        /// Gets the thermal stage using a mock generated on a HoloLens.
        /// Gets the system performance using a mock generated on a HoloLens.
        /// </summary>
        [TestMethod]
        public void GetThermalStage_HoloLens_1607()
        public void GetSystemPerf_HoloLens_1607()
        {
            TestHelpers.MockHttpResponder.AddMockResponse(
                DevicePortal.ThermalStageApi, 
                DevicePortal.SystemPerfApi, 
                this.PlatformType, 
                this.FriendlyOperatingSystemVersion, 
                HttpMethods.Get);

            Task<ThermalStages> getTask  = TestHelpers.Portal.GetThermalStage();
            getTask.Wait();
            Task<SystemPerformanceInformation> getSystemPerfTask = TestHelpers.Portal.GetSystemPerf();
            getSystemPerfTask.Wait();

            Assert.AreEqual(TaskStatus.RanToCompletion, getTask.Status);
            Assert.AreEqual(TaskStatus.RanToCompletion, getSystemPerfTask.Status);

            // Check some known things about this response.
            Assert.AreEqual(ThermalStages.Normal, getTask.Result);
            HoloLensHelpers.ValidateSystemPerf(getSystemPerfTask.Result);
        }

        /// <summary>
+1 −1
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ namespace Microsoft.Tools.WindowsDevicePortal
        /// </summary>
        /// <returns>True if WiFi based communication requires a secure connection, false otherwise.</returns>
        /// <remarks>This method is only supported on HoloLens devices.</remarks>
        private async Task<bool> GetIsHttpsRequired()
        public async Task<bool> GetIsHttpsRequired()
        {
            if (this.Platform != DevicePortalPlatforms.HoloLens)
            {