Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TreeView root node ItemsSource syncing #865

Merged
merged 8 commits into from
Jun 14, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions dev/TreeView/APITests/TreeViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,11 @@ public void TreeViewItemsSourceUpdateTest()
treeView.ItemsSource = items;

// Insert
var newItem = new TreeViewItemSource();
var newItem = new TreeViewItemSource() { Content = "newItem" };
items.Add(newItem);
Verify.AreEqual(treeView.RootNodes.Count, 3);
Verify.AreEqual(treeView.RootNodes[2].Content as TreeViewItemSource, newItem);
var itemFromNode = treeView.RootNodes[2].Content as TreeViewItemSource;
Verify.AreEqual(newItem.Content, itemFromNode.Content);

// Remove
items.Remove(newItem);
Expand All @@ -445,7 +446,8 @@ public void TreeViewItemsSourceUpdateTest()
// Replace
var item3 = new TreeViewItemSource() { Content = "3" };
items[1] = item3;
Verify.AreEqual(treeView.RootNodes[1].Content as TreeViewItemSource, item3);
itemFromNode = treeView.RootNodes[1].Content as TreeViewItemSource;
Verify.AreEqual(item3.Content, itemFromNode.Content);

// Clear
items.Clear();
Expand Down
32 changes: 32 additions & 0 deletions dev/TreeView/InteractionTests/TreeViewTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2578,6 +2578,38 @@ public void TreeViewNodeInMarkupTest()
}
}

[TestMethod]
[TestProperty("TestSuite", "B")]
public void TreeViewRootNodeBindingTest()
Copy link
Contributor Author

@kaiguo kaiguo Jun 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RBrid there are some async updates when ItemsSource changes, I feel it's easier to do it in interaction test compare to API test (especially with all your helper functions in place to repro the issue 😊).

{
using (var setup = new TestSetupHelper("TreeView Tests"))
{
SetContentMode(true);

ClickButton("ClearNodes");
ClickButton("AddRootNode");
ClickButton("AddRootNode");
ClickButton("GetItemCount");
Verify.AreEqual("2", ReadResult());

ClickButton("LabelItems");
var root0 = FindElement.ById("Root0");
var root1 = FindElement.ById("Root1");

Log.Comment("Drag Root1 onto Root0...");
InputHelper.DragToTarget(root1, root0);

ClickButton("GetItemCount");
Verify.AreEqual("1", ReadResult());

var rootTreeItem = new TreeItem(root0);
rootTreeItem.Expand();
Wait.ForIdle();
ClickButton("GetChildrenOrder");
Verify.AreEqual("Root0 | Root1", ReadResult());
}
}

private void ClickButton(string buttonName)
{
var button = new Button(FindElement.ByName(buttonName));
Expand Down
253 changes: 135 additions & 118 deletions dev/TreeView/TestUI/TreeViewPage.xaml

Large diffs are not rendered by default.

Loading