Skip to content

Commit

Permalink
Add more diagnostics output on Service Connection Closed
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-hawker committed Jul 9, 2021
1 parent da0abbf commit caf0d7f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions UITests/UITests.App/App.AppService.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,15 @@ private async void OnAppServiceRequestReceived(AppServiceConnection sender, AppS

private void OnAppServicesCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
{
Log.Error("Background Task Instance Canceled. Reason: {0}", reason.ToString());

_appServiceDeferral.Complete();
}

private void AppServiceConnection_ServiceClosed(AppServiceConnection sender, AppServiceClosedEventArgs args)
{
Log.Error("AppServiceConnection Service Closed. AppServicesClosedStatus: {0}", args.Status.ToString();

_appServiceDeferral.Complete();
}

Expand Down
8 changes: 6 additions & 2 deletions UITests/UITests.App/TestInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Diagnostics;
using Windows.UI.Xaml;

namespace UITests.App.Pages
Expand Down Expand Up @@ -37,9 +37,13 @@ private static void LogMessage(string level, string format, object[] args)
format = format.Replace("{", "{{").Replace("}", "}}");
}

var message = string.Format(format, args);

Debug.WriteLine(message);

// Send back to Test Harness via AppService
// TODO: Make this a cleaner connection/pattern
((App)Application.Current).SendLogMessage(level, string.Format(format, args));
_ = ((App)Application.Current).SendLogMessage(level, message);
}
}
}
6 changes: 6 additions & 0 deletions UITests/UITests.Tests.Shared/TestAssembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ private static async Task InitalizeComService()
CommunicationService = new AppServiceConnection();

CommunicationService.RequestReceived += CommunicationService_RequestReceived;
CommunicationService.ServiceClosed += CommunicationService_ServiceClosed;

// Here, we use the app service name defined in the app service
// provider's Package.appxmanifest file in the <Extension> section.
Expand All @@ -63,6 +64,11 @@ private static async Task InitalizeComService()
}
}

private static void CommunicationService_ServiceClosed(AppServiceConnection sender, AppServiceClosedEventArgs args)
{
Log.Warning("[Harness] Communication Service Closed! AppServiceClosedStatus: {0}", args.Status.ToString());
}

internal static Task<bool> OpenPage(string pageName)
{
Log.Comment("[Harness] Sending Host Page Request: {0}", pageName);
Expand Down

0 comments on commit caf0d7f

Please sign in to comment.