Skip to content

Commit

Permalink
Add WinUI 2.6 Dependency to UnitTests.UWP App (#4156)
Browse files Browse the repository at this point in the history
## Related to #3650
Splitting out the upgrade to WinUI 2.6 in the Unit Tests project to help try and isolate what might be going on.

Noticed some our other NuGet dependencies have updates as well, so if this works as-is, will try and update those as well.

Then we can check this in, and rebase #3650 to try and determine what else might be going on or pull in others to help investigate.

FYI @huynhsontung @azchohfi 

## PR Type
What kind of change does this PR introduce?
<!-- Please uncomment one or more options below that apply to this PR. -->

<!-- - Bugfix -->
<!-- - Feature -->
<!-- - Code style update (formatting) -->
- Refactoring (no functional changes, no api changes)
<!-- - Build or CI related changes -->
<!-- - Documentation content changes -->
<!-- - Sample app changes -->
<!-- - Other... Please describe: -->

## What is the current behavior?
WinUI 2.6 not included when we run unit tests

## What is the new behavior?
WinUI 2.6 is now included when we run unit tests.

## PR Checklist

Please check if your PR fulfills the following requirements:

- [ ] Tested code with current [supported SDKs](../readme.md#supported)
- [ ] Pull Request has been submitted to the documentation repository [instructions](..\contributing.md#docs). Link: <!-- docs PR link -->
- [ ] Sample in sample app has been added / updated (for bug fixes / features)
    - [ ] Icon has been created (if new sample) following the [Thumbnail Style Guide and templates](https://github.com/CommunityToolkit/WindowsCommunityToolkit-design-assets)
- [ ] New major technical changes in the toolkit have or will be added to the [Wiki](https://github.com/CommunityToolkit/WindowsCommunityToolkit/wiki) e.g. build changes, source generators, testing infrastructure, sample creation changes, etc...
- [ ] Tests for the changes have been added (for bug fixes / features) (if applicable)
- [ ] Header has been added to all new source files (run *build/UpdateHeaders.bat*)
- [ ] Contains **NO** breaking changes

<!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below.
     Please note that breaking changes are likely to be rejected within minor release cycles or held until major versions. -->


## Other information
  • Loading branch information
msftbot[bot] committed Aug 4, 2021
2 parents 16d2886 + db71796 commit 794b295
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 72 deletions.
2 changes: 1 addition & 1 deletion UITests/UITests.Tests.MSTest/UITests.Tests.MSTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<!-- MSTest -->
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<!-- Microsoft.UI.Xaml MSTest Extension -->
<PackageReference Include="MUXTestInfra.MSTest" Version="0.0.4" />
<!-- System packages -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ItemGroup>
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
</ItemGroup>

<!-- .NET Core 2.1 doesn't have the Unsafe type -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
<PackageReference Include="MSTest.TestFramework">
<Version>2.1.2</Version>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe">
<Version>5.0.0</Version>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions UnitTests/UnitTests.NetCore/UnitTests.NetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.2" />
</ItemGroup>

<!-- Workaround for the .NET Core 2.1 binary not resolving the Unsafe assembly properly -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
</ItemGroup>

<Import Project="..\UnitTests.Notifications.Shared\UnitTests.Notifications.Shared.projitems" Label="Shared" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
<PackageReference Include="MSTest.TestFramework">
<Version>2.1.2</Version>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="System.ValueTuple">
<Version>4.5.0</Version>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.10.0-1.final" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
</ItemGroup>
Expand Down
59 changes: 59 additions & 0 deletions UnitTests/UnitTests.UWP/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<Application x:Class="UnitTests.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:behaviors="using:Microsoft.Toolkit.Uwp.UI.Behaviors"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
xmlns:helpers="using:UnitTests.Extensions.Helpers"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
xmlns:unitTestExtensions="using:UnitTests.Extensions"
RequestedTheme="Light">
<Application.Resources>
<muxc:XamlControlsResources>
<muxc:XamlControlsResources.MergedDictionaries>
<ResourceDictionary>
<!-- Workarounds for .NET Native issue in unit tests -->
<ui:EnumValuesExtension x:Key="DummyExtension" />

<unitTestExtensions:Animal x:Key="Animal">Cat</unitTestExtensions:Animal>

<CommandBar x:Key="DummyCommandBar">
<AppBarButton Icon="{ui:FontIcon Glyph=&#xE102;}" />
<AppBarButton Icon="{ui:SymbolIcon Symbol=Play}" />
</CommandBar>

<unitTestExtensions:MockSwipeItem x:Key="DummySwipeControl1"
IconSource="{ui:FontIconSource Glyph=&#xE10B;}" />

<unitTestExtensions:MockSwipeItem x:Key="DummySwipeControl2"
IconSource="{ui:SymbolIconSource Symbol=Play}" />

<unitTestExtensions:MockSwipeItem x:Key="DummySwipeControl3"
IconSource="{ui:BitmapIconSource Source=/Assets/StoreLogo.png}" />

<Button x:Key="DummyButton">
<Button.Flyout>
<MenuFlyout>
<MenuFlyoutItem Icon="{ui:BitmapIcon Source=/Assets/StoreLogo.png}" />
</MenuFlyout>
</Button.Flyout>
</Button>

<TextBox x:Key="DummyTextBox">
<interactivity:Interaction.Behaviors>
<behaviors:AutoSelectBehavior />
</interactivity:Interaction.Behaviors>
</TextBox>

<controls:ConstrainedBox x:Key="TestConstrainedBox" />
<controls:UniformGrid x:Key="TestUniformGrid" />
<controls:WrapPanel x:Key="TestWrapPanel" />
<ui:NullableBoolExtension x:Key="nullableBool" />

<helpers:ObjectWithNullableBoolProperty x:Key="objectWithNullableBoolProperty" />
</ResourceDictionary>
</muxc:XamlControlsResources.MergedDictionaries>
</muxc:XamlControlsResources>
</Application.Resources>
</Application>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
using System;
using UnitTests.Extensions;
using Windows.ApplicationModel;
Expand Down Expand Up @@ -90,6 +91,17 @@ protected override void OnLaunched(LaunchActivatedEventArgs e)
// TODO: Load state from previously suspended application
}

Logger.LogMessage("Looking for DefaultRichEditBoxStyle...");
if (!Resources.TryGetValue("DefaultRichEditBoxStyle", out var value))
{
Logger.LogMessage("ERROR: Couldn't find DefaultRichEditBoxStyle in WinUI!");
throw new ApplicationException("Couldn't find DefaultRichEditBoxStyle resource.");
}
else
{
Logger.LogMessage("FOUND!");
}

// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
Expand Down
54 changes: 0 additions & 54 deletions UnitTests/UnitTests.UWP/UnitTestApp.xaml

This file was deleted.

25 changes: 14 additions & 11 deletions UnitTests/UnitTests.UWP/UnitTests.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,24 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection">
<Version>3.1.5</Version>
<Version>5.0.2</Version>
</PackageReference>
<PackageReference Include="FluentAssertions">
<Version>5.10.3</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.12</Version>
</PackageReference>
<PackageReference Include="Microsoft.UI.Xaml">
<Version>2.6.1</Version>
</PackageReference>
<PackageReference Include="MSTest.TestAdapter">
<Version>2.1.2</Version>
</PackageReference>
<PackageReference Include="MSTest.TestFramework">
<Version>2.1.2</Version>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="Newtonsoft.Json">
<Version>10.0.3</Version>
<!-- DO NOT UPGRADE THIS PACKAGE FROM 10.0.3, this is used for upgrade testing between 6.1.1 and 7.0.0 for the Object Serializers -->
Expand All @@ -149,6 +153,9 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Behaviors\Test_AutoSelectBehavior.cs" />
<Compile Include="Converters\Test_AdaptiveHeightValueConverter.cs" />
<Compile Include="Converters\Test_TaskResultConverter.cs" />
Expand Down Expand Up @@ -243,17 +250,8 @@
<Compile Include="UI\Extensions\Test_VisualExtensions.cs" />
<Compile Include="UI\Person.cs" />
<Compile Include="UI\Test_AdvancedCollectionView.cs" />
<Compile Include="UnitTestApp.xaml.cs">
<DependentUpon>UnitTestApp.xaml</DependentUpon>
</Compile>
<Compile Include="VisualUITestBase.cs" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="UnitTestApp.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
Expand Down Expand Up @@ -343,7 +341,12 @@
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
</ItemGroup>
<Import Project="..\UnitTests.Shared\UnitTests.Shared.projitems" Label="Shared" />
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
<Version>6.1.2</Version>
</PackageReference>
<!-- Ignored for now, until it supports Xaml Islands
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.2" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
-->
Expand Down

0 comments on commit 794b295

Please sign in to comment.