diff --git a/tests/app/testRunner.ts b/tests/app/testRunner.ts index a0947ed32..1298d5a75 100644 --- a/tests/app/testRunner.ts +++ b/tests/app/testRunner.ts @@ -226,7 +226,7 @@ import * as cssAnimationTests from "./ui/animation/css-animation-tests"; allTests["CSS-ANIMATION"] = cssAnimationTests; import * as transitionTests from "./navigation/transition-tests"; -allTests["TANSITIONS"] = transitionTests; +allTests["TRANSITIONS"] = transitionTests; import * as searchBarTests from "./ui/search-bar/search-bar-tests"; allTests["SEARCH-BAR"] = searchBarTests; diff --git a/tests/app/ui/page/page-tests-common.ts b/tests/app/ui/page/page-tests-common.ts index 4b8ee7569..3ed63cb6f 100644 --- a/tests/app/ui/page/page-tests-common.ts +++ b/tests/app/ui/page/page-tests-common.ts @@ -19,7 +19,7 @@ import * as helper from "../helper"; import { GridLayout } from "tns-core-modules/ui/layouts/grid-layout"; import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout"; import { View, PercentLength, Observable, unsetValue, EventData, isIOS } from "tns-core-modules/ui/core/view"; -import { Frame } from "tns-core-modules/ui/frame"; +import { Frame, stack } from "tns-core-modules/ui/frame"; import { Label } from "tns-core-modules/ui/label"; import { Color } from "tns-core-modules/color"; @@ -548,6 +548,7 @@ export function test_WhenModalPageShownHostPageNavigationEventsShouldNotBeRaised let ready = false; const modalCloseCallback = function (returnValue: any) { + TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!"); ready = true; } @@ -567,6 +568,10 @@ export function test_WhenModalPageShownHostPageNavigationEventsShouldNotBeRaised hostNavigatedFromCount++; }; + const modalPageShownModallyEventHandler = function() { + TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!"); + } + const hostNavigatedToEventHandler2 = function(args: NavigatedData) { const page = args.object; page.off(Page.navigatedToEvent, hostNavigatedToEventHandler2); @@ -576,7 +581,11 @@ export function test_WhenModalPageShownHostPageNavigationEventsShouldNotBeRaised moduleName: basePath + "modal-page" }; + TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!"); + const modalPage = createViewFromEntry(entry) as Page; + modalPage.on(Frame.shownModallyEvent, modalPageShownModallyEventHandler); + page.showModal(modalPage, {}, modalCloseCallback, false, false); } @@ -694,6 +703,7 @@ export function test_WhenModalFrameShownModalEventsRaisedOnRootModalFrame() { let ready = false; const modalCloseCallback = function (returnValue: any) { + TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!"); ready = true; } @@ -703,6 +713,7 @@ export function test_WhenModalFrameShownModalEventsRaisedOnRootModalFrame() { const modalFrameShownModallyEventHandler = function(args: ShownModallyData) { shownModallyCount++; + TKUnit.assertEqual(stack().length, 2, "Host and modal frame should be instantiated at this point!"); args.closeCallback("return value"); } @@ -720,11 +731,15 @@ export function test_WhenModalFrameShownModalEventsRaisedOnRootModalFrame() { const modalPage = createViewFromEntry(entry) as Page; + TKUnit.assertEqual(stack().length, 1, "Single frame should be instantiated at this point!"); + modalFrame = new Frame(); modalFrame.on(Frame.showingModallyEvent, modalFrameShowingModallyEventHandler); modalFrame.on(Frame.shownModallyEvent, modalFrameShownModallyEventHandler); modalFrame.navigate(() => modalPage); + TKUnit.assertEqual(stack().length, 2, "Host and modal frame should be instantiated at this point!"); + page.showModal(modalFrame, {}, modalCloseCallback, false, false); } diff --git a/tns-core-modules/ui/core/view-base/view-base.d.ts b/tns-core-modules/ui/core/view-base/view-base.d.ts index 10f9393c0..c28482d6e 100644 --- a/tns-core-modules/ui/core/view-base/view-base.d.ts +++ b/tns-core-modules/ui/core/view-base/view-base.d.ts @@ -263,6 +263,10 @@ export abstract class ViewBase extends Observable { */ public _removeViewCore(view: ViewBase): void; public _parentChanged(oldParent: ViewBase): void; + /** + * Method is intended to be overridden by inheritors and used as "protected" + */ + public _dialogClosed(): void; _domId: number; diff --git a/tns-core-modules/ui/core/view-base/view-base.ts b/tns-core-modules/ui/core/view-base/view-base.ts index 8269a8d02..11f4e809c 100644 --- a/tns-core-modules/ui/core/view-base/view-base.ts +++ b/tns-core-modules/ui/core/view-base/view-base.ts @@ -956,6 +956,10 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition parent.closeModal(); } } + + public _dialogClosed(): void { + return; + } } ViewBase.prototype.isCollapsed = false; diff --git a/tns-core-modules/ui/core/view/view-common.ts b/tns-core-modules/ui/core/view/view-common.ts index 6751e13bb..f9c023863 100644 --- a/tns-core-modules/ui/core/view/view-common.ts +++ b/tns-core-modules/ui/core/view/view-common.ts @@ -251,10 +251,12 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition { const modalIndex = _rootModalViews.indexOf(that); _rootModalViews.splice(modalIndex); that._hideNativeModalView(parent); - that._modalParent = null + that._modalParent = null; that._modalContext = null; that._closeModalCallback = null; + that._dialogClosed(); parent._modal = null; + if (typeof closeCallback === "function") { closeCallback.apply(undefined, arguments); } diff --git a/tns-core-modules/ui/frame/frame-common.ts b/tns-core-modules/ui/frame/frame-common.ts index 3e43cfb17..7ac8eff81 100644 --- a/tns-core-modules/ui/frame/frame-common.ts +++ b/tns-core-modules/ui/frame/frame-common.ts @@ -58,18 +58,10 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition { @profile public onLoaded() { super.onLoaded(); - - this._pushInFrameStack(); + this._processNextNavigationEntry(); } - @profile - public onUnloaded() { - super.onUnloaded(); - - this._popFromFrameStack(); - } - public canGoBack(): boolean { let backstack = this._backStack.length; let previousForwardNotInBackstack = false; @@ -192,6 +184,8 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition { // app.on(app.orientationChangedEvent, (data) => this._onOrientationChanged()); // } + this._pushInFrameStack(); + const backstackEntry: BackstackEntry = { entry: entry, resolvedPage: page, @@ -430,6 +424,10 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition { this._isInFrameStack = false; } + public _dialogClosed(): void { + this._popFromFrameStack(); + } + get _childrenCount(): number { if (this.currentPage) { return 1; diff --git a/tns-core-modules/ui/frame/frame.android.ts b/tns-core-modules/ui/frame/frame.android.ts index ccaa53e13..56c38d545 100644 --- a/tns-core-modules/ui/frame/frame.android.ts +++ b/tns-core-modules/ui/frame/frame.android.ts @@ -243,7 +243,9 @@ export class Frame extends FrameBase { if (this.canGoBack()) { this.goBack(); return true; - } else if (!this.navigationQueueIsEmpty()) { + } + + if (!this.navigationQueueIsEmpty()) { const manager = this._getFragmentManager(); if (manager) { manager.executePendingTransactions();