Merge pull request #1186 from NativeScript/cankov/frame-currentEntry-fix

Fix currentEntry to return NavigationEntry instead of BackstackEntry
This commit is contained in:
Panayot Cankov
2015-12-01 09:48:26 +02:00
4 changed files with 16 additions and 8 deletions

View File

@@ -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 () {
// <snippet module="ui/frame" title="frame">
// ### Navigating to a Module
// ``` JavaScript
@@ -18,7 +20,7 @@ export var test_DummyTestForSnippetOnly0 = function () {
// </snippet>
}
export var test_DummyTestForSnippetOnly1 = function () {
export var ignore_test_DummyTestForSnippetOnly1 = function () {
// <snippet module="ui/frame" title="frame">
// ### Navigating with a Factory Function
// ``` JavaScript
@@ -34,7 +36,7 @@ export var test_DummyTestForSnippetOnly1 = function () {
// </snippet>
}
export var test_DummyTestForSnippetOnly2 = function () {
export var ignore_test_DummyTestForSnippetOnly2 = function () {
// <snippet module="ui/frame" title="frame">
// ### Navigating with NavigationEntry
// ``` JavaScript
@@ -48,7 +50,7 @@ export var test_DummyTestForSnippetOnly2 = function () {
// </snippet>
}
export var test_DummyTestForSnippetOnly3 = function () {
export var ignore_test_DummyTestForSnippetOnly3 = function () {
// <snippet module="ui/frame" title="frame">
// ### Navigating Back
// ``` JavaScript
@@ -56,3 +58,8 @@ export var test_DummyTestForSnippetOnly3 = function () {
// ```
// </snippet>
}
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);
}

View File

@@ -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");

View File

@@ -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() {

View File

@@ -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 {