From cfe090244176f6def780edda482bb8d48989681f Mon Sep 17 00:00:00 2001 From: Rossen Hristov Date: Thu, 3 Sep 2015 15:03:38 +0300 Subject: [PATCH] Added a unit test for backstackVisible --- CrossPlatformModules.csproj | 3 ++- apps/tests/navigation-tests.ts | 32 ++++++++++++++++++++++++++++++++ apps/tests/testRunner.ts | 1 + 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 apps/tests/navigation-tests.ts diff --git a/CrossPlatformModules.csproj b/CrossPlatformModules.csproj index 4f26631e7..0b7e7fd6f 100644 --- a/CrossPlatformModules.csproj +++ b/CrossPlatformModules.csproj @@ -143,6 +143,7 @@ + @@ -1950,7 +1951,7 @@ False - + \ No newline at end of file diff --git a/apps/tests/navigation-tests.ts b/apps/tests/navigation-tests.ts new file mode 100644 index 000000000..5424015a7 --- /dev/null +++ b/apps/tests/navigation-tests.ts @@ -0,0 +1,32 @@ +import TKUnit = require("./TKUnit"); +import pageModule = require("ui/page"); +import frame = require("ui/frame"); + +export var test_backstackVisible = function() { + var pageFactory = function (): pageModule.Page { + return new pageModule.Page(); + }; + + var mainTestPage = frame.topmost().currentPage; + frame.topmost().navigate({ create: pageFactory }); + TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== mainTestPage; }); + + // page1 should not be added to the backstack + var page0 = frame.topmost().currentPage; + frame.topmost().navigate({ create: pageFactory, backstackVisible: false }); + TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== page0; }); + + var page1 = frame.topmost().currentPage; + frame.topmost().navigate({ create: pageFactory }); + TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== page1; }); + + var page2 = frame.topmost().currentPage; + frame.topmost().goBack(); + TKUnit.waitUntilReady(() => { return frame.topmost().currentPage !== page2; }); + + // From page2 we have to go directly to page0, skipping page1. + TKUnit.assert(frame.topmost().currentPage === page0, "Page 1 should be skipped when going back."); + + frame.topmost().goBack(); + 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 25399b0b2..6f63cdd1a 100644 --- a/apps/tests/testRunner.ts +++ b/apps/tests/testRunner.ts @@ -79,6 +79,7 @@ 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"); if (!isRunningOnEmulator()) { allTests["LOCATION"] = require("./location-tests");