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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tests/app/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 14 additions & 5 deletions tests/app/ui/root-view/reset-root-view-tests.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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;

Expand Down
40 changes: 23 additions & 17 deletions tests/app/ui/tab-view/tab-view-root-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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 = [
[
Expand Down Expand Up @@ -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 = [
[
Expand Down
6 changes: 3 additions & 3 deletions tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -25,4 +25,4 @@
"tns-platform-declarations": "*",
"typescript": "^3.1.6"
}
}
}