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:
Rossen Hristov
2016-11-08 17:17:30 +02:00
parent 8e2af03e8f
commit e59d145705
4 changed files with 84 additions and 0 deletions

View File

@ -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() {