diff --git a/csharp/Facebook.Yoga.Universal.sln b/csharp/Facebook.Yoga.Universal.sln index 8058b4ea..c69bf78a 100644 --- a/csharp/Facebook.Yoga.Universal.sln +++ b/csharp/Facebook.Yoga.Universal.sln @@ -18,8 +18,6 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Facebook.Yoga.Shared.Tests" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NETStandard", "NETStandard", "{DCF7899B-A487-49C0-BCDE-DC088B6750C2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Desktop.Tests", "tests\Facebook.Yoga.Desktop.Tests\Facebook.Yoga.Desktop.Tests.csproj", "{AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{EA552E8A-0245-4614-84D6-DFC5C582004B}" ProjectSection(SolutionItems) = preProject NuGet\Facebook.Yoga.Native.nuspec = NuGet\Facebook.Yoga.Native.nuspec @@ -30,10 +28,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution nuget\NuGetPackageBuilder.ps1 = nuget\NuGetPackageBuilder.ps1 EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Universal.Tests", "tests\Facebook.Yoga.Universal.Tests\Facebook.Yoga.Universal.Tests.csproj", "{0856757B-1671-4E43-AF41-4AEA53988796}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution tests\Facebook.Yoga\Facebook.Yoga.Shared.Tests.projitems*{320eb7b7-ce99-4382-b145-bdd49f33c7b2}*SharedItemsImports = 13 - tests\Facebook.Yoga\Facebook.Yoga.Shared.Tests.projitems*{ac23f444-5545-4196-8b9f-5c1f6b3e7fb3}*SharedItemsImports = 4 EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -76,19 +75,30 @@ Global {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|x64.Build.0 = Release|x64 {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|x86.ActiveCfg = Release|x86 {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD}.Release|x86.Build.0 = Release|x86 - {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}.Debug|ARM.ActiveCfg = Debug|x86 - {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}.Debug|x64.ActiveCfg = Debug|x64 - {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}.Debug|x64.Build.0 = Debug|x64 - {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}.Debug|x86.ActiveCfg = Debug|x86 - {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}.Debug|x86.Build.0 = Debug|x86 - {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}.Release|Any CPU.ActiveCfg = Release|x86 - {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}.Release|ARM.ActiveCfg = Release|x86 - {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}.Release|x64.ActiveCfg = Release|x64 - {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}.Release|x64.Build.0 = Release|x64 - {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}.Release|x86.ActiveCfg = Release|x86 - {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}.Release|x86.Build.0 = Release|x86 + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|ARM.ActiveCfg = Debug|ARM + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|ARM.Build.0 = Debug|ARM + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|ARM.Deploy.0 = Debug|ARM + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|x64.ActiveCfg = Debug|x64 + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|x64.Build.0 = Debug|x64 + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|x64.Deploy.0 = Debug|x64 + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|x86.ActiveCfg = Debug|x86 + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|x86.Build.0 = Debug|x86 + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|x86.Deploy.0 = Debug|x86 + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|Any CPU.Build.0 = Release|Any CPU + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|Any CPU.Deploy.0 = Release|Any CPU + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|ARM.ActiveCfg = Release|ARM + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|ARM.Build.0 = Release|ARM + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|ARM.Deploy.0 = Release|ARM + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|x64.ActiveCfg = Release|x64 + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|x64.Build.0 = Release|x64 + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|x64.Deploy.0 = Release|x64 + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|x86.ActiveCfg = Release|x86 + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|x86.Build.0 = Release|x86 + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|x86.Deploy.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -97,6 +107,6 @@ Global {0446C86B-F47B-4C46-B673-C7AE0CFF35D5} = {51A8E803-C084-431F-9130-F277481C2BB2} {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD} = {DCF7899B-A487-49C0-BCDE-DC088B6750C2} {320EB7B7-CE99-4382-B145-BDD49F33C7B2} = {5289E508-8386-45A1-A12B-258A5899CD45} - {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3} = {5289E508-8386-45A1-A12B-258A5899CD45} + {0856757B-1671-4E43-AF41-4AEA53988796} = {5289E508-8386-45A1-A12B-258A5899CD45} EndGlobalSection EndGlobal diff --git a/csharp/Facebook.Yoga.sln b/csharp/Facebook.Yoga.sln index 8058b4ea..b9553ebc 100644 --- a/csharp/Facebook.Yoga.sln +++ b/csharp/Facebook.Yoga.sln @@ -30,6 +30,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution nuget\NuGetPackageBuilder.ps1 = nuget\NuGetPackageBuilder.ps1 EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Facebook.Yoga.Universal.Tests", "tests\Facebook.Yoga.Universal.Tests\Facebook.Yoga.Universal.Tests.csproj", "{0856757B-1671-4E43-AF41-4AEA53988796}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution tests\Facebook.Yoga\Facebook.Yoga.Shared.Tests.projitems*{320eb7b7-ce99-4382-b145-bdd49f33c7b2}*SharedItemsImports = 13 @@ -55,7 +57,9 @@ Global {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Debug|x86.ActiveCfg = Debug|Win32 {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Debug|x86.Build.0 = Debug|Win32 {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|Any CPU.ActiveCfg = Release|Win32 - {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|ARM.ActiveCfg = Release|Win32 + {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|Any CPU.Build.0 = Release|Win32 + {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|ARM.ActiveCfg = Release|ARM + {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|ARM.Build.0 = Release|ARM {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|x64.ActiveCfg = Release|x64 {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|x64.Build.0 = Release|x64 {0446C86B-F47B-4C46-B673-C7AE0CFF35D5}.Release|x86.ActiveCfg = Release|Win32 @@ -89,6 +93,27 @@ Global {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}.Release|x64.Build.0 = Release|x64 {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}.Release|x86.ActiveCfg = Release|x86 {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3}.Release|x86.Build.0 = Release|x86 + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|Any CPU.ActiveCfg = Debug|x86 + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|ARM.ActiveCfg = Debug|ARM + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|ARM.Build.0 = Debug|ARM + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|ARM.Deploy.0 = Debug|ARM + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|x64.ActiveCfg = Debug|x64 + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|x64.Build.0 = Debug|x64 + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|x64.Deploy.0 = Debug|x64 + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|x86.ActiveCfg = Debug|x86 + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|x86.Build.0 = Debug|x86 + {0856757B-1671-4E43-AF41-4AEA53988796}.Debug|x86.Deploy.0 = Debug|x86 + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|Any CPU.ActiveCfg = Release|x86 + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|Any CPU.Build.0 = Release|x86 + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|ARM.ActiveCfg = Release|ARM + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|ARM.Build.0 = Release|ARM + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|ARM.Deploy.0 = Release|ARM + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|x64.ActiveCfg = Release|x64 + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|x64.Build.0 = Release|x64 + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|x64.Deploy.0 = Release|x64 + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|x86.ActiveCfg = Release|x86 + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|x86.Build.0 = Release|x86 + {0856757B-1671-4E43-AF41-4AEA53988796}.Release|x86.Deploy.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -98,5 +123,6 @@ Global {3AACE384-FDEC-4D91-A3B2-EEB21B46C9AD} = {DCF7899B-A487-49C0-BCDE-DC088B6750C2} {320EB7B7-CE99-4382-B145-BDD49F33C7B2} = {5289E508-8386-45A1-A12B-258A5899CD45} {AC23F444-5545-4196-8B9F-5C1F6B3E7FB3} = {5289E508-8386-45A1-A12B-258A5899CD45} + {0856757B-1671-4E43-AF41-4AEA53988796} = {5289E508-8386-45A1-A12B-258A5899CD45} EndGlobalSection EndGlobal diff --git a/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/LockScreenLogo.scale-200.png b/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 00000000..735f57ad Binary files /dev/null and b/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/LockScreenLogo.scale-200.png differ diff --git a/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/SplashScreen.scale-200.png b/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/SplashScreen.scale-200.png new file mode 100644 index 00000000..023e7f1f Binary files /dev/null and b/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/SplashScreen.scale-200.png differ diff --git a/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/Square150x150Logo.scale-200.png b/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 00000000..af49fec1 Binary files /dev/null and b/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/Square150x150Logo.scale-200.png differ diff --git a/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/Square44x44Logo.scale-200.png b/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 00000000..ce342a2e Binary files /dev/null and b/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/Square44x44Logo.scale-200.png differ diff --git a/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 00000000..f6c02ce9 Binary files /dev/null and b/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/StoreLogo.png b/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/StoreLogo.png new file mode 100644 index 00000000..7385b56c Binary files /dev/null and b/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/StoreLogo.png differ diff --git a/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/Wide310x150Logo.scale-200.png b/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 00000000..288995b3 Binary files /dev/null and b/csharp/tests/Facebook.Yoga.Universal.Tests/Assets/Wide310x150Logo.scale-200.png differ diff --git a/csharp/tests/Facebook.Yoga.Universal.Tests/Facebook.Yoga.Universal.Tests.csproj b/csharp/tests/Facebook.Yoga.Universal.Tests/Facebook.Yoga.Universal.Tests.csproj new file mode 100644 index 00000000..de5f710d --- /dev/null +++ b/csharp/tests/Facebook.Yoga.Universal.Tests/Facebook.Yoga.Universal.Tests.csproj @@ -0,0 +1,146 @@ + + + + + Debug + x86 + {0856757B-1671-4E43-AF41-4AEA53988796} + AppContainerExe + Properties + Facebook.Yoga.Universal.Tests + Facebook.Yoga.Universal.Tests + en-US + UAP + 10.0.10586.0 + 10.0.10240.0 + 14 + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Facebook.Yoga.Universal.Tests_TemporaryKey.pfx + 14.0 + + + true + bin\x86\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x86 + false + prompt + true + + + bin\x86\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x86 + false + prompt + true + true + + + true + bin\ARM\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + ARM + false + prompt + true + + + bin\ARM\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + ARM + false + prompt + true + true + + + true + bin\x64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x64 + false + prompt + true + + + bin\x64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x64 + false + prompt + true + true + + + + + + + + + + + UnitTestApp.xaml + + + + + + MSBuild:Compile + Designer + + + + + Designer + + + + + + + + + + + + + + + + {3aace384-fdec-4d91-a3b2-eeb21b46c9ad} + Facebook.Yoga + + + + + + + 14.0 + + + + + + This project references a native interop target that is missing. The missing build target is {0}. + + + + \ No newline at end of file diff --git a/csharp/tests/Facebook.Yoga.Universal.Tests/Package.appxmanifest b/csharp/tests/Facebook.Yoga.Universal.Tests/Package.appxmanifest new file mode 100644 index 00000000..a12355dc --- /dev/null +++ b/csharp/tests/Facebook.Yoga.Universal.Tests/Package.appxmanifest @@ -0,0 +1,45 @@ + + + + + + + + + Facebook.Yoga.Universal.Tests + blue + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/csharp/tests/Facebook.Yoga.Universal.Tests/Properties/AssemblyInfo.cs b/csharp/tests/Facebook.Yoga.Universal.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..719f6a3c --- /dev/null +++ b/csharp/tests/Facebook.Yoga.Universal.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,30 @@ +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("Facebook.Yoga.Universal.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Facebook.Yoga.Universal.Tests")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: AssemblyMetadata("TargetPlatform","UAP")] + +// 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 Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/csharp/tests/Facebook.Yoga.Universal.Tests/Properties/UnitTestApp.rd.xml b/csharp/tests/Facebook.Yoga.Universal.Tests/Properties/UnitTestApp.rd.xml new file mode 100644 index 00000000..efee59d2 --- /dev/null +++ b/csharp/tests/Facebook.Yoga.Universal.Tests/Properties/UnitTestApp.rd.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/csharp/tests/Facebook.Yoga.Universal.Tests/UnitTestApp.xaml b/csharp/tests/Facebook.Yoga.Universal.Tests/UnitTestApp.xaml new file mode 100644 index 00000000..d8e15f82 --- /dev/null +++ b/csharp/tests/Facebook.Yoga.Universal.Tests/UnitTestApp.xaml @@ -0,0 +1,8 @@ + + + diff --git a/csharp/tests/Facebook.Yoga.Universal.Tests/UnitTestApp.xaml.cs b/csharp/tests/Facebook.Yoga.Universal.Tests/UnitTestApp.xaml.cs new file mode 100644 index 00000000..b9564ac8 --- /dev/null +++ b/csharp/tests/Facebook.Yoga.Universal.Tests/UnitTestApp.xaml.cs @@ -0,0 +1,102 @@ +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; + +namespace Facebook.Yoga.Universal.Tests +{ + /// + /// Provides application-specific behavior to supplement the default Application class. + /// + sealed partial class App : Application + { + /// + /// 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(). + /// + public App() + { + this.InitializeComponent(); + this.Suspending += OnSuspending; + } + + /// + /// 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. + /// + /// Details about the launch request and process. + 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; + } + + Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI(); + + // Ensure the current window is active + Window.Current.Activate(); + + Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(e.Arguments); + } + + /// + /// Invoked when Navigation to a certain page fails + /// + /// The Frame which failed navigation + /// Details about the navigation failure + void OnNavigationFailed(object sender, NavigationFailedEventArgs e) + { + throw new Exception("Failed to load Page " + e.SourcePageType.FullName); + } + + /// + /// 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. + /// + /// The source of the suspend request. + /// Details about the suspend request. + private void OnSuspending(object sender, SuspendingEventArgs e) + { + var deferral = e.SuspendingOperation.GetDeferral(); + //TODO: Save application state and stop any background activity + deferral.Complete(); + } + } +} diff --git a/csharp/tests/Facebook.Yoga.Universal.Tests/YogaNodeTest.cs b/csharp/tests/Facebook.Yoga.Universal.Tests/YogaNodeTest.cs new file mode 100644 index 00000000..1030fe10 --- /dev/null +++ b/csharp/tests/Facebook.Yoga.Universal.Tests/YogaNodeTest.cs @@ -0,0 +1,417 @@ +using System; +using Microsoft.VisualStudio.TestPlatform.UnitTestFramework; +using Facebook.Yoga; + +namespace Facebook.Yoga.Universal.Tests +{ + [TestClass] + public class YogaNodeTest + { + [TestMethod] + public void TestAddChildGetParent() + { + YogaNode parent = new YogaNode(); + YogaNode child = new YogaNode(); + + Assert.IsNull(child.Parent); + Assert.AreEqual(0, parent.Count); + + parent.Insert(0, child); + + Assert.AreEqual(1, parent.Count); + Assert.AreEqual(child, parent[0]); + Assert.AreEqual(parent, child.Parent); + + parent.RemoveAt(0); + + Assert.IsNull(child.Parent); + Assert.AreEqual(0, parent.Count); + } + + [TestMethod] + public void TestChildren() + { + YogaNode parent = new YogaNode(); + foreach (YogaNode node in parent) + { + Assert.Fail(node.ToString()); + } + + YogaNode child0 = new YogaNode(); + Assert.AreEqual(-1, parent.IndexOf(child0)); + parent.Insert(0, child0); + foreach (YogaNode node in parent) + { + Assert.AreEqual(0, parent.IndexOf(node)); + } + + YogaNode child1 = new YogaNode(); + parent.Insert(1, child1); + int index = 0; + foreach (YogaNode node in parent) + { + Assert.AreEqual(index++, parent.IndexOf(node)); + } + + parent.RemoveAt(0); + Assert.AreEqual(-1, parent.IndexOf(child0)); + Assert.AreEqual(0, parent.IndexOf(child1)); + + parent.Clear(); + Assert.AreEqual(0, parent.Count); + + parent.Clear(); + Assert.AreEqual(0, parent.Count); + } + + [TestMethod] + public void TestRemoveAtFromEmpty() + { + YogaNode parent = new YogaNode(); + + try + { + parent.RemoveAt(0); + } + catch (System.NullReferenceException) + { + return; + } + + Assert.Fail("Excepted exception of type 'System.NullReferenceException'."); + } + + [TestMethod] + public void TestRemoveAtOutOfRange() + { + YogaNode parent = new YogaNode(); + YogaNode child = new YogaNode(); + parent.Insert(0, child); + + try + { + parent.RemoveAt(1); + } + catch (System.ArgumentOutOfRangeException) + { + return; + } + + Assert.Fail("Excepted exception of type 'System.ArgumentOutOfRangeException'."); + } + + [TestMethod] + public void TestCannotAddChildToMultipleParents() + { + YogaNode parent1 = new YogaNode(); + YogaNode parent2 = new YogaNode(); + YogaNode child = new YogaNode(); + + parent1.Insert(0, child); + + try + { + parent2.Insert(0, child); + } + catch (System.InvalidOperationException) + { + return; + } + + Assert.Fail("Excepted exception of type 'System.InvalidOperationException'."); + } + + [TestMethod] + public void TestReset() + { + int instanceCount = YogaNode.GetInstanceCount(); + YogaNode node = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); + node.Reset(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); + } + + [TestMethod] + public void TestResetParent() + { + YogaNode parent = new YogaNode(); + YogaNode child = new YogaNode(); + parent.Insert(0, child); + + try + { + parent.Reset(); + } + catch (System.InvalidOperationException) + { + return; + } + + Assert.Fail("Excepted exception of type 'System.InvalidOperationException'."); + } + + [TestMethod] + public void TestResetChild() + { + YogaNode parent = new YogaNode(); + YogaNode child = new YogaNode(); + parent.Insert(0, child); + + try + { + child.Reset(); + } + catch (System.InvalidOperationException) + { + return; + } + + Assert.Fail("Excepted exception of type 'System.InvalidOperationException'."); + } + + [TestMethod] + public void TestClear() + { + int instanceCount = YogaNode.GetInstanceCount(); + YogaNode parent = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); + YogaNode child = new YogaNode(); + Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount()); + parent.Insert(0, child); + Assert.AreEqual(1, parent.Count); + Assert.AreEqual(parent, child.Parent); + parent.Clear(); + Assert.AreEqual(0, parent.Count); + Assert.IsNull(child.Parent); + Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount()); + } + + [TestMethod] + public void TestMeasureFunc() + { + YogaNode node = new YogaNode(); + node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { + return MeasureOutput.Make(100, 150); + }); + node.CalculateLayout(); + Assert.AreEqual(100, node.LayoutWidth); + Assert.AreEqual(150, node.LayoutHeight); + } + + [TestMethod] + public void TestMeasureFuncWithFloat() + { + YogaNode node = new YogaNode(); + node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { + return MeasureOutput.Make(123.4f, 81.7f); + }); + node.CalculateLayout(); + Assert.AreEqual(123, node.LayoutWidth); + Assert.AreEqual(81, node.LayoutHeight); + } + + [TestMethod] + public void TestChildWithMeasureFunc() + { + YogaNode node = new YogaNode(); + + node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { + return MeasureOutput.Make(100, 150); + }); + YogaNode child = new YogaNode(); + + try + { + node.Insert(0, child); + } + catch (System.InvalidOperationException) + { + return; + } + + Assert.Fail("Excepted exception of type 'System.InvalidOperationException'."); + } + + [TestMethod] + public void TestMeasureFuncWithChild() + { + YogaNode node = new YogaNode(); + YogaNode child = new YogaNode(); + node.Insert(0, child); + + try + { + node.SetMeasureFunction((_, width, widthMode, height, heightMode) => { + return MeasureOutput.Make(100, 150); + }); + } + catch (System.InvalidOperationException) + { + return; + } + + Assert.Fail("Excepted exception of type 'System.InvalidOperationException'."); + } + + [TestMethod] + public void TestPrint() + { + YogaNode parent = new YogaNode(); + parent.Width = 100; + parent.Height = 120; + YogaNode child0 = new YogaNode(); + child0.Width = 30; + child0.Height = 40; + YogaNode child1 = new YogaNode(); + child1.Width = 35; + child1.Height = 45; + parent.Insert(0, child0); + parent.Insert(0, child1); + parent.CalculateLayout(); + Assert.AreEqual(parent.Print(), "{layout: {width: 100, height: 120, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 100, height: 120, children: [\n {layout: {width: 35, height: 45, top: 0, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 35, height: 45, },\n {layout: {width: 30, height: 40, top: 45, left: 0}, flexDirection: 'column', alignItems: 'stretch', flexGrow: 0, flexShrink: 0, overflow: 'visible', width: 30, height: 40, },\n]},\n"); + } + + [TestMethod] + public void TestCopyStyle() + { + YogaNode node0 = new YogaNode(); + Assert.IsTrue(YogaConstants.IsUndefined(node0.MaxHeight)); + + YogaNode node1 = new YogaNode(); + node1.MaxHeight = 100; + + node0.CopyStyle(node1); + Assert.AreEqual(100, node0.MaxHeight); + } + +#if !UNITY_EDITOR + private void ForceGC() + { + GC.Collect(GC.MaxGeneration); + GC.WaitForPendingFinalizers(); + } + + [TestMethod] + public void TestDestructor() + { + ForceGC(); + int instanceCount = YogaNode.GetInstanceCount(); + TestDestructorForGC(instanceCount); + ForceGC(); + Assert.AreEqual(instanceCount, YogaNode.GetInstanceCount()); + } + + private void TestDestructorForGC(int instanceCount) + { + YogaNode node = new YogaNode(); + Assert.IsNotNull(node); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); + node = null; + } + + [TestMethod] + public void TestDestructorWithChildren() + { + ForceGC(); + int instanceCount = YogaNode.GetInstanceCount(); + TestDestructorWithChildrenForGC1(instanceCount); + ForceGC(); + Assert.AreEqual(instanceCount, YogaNode.GetInstanceCount()); + } + + private void TestDestructorWithChildrenForGC1(int instanceCount) + { + YogaNode node = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); + + TestDestructorWithChildrenForGC2(node, instanceCount + 1); + ForceGC(); + Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount()); + + TestDestructorWithChildrenForGC2(node, instanceCount + 2); + ForceGC(); + Assert.AreEqual(instanceCount + 3, YogaNode.GetInstanceCount()); + + node = null; + } + + private void TestDestructorWithChildrenForGC2(YogaNode parent, int instanceCount) + { + YogaNode child = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); + + parent.Insert(0, child); + child = null; + } + + [TestMethod] + public void TestParentDestructor() + { + ForceGC(); + int instanceCount = YogaNode.GetInstanceCount(); + YogaNode child = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); + + TestParentDestructorForGC(child, instanceCount + 1); + ForceGC(); + + Assert.IsNull(child.Parent); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); + } + + private void TestParentDestructorForGC(YogaNode child, int instanceCount) + { + YogaNode parent = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); + parent.Insert(0, child); + } + + [TestMethod] + public void TestClearWithChildDestructor() + { + ForceGC(); + int instanceCount = YogaNode.GetInstanceCount(); + YogaNode node = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); + TestClearWithChildDestructorForGC(node, instanceCount + 1); + ForceGC(); + Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount()); + node.Clear(); + Assert.AreEqual(0, node.Count); + ForceGC(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); + } + + private void TestClearWithChildDestructorForGC(YogaNode parent, int instanceCount) + { + YogaNode child = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); + parent.Insert(0, child); + } + + [TestMethod] + public void TestMeasureFuncWithDestructor() + { + ForceGC(); + int instanceCount = YogaNode.GetInstanceCount(); + YogaNode parent = new YogaNode(); + Assert.AreEqual(instanceCount + 1, YogaNode.GetInstanceCount()); + TestMeasureFuncWithDestructorForGC(parent); + ForceGC(); + Assert.AreEqual(instanceCount + 2, YogaNode.GetInstanceCount()); + parent.CalculateLayout(); + Assert.AreEqual(120, (int)parent.LayoutWidth); + Assert.AreEqual(130, (int)parent.LayoutHeight); + } + + private void TestMeasureFuncWithDestructorForGC(YogaNode parent) + { + YogaNode child = new YogaNode(); + parent.Insert(0, child); + child.SetMeasureFunction((_, width, widthMode, height, heightMode) => { + return MeasureOutput.Make(120, 130); + }); + } +#endif + } +} \ No newline at end of file diff --git a/csharp/tests/Facebook.Yoga.Universal.Tests/project.json b/csharp/tests/Facebook.Yoga.Universal.Tests/project.json new file mode 100644 index 00000000..32d92747 --- /dev/null +++ b/csharp/tests/Facebook.Yoga.Universal.Tests/project.json @@ -0,0 +1,16 @@ +{ + "dependencies": { + "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2" + }, + "frameworks": { + "uap10.0": {} + }, + "runtimes": { + "win10-arm": {}, + "win10-arm-aot": {}, + "win10-x86": {}, + "win10-x86-aot": {}, + "win10-x64": {}, + "win10-x64-aot": {} + } +} \ No newline at end of file