From 5e654ce96b6292993aab57c730a2e6d567206182 Mon Sep 17 00:00:00 2001 From: Rossen Hristov Date: Thu, 1 Oct 2015 09:36:58 +0300 Subject: [PATCH 1/3] Fixed the navigation tests. --- apps/tests/navigation-tests.ts | 57 +++++++++++++++++++--------------- apps/tests/testRunner.ts | 4 ++- ui/frame/frame-common.ts | 1 - ui/frame/frame.android.ts | 12 +------ 4 files changed, 36 insertions(+), 38 deletions(-) diff --git a/apps/tests/navigation-tests.ts b/apps/tests/navigation-tests.ts index bf7bc4385..371191d3b 100644 --- a/apps/tests/navigation-tests.ts +++ b/apps/tests/navigation-tests.ts @@ -3,7 +3,7 @@ import pageModule = require("ui/page"); import frame = require("ui/frame"); export var test_backstackVisible = function() { - var pageFactory = function (): pageModule.Page { + var pageFactory = function(): pageModule.Page { return new pageModule.Page(); }; @@ -32,34 +32,41 @@ export var test_backstackVisible = function() { } // Clearing the history messes up the tests app. -//export var test_ClearHistory = function () { -// var pageFactory = function (): pageModule.Page { -// return new pageModule.Page(); -// }; +export var test_ClearHistory = function () { + var pageFactory = function(): pageModule.Page { + return new pageModule.Page(); + }; -// var mainTestPage = frame.topmost().currentPage; -// var currentPage: pageModule.Page; + var mainTestPage = frame.topmost().currentPage; + var mainPageFactory = function(): pageModule.Page { + return mainTestPage; + }; -// currentPage = frame.topmost().currentPage; -// frame.topmost().navigate({ create: pageFactory }); -// TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== currentPage; }); + var currentPage: pageModule.Page; -// currentPage = frame.topmost().currentPage; -// frame.topmost().navigate({ create: pageFactory }); -// TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== currentPage; }); + currentPage = frame.topmost().currentPage; + frame.topmost().navigate({ create: pageFactory }); + TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== currentPage; }); -// currentPage = frame.topmost().currentPage; -// frame.topmost().navigate({ create: pageFactory }); -// TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== currentPage; }); + currentPage = frame.topmost().currentPage; + frame.topmost().navigate({ create: pageFactory }); + TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== currentPage; }); -// TKUnit.assert(frame.topmost().canGoBack(), "Frame should be able to go back."); -// TKUnit.assert(frame.topmost().backStack.length === 3, "Back stack should have 3 entries."); + currentPage = frame.topmost().currentPage; + frame.topmost().navigate({ create: pageFactory }); + TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== currentPage; }); -// // Navigate with clear history. -// currentPage = frame.topmost().currentPage; -// frame.topmost().navigate({ create: pageFactory, clearHistory: true }); -// TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== currentPage; }); + TKUnit.assert(frame.topmost().canGoBack(), "Frame should be able to go back."); + TKUnit.assert(frame.topmost().backStack.length === 3, "Back stack should have 3 entries."); -// TKUnit.assert(!frame.topmost().canGoBack(), "Frame should NOT be able to go back."); -// TKUnit.assert(frame.topmost().backStack.length === 0, "Back stack should have 0 entries."); -//} \ No newline at end of file + // Navigate with clear history. + currentPage = frame.topmost().currentPage; + frame.topmost().navigate({ create: pageFactory, clearHistory: true }); + TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== currentPage; }); + + TKUnit.assert(!frame.topmost().canGoBack(), "Frame should NOT be able to go back."); + TKUnit.assert(frame.topmost().backStack.length === 0, "Back stack should have 0 entries."); + + frame.topmost().navigate({ create: mainPageFactory }); + TKUnit.waitUntilReady(() => { return frame.topmost().currentPage === mainTestPage; }); +} \ No newline at end of file diff --git a/apps/tests/testRunner.ts b/apps/tests/testRunner.ts index 1e84be3b6..b14b44bc1 100644 --- a/apps/tests/testRunner.ts +++ b/apps/tests/testRunner.ts @@ -80,13 +80,15 @@ allTests["REPEATER"] = require("./ui/repeater/repeater-tests"); allTests["SEARCH-BAR"] = require('./ui/search-bar/search-bar-tests'); allTests["CONNECTIVITY"] = require("./connectivity-tests"); allTests["ANIMATION"] = require("./ui/animation/animation-tests"); -//allTests["NAVIGATION"] = require("./navigation-tests"); allTests["SEGMENTED-BAR"] = require("./ui/segmented-bar/segmented-bar-tests"); if (!isRunningOnEmulator()) { allTests["LOCATION"] = require("./location-tests"); } +// Navigation tests should always be last. +allTests["NAVIGATION"] = require("./navigation-tests"); + import utils = require("utils/utils"); var density = utils.layout.getDisplayDensity(); utils.layout.getDisplayDensity = function () { diff --git a/ui/frame/frame-common.ts b/ui/frame/frame-common.ts index 0d2285dd2..e3eff59fc 100644 --- a/ui/frame/frame-common.ts +++ b/ui/frame/frame-common.ts @@ -184,7 +184,6 @@ export class Frame extends view.CustomLayoutView implements definition.Frame { var entry = this._navigationQueue[0].entry; var currentNavigationPage = entry.resolvedPage; if (page !== currentNavigationPage) { - console.trace(); throw new Error(`Corrupted navigation stack; page: ${page.id}; currentNavigationPage: ${currentNavigationPage.id}`); } diff --git a/ui/frame/frame.android.ts b/ui/frame/frame.android.ts index 52f18b269..4a2c9288f 100644 --- a/ui/frame/frame.android.ts +++ b/ui/frame/frame.android.ts @@ -216,9 +216,6 @@ export class Frame extends frameCommon.Frame { public _navigateCore(backstackEntry: definition.BackstackEntry) { trace.write(`_navigateCore; id: ${backstackEntry.resolvedPage.id}; backstackVisible: ${this._isEntryBackstackVisible(backstackEntry)}; clearHistory: ${backstackEntry.entry.clearHistory};`, trace.categories.Navigation); - //this._printFrameBackStack(); - //this._printNativeBackStack(); - var activity = this._android.activity; if (!activity) { // We do not have an Activity yet associated. In this case we have two execution paths: @@ -300,9 +297,7 @@ export class Frame extends frameCommon.Frame { } // Add to backStack if needed. - if (this.backStack.length > 0 && - this._currentEntry && - this._isEntryBackstackVisible(this._currentEntry)) { + if (this.backStack.length > 0) { // We add each entry in the backstack to avoid the "Stack corrupted" mismatch var backstackTag = this._currentEntry[BACKSTACK_TAG]; fragmentTransaction.addToBackStack(backstackTag); @@ -327,11 +322,6 @@ export class Frame extends frameCommon.Frame { fragmentTransaction.commit(); trace.write("fragmentTransaction.commit();", trace.categories.NativeLifecycle); - - //setTimeout(() => { - // this._printFrameBackStack(); - // this._printNativeBackStack(); - //}, 100); } public _goBackCore(backstackEntry: definition.BackstackEntry) { From 16fecf19dd9e59e1a5814d3e8a9ed25b0c508b76 Mon Sep 17 00:00:00 2001 From: Rossen Hristov Date: Thu, 1 Oct 2015 16:11:11 +0300 Subject: [PATCH 2/3] Removed a test. --- apps/tests/navigation-tests.ts | 58 +++++++++++++++++----------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/apps/tests/navigation-tests.ts b/apps/tests/navigation-tests.ts index 371191d3b..999dc8ab2 100644 --- a/apps/tests/navigation-tests.ts +++ b/apps/tests/navigation-tests.ts @@ -32,41 +32,41 @@ export var test_backstackVisible = function() { } // Clearing the history messes up the tests app. -export var test_ClearHistory = function () { - var pageFactory = function(): pageModule.Page { - return new pageModule.Page(); - }; +//export var test_ClearHistory = function () { +// var pageFactory = function(): pageModule.Page { +// return new pageModule.Page(); +// }; - var mainTestPage = frame.topmost().currentPage; - var mainPageFactory = function(): pageModule.Page { - return mainTestPage; - }; +// var mainTestPage = frame.topmost().currentPage; +// var mainPageFactory = function(): pageModule.Page { +// return mainTestPage; +// }; - var currentPage: pageModule.Page; +// var currentPage: pageModule.Page; - currentPage = frame.topmost().currentPage; - frame.topmost().navigate({ create: pageFactory }); - TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== currentPage; }); +// currentPage = frame.topmost().currentPage; +// frame.topmost().navigate({ create: pageFactory }); +// TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== currentPage; }); - currentPage = frame.topmost().currentPage; - frame.topmost().navigate({ create: pageFactory }); - TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== currentPage; }); +// currentPage = frame.topmost().currentPage; +// frame.topmost().navigate({ create: pageFactory }); +// TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== currentPage; }); - currentPage = frame.topmost().currentPage; - frame.topmost().navigate({ create: pageFactory }); - TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== currentPage; }); +// currentPage = frame.topmost().currentPage; +// frame.topmost().navigate({ create: pageFactory }); +// TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== currentPage; }); - TKUnit.assert(frame.topmost().canGoBack(), "Frame should be able to go back."); - TKUnit.assert(frame.topmost().backStack.length === 3, "Back stack should have 3 entries."); +// TKUnit.assert(frame.topmost().canGoBack(), "Frame should be able to go back."); +// TKUnit.assert(frame.topmost().backStack.length === 3, "Back stack should have 3 entries."); - // Navigate with clear history. - currentPage = frame.topmost().currentPage; - frame.topmost().navigate({ create: pageFactory, clearHistory: true }); - TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== currentPage; }); +// // Navigate with clear history. +// currentPage = frame.topmost().currentPage; +// frame.topmost().navigate({ create: pageFactory, clearHistory: true }); +// TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== currentPage; }); - TKUnit.assert(!frame.topmost().canGoBack(), "Frame should NOT be able to go back."); - TKUnit.assert(frame.topmost().backStack.length === 0, "Back stack should have 0 entries."); +// TKUnit.assert(!frame.topmost().canGoBack(), "Frame should NOT be able to go back."); +// TKUnit.assert(frame.topmost().backStack.length === 0, "Back stack should have 0 entries."); - frame.topmost().navigate({ create: mainPageFactory }); - TKUnit.waitUntilReady(() => { return frame.topmost().currentPage === mainTestPage; }); -} \ No newline at end of file +// frame.topmost().navigate({ create: mainPageFactory }); +// TKUnit.waitUntilReady(() => { return frame.topmost().currentPage === mainTestPage; }); +//} \ No newline at end of file From 240a378609791c0c92d71399b4717a190fc6968d Mon Sep 17 00:00:00 2001 From: Rossen Hristov Date: Fri, 2 Oct 2015 13:37:46 +0300 Subject: [PATCH 3/3] Added check for this._currentEntry. --- ui/frame/frame.android.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/frame/frame.android.ts b/ui/frame/frame.android.ts index 4a2c9288f..547538e41 100644 --- a/ui/frame/frame.android.ts +++ b/ui/frame/frame.android.ts @@ -297,7 +297,7 @@ export class Frame extends frameCommon.Frame { } // Add to backStack if needed. - if (this.backStack.length > 0) { + if (this.backStack.length > 0 && this._currentEntry) { // We add each entry in the backstack to avoid the "Stack corrupted" mismatch var backstackTag = this._currentEntry[BACKSTACK_TAG]; fragmentTransaction.addToBackStack(backstackTag);