Commit 4a28f0d8 authored by Ghislain MARY's avatar Ghislain MARY

Add dynamic test case list.

parent d2e14780
......@@ -8,7 +8,7 @@ using namespace mediastreamer2_tester_native;
using namespace Platform;
#define MAX_TRACE_SIZE 512
#define MAX_SUITE_NAME_SIZE 64
#define MAX_SUITE_NAME_SIZE 128
static OutputTraceListener^ sTraceListener;
......@@ -52,7 +52,7 @@ void Mediastreamer2TesterNative::run(Platform::String^ name, Platform::Boolean v
{
std::wstring all(L"ALL");
std::wstring suitename = name->Data();
char cname[128] = { 0 };
char cname[MAX_SUITE_NAME_SIZE] = { 0 };
wcstombs(cname, suitename.c_str(), sizeof(cname));
if (verbose) {
......@@ -71,9 +71,28 @@ unsigned int Mediastreamer2TesterNative::nbTestSuites()
return mediastreamer2_tester_nb_test_suites();
}
unsigned int Mediastreamer2TesterNative::nbTests(Platform::String^ suiteName)
{
std::wstring suitename = suiteName->Data();
char cname[MAX_SUITE_NAME_SIZE] = { 0 };
wcstombs(cname, suitename.c_str(), sizeof(cname));
return mediastreamer2_tester_nb_tests(cname);
}
Platform::String^ Mediastreamer2TesterNative::testSuiteName(int index)
{
const char * cname = mediastreamer2_tester_test_suite_name(index);
const char *cname = mediastreamer2_tester_test_suite_name(index);
wchar_t wcname[MAX_SUITE_NAME_SIZE];
mbstowcs(wcname, cname, sizeof(wcname));
return ref new String(wcname);
}
Platform::String^ Mediastreamer2TesterNative::testName(Platform::String^ suiteName, int testIndex)
{
std::wstring suitename = suiteName->Data();
char csuitename[MAX_SUITE_NAME_SIZE] = { 0 };
wcstombs(csuitename, suitename.c_str(), sizeof(csuitename));
const char *cname = mediastreamer2_tester_test_name(csuitename, testIndex);
wchar_t wcname[MAX_SUITE_NAME_SIZE];
mbstowcs(wcname, cname, sizeof(wcname));
return ref new String(wcname);
......
......@@ -17,7 +17,9 @@ namespace mediastreamer2_tester_native
virtual ~Mediastreamer2TesterNative();
void setOutputTraceListener(OutputTraceListener^ traceListener);
unsigned int nbTestSuites();
unsigned int nbTests(Platform::String^ suiteName);
Platform::String^ testSuiteName(int index);
Platform::String^ testName(Platform::String^ suiteName, int testIndex);
void run(Platform::String^ name, Platform::Boolean verbose);
};
}
\ No newline at end of file
......@@ -36,7 +36,14 @@ namespace mediastreamer2_tester_wp8
void tests_selectionChanged(object sender, EventArgs e)
{
UnitTestSuiteName test = (sender as LongListSelector).SelectedItem as UnitTestSuiteName;
NavigationService.Navigate(new Uri("/TestResultPage.xaml?SuiteName=" + test.Name + "&Verbose=" + Verbose.IsChecked.GetValueOrDefault(), UriKind.Relative));
if (test.Name == "ALL")
{
NavigationService.Navigate(new Uri("/TestResultPage.xaml?SuiteName=" + test.Name + "&Verbose=" + Verbose.IsChecked.GetValueOrDefault(), UriKind.Relative));
}
else
{
NavigationService.Navigate(new Uri("/TestCasePage.xaml?SuiteName=" + test.Name + "&Verbose=" + Verbose.IsChecked.GetValueOrDefault(), UriKind.Relative));
}
}
// Sample code for building a localized ApplicationBar
......
<phone:PhoneApplicationPage
x:Class="mediastreamer2_tester_wp8.TestCasePage"
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">
<phone:PhoneApplicationPage.Resources>
<DataTemplate x:Key="UnitTestItemTemplate">
<TextBlock Style="{StaticResource PhoneTextTitle2Style}" Text="{Binding Name}"/>
</DataTemplate>
</phone:PhoneApplicationPage.Resources>
<!--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 Text="MEDIASTREAMER2 TESTER" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="Test Case" 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">
<phone:LongListSelector x:Name="Tests" HorizontalAlignment="Left" Height="510" VerticalAlignment="Top" Width="456" ItemTemplate="{StaticResource UnitTestItemTemplate}" LayoutMode="List" Margin="0,70,0,-10"/>
</Grid>
</Grid>
</phone:PhoneApplicationPage>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
namespace mediastreamer2_tester_wp8
{
public partial class TestCasePage : PhoneApplicationPage
{
public TestCasePage()
{
InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
suiteName = NavigationContext.QueryString["SuiteName"];
verbose = Convert.ToBoolean(NavigationContext.QueryString["Verbose"]);
var tester = (Application.Current as App).tester;
List<UnitTestCaseName> source = new List<UnitTestCaseName>();
source.Add(new UnitTestCaseName("ALL"));
for (int i = 0; i < tester.nbTests(suiteName); i++)
{
source.Add(new UnitTestCaseName(tester.testName(suiteName, i)));
}
Tests.ItemsSource = source;
Tests.SelectionChanged += tests_selectionChanged;
}
void tests_selectionChanged(object sender, EventArgs e)
{
UnitTestCaseName test = (sender as LongListSelector).SelectedItem as UnitTestCaseName;
NavigationService.Navigate(new Uri("/TestResultPage.xaml?SuiteName=" + suiteName + "&CaseName=" + test.Name + "&Verbose=" + verbose, UriKind.Relative));
}
private string suiteName;
private bool verbose;
}
public class UnitTestCaseName
{
public string Name
{
get;
set;
}
public UnitTestCaseName(string name)
{
this.Name = name;
}
}
}
\ No newline at end of file
......@@ -29,7 +29,6 @@ namespace cain_sip_tester_wp8
bool verbose = Convert.ToBoolean(NavigationContext.QueryString["Verbose"]);
var suite = new UnitTestSuite(suiteName, verbose, new OutputDisplayDelegate(OutputDisplay));
suite.run();
;
}
public void OutputDisplay(String msg)
......
......@@ -103,6 +103,9 @@
<DesignTime>True</DesignTime>
<DependentUpon>AppResources.resx</DependentUpon>
</Compile>
<Compile Include="TestCasePage.xaml.cs">
<DependentUpon>TestCasePage.xaml</DependentUpon>
</Compile>
<Compile Include="TestResultPage.xaml.cs" />
</ItemGroup>
<ItemGroup>
......@@ -114,6 +117,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="TestCasePage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="TestResultPage.xaml">
<SubType>Designer</SubType>
</Page>
......
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