| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -153,8 +153,8 @@ allTests["STYLE-PROPERTIES"] = stylePropertiesTests; | |||
| 153 | 153 | import * as frameTests from "./ui/frame/frame-tests"; | |
| 154 | 154 | allTests["FRAME"] = frameTests; | |
| 155 | 155 | ||
| 156 | - // import * as tabViewRootTests from "./ui/tab-view/tab-view-root-tests"; | ||
| 157 | - // allTests["TAB-VIEW-ROOT"] = tabViewRootTests; | ||
| 156 | + import * as tabViewRootTests from "./ui/tab-view/tab-view-root-tests"; | ||
| 157 | + allTests["TAB-VIEW-ROOT"] = tabViewRootTests; | ||
| 158 | 158 | ||
| 159 | 159 | import * as viewTests from "./ui/view/view-tests"; | |
| 160 | 160 | allTests["VIEW"] = viewTests; | |
@@ -255,8 +255,8 @@ allTests["SEARCH-BAR"] = searchBarTests; | |||
| 255 | 255 | import * as navigationTests from "./navigation/navigation-tests"; | |
| 256 | 256 | allTests["NAVIGATION"] = navigationTests; | |
| 257 | 257 | ||
| 258 | - // import * as resetRootViewTests from "./ui/root-view/reset-root-view-tests"; | ||
| 259 | - // allTests["RESET-ROOT-VIEW"] = resetRootViewTests; | ||
| 258 | + import * as resetRootViewTests from "./ui/root-view/reset-root-view-tests"; | ||
| 259 | + allTests["RESET-ROOT-VIEW"] = resetRootViewTests; | ||
| 260 | 260 | ||
| 261 | 261 | import * as rootViewTests from "./ui/root-view/root-view-tests"; | |
| 262 | 262 | allTests["ROOT-VIEW"] = rootViewTests; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,19 @@ | |||
| 1 | 1 | import * as TKUnit from "../../TKUnit"; | |
| 2 | 2 | import * as helper from "../helper"; | |
| 3 | 3 | import { Page } from "tns-core-modules/ui/page"; | |
| 4 | + import { isAndroid } from "tns-core-modules/platform"; | ||
| 4 | 5 | import { Frame, NavigationEntry, stack } from "tns-core-modules/ui/frame"; | |
| 5 | 6 | import { _resetRootView, getRootView } from "tns-core-modules/application"; | |
| 6 | 7 | import { TabView, TabViewItem } from "tns-core-modules/ui/tab-view"; | |
| 7 | 8 | ||
| 9 | + function waitUntilTabViewReady(page: Page, action: Function) { | ||
| 10 | + helper.waitUntilNavigatedTo(page, action); | ||
| 11 | + | ||
| 12 | + if (isAndroid) { | ||
| 13 | + TKUnit.waitUntilReady(() => page.frame._currentEntry.fragment.isAdded()); | ||
| 14 | + } | ||
| 15 | + } | ||
| 16 | + | ||
| 8 | 17 | function createTestFrameRootEntry() { | |
| 9 | 18 | const page = new Page(); | |
| 10 | 19 | const frameRoot = new Frame(); | |
@@ -77,7 +86,7 @@ export function test_reset_frame_to_tab() { | |||
| 77 | 86 | ||
| 78 | 87 | const testTabRoot = createTestTabRootEntry(); | |
| 79 | 88 | ||
| 80 | - helper.waitUntilNavigatedTo(testTabRoot.page, () => _resetRootView(testTabRoot.entry)); | ||
| 89 | + waitUntilTabViewReady(testTabRoot.page, () => _resetRootView(testTabRoot.entry)); | ||
| 81 | 90 | ||
| 82 | 91 | const rootView2 = getRootView(); | |
| 83 | 92 | const frameStack2 = stack(); | |
@@ -88,7 +97,7 @@ export function test_reset_frame_to_tab() { | |||
| 88 | 97 | export function test_reset_tab_to_frame() { | |
| 89 | 98 | const testTabRoot = createTestTabRootEntry(); | |
| 90 | 99 | ||
| 91 | - helper.waitUntilNavigatedTo(testTabRoot.page, () => _resetRootView(testTabRoot.entry)); | ||
| 100 | + waitUntilTabViewReady(testTabRoot.page, () => _resetRootView(testTabRoot.entry)); | ||
| 92 | 101 | ||
| 93 | 102 | const rootView2 = getRootView(); | |
| 94 | 103 | const frameStack2 = stack(); | |
@@ -108,7 +117,7 @@ export function test_reset_tab_to_frame() { | |||
| 108 | 117 | export function test_reset_tab_to_tab() { | |
| 109 | 118 | const testTabRoot1 = createTestTabRootEntry(); | |
| 110 | 119 | ||
| 111 | - helper.waitUntilNavigatedTo(testTabRoot1.page, () => _resetRootView(testTabRoot1.entry)); | ||
| 120 | + waitUntilTabViewReady(testTabRoot1.page, () => _resetRootView(testTabRoot1.entry)); | ||
| 112 | 121 | ||
| 113 | 122 | const rootView1 = getRootView(); | |
| 114 | 123 | const frameStack1 = stack(); | |
@@ -117,7 +126,7 @@ export function test_reset_tab_to_tab() { | |||
| 117 | 126 | ||
| 118 | 127 | const testTabRoot2 = createTestTabRootEntry(); | |
| 119 | 128 | ||
| 120 | - helper.waitUntilNavigatedTo(testTabRoot2.page, () => _resetRootView(testTabRoot2.entry)); | ||
| 129 | + waitUntilTabViewReady(testTabRoot2.page, () => _resetRootView(testTabRoot2.entry)); | ||
| 121 | 130 | ||
| 122 | 131 | const rootView2 = getRootView(); | |
| 123 | 132 | const frameStack2 = stack(); | |
@@ -128,7 +137,7 @@ export function test_reset_tab_to_tab() { | |||
| 128 | 137 | export function test_reset_during_tab_index_change() { | |
| 129 | 138 | const testTabRoot = createTestTabRootEntry(); | |
| 130 | 139 | ||
| 131 | - helper.waitUntilNavigatedTo(testTabRoot.page, () => _resetRootView(testTabRoot.entry)); | ||
| 140 | + waitUntilTabViewReady(testTabRoot.page, () => _resetRootView(testTabRoot.entry)); | ||
| 132 | 141 | ||
| 133 | 142 | testTabRoot.root.selectedIndex = 1; | |
| 134 | 143 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,16 @@ function waitUntilNavigatedToMaxTimeout(pages: Page[], action: Function) { | |||
| 18 | 18 | TKUnit.waitUntilReady(() => completed === pages.length, maxTimeout); | |
| 19 | 19 | } | |
| 20 | 20 | ||
| 21 | + function waitUntilTabViewReady(page: Page, action: Function) { | ||
| 22 | + action(); | ||
| 23 | + | ||
| 24 | + if (isAndroid) { | ||
| 25 | + TKUnit.waitUntilReady(() => page.frame._currentEntry.fragment.isAdded()); | ||
| 26 | + } else { | ||
| 27 | + TKUnit.waitUntilReady(() => page.isLoaded); | ||
| 28 | + } | ||
| 29 | + } | ||
| 30 | + | ||
| 21 | 31 | function createPage(i: number) { | |
| 22 | 32 | const page = new Page(); | |
| 23 | 33 | page.id = `Tab${i} Frame${i} Page${i}`; | |
@@ -60,25 +70,21 @@ export function test_frame_topmost_matches_selectedIndex() { | |||
| 60 | 70 | const items = createTabItemsWithFrames(3); | |
| 61 | 71 | const tabView = new TabView(); | |
| 62 | 72 | tabView.items = items.map(item => item.tabItem); | |
| 63 | - tabView.selectedIndex = 0; | ||
| 73 | + | ||
| 74 | + // iOS cannot preload tab items | ||
| 75 | + // Android preloads 1 tab item to the sides by default | ||
| 76 | + // set this to 0, so that both platforms behave the same. | ||
| 77 | + tabView.androidOffscreenTabLimit = 0; | ||
| 64 | 78 | ||
| 65 | 79 | const entry: NavigationEntry = { | |
| 66 | 80 | create: () => tabView | |
| 67 | 81 | }; | |
| 68 | 82 | ||
| 69 | - if (isAndroid) { | ||
| 70 | - waitUntilNavigatedToMaxTimeout([items[0].page, items[1].page], () => _resetRootView(entry)); | ||
| 71 | - TKUnit.assertEqual(topmost().id, "Tab0 Frame0"); | ||
| 72 | - | ||
| 73 | - tabView.selectedIndex = 1; | ||
| 74 | - TKUnit.assertEqual(topmost().id, "Tab1 Frame1"); | ||
| 75 | - } else { | ||
| 76 | - waitUntilNavigatedToMaxTimeout([items[0].page], () => _resetRootView(entry)); | ||
| 77 | - TKUnit.assertEqual(topmost().id, "Tab0 Frame0"); | ||
| 83 | + waitUntilNavigatedToMaxTimeout([items[0].page], () => _resetRootView(entry)); | ||
| 84 | + TKUnit.assertEqual(topmost().id, "Tab0 Frame0"); | ||
| 78 | 85 | ||
| 79 | - waitUntilNavigatedToMaxTimeout([items[1].page], () => tabView.selectedIndex = 1); | ||
| 80 | - TKUnit.assertEqual(topmost().id, "Tab1 Frame1"); | ||
| 81 | - } | ||
| 86 | + waitUntilNavigatedToMaxTimeout([items[1].page], () => tabView.selectedIndex = 1); | ||
| 87 | + TKUnit.assertEqual(topmost().id, "Tab1 Frame1"); | ||
| 82 | 88 | } | |
| 83 | 89 | ||
| 84 | 90 | export function test_offset_zero_should_raise_same_events() { | |
@@ -159,8 +165,8 @@ export function test_offset_zero_should_raise_same_events() { | |||
| 159 | 165 | TKUnit.assertDeepEqual(actualEventsRaised, expectedEventsRaisedAfterSelectThirdTab); | |
| 160 | 166 | ||
| 161 | 167 | resetActualEventsRaised(); | |
| 162 | - tabView.selectedIndex = 0; | ||
| 163 | - TKUnit.waitUntilReady(() => items[0].page.isLoaded); | ||
| 168 | + | ||
| 169 | + waitUntilTabViewReady(items[0].page, () => tabView.selectedIndex = 0); | ||
| 164 | 170 | ||
| 165 | 171 | const expectedEventsRaisedAfterReturnToFirstTab = [ | |
| 166 | 172 | [ | |
@@ -256,8 +262,8 @@ export function test_android_default_offset_should_preload_1_tab_on_each_side() | |||
| 256 | 262 | TKUnit.assertDeepEqual(actualEventsRaised, expectedEventsRaisedAfterSelectThirdTab); | |
| 257 | 263 | ||
| 258 | 264 | resetActualEventsRaised(); | |
| 259 | - tabView.selectedIndex = 0; | ||
| 260 | - TKUnit.waitUntilReady(() => items[0].page.isLoaded); | ||
| 265 | + | ||
| 266 | + waitUntilTabViewReady(items[0].page, () => tabView.selectedIndex = 0); | ||
| 261 | 267 | ||
| 262 | 268 | const expectedEventsRaisedAfterReturnToFirstTab = [ | |
| 263 | 269 | [ | |
| 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": "5.0.0" | ||
| 9 | + "version": "5.1.0" | ||
| 10 | 10 | }, | |
| 11 | 11 | "tns-android": { | |
| 12 | - "version": "5.0.0" | ||
| 12 | + "version": "5.1.0" | ||
| 13 | 13 | } | |
| 14 | 14 | }, | |
| 15 | 15 | "dependencies": { | |
@@ -25,4 +25,4 @@ | |||
| 25 | 25 | "tns-platform-declarations": "*", | |
| 26 | 26 | "typescript": "^3.1.6" | |
| 27 | 27 | } | |
| 28 | - } | ||
| 28 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments