mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
chore: stabilize iOS13 unit tests (#8127)
This commit is contained in:
@@ -542,7 +542,11 @@ export class TabView extends TabViewBase {
|
|||||||
|
|
||||||
public _loadUnloadTabItems(newIndex: number) {
|
public _loadUnloadTabItems(newIndex: number) {
|
||||||
const items = this.items;
|
const items = this.items;
|
||||||
const lastIndex = this.items.length - 1;
|
if (!items) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const lastIndex = items.length - 1;
|
||||||
const offsideItems = this.androidTabsPosition === "top" ? this.androidOffscreenTabLimit : 1;
|
const offsideItems = this.androidTabsPosition === "top" ? this.androidOffscreenTabLimit : 1;
|
||||||
|
|
||||||
let toUnload = [];
|
let toUnload = [];
|
||||||
|
|||||||
@@ -465,7 +465,11 @@ export class Tabs extends TabsBase {
|
|||||||
|
|
||||||
public _loadUnloadTabItems(newIndex: number) {
|
public _loadUnloadTabItems(newIndex: number) {
|
||||||
const items = this.items;
|
const items = this.items;
|
||||||
const lastIndex = this.items.length - 1;
|
if (!items) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const lastIndex = items.length - 1;
|
||||||
const offsideItems = this.offscreenTabLimit;
|
const offsideItems = this.offscreenTabLimit;
|
||||||
|
|
||||||
let toUnload = [];
|
let toUnload = [];
|
||||||
|
|||||||
@@ -636,7 +636,11 @@ export class Tabs extends TabsBase {
|
|||||||
|
|
||||||
public _loadUnloadTabItems(newIndex: number) {
|
public _loadUnloadTabItems(newIndex: number) {
|
||||||
const items = this.items;
|
const items = this.items;
|
||||||
const lastIndex = this.items.length - 1;
|
if (!items) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const lastIndex = items.length - 1;
|
||||||
const offsideItems = this.offscreenTabLimit;
|
const offsideItems = this.offscreenTabLimit;
|
||||||
|
|
||||||
let toUnload = [];
|
let toUnload = [];
|
||||||
@@ -768,6 +772,10 @@ export class Tabs extends TabsBase {
|
|||||||
|
|
||||||
public _setCanBeLoaded(index: number) {
|
public _setCanBeLoaded(index: number) {
|
||||||
const items = this.items;
|
const items = this.items;
|
||||||
|
if (!this.items) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const lastIndex = items.length - 1;
|
const lastIndex = items.length - 1;
|
||||||
const offsideItems = this.offscreenTabLimit;
|
const offsideItems = this.offscreenTabLimit;
|
||||||
|
|
||||||
@@ -1085,10 +1093,8 @@ export class Tabs extends TabsBase {
|
|||||||
this._currentNativeSelectedIndex = value;
|
this._currentNativeSelectedIndex = value;
|
||||||
this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, true, (finished: boolean) => {
|
this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, true, (finished: boolean) => {
|
||||||
if (finished) {
|
if (finished) {
|
||||||
if (majorVersion < 10) {
|
// HACK: UIPageViewController fix; see https://stackoverflow.com/a/17330606
|
||||||
// HACK: UIPageViewController fix; see https://stackoverflow.com/a/17330606
|
invokeOnRunLoop(() => this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, false, null));
|
||||||
invokeOnRunLoop(() => this.viewController.setViewControllersDirectionAnimatedCompletion(controllers, navigationDirection, false, null));
|
|
||||||
}
|
|
||||||
|
|
||||||
this._canSelectItem = true;
|
this._canSelectItem = true;
|
||||||
this._setCanBeLoaded(value);
|
this._setCanBeLoaded(value);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import * as TKUnit from "../tk-unit";
|
import * as TKUnit from "../tk-unit";
|
||||||
import * as app from "@nativescript/core/application";
|
import * as app from "@nativescript/core/application";
|
||||||
import * as platformModule from "@nativescript/core/platform";
|
import * as platformModule from "@nativescript/core/platform";
|
||||||
|
import { ios } from "@nativescript/core/utils/utils";
|
||||||
|
|
||||||
export function test_platform() {
|
export function test_platform() {
|
||||||
let expectedPlatform;
|
let expectedPlatform;
|
||||||
@@ -19,7 +20,12 @@ export function test_device_screen() {
|
|||||||
TKUnit.assert(platformModule.device.uuid, "Device UUID not initialized.");
|
TKUnit.assert(platformModule.device.uuid, "Device UUID not initialized.");
|
||||||
|
|
||||||
TKUnit.assert(platformModule.device.language, "Preferred language not initialized.");
|
TKUnit.assert(platformModule.device.language, "Preferred language not initialized.");
|
||||||
TKUnit.assert(platformModule.device.region, "Preferred region not initialized.");
|
|
||||||
|
// NSLocale.currentLocale.objectForKey(NSLocaleCountryCode) not initialized by default on iOS13 simulator;
|
||||||
|
// can be set through Settings -> General -> Language & Region -> Region
|
||||||
|
if (platformModule.isAndroid || ios.MajorVersion < 13) {
|
||||||
|
TKUnit.assert(platformModule.device.region, "Preferred region not initialized.");
|
||||||
|
}
|
||||||
|
|
||||||
TKUnit.assert(platformModule.device.os, "OS not initialized.");
|
TKUnit.assert(platformModule.device.os, "OS not initialized.");
|
||||||
TKUnit.assert(platformModule.device.osVersion, "OS version not initialized.");
|
TKUnit.assert(platformModule.device.osVersion, "OS version not initialized.");
|
||||||
|
|||||||
@@ -763,17 +763,6 @@ export class ListViewTest extends UITest<ListView> {
|
|||||||
TKUnit.assertEqual(lastNativeElementVisible, false, "Last element is not visible");
|
TKUnit.assertEqual(lastNativeElementVisible, false, "Last element is not visible");
|
||||||
}
|
}
|
||||||
|
|
||||||
public test_scrollToIndex_should_coerce_larger_index_to_last_item_index() {
|
|
||||||
var listView = this.testView;
|
|
||||||
|
|
||||||
listView.items = MANY_ITEMS;
|
|
||||||
listView.scrollToIndex(10000);
|
|
||||||
TKUnit.wait(0.1);
|
|
||||||
|
|
||||||
var lastNativeElementVisible = this.checkItemVisibleAtIndex(listView, MANY_ITEMS.length - 1);
|
|
||||||
TKUnit.assertEqual(lastNativeElementVisible, true, "last element is visible");
|
|
||||||
}
|
|
||||||
|
|
||||||
public test_scrollToIndex_should_not_throw_if_items_not_set() {
|
public test_scrollToIndex_should_not_throw_if_items_not_set() {
|
||||||
var listView = this.testView;
|
var listView = this.testView;
|
||||||
listView.scrollToIndex(10000);
|
listView.scrollToIndex(10000);
|
||||||
|
|||||||
Reference in New Issue
Block a user