Skip to content
This repository has been archived by the owner on May 6, 2022. It is now read-only.

Commit

Permalink
Making the tests run asynchronously giving an update at each stage.
Browse files Browse the repository at this point in the history
This frees up the UI thread from the test framework allowing for tests to
scroll through as they are passing or failling making the application much
more responsive.
  • Loading branch information
Gilles Khouzam committed Nov 22, 2014
1 parent 0f79514 commit 21d2dc2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
25 changes: 21 additions & 4 deletions ms/vstemplates/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.Foundation.Collections;
#if WINDOWS_APP
Expand All @@ -14,6 +15,7 @@
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using Windows.UI;
using Windows.UI.Core;
#else
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
Expand Down Expand Up @@ -70,16 +72,31 @@ public MainPage()
}
private void updateRun(object sender, string testrun, int errorcode, double time)
{
if (errorcode != 0) anyError++;
Tests.Items.Add(new TestRun(testrun,errorcode,time));
#if WINDOWS_APP
Tests.Dispatcher.RunAsync( CoreDispatcherPriority.Normal, () =>
#else
Tests.Dispatcher.BeginInvoke(() =>
#endif
{
if (errorcode != 0) anyError++;
var item = new TestRun( testrun, errorcode, time );
Tests.Items.Add( item );
Tests.ScrollIntoView( item );
} );
}

private void Button_Click(object sender, RoutedEventArgs e)
private async void Button_Click(object sender, RoutedEventArgs e)
{
Tests.Items.Clear();
anyError = 0;
Title.Text = "Running ... ";
int errorlevel= testRunner.test();
RunTests.IsEnabled = false;
int errorlevel = 0;
await Task.Run( () =>
{
errorlevel = testRunner.test();
} );
RunTests.IsEnabled = true;
if (anyError != 0 || errorlevel !=0 )
Title.Text = "Errors ocurred...";
else
Expand Down
2 changes: 1 addition & 1 deletion ms/vstemplates/OpenSSLTestAppPhone8.0/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<StackPanel x:Name="MainPanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="OpenSSL Test App" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
<TextBlock x:Name="Title" Text="" Margin="9,-7,0,0" FontSize="35"/>
<Button Click="Button_Click" >Run Tests</Button>
<Button x:Name="RunTests" Click="Button_Click" >Run Tests</Button>
</StackPanel>

<!--ContentPanel - place additional content here-->
Expand Down
2 changes: 1 addition & 1 deletion ms/vstemplates/OpenSSLTestAppPhone8.1/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<StackPanel x:Name="MainPanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="OpenSSL Test App" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
<TextBlock x:Name="Title" Text="" Margin="9,-7,0,0" FontSize="35"/>
<Button Click="Button_Click" >Run Tests</Button>
<Button x:Name="RunTests" Click="Button_Click" >Run Tests</Button>
</StackPanel>

<!--ContentPanel - place additional content here-->
Expand Down

0 comments on commit 21d2dc2

Please sign in to comment.