Commit d43483e1 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Display test results on the screen.

parent a15b647e
......@@ -47,11 +47,11 @@
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0">
<Run Text="BELLE-SIP"/>
<Run Text="BELLE-SIP TESTER"/>
<LineBreak/>
<Run/>
</TextBlock>
<TextBlock Text="Tester" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
<TextBlock Text="Test Selection" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
......
......@@ -2,14 +2,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using belle_sip_tester_wp8.Resources;
using belle_sip_tester_native;
namespace belle_sip_tester_wp8
{
......@@ -42,11 +40,8 @@ namespace belle_sip_tester_wp8
void tests_selectionChanged(object sender, EventArgs e)
{
(sender as LongListSelector).Visibility = Visibility.Collapsed;
UnitTestSuiteName test = (sender as LongListSelector).SelectedItem as UnitTestSuiteName;
var suite = new UnitTestSuite(test, Verbose.IsChecked.GetValueOrDefault());
suite.run();
(sender as LongListSelector).Visibility = Visibility.Visible;
NavigationService.Navigate(new Uri("/TestResultPage.xaml?SuiteName=" + test.Name + "&Verbose=" + Verbose.IsChecked.GetValueOrDefault(), UriKind.Relative));
}
// Sample code for building a localized ApplicationBar
......@@ -66,35 +61,6 @@ namespace belle_sip_tester_wp8
//}
}
public class UnitTestSuite : OutputTraceListener
{
public UnitTestSuite(UnitTestSuiteName test, bool verbose)
{
this.test = test;
this.verbose = verbose;
}
async public void run()
{
var tup = new Tuple<String, bool>(test.Name, verbose);
var t = Task.Factory.StartNew((object parameters) =>
{
var tester = new CainSipTesterNative(this);
var p = parameters as Tuple<String, bool>;
tester.run(p.Item1, p.Item2);
}, tup);
await t;
}
public void outputTrace(String msg)
{
System.Diagnostics.Debug.WriteLine(msg);
}
private UnitTestSuiteName test;
private bool verbose;
}
public class UnitTestSuiteName
{
public string Name
......
<phone:PhoneApplicationPage
x:Class="belle_sip_tester_wp8.TestResultPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Style="{StaticResource PhoneTextNormalStyle}">
<Run Text="BELLE-SIP TESTER"/>
<LineBreak/>
<Run/>
</TextBlock>
<TextBlock Text="Test Results" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ScrollViewer HorizontalScrollBarVisibility="Visible">
<TextBlock x:Name="TestResults" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}" FontFamily="Courier New" FontSize="16"/>
</ScrollViewer>
</Grid>
</Grid>
</phone:PhoneApplicationPage>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using belle_sip_tester_native;
namespace belle_sip_tester_wp8
{
public delegate void OutputDisplayDelegate(String msg);
public partial class TestResultPage : PhoneApplicationPage
{
public TestResultPage()
{
InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string suiteName = NavigationContext.QueryString["SuiteName"];
bool verbose = Convert.ToBoolean(NavigationContext.QueryString["Verbose"]);
var suite = new UnitTestSuite(suiteName, verbose, new OutputDisplayDelegate(OutputDisplay));
suite.run();
;
}
public void OutputDisplay(String msg)
{
this.Dispatcher.BeginInvoke(() =>
{
TestResults.Text += msg;
});
}
}
public class UnitTestSuite : OutputTraceListener
{
public UnitTestSuite(string SuiteName, bool Verbose, OutputDisplayDelegate OutputDisplay)
{
this.SuiteName = SuiteName;
this.Verbose = Verbose;
this.OutputDisplay = OutputDisplay;
}
async public void run()
{
var tup = new Tuple<String, bool>(SuiteName, Verbose);
var t = Task.Factory.StartNew((object parameters) =>
{
var tester = new CainSipTesterNative(this);
var p = parameters as Tuple<String, bool>;
tester.run(p.Item1, p.Item2);
}, tup);
await t;
}
public void outputTrace(String msg)
{
if (OutputDisplay != null)
{
OutputDisplay(msg);
}
System.Diagnostics.Debug.WriteLine(msg);
}
private string SuiteName;
private bool Verbose;
private OutputDisplayDelegate OutputDisplay;
}
}
\ No newline at end of file
......@@ -103,6 +103,9 @@
<DesignTime>True</DesignTime>
<DependentUpon>AppResources.resx</DependentUpon>
</Compile>
<Compile Include="TestResultPage.xaml.cs">
<DependentUpon>TestResultPage.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
......@@ -113,6 +116,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="TestResultPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="Properties\AppManifest.xml" />
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment