Skip to content

Commit caf0d7f

Browse files
Add more diagnostics output on Service Connection Closed
1 parent da0abbf commit caf0d7f

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

UITests/UITests.App/App.AppService.xaml.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,15 @@ private async void OnAppServiceRequestReceived(AppServiceConnection sender, AppS
118118

119119
private void OnAppServicesCanceled(IBackgroundTaskInstance sender, BackgroundTaskCancellationReason reason)
120120
{
121+
Log.Error("Background Task Instance Canceled. Reason: {0}", reason.ToString());
122+
121123
_appServiceDeferral.Complete();
122124
}
123125

124126
private void AppServiceConnection_ServiceClosed(AppServiceConnection sender, AppServiceClosedEventArgs args)
125127
{
128+
Log.Error("AppServiceConnection Service Closed. AppServicesClosedStatus: {0}", args.Status.ToString();
129+
126130
_appServiceDeferral.Complete();
127131
}
128132

UITests/UITests.App/TestInterop.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using System;
5+
using System.Diagnostics;
66
using Windows.UI.Xaml;
77

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

40+
var message = string.Format(format, args);
41+
42+
Debug.WriteLine(message);
43+
4044
// Send back to Test Harness via AppService
4145
// TODO: Make this a cleaner connection/pattern
42-
((App)Application.Current).SendLogMessage(level, string.Format(format, args));
46+
_ = ((App)Application.Current).SendLogMessage(level, message);
4347
}
4448
}
4549
}

UITests/UITests.Tests.Shared/TestAssembly.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ private static async Task InitalizeComService()
4444
CommunicationService = new AppServiceConnection();
4545

4646
CommunicationService.RequestReceived += CommunicationService_RequestReceived;
47+
CommunicationService.ServiceClosed += CommunicationService_ServiceClosed;
4748

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

67+
private static void CommunicationService_ServiceClosed(AppServiceConnection sender, AppServiceClosedEventArgs args)
68+
{
69+
Log.Warning("[Harness] Communication Service Closed! AppServiceClosedStatus: {0}", args.Status.ToString());
70+
}
71+
6672
internal static Task<bool> OpenPage(string pageName)
6773
{
6874
Log.Comment("[Harness] Sending Host Page Request: {0}", pageName);

0 commit comments

Comments
 (0)