| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -209,8 +209,8 @@ export function waitUntilNavigatedTo(page: Page, action: Function) { | |||
| 209 | 209 | TKUnit.waitUntilReady(() => completed, 5); | |
| 210 | 210 | } | |
| 211 | 211 | ||
| 212 | - export function waitUntilNavigatedFrom(action: Function) { | ||
| 213 | - const currentPage = frame.topmost().currentPage; | ||
| 212 | + export function waitUntilNavigatedFrom(action: Function, topFrame?: frame.Frame) { | ||
| 213 | + const currentPage = topFrame ? topFrame.currentPage : frame.topmost().currentPage; | ||
| 214 | 214 | let completed = false; | |
| 215 | 215 | function navigatedFrom(args) { | |
| 216 | 216 | args.object.page.off("navigatedFrom", navigatedFrom); | |
@@ -226,19 +226,19 @@ export function waitUntilLayoutReady(view: View): void { | |||
| 226 | 226 | TKUnit.waitUntilReady(() => view.isLayoutValid); | |
| 227 | 227 | } | |
| 228 | 228 | ||
| 229 | - export function navigateWithEntry(entry: frame.NavigationEntry): Page { | ||
| 229 | + export function navigateWithEntry(entry: frame.NavigationEntry, topFrame?: frame.Frame): Page { | ||
| 230 | 230 | const page = createViewFromEntry(entry) as Page; | |
| 231 | 231 | entry.moduleName = null; | |
| 232 | 232 | entry.create = function () { | |
| 233 | 233 | return page; | |
| 234 | 234 | }; | |
| 235 | 235 | ||
| 236 | - waitUntilNavigatedFrom(() => frame.topmost().navigate(entry)); | ||
| 236 | + waitUntilNavigatedFrom(() => topFrame ? topFrame.navigate(entry) : frame.topmost().navigate(entry)); | ||
| 237 | 237 | return page; | |
| 238 | 238 | } | |
| 239 | 239 | ||
| 240 | - export function goBack() { | ||
| 241 | - waitUntilNavigatedFrom(() => frame.topmost().goBack()); | ||
| 240 | + export function goBack(topFrame?: frame.Frame) { | ||
| 241 | + waitUntilNavigatedFrom(() => topFrame ? topFrame.goBack() : frame.topmost().goBack()); | ||
| 242 | 242 | } | |
| 243 | 243 | ||
| 244 | 244 | export function assertAreClose(actual: number, expected: number, message: string): void { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ import { isIOS, isAndroid } from "tns-core-modules/platform"; | |||
| 4 | 4 | import { Label } from "tns-core-modules/ui/label"; | |
| 5 | 5 | import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout"; | |
| 6 | 6 | import * as frameModule from "tns-core-modules/ui/frame"; | |
| 7 | - import { Page } from "tns-core-modules/ui/page"; | ||
| 7 | + import { Page, NavigatedData } from "tns-core-modules/ui/page"; | ||
| 8 | 8 | import { ListView, ItemEventData } from "tns-core-modules/ui/list-view"; | |
| 9 | 9 | import { TabView, TabViewItem } from "tns-core-modules/ui/tab-view"; | |
| 10 | 10 | import { Button } from "tns-core-modules/ui/button"; | |
@@ -68,6 +68,56 @@ function _clickHandlerFactory(index: number) { | |||
| 68 | 68 | } | |
| 69 | 69 | } | |
| 70 | 70 | ||
| 71 | + function _createFrameView(): frameModule.Frame { | ||
| 72 | + const frame = new frameModule.Frame(); | ||
| 73 | + frame.navigate({ create: () => new Page() }); | ||
| 74 | + return frame; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + export function testBackNavigationToTabViewWithNestedFramesShouldWork() { | ||
| 78 | + // https://github.com/NativeScript/NativeScript/issues/6490 | ||
| 79 | + const topFrame = frameModule.topmost(); | ||
| 80 | + | ||
| 81 | + let tabViewPage: Page; | ||
| 82 | + let tabView: TabView; | ||
| 83 | + | ||
| 84 | + const pageFactory = function (): Page { | ||
| 85 | + tabView = _createTabView(); | ||
| 86 | + let items = Array<TabViewItem>(); | ||
| 87 | + let tabViewitem = new TabViewItem(); | ||
| 88 | + tabViewitem.title = "Item1"; | ||
| 89 | + tabViewitem.view = _createFrameView(); | ||
| 90 | + items.push(tabViewitem); | ||
| 91 | + | ||
| 92 | + let tabViewitem2 = new TabViewItem(); | ||
| 93 | + tabViewitem2.title = "Item2"; | ||
| 94 | + tabViewitem2.view = _createFrameView(); | ||
| 95 | + items.push(tabViewitem2); | ||
| 96 | + | ||
| 97 | + tabView.items = items; | ||
| 98 | + | ||
| 99 | + tabViewPage = new Page(); | ||
| 100 | + tabViewPage.id = "tab-view-page"; | ||
| 101 | + tabViewPage.content = tabView; | ||
| 102 | + | ||
| 103 | + return tabViewPage; | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + helper.waitUntilNavigatedFrom(() => topFrame.navigate(pageFactory), topFrame); | ||
| 107 | + | ||
| 108 | + TKUnit.waitUntilReady(() => topFrame.currentPage === tabViewPage); | ||
| 109 | + TKUnit.waitUntilReady(() => tabViewIsFullyLoaded(tabView)); | ||
| 110 | + | ||
| 111 | + // navigate to a different page | ||
| 112 | + helper.waitUntilNavigatedFrom(() => topFrame.navigate({ create: () => new Page(), animated: false }), topFrame); | ||
| 113 | + | ||
| 114 | + // navigate back to the page that hold the tabview with nested frames | ||
| 115 | + topFrame.goBack(); | ||
| 116 | + | ||
| 117 | + // make sure the app did not crash | ||
| 118 | + TKUnit.waitUntilReady(() => topFrame.navigationQueueIsEmpty()); | ||
| 119 | + } | ||
| 120 | + | ||
| 71 | 121 | export function testWhenNavigatingBackToANonCachedPageContainingATabViewWithAListViewTheListViewIsThere() { | |
| 72 | 122 | var topFrame = frameModule.topmost(); | |
| 73 | 123 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,10 +6,10 @@ | |||
| 6 | 6 | "nativescript": { | |
| 7 | 7 | "id": "org.nativescript.UnitTestApp", | |
| 8 | 8 | "tns-ios": { | |
| 9 | - "version": "4.2.0" | ||
| 9 | + "version": "5.0.0" | ||
| 10 | 10 | }, | |
| 11 | 11 | "tns-android": { | |
| 12 | - "version": "4.2.0" | ||
| 12 | + "version": "5.0.0" | ||
| 13 | 13 | } | |
| 14 | 14 | }, | |
| 15 | 15 | "dependencies": { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments