From 4a14aa34622be7f3ab5e61ece863ed1d95b84b24 Mon Sep 17 00:00:00 2001 From: Di Da Date: Mon, 2 Dec 2019 19:55:50 -0800 Subject: [PATCH 1/8] Update E2ETest to use ReactApplication --- packages/E2ETest/windows/ReactUWPTestApp.sln | 30 +++++ .../E2ETest/windows/ReactUWPTestApp/App.xaml | 5 +- .../windows/ReactUWPTestApp/App.xaml.cs | 108 ++++++------------ .../ReactUWPTestApp/ReactTestPage.xaml | 20 ---- .../ReactUWPTestApp/ReactTestPage.xaml.cs | 56 --------- .../ReactUWPTestApp/ReactUWPTestApp.csproj | 24 ++-- yarn.lock | 7 +- 7 files changed, 82 insertions(+), 168 deletions(-) delete mode 100644 packages/E2ETest/windows/ReactUWPTestApp/ReactTestPage.xaml delete mode 100644 packages/E2ETest/windows/ReactUWPTestApp/ReactTestPage.xaml.cs diff --git a/packages/E2ETest/windows/ReactUWPTestApp.sln b/packages/E2ETest/windows/ReactUWPTestApp.sln index 328be270c74..72a6b2edf8a 100644 --- a/packages/E2ETest/windows/ReactUWPTestApp.sln +++ b/packages/E2ETest/windows/ReactUWPTestApp.sln @@ -38,11 +38,19 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JSI.Universal", "..\..\..\v EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Common", "..\..\..\vnext\Common\Common.vcxproj", "{FCA38F3C-7C73-4C47-BE4E-32F77FA8538D}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ReactNative", "ReactNative", "{AB7DB37D-898C-4BBC-9F2A-E043EC90C8F3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.ReactNative", "..\..\..\vnext\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj", "{F7D32BD0-2749-483E-9A0D-1635EF7E3136}" +EndProject +Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.ReactNative.SharedManaged", "..\..\..\vnext\Microsoft.ReactNative.SharedManaged\Microsoft.ReactNative.SharedManaged.shproj", "{67A1076F-7790-4203-86EA-4402CCB5E782}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution ..\..\..\vnext\Chakra\Chakra.vcxitems*{2d5d43d9-cffc-4c40-b4cd-02efb4e2742b}*SharedItemsImports = 4 ..\..\..\vnext\Shared\Shared.vcxitems*{2d5d43d9-cffc-4c40-b4cd-02efb4e2742b}*SharedItemsImports = 4 + ..\..\..\vnext\Microsoft.ReactNative.SharedManaged\Microsoft.ReactNative.SharedManaged.projitems*{67a1076f-7790-4203-86ea-4402ccb5e782}*SharedItemsImports = 13 ..\..\..\vnext\JSI\Shared\JSI.Shared.vcxitems*{a62d504a-16b8-41d2-9f19-e2e86019e5e4}*SharedItemsImports = 4 + ..\..\..\vnext\Microsoft.ReactNative.SharedManaged\Microsoft.ReactNative.SharedManaged.projitems*{abbb0407-0e82-486f-94ce-710900fcaadc}*SharedItemsImports = 4 EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM @@ -143,10 +151,32 @@ Global {FCA38F3C-7C73-4C47-BE4E-32F77FA8538D}.Release|x64.Build.0 = Release|x64 {FCA38F3C-7C73-4C47-BE4E-32F77FA8538D}.Release|x86.ActiveCfg = Release|Win32 {FCA38F3C-7C73-4C47-BE4E-32F77FA8538D}.Release|x86.Build.0 = Release|Win32 + {F7D32BD0-2749-483E-9A0D-1635EF7E3136}.Debug|ARM.ActiveCfg = Debug|ARM + {F7D32BD0-2749-483E-9A0D-1635EF7E3136}.Debug|ARM.Build.0 = Debug|ARM + {F7D32BD0-2749-483E-9A0D-1635EF7E3136}.Debug|x64.ActiveCfg = Debug|x64 + {F7D32BD0-2749-483E-9A0D-1635EF7E3136}.Debug|x64.Build.0 = Debug|x64 + {F7D32BD0-2749-483E-9A0D-1635EF7E3136}.Debug|x86.ActiveCfg = Debug|Win32 + {F7D32BD0-2749-483E-9A0D-1635EF7E3136}.Debug|x86.Build.0 = Debug|Win32 + {F7D32BD0-2749-483E-9A0D-1635EF7E3136}.Release|ARM.ActiveCfg = Release|ARM + {F7D32BD0-2749-483E-9A0D-1635EF7E3136}.Release|ARM.Build.0 = Release|ARM + {F7D32BD0-2749-483E-9A0D-1635EF7E3136}.Release|x64.ActiveCfg = Release|x64 + {F7D32BD0-2749-483E-9A0D-1635EF7E3136}.Release|x64.Build.0 = Release|x64 + {F7D32BD0-2749-483E-9A0D-1635EF7E3136}.Release|x86.ActiveCfg = Release|Win32 + {F7D32BD0-2749-483E-9A0D-1635EF7E3136}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {A990658C-CE31-4BCC-976F-0FC6B1AF693D} = {AB7DB37D-898C-4BBC-9F2A-E043EC90C8F3} + {2D5D43D9-CFFC-4C40-B4CD-02EFB4E2742B} = {AB7DB37D-898C-4BBC-9F2A-E043EC90C8F3} + {A9D95A91-4DB7-4F72-BEB6-FE8A5C89BFBD} = {AB7DB37D-898C-4BBC-9F2A-E043EC90C8F3} + {11C084A3-A57C-4296-A679-CAC17B603144} = {AB7DB37D-898C-4BBC-9F2A-E043EC90C8F3} + {A62D504A-16B8-41D2-9F19-E2E86019E5E4} = {AB7DB37D-898C-4BBC-9F2A-E043EC90C8F3} + {FCA38F3C-7C73-4C47-BE4E-32F77FA8538D} = {AB7DB37D-898C-4BBC-9F2A-E043EC90C8F3} + {F7D32BD0-2749-483E-9A0D-1635EF7E3136} = {AB7DB37D-898C-4BBC-9F2A-E043EC90C8F3} + {67A1076F-7790-4203-86EA-4402CCB5E782} = {AB7DB37D-898C-4BBC-9F2A-E043EC90C8F3} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {F5EAF3BA-6B6F-4E81-B5C6-49B30EC0A32E} EndGlobalSection diff --git a/packages/E2ETest/windows/ReactUWPTestApp/App.xaml b/packages/E2ETest/windows/ReactUWPTestApp/App.xaml index b0c429ea36d..b7f59ab4a7a 100644 --- a/packages/E2ETest/windows/ReactUWPTestApp/App.xaml +++ b/packages/E2ETest/windows/ReactUWPTestApp/App.xaml @@ -1,7 +1,8 @@ - - + diff --git a/packages/E2ETest/windows/ReactUWPTestApp/App.xaml.cs b/packages/E2ETest/windows/ReactUWPTestApp/App.xaml.cs index 07f738fd624..16d3716cf67 100644 --- a/packages/E2ETest/windows/ReactUWPTestApp/App.xaml.cs +++ b/packages/E2ETest/windows/ReactUWPTestApp/App.xaml.cs @@ -7,87 +7,53 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; +using Microsoft.ReactNative; +using Windows.UI.Core; namespace ReactUWPTestApp { - /// - /// 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(). + /// Provides application-specific behavior to supplement the default Application class. /// - public App() + sealed partial class App : ReactApplication { - 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) - { - 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) + /// + /// 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() { - //TODO: Load state from previously suspended application + MainComponentName = "ReactUWPTestApp"; + +#if BUNDLE + JavaScriptBundleFile = "index.windows"; + InstanceSettings.UseWebDebugger = false; + InstanceSettings.UseLiveReload = false; +#else + JavaScriptMainModuleName = "app/index"; + InstanceSettings.UseWebDebugger = true; + InstanceSettings.UseLiveReload = true; +#endif + +#if DEBUG + InstanceSettings.EnableDeveloperMenu = true; +#else + InstanceSettings.EnableDeveloperMenu = false; +#endif + + PackageProviders.Add(new Microsoft.ReactNative.Managed.ReactPackageProvider()); // Includes any modules in this project + this.InitializeComponent(); } - // Place the frame in the current Window - Window.Current.Content = rootFrame; - } - - if (e.PrelaunchActivated == false) - { - if (rootFrame.Content == null) + /// + /// 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) { - // 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(ReactTestPage), e.Arguments); + base.OnLaunched(e); + SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = AppViewBackButtonVisibility.Collapsed; } - // Ensure the current window is active - Window.Current.Activate(); - } - } - - /// - /// 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/packages/E2ETest/windows/ReactUWPTestApp/ReactTestPage.xaml b/packages/E2ETest/windows/ReactUWPTestApp/ReactTestPage.xaml deleted file mode 100644 index b5d565c8a09..00000000000 --- a/packages/E2ETest/windows/ReactUWPTestApp/ReactTestPage.xaml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - -