FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: add test for #6490 by manoldonev · Pull Request #6517 · NativeScript/NativeScript · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .json  (1) .ts  (2) All 2 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
12 changes: 6 additions & 6 deletions tests/app/ui/helper.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ export function waitUntilNavigatedTo(page: Page, action: Function) {
TKUnit.waitUntilReady(() => completed, 5);
}

export function waitUntilNavigatedFrom(action: Function) {
const currentPage = frame.topmost().currentPage;
export function waitUntilNavigatedFrom(action: Function, topFrame?: frame.Frame) {
const currentPage = topFrame ? topFrame.currentPage : frame.topmost().currentPage;
let completed = false;
function navigatedFrom(args) {
args.object.page.off("navigatedFrom", navigatedFrom);
Expand All @@ -226,19 +226,19 @@ export function waitUntilLayoutReady(view: View): void {
TKUnit.waitUntilReady(() => view.isLayoutValid);
}

export function navigateWithEntry(entry: frame.NavigationEntry): Page {
export function navigateWithEntry(entry: frame.NavigationEntry, topFrame?: frame.Frame): Page {
const page = createViewFromEntry(entry) as Page;
entry.moduleName = null;
entry.create = function () {
return page;
};

waitUntilNavigatedFrom(() => frame.topmost().navigate(entry));
waitUntilNavigatedFrom(() => topFrame ? topFrame.navigate(entry) : frame.topmost().navigate(entry));
return page;
}

export function goBack() {
waitUntilNavigatedFrom(() => frame.topmost().goBack());
export function goBack(topFrame?: frame.Frame) {
waitUntilNavigatedFrom(() => topFrame ? topFrame.goBack() : frame.topmost().goBack());
}

export function assertAreClose(actual: number, expected: number, message: string): void {
Expand Down
52 changes: 51 additions & 1 deletion tests/app/ui/tab-view/tab-view-navigation-tests.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { isIOS, isAndroid } from "tns-core-modules/platform";
import { Label } from "tns-core-modules/ui/label";
import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout";
import * as frameModule from "tns-core-modules/ui/frame";
import { Page } from "tns-core-modules/ui/page";
import { Page, NavigatedData } from "tns-core-modules/ui/page";
import { ListView, ItemEventData } from "tns-core-modules/ui/list-view";
import { TabView, TabViewItem } from "tns-core-modules/ui/tab-view";
import { Button } from "tns-core-modules/ui/button";
Expand Down Expand Up @@ -68,6 +68,56 @@ function _clickHandlerFactory(index: number) {
}
}

function _createFrameView(): frameModule.Frame {
const frame = new frameModule.Frame();
frame.navigate({ create: () => new Page() });
return frame;
}

export function testBackNavigationToTabViewWithNestedFramesShouldWork() {
// https://github.com/NativeScript/NativeScript/issues/6490
const topFrame = frameModule.topmost();

let tabViewPage: Page;
let tabView: TabView;

const pageFactory = function (): Page {
tabView = _createTabView();
let items = Array<TabViewItem>();
let tabViewitem = new TabViewItem();
tabViewitem.title = "Item1";
tabViewitem.view = _createFrameView();
items.push(tabViewitem);

let tabViewitem2 = new TabViewItem();
tabViewitem2.title = "Item2";
tabViewitem2.view = _createFrameView();
items.push(tabViewitem2);

tabView.items = items;

tabViewPage = new Page();
tabViewPage.id = "tab-view-page";
tabViewPage.content = tabView;

return tabViewPage;
}

helper.waitUntilNavigatedFrom(() => topFrame.navigate(pageFactory), topFrame);

TKUnit.waitUntilReady(() => topFrame.currentPage === tabViewPage);
TKUnit.waitUntilReady(() => tabViewIsFullyLoaded(tabView));

// navigate to a different page
helper.waitUntilNavigatedFrom(() => topFrame.navigate({ create: () => new Page(), animated: false }), topFrame);

// navigate back to the page that hold the tabview with nested frames
topFrame.goBack();

// make sure the app did not crash
TKUnit.waitUntilReady(() => topFrame.navigationQueueIsEmpty());
}

export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithAListViewTheListViewIsThere() {
var topFrame = frameModule.topmost();

Expand Down
4 changes: 2 additions & 2 deletions tests/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"nativescript": {
"id": "org.nativescript.UnitTestApp",
"tns-ios": {
"version": "4.2.0"
"version": "5.0.0"
},
"tns-android": {
"version": "4.2.0"
"version": "5.0.0"
}
},
"dependencies": {
Expand Down

Back | FazBrowse Home | New Git URL