forked from xamarin/Xamarin.Forms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verify sections exist before calling NumberOfItemsInSection; fixes xa…
…marin#7338 (xamarin#7354) fixes xamarin#7338
- Loading branch information
Showing
3 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue7338.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
|
||
#if UITEST | ||
using Xamarin.Forms.Core.UITests; | ||
using Xamarin.UITest; | ||
using NUnit.Framework; | ||
#endif | ||
|
||
|
||
namespace Xamarin.Forms.Controls.Issues | ||
{ | ||
#if UITEST | ||
[Category(UITestCategories.CollectionView)] | ||
#endif | ||
[Preserve(AllMembers = true)] | ||
[Issue(IssueTracker.Github, 7338, "[Bug] CollectionView crash if source is empty in XF 4.2.0.709249", | ||
PlatformAffected.iOS)] | ||
class Issue7338 : TestNavigationPage | ||
{ | ||
const string Success = "success"; | ||
|
||
protected override void Init() | ||
{ | ||
FlagTestHelpers.SetCollectionViewTestFlag(); | ||
PushAsync(CreateRoot()); | ||
} | ||
|
||
Page CreateRoot() | ||
{ | ||
var page = new ContentPage() { Title = "Issue7338" }; | ||
|
||
var instructions = new Label { AutomationId = Success, Text = "If you can see this label, the test has passed." }; | ||
|
||
var layout = new StackLayout(); | ||
|
||
var cv = new CollectionView | ||
{ | ||
ItemsLayout = new GridItemsLayout(orientation: ItemsLayoutOrientation.Horizontal), | ||
ItemTemplate = new DataTemplate(() => | ||
{ | ||
return Template(); | ||
}) | ||
}; | ||
|
||
layout.Children.Add(instructions); | ||
layout.Children.Add(cv); | ||
|
||
page.Content = layout; | ||
|
||
return page; | ||
} | ||
|
||
View Template() | ||
{ | ||
var label1 = new Label { Text = "Text", HeightRequest = 100 }; | ||
return label1; | ||
} | ||
|
||
#if UITEST | ||
[Test] | ||
public void EmptyHorizontalCollectionShouldNotCrash() | ||
{ | ||
// If the instructions are visible at all, then this has succeeded | ||
RunningApp.WaitForElement(Success); | ||
} | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters