From 0c015820fbcfc1ee72f5f96dd1349bf435c829eb Mon Sep 17 00:00:00 2001 From: Panayot Cankov Date: Mon, 30 Nov 2015 17:43:57 +0200 Subject: [PATCH] Fixed the currentEntry property to return navigation entry instead of backstack entry --- apps/tests/frame-tests.ts | 15 +++++++++++---- apps/tests/testRunner.ts | 1 + ui/frame/frame-common.ts | 4 ++-- ui/frame/frame.android.ts | 4 ++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/apps/tests/frame-tests.ts b/apps/tests/frame-tests.ts index e17883763..cbefa8232 100644 --- a/apps/tests/frame-tests.ts +++ b/apps/tests/frame-tests.ts @@ -9,7 +9,9 @@ var topmost = frameModule.topmost(); import labelModule = require("ui/label"); import pagesModule = require("ui/page"); -export var test_DummyTestForSnippetOnly0 = function () { +import TKUnit = require("./TKUnit"); + +export var ignore_test_DummyTestForSnippetOnly0 = function () { // // ### Navigating to a Module // ``` JavaScript @@ -18,7 +20,7 @@ export var test_DummyTestForSnippetOnly0 = function () { // } -export var test_DummyTestForSnippetOnly1 = function () { +export var ignore_test_DummyTestForSnippetOnly1 = function () { // // ### Navigating with a Factory Function // ``` JavaScript @@ -34,7 +36,7 @@ export var test_DummyTestForSnippetOnly1 = function () { // } -export var test_DummyTestForSnippetOnly2 = function () { +export var ignore_test_DummyTestForSnippetOnly2 = function () { // // ### Navigating with NavigationEntry // ``` JavaScript @@ -48,7 +50,7 @@ export var test_DummyTestForSnippetOnly2 = function () { // } -export var test_DummyTestForSnippetOnly3 = function () { +export var ignore_test_DummyTestForSnippetOnly3 = function () { // // ### Navigating Back // ``` JavaScript @@ -56,3 +58,8 @@ export var test_DummyTestForSnippetOnly3 = function () { // ``` // } + +export function test_currentEntry() { + var moduleName = frameModule.topmost().currentEntry.moduleName; + TKUnit.assert(moduleName === "tests/app/mainPage" || moduleName === "app/mainPage", "Expected frameModule.topmost().currentEntry.moduleName to return tests/app/mainPage or app/mainPage but instead returned " + moduleName); +} \ No newline at end of file diff --git a/apps/tests/testRunner.ts b/apps/tests/testRunner.ts index 7353c6b0d..55216be2f 100644 --- a/apps/tests/testRunner.ts +++ b/apps/tests/testRunner.ts @@ -40,6 +40,7 @@ allTests["FILE SYSTEM"] = require("./file-system-tests"); allTests["HTTP"] = require("./http-tests"); allTests["XHR"] = require("./xhr-tests"); allTests["FETCH"] = require("./fetch-tests"); +allTests["FRAME"] = require("./frame-tests"); allTests["APPLICATION SETTINGS"] = require("./application-settings-tests"); allTests["IMAGE SOURCE"] = require("./image-source-tests"); allTests["TIMER"] = require("./timer-tests"); diff --git a/ui/frame/frame-common.ts b/ui/frame/frame-common.ts index e436d7a75..617f0f8b4 100644 --- a/ui/frame/frame-common.ts +++ b/ui/frame/frame-common.ts @@ -307,8 +307,8 @@ export class Frame extends view.CustomLayoutView implements definition.Frame { return null; } - get currentEntry(): definition.BackstackEntry { - return this._currentEntry; + get currentEntry(): definition.NavigationEntry { + return this._currentEntry.entry; } public _pushInFrameStack() { diff --git a/ui/frame/frame.android.ts b/ui/frame/frame.android.ts index ed4fc9ee1..46ead71bf 100644 --- a/ui/frame/frame.android.ts +++ b/ui/frame/frame.android.ts @@ -290,7 +290,7 @@ export class Frame extends frameCommon.Frame { public _onActivityCreated(isRestart: boolean) { this._onAttached(this._android.activity); - var backstackEntry = this.currentEntry || this._delayedNavigationEntry; + var backstackEntry = this._currentEntry || this._delayedNavigationEntry; if (isRestart) { this._onNavigatingTo(backstackEntry, false); @@ -672,7 +672,7 @@ function findPageForFragment(fragment: android.app.Fragment, frame: Frame) { trace.write("Attached fragment with no page: " + fragmentTag, trace.categories.NativeLifecycle); if (frame.currentPage && frame.currentPage[TAG] === fragmentTag) { page = frame.currentPage; - entry = frame.currentEntry; + entry = frame._currentEntry; trace.write("Current page matches fragment: " + fragmentTag, trace.categories.NativeLifecycle); } else {