Skip to content

Support for ListView cell recycling

Compare
Choose a tag to compare
@stephanpalmer stephanpalmer released this 14 Mar 09:02
· 78 commits to master since this release

QuickTest now supports testing of ListView cell reuse.

Changed behaviour:

  • Xamarin.Forms.Mocks is now initialised with runtimePlatform: null to be able to set all ListViewCachingStrategies in the test.
  • For ListViews with caching strategy RecycleElement and RecycleElementAndDataTemplate, cells are reused for each ShouldSee/Tap/Find after the first.

Details:

  • When a ListView is first traversed (by a ShouldSee, Tap, Find, ...), new cells are created. QuickTest has no concept of a limited screen, so it creates as many cells as there are items in the source. Created cells are cached.
  • On each subsequent traversal, the cached cells are reused. Cells are reused in order, so the cells which was created first is reused for the first item to display.
    • This also applies to text rendering of the view hierarchy, e.g. when tests fail.
    • NOTE: Some calls traverse the view hierarchy more than once (e.g. Tap).
  • When a cell is reused, the OnBindingContextChanged, OnAppearing and OnDisappearing methods are called, as Xamarin.Forms would do in a live app.
    • NOTE: The OnAppearing and OnDisappearing methods are currently not called for caching strategy RetainElement.
  • DataTemplateSelectors are supported. In this case, cells are cached and reused by template type.
  • Group header cells are not reused, as it is in Xamarin.Forms.