Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed Issue #10792. Created an Out Of Browser enabled integration tes…
…t project. Fixed some poor XML parsing of the AppManifest.xaml (there's prob better way to parse it than this fix - but it seems to work)
  • Loading branch information
staxmanade committed May 8, 2010
1 parent 4f29ab8 commit 52a1e54
Show file tree
Hide file tree
Showing 10 changed files with 261 additions and 3 deletions.
6 changes: 5 additions & 1 deletion TODO.txt
Expand Up @@ -7,4 +7,8 @@ look into replacing Default testing framework version - also the string file nam

wrap real unit tests around the XapReader

cleanup logger passed into XapReader
cleanup logger passed into XapReader


OOB notes:
http://debuggingblog.com/wp/2009/07/17/silverlight-3-outofbrowseroob-explained-and-how-to-host-any-xap-package-by-modifying-the-metadata/
8 changes: 6 additions & 2 deletions src/StatLight.Client.Harness/LoadedXapData.cs
Expand Up @@ -43,7 +43,11 @@ public LoadedXapData(Stream xapStream)
if (root != null)
{
string entryPoint = root.Attribute("EntryPointAssembly").Value;
var partsElement = root.FirstNode as XElement;

//TODO: There has to be a better way to get the Deployment.Parts out of the xml than this...
var partsElement = root.Elements()
.Where(w => w.Name.LocalName.Equals("Deployment.Parts", StringComparison.OrdinalIgnoreCase))
.SingleOrDefault();

if (partsElement != null)
{
Expand Down Expand Up @@ -82,7 +86,7 @@ public LoadedXapData(Stream xapStream)
}
}
else
throw new InvalidOperationException("The application manifest did not contain any assembly part xml nodes.");
throw new InvalidOperationException("The application manifest does not contain a Deployment.Parts xml element.");

if (_testAssemblies.Count == 0)
throw new InvalidOperationException("Could not find the entry poing assembly [{0}].".FormatWith(entryPoint));
Expand Down
8 changes: 8 additions & 0 deletions src/StatLight.IntegrationTests.OutOfBrowser/App.xaml
@@ -0,0 +1,8 @@
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="StatLight.IntegrationTests.OutOfBrowser.App"
>
<Application.Resources>

</Application.Resources>
</Application>
60 changes: 60 additions & 0 deletions src/StatLight.IntegrationTests.OutOfBrowser/App.xaml.cs
@@ -0,0 +1,60 @@
using System;
using System.Windows;
using Microsoft.Silverlight.Testing;

namespace StatLight.IntegrationTests.OutOfBrowser
{
public partial class App : Application
{

public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;

InitializeComponent();
}

private void Application_Startup(object sender, StartupEventArgs e)
{
this.RootVisual = UnitTestSystem.CreateTestPage();
}

private void Application_Exit(object sender, EventArgs e)
{

}

private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
// If the app is running outside of the debugger then report the exception using
// the browser's exception mechanism. On IE this will display it a yellow alert
// icon in the status bar and Firefox will display a script error.
if (!System.Diagnostics.Debugger.IsAttached)
{

// NOTE: This will allow the application to continue running after an exception has been thrown
// but not handled.
// For production applications this error handling should be replaced with something that will
// report the error to the website and stop the application.
e.Handled = true;
Deployment.Current.Dispatcher.BeginInvoke(delegate { ReportErrorToDOM(e); });
}
}

private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
{
try
{
string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");

System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " + errorMsg + "\");");
}
catch (Exception)
{
}
}
}
}
@@ -0,0 +1,6 @@
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Deployment.Parts>
</Deployment.Parts>
</Deployment>
@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("StatLight.IntegrationTests.OutOfBrowser")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StatLight.IntegrationTests.OutOfBrowser")]
[assembly: AssemblyCopyright("Copyright © 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("08c5d1b0-afd1-4025-b5bb-ec86610a6d38")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,7 @@
<OutOfBrowserSettings ShortName="StatLight.IntegrationTests.OutOfBrowser Application" EnableGPUAcceleration="False" ShowInstallMenuItem="True">
<OutOfBrowserSettings.Blurb>StatLight.IntegrationTests.OutOfBrowser Application on your desktop; at home, at work or on the go.</OutOfBrowserSettings.Blurb>
<OutOfBrowserSettings.WindowSettings>
<WindowSettings Title="StatLight.IntegrationTests.OutOfBrowser Application" />
</OutOfBrowserSettings.WindowSettings>
<OutOfBrowserSettings.Icons />
</OutOfBrowserSettings>
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CB2B6883-2461-4115-848C-DA79D20A3E0A}</ProjectGuid>
<ProjectTypeGuids>{A1591282-1198-4647-A2B1-27E5FF5F6F3B};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>StatLight.IntegrationTests.OutOfBrowser</RootNamespace>
<AssemblyName>StatLight.IntegrationTests.OutOfBrowser</AssemblyName>
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
<SilverlightApplication>true</SilverlightApplication>
<SupportedCultures>
</SupportedCultures>
<XapOutputs>true</XapOutputs>
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
<XapFilename>StatLight.IntegrationTests.OutOfBrowser.xap</XapFilename>
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
<SilverlightAppEntry>StatLight.IntegrationTests.OutOfBrowser.App</SilverlightAppEntry>
<TestPageFileName>StatLight.IntegrationTests.OutOfBrowserTestPage.html</TestPageFileName>
<CreateTestPage>true</CreateTestPage>
<ValidateXaml>true</ValidateXaml>
<EnableOutOfBrowser>true</EnableOutOfBrowser>
<OutOfBrowserSettingsFile>Properties\OutOfBrowserSettings.xml</OutOfBrowserSettingsFile>
<UsePlatformExtensions>false</UsePlatformExtensions>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
<LinkedServerProject>
</LinkedServerProject>
</PropertyGroup>
<!-- This property group is only here to support building this project using the
MSBuild 3.5 toolset. In order to work correctly with this older toolset, it needs
to set the TargetFrameworkVersion to v3.5 -->
<PropertyGroup Condition="'$(MSBuildToolsVersion)' == '3.5'">
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Bin\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE;SILVERLIGHT</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>Bin\Release</OutputPath>
<DefineConstants>TRACE;SILVERLIGHT</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Silverlight.Testing">
<HintPath>..\..\lib\Silverlight\Microsoft\April2010\Microsoft.Silverlight.Testing.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight">
<HintPath>..\..\lib\Silverlight\Microsoft\April2010\Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll</HintPath>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="System.Windows" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Xml" />
<Reference Include="System.Windows.Browser" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tests.cs" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<None Include="Properties\AppManifest.xml" />
</ItemGroup>
<ItemGroup>
<None Include="Properties\OutOfBrowserSettings.xml" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Silverlight\$(SilverlightVersion)\Microsoft.Silverlight.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
<SilverlightProjectProperties />
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>
14 changes: 14 additions & 0 deletions src/StatLight.IntegrationTests.OutOfBrowser/Tests.cs
@@ -0,0 +1,14 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace StatLight.IntegrationTests.OutOfBrowser
{
[TestClass]
public class Tests
{
[TestMethod]
public void Should_Run_this_passing_test()
{

}
}
}
9 changes: 9 additions & 0 deletions src/StatLight.sln
Expand Up @@ -49,6 +49,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StatLight.Client.Harness.Un
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StatLight.IntegrationTests.Silverlight.LotsOfTests", "StatLight.IntegrationTests.Silverlight.LotsOfTests\StatLight.IntegrationTests.Silverlight.LotsOfTests.csproj", "{6454A8DE-C1E8-4A34-86B0-89E364861BAC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StatLight.IntegrationTests.OutOfBrowser", "StatLight.IntegrationTests.OutOfBrowser\StatLight.IntegrationTests.OutOfBrowser.csproj", "{CB2B6883-2461-4115-848C-DA79D20A3E0A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -193,6 +195,12 @@ Global
{6454A8DE-C1E8-4A34-86B0-89E364861BAC}.Release|Any CPU.Build.0 = Release|Any CPU
{6454A8DE-C1E8-4A34-86B0-89E364861BAC}.Release|x86.ActiveCfg = Release|Any CPU
{6454A8DE-C1E8-4A34-86B0-89E364861BAC}.Release|x86.Build.0 = Release|Any CPU
{CB2B6883-2461-4115-848C-DA79D20A3E0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CB2B6883-2461-4115-848C-DA79D20A3E0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB2B6883-2461-4115-848C-DA79D20A3E0A}.Debug|x86.ActiveCfg = Debug|Any CPU
{CB2B6883-2461-4115-848C-DA79D20A3E0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB2B6883-2461-4115-848C-DA79D20A3E0A}.Release|Any CPU.Build.0 = Release|Any CPU
{CB2B6883-2461-4115-848C-DA79D20A3E0A}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -208,5 +216,6 @@ Global
{6DC93A95-7B8E-4D2E-BFB7-E2D3BCE089C8} = {CBFFC0A9-9D77-443F-84FB-831A1C368EA0}
{E99066B4-F2FC-469D-B427-CA1793BB0B23} = {CBFFC0A9-9D77-443F-84FB-831A1C368EA0}
{6454A8DE-C1E8-4A34-86B0-89E364861BAC} = {CBFFC0A9-9D77-443F-84FB-831A1C368EA0}
{CB2B6883-2461-4115-848C-DA79D20A3E0A} = {CBFFC0A9-9D77-443F-84FB-831A1C368EA0}
EndGlobalSection
EndGlobal

0 comments on commit 52a1e54

Please sign in to comment.