Skip to content

Commit fe209cd

Browse files
committed
Merge pull request NativeScript#1186 from NativeScript/cankov/frame-currentEntry-fix
Fix currentEntry to return NavigationEntry instead of BackstackEntry
2 parents 986cf41 + 0c01582 commit fe209cd

File tree

4 files changed

+16
-8
lines changed

4 files changed

+16
-8
lines changed

apps/tests/frame-tests.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ var topmost = frameModule.topmost();
99
import labelModule = require("ui/label");
1010
import pagesModule = require("ui/page");
1111

12-
export var test_DummyTestForSnippetOnly0 = function () {
12+
import TKUnit = require("./TKUnit");
13+
14+
export var ignore_test_DummyTestForSnippetOnly0 = function () {
1315
// <snippet module="ui/frame" title="frame">
1416
// ### Navigating to a Module
1517
// ``` JavaScript
@@ -18,7 +20,7 @@ export var test_DummyTestForSnippetOnly0 = function () {
1820
// </snippet>
1921
}
2022

21-
export var test_DummyTestForSnippetOnly1 = function () {
23+
export var ignore_test_DummyTestForSnippetOnly1 = function () {
2224
// <snippet module="ui/frame" title="frame">
2325
// ### Navigating with a Factory Function
2426
// ``` JavaScript
@@ -34,7 +36,7 @@ export var test_DummyTestForSnippetOnly1 = function () {
3436
// </snippet>
3537
}
3638

37-
export var test_DummyTestForSnippetOnly2 = function () {
39+
export var ignore_test_DummyTestForSnippetOnly2 = function () {
3840
// <snippet module="ui/frame" title="frame">
3941
// ### Navigating with NavigationEntry
4042
// ``` JavaScript
@@ -48,11 +50,16 @@ export var test_DummyTestForSnippetOnly2 = function () {
4850
// </snippet>
4951
}
5052

51-
export var test_DummyTestForSnippetOnly3 = function () {
53+
export var ignore_test_DummyTestForSnippetOnly3 = function () {
5254
// <snippet module="ui/frame" title="frame">
5355
// ### Navigating Back
5456
// ``` JavaScript
5557
topmost.goBack();
5658
// ```
5759
// </snippet>
5860
}
61+
62+
export function test_currentEntry() {
63+
var moduleName = frameModule.topmost().currentEntry.moduleName;
64+
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);
65+
}

apps/tests/testRunner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ allTests["FILE SYSTEM"] = require("./file-system-tests");
4040
allTests["HTTP"] = require("./http-tests");
4141
allTests["XHR"] = require("./xhr-tests");
4242
allTests["FETCH"] = require("./fetch-tests");
43+
allTests["FRAME"] = require("./frame-tests");
4344
allTests["APPLICATION SETTINGS"] = require("./application-settings-tests");
4445
allTests["IMAGE SOURCE"] = require("./image-source-tests");
4546
allTests["TIMER"] = require("./timer-tests");

ui/frame/frame-common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ export class Frame extends view.CustomLayoutView implements definition.Frame {
307307
return null;
308308
}
309309

310-
get currentEntry(): definition.BackstackEntry {
311-
return this._currentEntry;
310+
get currentEntry(): definition.NavigationEntry {
311+
return this._currentEntry.entry;
312312
}
313313

314314
public _pushInFrameStack() {

ui/frame/frame.android.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ export class Frame extends frameCommon.Frame {
290290
public _onActivityCreated(isRestart: boolean) {
291291
this._onAttached(this._android.activity);
292292

293-
var backstackEntry = this.currentEntry || this._delayedNavigationEntry;
293+
var backstackEntry = this._currentEntry || this._delayedNavigationEntry;
294294

295295
if (isRestart) {
296296
this._onNavigatingTo(backstackEntry, false);
@@ -672,7 +672,7 @@ function findPageForFragment(fragment: android.app.Fragment, frame: Frame) {
672672
trace.write("Attached fragment with no page: " + fragmentTag, trace.categories.NativeLifecycle);
673673
if (frame.currentPage && frame.currentPage[TAG] === fragmentTag) {
674674
page = frame.currentPage;
675-
entry = frame.currentEntry;
675+
entry = frame._currentEntry;
676676
trace.write("Current page matches fragment: " + fragmentTag, trace.categories.NativeLifecycle);
677677
}
678678
else {

0 commit comments

Comments
 (0)