mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 05:18:39 +08:00
Add TabView.androidOffscreenTabLimit property
Resolves #2815 * Gets or sets the number of tabs that should be retained to either side of the current tab in the view hierarchy in an idle state. * Tabs beyond this limit will be recreated from the TabView when needed.
This commit is contained in:
@ -275,6 +275,60 @@ export class TabViewTest extends testModule.UITest<tabViewModule.TabView> {
|
||||
TKUnit.assertEqual(actualOldIndex, expectedOldIndex, "expectedOldIndex");
|
||||
TKUnit.assertEqual(actualNewIndex, expectedNewIndex, "expectedNewIndex");
|
||||
}
|
||||
|
||||
public testAndroidOffscreenTabLimit_Default = function () {
|
||||
let tabView = this.testView;
|
||||
if (!tabView.android){
|
||||
return;
|
||||
}
|
||||
|
||||
// The default setting is 1.
|
||||
// tabView.androidOffscreenTabLimit = 1;
|
||||
tabView.items = this._createItems(20);
|
||||
this.waitUntilTestElementIsLoaded();
|
||||
for (let index = 0, length = tabView.items.length; index < length; index++){
|
||||
tabViewTestsNative.selectNativeTab(tabView, index);
|
||||
TKUnit.waitUntilReady(function () {
|
||||
return tabView.selectedIndex === index;
|
||||
}, helper.ASYNC);
|
||||
}
|
||||
|
||||
let viewsWithParent = 0;
|
||||
let viewsWithoutParent = 0;
|
||||
for (let i = 0, length = tabView.items.length; i < length; i++){
|
||||
if (tabView.items[i].view.parent) {
|
||||
viewsWithParent++;
|
||||
}
|
||||
else {
|
||||
viewsWithoutParent++;
|
||||
}
|
||||
}
|
||||
|
||||
TKUnit.assertTrue(viewsWithoutParent > viewsWithParent, "Most of the views should be recycled!");
|
||||
}
|
||||
|
||||
public testAndroidOffscreenTabLimit_KeepAllAlive = function () {
|
||||
let tabView = this.testView;
|
||||
if (!tabView.android){
|
||||
return;
|
||||
}
|
||||
|
||||
tabView.androidOffscreenTabLimit = 20;
|
||||
|
||||
tabView.items = this._createItems(20);
|
||||
this.waitUntilTestElementIsLoaded();
|
||||
for (let index = 0, length = tabView.items.length; index < length; index++){
|
||||
tabViewTestsNative.selectNativeTab(tabView, index);
|
||||
TKUnit.waitUntilReady(function () {
|
||||
return tabView.selectedIndex === index;
|
||||
}, helper.ASYNC);
|
||||
}
|
||||
|
||||
for (let i = 0, length = tabView.items.length; i < length; i++){
|
||||
TKUnit.assertNotNull(tabView.items[i].view.parent, `tabView.items[${i}].view should have a parent!`);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public testBindingIsRefreshedWhenTabViewItemIsUnselectedAndThenSelectedAgain() {
|
||||
|
||||
|
Reference in New Issue
Block a user