-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert changes to setting context and add tests (#17348)
- Loading branch information
Showing
3 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
src/Controls/samples/Controls.Sample.UITests/Issues/Issue16787.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,48 @@ | ||
using Microsoft.Maui.Controls; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[Issue(IssueTracker.Github, 16787, "CollectionView runtime binding errors when loading the ItemSource asynchronously", PlatformAffected.UWP)] | ||
public class Issue16787 : TestContentPage | ||
{ | ||
protected override void OnBindingContextChanged() | ||
{ | ||
base.OnBindingContextChanged(); | ||
} | ||
protected override void Init() | ||
{ | ||
var cv = new CollectionView(); | ||
cv.BindingContextChanged += Cv_BindingContextChanged; | ||
this.BindingContext = this; | ||
cv.ItemTemplate = new DataTemplate(() => | ||
{ | ||
int bindingContextChanges = 0; | ||
var label = new Label(); | ||
label.BindingContextChanged += (_, _) => | ||
{ | ||
bindingContextChanges++; | ||
label.Text = bindingContextChanges.ToString(); | ||
}; | ||
label.AutomationId = "LabelBindingCount"; | ||
return label; | ||
}); | ||
|
||
cv.ItemsSource = new[] { "random" }; | ||
|
||
|
||
var layout = new VerticalStackLayout() | ||
{ | ||
new Label() | ||
{ | ||
Text = "The value below this label should be a 1. That's how many times the BindingContext has changed on the Templated element" | ||
} | ||
}; | ||
|
||
Content = cv; | ||
} | ||
|
||
private void Cv_BindingContextChanged(object sender, System.EventArgs e) | ||
{ | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Microsoft.Maui.Appium; | ||
using NUnit.Framework; | ||
|
||
namespace Microsoft.Maui.AppiumTests.Issues | ||
{ | ||
public class Issue16787 : _IssuesUITest | ||
{ | ||
public Issue16787(TestDevice device) : base(device) | ||
{ | ||
} | ||
|
||
public override string Issue => "CollectionView runtime binding errors when loading the ItemSource asynchronously"; | ||
|
||
[Test] | ||
public void CollectionViewBindingContextOnlyChangesOnce() | ||
{ | ||
Assert.AreEqual("1", App.WaitForElement("LabelBindingCount")[0].ReadText()); | ||
} | ||
} | ||
} |