Commit 2575d973 authored by Ghislain MARY's avatar Ghislain MARY

Remove deprecated Visual Studio solution for Windows 10.

parent 0a56f58f
<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:liblinphone_tester"
xmlns:model="using:liblinphone_tester.DataModel" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
x:Class="liblinphone_tester.App"
RequestedTheme="Light">
<Application.Resources>
<ResourceDictionary>
<model:UnitTestCaseStateToSymbolConverter x:Key="UnitTestCaseStateToSymbol"/>
<model:UnitTestCaseStateToSymbolColorConverter x:Key="UnitTestCaseStateToSymbolColor"/>
<model:OutputTraceLevelToColorConverter x:Key="OutputTraceLevelToColor"/>
</ResourceDictionary>
</Application.Resources>
</Application>
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=402347&clcid=0x409
namespace liblinphone_tester
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
sealed partial class App : Application
{
/// <summary>
/// Allows tracking page views, exceptions and other telemetry through the Microsoft Application Insights service.
/// </summary>
public static Microsoft.ApplicationInsights.TelemetryClient TelemetryClient;
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
TelemetryClient = new Microsoft.ApplicationInsights.TelemetryClient();
this.InitializeComponent();
this.Suspending += OnSuspending;
}
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
#if DEBUG
if (System.Diagnostics.Debugger.IsAttached)
{
this.DebugSettings.EnableFrameRateCounter = true;
}
#endif
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}
/// <summary>
/// Invoked when Navigation to a certain page fails
/// </summary>
/// <param name="sender">The Frame which failed navigation</param>
/// <param name="e">Details about the navigation failure</param>
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}
/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity
deferral.Complete();
}
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.Protocol)
{
var protocolArgs = (ProtocolActivatedEventArgs)args;
var uri = protocolArgs.Uri;
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
rootFrame.Navigate(typeof(MainPage), uri);
Window.Current.Content = rootFrame;
Window.Current.Activate();
}
base.OnActivated(args);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
<!--
Learn more about Application Insights configuration with ApplicationInsights.config here:
http://go.microsoft.com/fwlink/?LinkID=513840
Note: If not present, please add <InstrumentationKey>Your Key</InstrumentationKey> to the top of this file.
-->
<TelemetryModules>
<Add Type="Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing.DiagnosticsTelemetryModule, Microsoft.ApplicationInsights"/>
<Add Type="Microsoft.ApplicationInsights.Extensibility.Windows.SessionTelemetryModule, Microsoft.ApplicationInsights.Extensibility.Windows"/>
<Add Type="Microsoft.ApplicationInsights.Extensibility.Windows.PageViewTelemetryModule, Microsoft.ApplicationInsights.Extensibility.Windows"/>
<Add Type="Microsoft.ApplicationInsights.Extensibility.Windows.UnhandledExceptionTelemetryModule, Microsoft.ApplicationInsights.Extensibility.Windows"/>
</TelemetryModules>
<TelemetryChannel Type="Microsoft.ApplicationInsights.Channel.PersistenceChannel, Microsoft.ApplicationInsights.PersistenceChannel"/>
<ContextInitializers>
<Add Type="Microsoft.ApplicationInsights.Extensibility.ComponentContextInitializer, Microsoft.ApplicationInsights"/>
<Add Type="Microsoft.ApplicationInsights.Extensibility.DeviceContextInitializer, Microsoft.ApplicationInsights"/>
</ContextInitializers>
<TelemetryInitializers>
<Add Type="Microsoft.ApplicationInsights.Extensibility.Windows.UserContextInitializer, Microsoft.ApplicationInsights.Extensibility.Windows"/>
</TelemetryInitializers>
</ApplicationInsights>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using liblinphone_tester_runtime_component;
using System.Collections.ObjectModel;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Media;
using System.ComponentModel;
using Windows.UI;
using Windows.UI.Xaml.Documents;
using Windows.UI.Core;
namespace liblinphone_tester.DataModel
{
public class OutputTrace
{
public OutputTrace(String lev, String msg)
{
Level = lev;
Msg = msg;
}
public String Level { get; private set; }
public String Msg { get; private set; }
}
public class UnitTestSuite
{
public UnitTestSuite(string name)
{
Name = name;
Cases = new ObservableCollection<UnitTestCase>();
Selected = false;
}
public string Name { get; private set; }
public bool Selected
{
get { return Cases.All(x => x.Selected); }
set
{
foreach (UnitTestCase c in Cases)
{
c.Selected = value;
}
}
}
public ObservableCollection<UnitTestCase> Cases { get; private set; }
}
public enum UnitTestCaseState
{
NotRun,
Success,
Failure
}
public class UnitTestCase : INotifyPropertyChanged
{
public UnitTestCase(UnitTestSuite suite, string name)
{
_suite = new WeakReference(suite);
Name = name;
Selected = false;
State = UnitTestCaseState.NotRun;
Traces = new ObservableCollection<OutputTrace>();
}
public UnitTestSuite Suite
{
get { return _suite.Target as UnitTestSuite; }
}
public string Name { get; private set; }
public bool Selected
{
get { return _selected; }
set
{
_selected = value;
RaisePropertyChanged("Selected");
}
}
public UnitTestCaseState State
{
get { return _state; }
set
{
_state = value;
RaisePropertyChanged("State");
}
}
public ObservableCollection<OutputTrace> Traces
{
get { return _traces; }
set
{
_traces = value;
RaisePropertyChanged("Traces");
}
}
public CoreDispatcher Dispatcher { get; set; }
public event PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string name)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
private WeakReference _suite;
private bool _selected;
private UnitTestCaseState _state;
private ObservableCollection<OutputTrace> _traces;
}
public sealed class UnitTestDataSource
{
private static UnitTestDataSource _unitTestDataSource = new UnitTestDataSource();
private ObservableCollection<UnitTestSuite> _suites = new ObservableCollection<UnitTestSuite>();
public ObservableCollection<UnitTestSuite> Suites
{
get { return this._suites; }
}
public static IEnumerable<UnitTestSuite> GetSuites(LibLinphoneTester tester)
{
return _unitTestDataSource.FillSuites(tester);
}
private IEnumerable<UnitTestSuite> FillSuites(LibLinphoneTester tester)
{
if (this.Suites.Count != 0) return this.Suites;
for (int i = 0; i < tester.nbTestSuites(); i++)
{
UnitTestSuite suite = new UnitTestSuite(tester.testSuiteName(i));
for (int j = 0; j < tester.nbTests(suite.Name); j++)
{
suite.Cases.Add(new UnitTestCase(suite, tester.testName(suite.Name, j)));
}
this.Suites.Add(suite);
}
return this.Suites;
}
}
public sealed class UnitTestCaseStateToSymbolConverter : IValueConverter
{
object IValueConverter.Convert(object value, Type targetType, object parametr, string language)
{
if (!value.GetType().Equals(typeof(UnitTestCaseState)))
{
throw new ArgumentException("Only UnitTestCaseState is supported");
}
if (targetType.Equals(typeof(Symbol)))
{
switch ((UnitTestCaseState)value)
{
case UnitTestCaseState.Success:
return Symbol.Like;
case UnitTestCaseState.Failure:
return Symbol.Dislike;
case UnitTestCaseState.NotRun:
default:
return Symbol.Help;
}
}
else
{
throw new ArgumentException(string.Format("Unsupported type {0}", targetType.FullName));
}
}
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
public sealed class UnitTestCaseStateToSymbolColorConverter : IValueConverter
{
object IValueConverter.Convert(object value, Type targetType, object parameter, string language)
{
if (!value.GetType().Equals(typeof(UnitTestCaseState)))
{
throw new ArgumentException("Only UnitTestCaseState is supported");
}
if (targetType.Equals(typeof(Brush)))
{
switch ((UnitTestCaseState)value)
{
case UnitTestCaseState.Success:
return new SolidColorBrush(Colors.ForestGreen);
case UnitTestCaseState.Failure:
return new SolidColorBrush(Colors.IndianRed);
case UnitTestCaseState.NotRun:
default:
return new SolidColorBrush(Colors.LightGray);
}
}
else
{
throw new ArgumentException(string.Format("Unsupported format {0}", targetType.FullName));
}
}
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
public sealed class OutputTraceLevelToColorConverter : IValueConverter
{
object IValueConverter.Convert(object value, Type targetType, object parameter, string language)
{
if (!value.GetType().Equals(typeof(String)))
{
throw new ArgumentException("Only String is supported");
}
if (targetType.Equals(typeof(Brush)))
{
if ((String)value == "Error")
{
return new SolidColorBrush(Colors.IndianRed);
}
else if ((String)value == "Warning")
{
return new SolidColorBrush(Colors.Orange);
}
return new SolidColorBrush(Colors.Black);
}
else
{
throw new ArgumentException(string.Format("Unsupported format {0}", targetType.FullName));
}
}
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:liblinphone_tester"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:model="using:liblinphone_tester.DataModel"
xmlns:uixdata="using:Windows.UI.Xaml.Data" x:Name="page"
x:Class="liblinphone_tester.MainPage">
<Page.Resources>
<CollectionViewSource x:Name="UnitTestCVS"
Source="{x:Bind Suites}"
ItemsPath="Cases"
IsSourceGrouped="True"/>
<DataTemplate x:Key="ZoomedInTemplate" x:DataType="model:UnitTestCase">
<Grid Width="320">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<CheckBox Grid.Column="0"
Content="{x:Bind Name}"
IsChecked="{Binding Selected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<SymbolIcon Grid.Column="1"
Symbol="{Binding State, Mode=OneWay, Converter={StaticResource UnitTestCaseStateToSymbol}, UpdateSourceTrigger=PropertyChanged}"
Foreground="{Binding State, Mode=OneWay, Converter={StaticResource UnitTestCaseStateToSymbolColor}, UpdateSourceTrigger=PropertyChanged}" Margin="16,0,32,0"/>
</Grid>
</DataTemplate>
<DataTemplate x:Key="ZoomedInGroupHeaderTemplate" x:DataType="model:UnitTestSuite">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{x:Bind Name}" Foreground="{ThemeResource ApplicationForegroundThemeBrush}" Style="{StaticResource SubtitleTextBlockStyle}"/>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="ZoomedOutTemplate" x:DataType="uixdata:ICollectionViewGroup">
<TextBlock Text="{x:Bind Group.(model:UnitTestSuite.Name)}" Style="{StaticResource SubtitleTextBlockStyle}" TextWrapping="Wrap"/>
</DataTemplate>
<DataTemplate x:Key="TraceTemplate">
<TextBlock FontFamily="Courier New">
<Run Text="{Binding Msg}" Foreground="{Binding Level, Converter={StaticResource OutputTraceLevelToColor}}"/>
</TextBlock>
</DataTemplate>
</Page.Resources>
<Page.BottomAppBar>
<CommandBar x:Name="CommandBar">
<AppBarButton x:Name="Run" Icon="Play" Label="Run" Click="RunSelected_Click"/>
<AppBarButton x:Name="SelectAll" Icon="SelectAll" Label="Select all" Click="SelectAll_Click"/>
<AppBarToggleButton x:Name="Verbose" Icon="Comment" IsChecked="True" Label="Verbose"/>
</CommandBar>
</Page.BottomAppBar>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<SplitView x:Name="splitView" Grid.Row="0" IsPaneOpen="True" DisplayMode="Inline">
<SplitView.Pane>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Test selection" Style="{StaticResource HeaderTextBlockStyle}" Margin="12,0,0,0"/>
<SemanticZoom x:Name="SemanticZoom" Grid.Row="1">
<SemanticZoom.ZoomedInView>
<ListView ItemsSource="{x:Bind UnitTestCVS.View}"
ScrollViewer.IsHorizontalScrollChainingEnabled="False"
SelectionMode="None"
ItemTemplate="{StaticResource ZoomedInTemplate}"
IsItemClickEnabled="True"
ItemClick="UnitTestCase_Click">
<ListView.GroupStyle>
<GroupStyle HeaderTemplate="{StaticResource ZoomedInGroupHeaderTemplate}" />
</ListView.GroupStyle>
</ListView>
</SemanticZoom.ZoomedInView>
<SemanticZoom.ZoomedOutView>
<ListView ItemsSource="{x:Bind UnitTestCVS.View.CollectionGroups}"
SelectionMode="None"
ItemTemplate="{StaticResource ZoomedOutTemplate}">
</ListView>
</SemanticZoom.ZoomedOutView>
</SemanticZoom>
</Grid>
</SplitView.Pane>
<Grid x:Name="TestResultPage">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Test result" Style="{StaticResource HeaderTextBlockStyle}" Margin="12,0,0,0"/>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Style="{StaticResource SubheaderTextBlockStyle}" Margin="16,0,0,0" Text="{Binding Name, Mode=OneWay}"/>
<SymbolIcon Grid.Column="1" x:Name="TestResultState"
Visibility="Collapsed"
Symbol="{Binding State, Mode=OneWay, Converter={StaticResource UnitTestCaseStateToSymbol}, UpdateSourceTrigger=PropertyChanged}"
Foreground="{Binding State, Mode=OneWay, Converter={StaticResource UnitTestCaseStateToSymbolColor}, UpdateSourceTrigger=PropertyChanged}" Margin="16,0,32,0"/>
<AppBarButton Grid.Column="2" x:Name="TestResultRun"
Icon="Play" Label="Run"
IsEnabled="{Binding IsEnabled, ElementName=CommandBar}"
Click="RunSingle_Click" Visibility="Collapsed"/>
</Grid>
<ScrollViewer Grid.Row="2">
<ItemsControl ItemsSource="{Binding Traces}" ItemTemplate="{StaticResource TraceTemplate}" Margin="20,12,0,0"/>
</ScrollViewer>
</Grid>
</SplitView>
<ProgressBar x:Name="ProgressIndicator" Grid.Row="1"
Width="{Binding ActualWidth, ElementName=CommandBar, Mode=OneWay}" Margin="16,0,0,0"/>
</Grid>
</Page>
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using liblinphone_tester.DataModel;
using liblinphone_tester_runtime_component;
using System.Threading.Tasks;
using Windows.UI.Core;
using Windows.UI.Xaml.Documents;
using Windows.Storage;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
namespace liblinphone_tester
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page, OutputTraceListener
{
public MainPage()
{
this.InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if ((e.Parameter is Uri) && (e.Parameter.ToString().Equals("liblinphone-tester:autolaunch")))
{
AutoLaunch();
}
else
{
LibLinphoneTester.Instance.initialize(ApplicationData.Current.LocalFolder, true);
_suites = UnitTestDataSource.GetSuites(LibLinphoneTester.Instance);
}
}
public IEnumerable<UnitTestSuite> Suites
{
get { return _suites; }
}
private IEnumerable<UnitTestSuite> _suites;
private void SelectAll_Click(object sender, RoutedEventArgs e)
{
bool allSelected = Suites.All(x => x.Selected);
foreach (UnitTestSuite suite in Suites)
{
suite.Selected = !allSelected;
}
}
private void RunSelected_Click(object sender, RoutedEventArgs e)
{
int nbCases = 0;
foreach (UnitTestSuite suite in Suites)
{
foreach (UnitTestCase c in suite.Cases)
{
if (c.Selected) nbCases++;
}
}
if (nbCases == 0) return;
PrepareRun(nbCases);
var tup = new Tuple<IEnumerable<UnitTestSuite>, bool?>(Suites, Verbose.IsChecked);
var t = Task.Factory.StartNew(async (object parameters) =>
{
var p = parameters as Tuple<IEnumerable<UnitTestSuite>, bool?>;
IEnumerable<UnitTestSuite> suites = p.Item1;
bool verbose = p.Item2 != null ? (bool)p.Item2 : false;
foreach (UnitTestSuite suite in suites)
{
foreach (UnitTestCase c in suite.Cases)
{
if (c.Selected)
{
await RunUnitTestCase(c, verbose);
}
}
}
}, tup);
}
private void RunSingle_Click(object sender, RoutedEventArgs e)
{
PrepareRun(1);
var tup = new Tuple<UnitTestCase, bool?>(DisplayedTestCase, Verbose.IsChecked);
var t = Task.Factory.StartNew(async (object parameters) =>
{
var p = parameters as Tuple<UnitTestCase, bool?>;
UnitTestCase c = p.Item1;
bool verbose = p.Item2 != null ? (bool)p.Item2 : false;
await RunUnitTestCase(c, verbose);
}, tup);
}
private void PrepareRun(int nbCases)
{
CommandBar.IsEnabled = false;
ProgressIndicator.IsEnabled = true;
ProgressIndicator.Minimum = 0;
ProgressIndicator.Maximum = nbCases;
ProgressIndicator.Value = 0;
LibLinphoneTester.Instance.setOutputTraceListener(this);
}
private async Task RunUnitTestCase(UnitTestCase c, bool verbose)
{
UnitTestCaseState newState = UnitTestCaseState.NotRun;
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
RunningTestCase = c;
});
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
{
c.Traces.Clear();
});
c.Dispatcher = Dispatcher;