public async Task ReactInstanceManager_Lifecycle_Simple() { var jsBundleFile = "ms-appx:///Resources/test.js"; ReactInstanceManager manager = null; await DispatcherHelpers.CallOnDispatcherAsync(() => manager = CreateReactInstanceManager(jsBundleFile, LifecycleState.BeforeCreate)); var listener = new LifecycleEventsListener(new LifecycleEventsListener.Step[] { LifecycleEventsListener.Step.Resume, LifecycleEventsListener.Step.LeavingBackground, LifecycleEventsListener.Step.EnteredBackground, LifecycleEventsListener.Step.LeavingBackground, LifecycleEventsListener.Step.EnteredBackground, LifecycleEventsListener.Step.Suspend, LifecycleEventsListener.Step.Resume, LifecycleEventsListener.Step.LeavingBackground, LifecycleEventsListener.Step.EnteredBackground, LifecycleEventsListener.Step.Suspend, }); await DispatcherHelpers.CallOnDispatcherAsync(async() => { var context = await manager.CreateReactContextAsync(CancellationToken.None); context.AddBackgroundEventListener(listener); context.AddLifecycleEventListener(listener); manager.OnResume(null); manager.OnLeavingBackground(); manager.OnEnteredBackground(); manager.OnLeavingBackground(); manager.OnEnteredBackground(); manager.OnSuspend(); manager.OnResume(null); manager.OnLeavingBackground(); manager.OnEnteredBackground(); manager.OnSuspend(); context.RemoveLifecycleEventListener(listener); context.RemoveBackgroundEventListener(listener); }); listener.Dispose(); await DispatcherHelpers.CallOnDispatcherAsync(async() => await DisposeInstanceManager(manager)); }
public async Task ReactInstanceManager_OnBackPressed_NoContext() { var waitHandle = new AutoResetEvent(false); ReactInstanceManager manager = null; await DispatcherHelpers.CallOnDispatcherAsync(() => manager = CreateReactInstanceManager()); await DispatcherHelpers.RunOnDispatcherAsync(() => { manager.OnResume(() => waitHandle.Set()); manager.OnBackPressed(); }); Assert.IsTrue(waitHandle.WaitOne()); await DispatcherHelpers.CallOnDispatcherAsync(async() => await DisposeInstanceManager(manager)); }