@@ -18,21 +18,21 @@ public void Run()
1818// Note: This test produces *a lot* of debug output to aid when debugging failures. The only output
1919// that is necessary for the functioning of this test is the "Test passed" at the end of this method.
2020
21- Console . WriteLine ( $ "Current directory:{ Environment . CurrentDirectory } ") ;
22- Console . WriteLine ( $ "Current assembly:{ typeof ( Program ) . Assembly . Location } ") ;
21+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] Current directory:{ Environment . CurrentDirectory } ") ;
22+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] Current assembly:{ typeof ( Program ) . Assembly . Location } ") ;
2323var thisProgramDir = Path . GetDirectoryName ( typeof ( Program ) . Assembly . Location ) ;
2424
2525// Add correct runtime sub-folder to PATH to ensure native files are discovered (this is supposed to happen automatically, but somehow it doesn't...)
2626var newNativePath = Path . Combine ( thisProgramDir , "runtimes" , RuntimeInformation . RuntimeIdentifier , "native" ) ;
27- Console . WriteLine ( $ "Adding new native path:{ newNativePath } ") ;
27+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] Adding new native path:{ newNativePath } ") ;
2828Environment . SetEnvironmentVariable ( "PATH" , newNativePath + ";" + Environment . GetEnvironmentVariable ( "PATH" ) ) ;
29- Console . WriteLine ( $ "New PATH env var:{ Environment . GetEnvironmentVariable ( "PATH" ) } ") ;
29+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] New PATH env var:{ Environment . GetEnvironmentVariable ( "PATH" ) } ") ;
3030
3131var thisAppFiles = Directory . GetFiles ( thisProgramDir , "*" , SearchOption . AllDirectories ) . ToArray ( ) ;
32- Console . WriteLine ( $ "Found{ thisAppFiles . Length } files in this app:") ;
32+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] Found{ thisAppFiles . Length } files in this app:") ;
3333foreach ( var file in thisAppFiles )
3434{
35- Console . WriteLine ( $ "\t { file } ") ;
35+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] \t { file } ") ;
3636}
3737
3838var hostPage = "wwwroot/webviewtesthost.html" ;
@@ -41,7 +41,7 @@ public void Run()
4141serviceCollection . AddBlazorWebView ( ) ;
4242serviceCollection . AddSingleton < HttpClient > ( ) ;
4343
44- Console . WriteLine ( $ "Creating BlazorWindow...") ;
44+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] Creating BlazorWindow...") ;
4545BlazorWindow mainWindow = null ;
4646try
4747{
@@ -53,27 +53,27 @@ public void Run()
5353}
5454catch ( Exception ex )
5555{
56- Console . WriteLine ( $ "Exception{ ex . GetType ( ) . FullName } while creating window:{ ex . Message } ") ;
56+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] Exception{ ex . GetType ( ) . FullName } while creating window:{ ex . Message } ") ;
5757Console . WriteLine ( ex . StackTrace ) ;
5858}
5959
60- Console . WriteLine ( $ "Hooking exception handler...") ;
60+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] Hooking exception handler...") ;
6161AppDomain . CurrentDomain . UnhandledException += ( sender , error ) =>
6262{
6363Console . Write (
6464"Fatal exception" + Environment . NewLine +
6565error . ExceptionObject . ToString ( ) + Environment . NewLine ) ;
6666} ;
6767
68- Console . WriteLine ( $ "Setting up root components...") ;
68+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] Setting up root components...") ;
6969mainWindow . RootComponents . Add < Pages . TestPage > ( "root" ) ;
7070
71- Console . WriteLine ( $ "Running window...") ;
71+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] Running window...") ;
7272
7373const string NewControlDivValueMessage = "wvt:NewControlDivValue" ;
7474var isWebViewReady = false ;
7575
76- Console . WriteLine ( $ "RegisterWebMessageReceivedHandler...") ;
76+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] RegisterWebMessageReceivedHandler...") ;
7777mainWindow . PhotinoWindow . RegisterWebMessageReceivedHandler ( ( s , msg ) =>
7878{
7979if ( ! msg . StartsWith ( "__bwv:" , StringComparison . Ordinal ) )
@@ -90,29 +90,33 @@ public void Run()
9090} ) ;
9191var testPassed = false ;
9292
93+ Console . WriteLine ( $ "[{ DateTime . Now . ToLongTimeString ( ) } ] Attaching WindowCreated handler...") ;
9394mainWindow . PhotinoWindow . WindowCreated += ( s , e ) =>
9495{
96+ Console . WriteLine ( $ "[{ DateTime . Now . ToLongTimeString ( ) } ] In WindowCreated event...") ;
9597Task . Run ( async ( ) =>
9698{
99+ Console . WriteLine ( $ "[{ DateTime . Now . ToLongTimeString ( ) } ] In async test task...") ;
100+
97101try
98102{
99103// This is the actual test logic here (wait for WebView, click button, verify updates, etc.)
100104
101105// 1. Wait for WebView ready
102- Console . WriteLine ( $ "Waiting for WebView ready...") ;
106+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] Waiting for WebView ready...") ;
103107var isWebViewReadyRetriesLeft = 20 ;
104108while ( ! isWebViewReady )
105109{
106- Console . WriteLine ( $ "WebView not ready yet, waiting 1sec...") ;
110+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] WebView not ready yet, waiting 1sec...") ;
107111await Task . Delay ( 1000 ) ;
108112isWebViewReadyRetriesLeft -- ;
109113if ( isWebViewReadyRetriesLeft == 0 )
110114{
111- Console . WriteLine ( $ "WebView never became ready, failing the test...") ;
115+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] WebView never became ready, failing the test...") ;
112116return ;
113117}
114118}
115- Console . WriteLine ( $ "WebView is ready!") ;
119+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] WebView is ready!") ;
116120
117121// 2. Check TestPage starting state
118122if ( ! await WaitForControlDiv ( mainWindow . PhotinoWindow , controlValueToWaitFor : "0" ) )
@@ -130,7 +134,7 @@ public void Run()
130134}
131135
132136// 5. If we get here, it all worked!
133- Console . WriteLine ( $ "All tests passed!") ;
137+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] All tests passed!") ;
134138testPassed = true ;
135139}
136140catch ( Exception ex )
@@ -153,16 +157,16 @@ public void Run()
153157}
154158catch ( Exception ex )
155159{
156- Console . WriteLine ( $ "Exception while running window:{ ex } ") ;
160+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] Exception while running window:{ ex } ") ;
157161}
158162
159163// This line is what's required for the test to be considered as passed. The xUnit test in WebViewManagerE2ETests checks
160164// that this reports success and that decides if the test is pass/fail.
161- Console . WriteLine ( $ "Test passed?{ testPassed } ") ;
165+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] Test passed?{ testPassed } ") ;
162166}
163167
164168const int MaxWaitTimes = 30 ;
165- const int WaitTimeInMS = 250 ;
169+ const int WaitTimeInMS = 1000 ;
166170
167171public async Task < bool > WaitForControlDiv ( PhotinoWindow photinoWindow , string controlValueToWaitFor )
168172{
@@ -172,20 +176,20 @@ public async Task<bool> WaitForControlDiv(PhotinoWindow photinoWindow, string co
172176// Tell WebView to report the current controlDiv value (this is inside the loop because
173177// it's possible for this to execute before the WebView has finished processing previous
174178// C#-generated events, such as WebView button clicks).
175- Console . WriteLine ( $ "Asking WebView for current controlDiv value...") ;
179+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] Asking WebView for current controlDiv value...") ;
176180photinoWindow . SendWebMessage ( $ "wvt:GetControlDivValue") ;
177181
178182// And wait for the value to appear
179183if ( _latestControlDivValue == controlValueToWaitFor )
180184{
181- Console . WriteLine ( $ "WebView reported the expected controlDiv value of{ controlValueToWaitFor } !") ;
185+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] WebView reported the expected controlDiv value of{ controlValueToWaitFor } !") ;
182186return true ;
183187}
184- Console . WriteLine ( $ "Waiting for controlDiv to have value '{ controlValueToWaitFor } ', but it's still '{ _latestControlDivValue } ', so waiting{ WaitTimeInMS } ms.") ;
188+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] Waiting for controlDiv to have value '{ controlValueToWaitFor } ', but it's still '{ _latestControlDivValue } ', so waiting{ WaitTimeInMS } ms.") ;
185189await Task . Delay ( WaitTimeInMS ) ;
186190}
187191
188- Console . WriteLine ( $ "Waited{ MaxWaitTimes * WaitTimeInMS } ms but couldn't get controlDiv to have value '{ controlValueToWaitFor } ' (last value is '{ _latestControlDivValue } ').") ;
192+ Console . WriteLine ( $ "[ { DateTime . Now . ToLongTimeString ( ) } ] Waited{ MaxWaitTimes * WaitTimeInMS } ms but couldn't get controlDiv to have value '{ controlValueToWaitFor } ' (last value is '{ _latestControlDivValue } ').") ;
189193return false ;
190194}
191195}