mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
fix(ios): listview scrollToIndex crash with async data (#6182)
This commit is contained in:
@@ -759,6 +759,33 @@ export class ListViewTest extends UITest<ListView> {
|
||||
TKUnit.assertEqual(lastNativeElementVisible, false, "Last element is not visible");
|
||||
}
|
||||
|
||||
public test_scrollToIndex_should_coerce_negative_index_to_zero_index() {
|
||||
var listView = this.testView;
|
||||
|
||||
listView.items = MANY_ITEMS;
|
||||
listView.scrollToIndex(-1);
|
||||
TKUnit.wait(0.1);
|
||||
|
||||
var firstNativeElementVisible = this.checkItemVisibleAtIndex(listView, 0);
|
||||
TKUnit.assertEqual(firstNativeElementVisible, true, "first element is 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() {
|
||||
var listView = this.testView;
|
||||
listView.scrollToIndex(10000);
|
||||
}
|
||||
|
||||
private checkItemVisibleAtIndex(listView: ListView, index: number): boolean {
|
||||
return listView.isItemAtIndexVisible(index);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user