Commit e3fea891 authored by Ghislain MARY's avatar Ghislain MARY

Dynamic list of test suites and test cases.

parent bec42d69
......@@ -7,7 +7,8 @@
using namespace belle_sip_tester_native;
using namespace Platform;
#define MAX_TRACE_SIZE 512
#define MAX_TRACE_SIZE 512
#define MAX_SUITE_NAME_SIZE 128
static OutputTraceListener^ sTraceListener;
......@@ -30,17 +31,30 @@ static void belleSipNativeOutputTraceHandler(belle_sip_log_level lev, const char
}
CainSipTesterNative::CainSipTesterNative(OutputTraceListener^ traceListener)
CainSipTesterNative::CainSipTesterNative()
{
belle_sip_tester_init();
}
CainSipTesterNative::~CainSipTesterNative()
{
belle_sip_tester_uninit();
}
void CainSipTesterNative::setOutputTraceListener(OutputTraceListener^ traceListener)
{
sTraceListener = traceListener;
}
void CainSipTesterNative::run(Platform::String^ name, Platform::Boolean verbose)
void CainSipTesterNative::run(Platform::String^ suiteName, Platform::String^ caseName, Platform::Boolean verbose)
{
std::wstring all(L"ALL");
std::wstring suitename = name->Data();
char cname[128] = { 0 };
wcstombs(cname, suitename.c_str(), sizeof(cname));
std::wstring wssuitename = suiteName->Data();
std::wstring wscasename = caseName->Data();
char csuitename[MAX_SUITE_NAME_SIZE] = { 0 };
char ccasename[MAX_SUITE_NAME_SIZE] = { 0 };
wcstombs(csuitename, wssuitename.c_str(), sizeof(csuitename));
wcstombs(ccasename, wscasename.c_str(), sizeof(ccasename));
if (verbose) {
belle_sip_set_log_level(BELLE_SIP_LOG_DEBUG);
......@@ -50,5 +64,37 @@ void CainSipTesterNative::run(Platform::String^ name, Platform::Boolean verbose)
belle_sip_set_log_handler(belleSipNativeOutputTraceHandler);
CU_set_trace_handler(nativeOutputTraceHandler);
belle_sip_tester_run_tests(suitename == all ? 0 : cname, 0);
belle_sip_tester_run_tests(wssuitename == all ? 0 : csuitename, wscasename == all ? 0 : ccasename);
}
unsigned int CainSipTesterNative::nbTestSuites()
{
return belle_sip_tester_nb_test_suites();
}
unsigned int CainSipTesterNative::nbTests(Platform::String^ suiteName)
{
std::wstring suitename = suiteName->Data();
char cname[MAX_SUITE_NAME_SIZE] = { 0 };
wcstombs(cname, suitename.c_str(), sizeof(cname));
return belle_sip_tester_nb_tests(cname);
}
Platform::String^ CainSipTesterNative::testSuiteName(int index)
{
const char *cname = belle_sip_tester_test_suite_name(index);
wchar_t wcname[MAX_SUITE_NAME_SIZE];
mbstowcs(wcname, cname, sizeof(wcname));
return ref new String(wcname);
}
Platform::String^ CainSipTesterNative::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 = belle_sip_tester_test_name(csuitename, testIndex);
wchar_t wcname[MAX_SUITE_NAME_SIZE];
mbstowcs(wcname, cname, sizeof(wcname));
return ref new String(wcname);
}
#pragma once
#include "belle-sip/belle-sip.h"
#ifdef __cplusplus
extern "C" {
#endif
int belle_sip_tester_run_tests(char *suite_name, char *test_name);
#ifdef __cplusplus
}
#endif
#include "belle_sip_tester.h"
namespace belle_sip_tester_native
{
......@@ -21,7 +14,13 @@ namespace belle_sip_tester_native
public ref class CainSipTesterNative sealed
{
public:
CainSipTesterNative(OutputTraceListener^ traceListener);
void run(Platform::String^ name, Platform::Boolean verbose);
CainSipTesterNative();
virtual ~CainSipTesterNative();
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^ suiteName, Platform::String^ caseName, Platform::Boolean verbose);
};
}
\ No newline at end of file
......@@ -63,7 +63,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<AdditionalIncludeDirectories>$(ProjectDir);$(GeneratedFilesDir);$(IntDir);$(ProjectDir)..\..\..\..\include;$(ProjectDir)..\..\..\..\src;$(ProjectDir)..\..\..\..\..\cunit\build\windows\cunit\$(Platform)\$(Configuration);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir);$(GeneratedFilesDir);$(IntDir);$(ProjectDir)..\..\..\..\include;$(ProjectDir)..\..\..\..\src;$(ProjectDir)..\..\..\..\tester;$(ProjectDir)..\..\..\..\..\cunit\build\windows\cunit\$(Platform)\$(Configuration);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_WINRT_DLL;_CRT_SECURE_NO_WARNINGS;HAVE_CU_GET_SUITE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
......@@ -83,7 +83,7 @@
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir);$(GeneratedFilesDir);$(IntDir);$(ProjectDir)..\..\..\..\include;$(ProjectDir)..\..\..\..\src;$(ProjectDir)..\..\..\..\..\cunit\build\windows\cunit\$(Platform)\$(Configuration);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir);$(GeneratedFilesDir);$(IntDir);$(ProjectDir)..\..\..\..\include;$(ProjectDir)..\..\..\..\src;$(ProjectDir)..\..\..\..\tester;$(ProjectDir)..\..\..\..\..\cunit\build\windows\cunit\$(Platform)\$(Configuration);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_WINRT_DLL;_CRT_SECURE_NO_WARNINGS;HAVE_CU_GET_SUITE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
......@@ -105,7 +105,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<AdditionalIncludeDirectories>$(ProjectDir);$(GeneratedFilesDir);$(IntDir);$(ProjectDir)..\..\..\..\include;$(ProjectDir)..\..\..\..\src;$(ProjectDir)..\..\..\..\..\cunit\build\windows\cunit\$(Platform)\$(Configuration);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir);$(GeneratedFilesDir);$(IntDir);$(ProjectDir)..\..\..\..\include;$(ProjectDir)..\..\..\..\src;$(ProjectDir)..\..\..\..\tester;$(ProjectDir)..\..\..\..\..\cunit\build\windows\cunit\$(Platform)\$(Configuration);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_WINRT_DLL;_CRT_SECURE_NO_WARNINGS;HAVE_CU_GET_SUITE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
......@@ -125,7 +125,7 @@
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<AdditionalIncludeDirectories>$(ProjectDir);$(GeneratedFilesDir);$(IntDir);$(ProjectDir)..\..\..\..\include;$(ProjectDir)..\..\..\..\src;$(ProjectDir)..\..\..\..\..\cunit\build\windows\cunit\$(Platform)\$(Configuration);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir);$(GeneratedFilesDir);$(IntDir);$(ProjectDir)..\..\..\..\include;$(ProjectDir)..\..\..\..\src;$(ProjectDir)..\..\..\..\tester;$(ProjectDir)..\..\..\..\..\cunit\build\windows\cunit\$(Platform)\$(Configuration);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_WINRT_DLL;_CRT_SECURE_NO_WARNINGS;HAVE_CU_GET_SUITE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
......@@ -151,6 +151,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\..\tester\belle_sip_tester.h" />
<ClInclude Include="..\..\..\..\tester\register_tester.h" />
<ClInclude Include="belle-sip-tester-native.h" />
</ItemGroup>
......
......@@ -7,6 +7,7 @@ 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
{
......@@ -55,6 +56,7 @@ namespace belle_sip_tester_wp8
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
}
tester = new CainSipTesterNative();
}
// Code to execute when the application is launching (eg, from Start)
......@@ -219,5 +221,7 @@ namespace belle_sip_tester_wp8
throw;
}
}
public CainSipTesterNative tester { get; set; }
}
}
\ No newline at end of file
......@@ -51,7 +51,7 @@
<LineBreak/>
<Run/>
</TextBlock>
<TextBlock Text="Test Selection" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
<TextBlock Text="Test Suite" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
......
......@@ -18,18 +18,13 @@ namespace belle_sip_tester_wp8
{
InitializeComponent();
var tester = (Application.Current as App).tester;
List<UnitTestSuiteName> source = new List<UnitTestSuiteName>();
source.Add(new UnitTestSuiteName("ALL"));
source.Add(new UnitTestSuiteName("Authentication-helper"));
source.Add(new UnitTestSuiteName("Dialog"));
source.Add(new UnitTestSuiteName("Headers"));
source.Add(new UnitTestSuiteName("Message"));
source.Add(new UnitTestSuiteName("Object inheritence"));
source.Add(new UnitTestSuiteName("Refresher"));
source.Add(new UnitTestSuiteName("Register"));
source.Add(new UnitTestSuiteName("Resolver"));
source.Add(new UnitTestSuiteName("SDP"));
source.Add(new UnitTestSuiteName("Uri"));
for (int i = 0; i < tester.nbTestSuites(); i++)
{
source.Add(new UnitTestSuiteName(tester.testSuiteName(i)));
}
Tests.ItemsSource = source;
Tests.SelectionChanged += tests_selectionChanged;
......@@ -41,7 +36,14 @@ namespace belle_sip_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="belle_sip_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="BELLE-SIP 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 belle_sip_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
......@@ -9,7 +9,7 @@
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
......
......@@ -9,6 +9,7 @@ using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using belle_sip_tester_native;
using belle_sip_tester_wp8;
namespace belle_sip_tester_wp8
{
......@@ -25,10 +26,18 @@ namespace belle_sip_tester_wp8
{
base.OnNavigatedTo(e);
string suiteName = NavigationContext.QueryString["SuiteName"];
string caseName;
if (NavigationContext.QueryString.ContainsKey("CaseName"))
{
caseName = NavigationContext.QueryString["CaseName"];
}
else
{
caseName = "ALL";
}
bool verbose = Convert.ToBoolean(NavigationContext.QueryString["Verbose"]);
var suite = new UnitTestSuite(suiteName, verbose, new OutputDisplayDelegate(OutputDisplay));
var suite = new UnitTestSuite(suiteName, caseName, verbose, new OutputDisplayDelegate(OutputDisplay));
suite.run();
;
}
public void OutputDisplay(String msg)
......@@ -42,21 +51,23 @@ namespace belle_sip_tester_wp8
public class UnitTestSuite : OutputTraceListener
{
public UnitTestSuite(string SuiteName, bool Verbose, OutputDisplayDelegate OutputDisplay)
public UnitTestSuite(string SuiteName, string CaseName, bool Verbose, OutputDisplayDelegate OutputDisplay)
{
this.SuiteName = SuiteName;
this.CaseName = CaseName;
this.Verbose = Verbose;
this.OutputDisplay = OutputDisplay;
}
async public void run()
{
var tup = new Tuple<String, bool>(SuiteName, Verbose);
var tup = new Tuple<string, string, bool>(SuiteName, CaseName, 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);
var tester = (Application.Current as App).tester;
tester.setOutputTraceListener(this);
var p = parameters as Tuple<string, string, bool>;
tester.run(p.Item1, p.Item2, p.Item3);
}, tup);
await t;
}
......@@ -71,6 +82,7 @@ namespace belle_sip_tester_wp8
}
private string SuiteName;
private string CaseName;
private bool Verbose;
private OutputDisplayDelegate OutputDisplay;
}
......
......@@ -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">
<DependentUpon>TestResultPage.xaml</DependentUpon>
</Compile>
......@@ -116,6 +119,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>
<Generator>MSBuild:Compile</Generator>
......
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