mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
chore: restore tabroot/resetrootview tests (#6705)
This commit is contained in:
@ -153,8 +153,8 @@ allTests["STYLE-PROPERTIES"] = stylePropertiesTests;
|
||||
import * as frameTests from "./ui/frame/frame-tests";
|
||||
allTests["FRAME"] = frameTests;
|
||||
|
||||
// import * as tabViewRootTests from "./ui/tab-view/tab-view-root-tests";
|
||||
// allTests["TAB-VIEW-ROOT"] = tabViewRootTests;
|
||||
import * as tabViewRootTests from "./ui/tab-view/tab-view-root-tests";
|
||||
allTests["TAB-VIEW-ROOT"] = tabViewRootTests;
|
||||
|
||||
import * as viewTests from "./ui/view/view-tests";
|
||||
allTests["VIEW"] = viewTests;
|
||||
@ -255,8 +255,8 @@ allTests["SEARCH-BAR"] = searchBarTests;
|
||||
import * as navigationTests from "./navigation/navigation-tests";
|
||||
allTests["NAVIGATION"] = navigationTests;
|
||||
|
||||
// import * as resetRootViewTests from "./ui/root-view/reset-root-view-tests";
|
||||
// allTests["RESET-ROOT-VIEW"] = resetRootViewTests;
|
||||
import * as resetRootViewTests from "./ui/root-view/reset-root-view-tests";
|
||||
allTests["RESET-ROOT-VIEW"] = resetRootViewTests;
|
||||
|
||||
import * as rootViewTests from "./ui/root-view/root-view-tests";
|
||||
allTests["ROOT-VIEW"] = rootViewTests;
|
||||
|
@ -1,10 +1,19 @@
|
||||
import * as TKUnit from "../../TKUnit";
|
||||
import * as helper from "../helper";
|
||||
import { Page } from "tns-core-modules/ui/page";
|
||||
import { isAndroid } from "tns-core-modules/platform";
|
||||
import { Frame, NavigationEntry, stack } from "tns-core-modules/ui/frame";
|
||||
import { _resetRootView, getRootView } from "tns-core-modules/application";
|
||||
import { TabView, TabViewItem } from "tns-core-modules/ui/tab-view";
|
||||
|
||||
function waitUntilTabViewReady(page: Page, action: Function) {
|
||||
helper.waitUntilNavigatedTo(page, action);
|
||||
|
||||
if (isAndroid) {
|
||||
TKUnit.waitUntilReady(() => page.frame._currentEntry.fragment.isAdded());
|
||||
}
|
||||
}
|
||||
|
||||
function createTestFrameRootEntry() {
|
||||
const page = new Page();
|
||||
const frameRoot = new Frame();
|
||||
@ -77,7 +86,7 @@ export function test_reset_frame_to_tab() {
|
||||
|
||||
const testTabRoot = createTestTabRootEntry();
|
||||
|
||||
helper.waitUntilNavigatedTo(testTabRoot.page, () => _resetRootView(testTabRoot.entry));
|
||||
waitUntilTabViewReady(testTabRoot.page, () => _resetRootView(testTabRoot.entry));
|
||||
|
||||
const rootView2 = getRootView();
|
||||
const frameStack2 = stack();
|
||||
@ -88,7 +97,7 @@ export function test_reset_frame_to_tab() {
|
||||
export function test_reset_tab_to_frame() {
|
||||
const testTabRoot = createTestTabRootEntry();
|
||||
|
||||
helper.waitUntilNavigatedTo(testTabRoot.page, () => _resetRootView(testTabRoot.entry));
|
||||
waitUntilTabViewReady(testTabRoot.page, () => _resetRootView(testTabRoot.entry));
|
||||
|
||||
const rootView2 = getRootView();
|
||||
const frameStack2 = stack();
|
||||
@ -108,7 +117,7 @@ export function test_reset_tab_to_frame() {
|
||||
export function test_reset_tab_to_tab() {
|
||||
const testTabRoot1 = createTestTabRootEntry();
|
||||
|
||||
helper.waitUntilNavigatedTo(testTabRoot1.page, () => _resetRootView(testTabRoot1.entry));
|
||||
waitUntilTabViewReady(testTabRoot1.page, () => _resetRootView(testTabRoot1.entry));
|
||||
|
||||
const rootView1 = getRootView();
|
||||
const frameStack1 = stack();
|
||||
@ -117,7 +126,7 @@ export function test_reset_tab_to_tab() {
|
||||
|
||||
const testTabRoot2 = createTestTabRootEntry();
|
||||
|
||||
helper.waitUntilNavigatedTo(testTabRoot2.page, () => _resetRootView(testTabRoot2.entry));
|
||||
waitUntilTabViewReady(testTabRoot2.page, () => _resetRootView(testTabRoot2.entry));
|
||||
|
||||
const rootView2 = getRootView();
|
||||
const frameStack2 = stack();
|
||||
@ -128,7 +137,7 @@ export function test_reset_tab_to_tab() {
|
||||
export function test_reset_during_tab_index_change() {
|
||||
const testTabRoot = createTestTabRootEntry();
|
||||
|
||||
helper.waitUntilNavigatedTo(testTabRoot.page, () => _resetRootView(testTabRoot.entry));
|
||||
waitUntilTabViewReady(testTabRoot.page, () => _resetRootView(testTabRoot.entry));
|
||||
|
||||
testTabRoot.root.selectedIndex = 1;
|
||||
|
||||
|
@ -18,6 +18,16 @@ function waitUntilNavigatedToMaxTimeout(pages: Page[], action: Function) {
|
||||
TKUnit.waitUntilReady(() => completed === pages.length, maxTimeout);
|
||||
}
|
||||
|
||||
function waitUntilTabViewReady(page: Page, action: Function) {
|
||||
action();
|
||||
|
||||
if (isAndroid) {
|
||||
TKUnit.waitUntilReady(() => page.frame._currentEntry.fragment.isAdded());
|
||||
} else {
|
||||
TKUnit.waitUntilReady(() => page.isLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
function createPage(i: number) {
|
||||
const page = new Page();
|
||||
page.id = `Tab${i} Frame${i} Page${i}`;
|
||||
@ -60,25 +70,21 @@ export function test_frame_topmost_matches_selectedIndex() {
|
||||
const items = createTabItemsWithFrames(3);
|
||||
const tabView = new TabView();
|
||||
tabView.items = items.map(item => item.tabItem);
|
||||
tabView.selectedIndex = 0;
|
||||
|
||||
// iOS cannot preload tab items
|
||||
// Android preloads 1 tab item to the sides by default
|
||||
// set this to 0, so that both platforms behave the same.
|
||||
tabView.androidOffscreenTabLimit = 0;
|
||||
|
||||
const entry: NavigationEntry = {
|
||||
create: () => tabView
|
||||
};
|
||||
|
||||
if (isAndroid) {
|
||||
waitUntilNavigatedToMaxTimeout([items[0].page, items[1].page], () => _resetRootView(entry));
|
||||
TKUnit.assertEqual(topmost().id, "Tab0 Frame0");
|
||||
|
||||
tabView.selectedIndex = 1;
|
||||
TKUnit.assertEqual(topmost().id, "Tab1 Frame1");
|
||||
} else {
|
||||
waitUntilNavigatedToMaxTimeout([items[0].page], () => _resetRootView(entry));
|
||||
TKUnit.assertEqual(topmost().id, "Tab0 Frame0");
|
||||
waitUntilNavigatedToMaxTimeout([items[0].page], () => _resetRootView(entry));
|
||||
TKUnit.assertEqual(topmost().id, "Tab0 Frame0");
|
||||
|
||||
waitUntilNavigatedToMaxTimeout([items[1].page], () => tabView.selectedIndex = 1);
|
||||
TKUnit.assertEqual(topmost().id, "Tab1 Frame1");
|
||||
}
|
||||
waitUntilNavigatedToMaxTimeout([items[1].page], () => tabView.selectedIndex = 1);
|
||||
TKUnit.assertEqual(topmost().id, "Tab1 Frame1");
|
||||
}
|
||||
|
||||
export function test_offset_zero_should_raise_same_events() {
|
||||
@ -159,8 +165,8 @@ export function test_offset_zero_should_raise_same_events() {
|
||||
TKUnit.assertDeepEqual(actualEventsRaised, expectedEventsRaisedAfterSelectThirdTab);
|
||||
|
||||
resetActualEventsRaised();
|
||||
tabView.selectedIndex = 0;
|
||||
TKUnit.waitUntilReady(() => items[0].page.isLoaded);
|
||||
|
||||
waitUntilTabViewReady(items[0].page, () => tabView.selectedIndex = 0);
|
||||
|
||||
const expectedEventsRaisedAfterReturnToFirstTab = [
|
||||
[
|
||||
@ -256,8 +262,8 @@ export function test_android_default_offset_should_preload_1_tab_on_each_side()
|
||||
TKUnit.assertDeepEqual(actualEventsRaised, expectedEventsRaisedAfterSelectThirdTab);
|
||||
|
||||
resetActualEventsRaised();
|
||||
tabView.selectedIndex = 0;
|
||||
TKUnit.waitUntilReady(() => items[0].page.isLoaded);
|
||||
|
||||
waitUntilTabViewReady(items[0].page, () => tabView.selectedIndex = 0);
|
||||
|
||||
const expectedEventsRaisedAfterReturnToFirstTab = [
|
||||
[
|
||||
|
@ -6,10 +6,10 @@
|
||||
"nativescript": {
|
||||
"id": "org.nativescript.UnitTestApp",
|
||||
"tns-ios": {
|
||||
"version": "5.0.0"
|
||||
"version": "5.1.0"
|
||||
},
|
||||
"tns-android": {
|
||||
"version": "5.0.0"
|
||||
"version": "5.1.0"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
@ -25,4 +25,4 @@
|
||||
"tns-platform-declarations": "*",
|
||||
"typescript": "^3.1.6"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user