From fe84b6dea6f158797c4b07551d80b61dd986afdc Mon Sep 17 00:00:00 2001 From: UXP Controls Automated Porting System Date: Tue, 22 Jan 2019 11:30:49 -0800 Subject: [PATCH 1/3] When in mutiselect make sure that the treeview list supports selection pattern --- .../InteractionTests/TreeViewTests.cs | 35 +++++++++++++++++++ dev/TreeView/TreeViewListAutomationPeer.cpp | 27 ++++++++++++-- dev/TreeView/TreeViewListAutomationPeer.h | 13 +++++-- 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/dev/TreeView/InteractionTests/TreeViewTests.cs b/dev/TreeView/InteractionTests/TreeViewTests.cs index af54f97f03..36c5bc1a1d 100644 --- a/dev/TreeView/InteractionTests/TreeViewTests.cs +++ b/dev/TreeView/InteractionTests/TreeViewTests.cs @@ -1807,6 +1807,41 @@ private void TreeViewItemUIATest(bool isContentMode = false) } } + [TestMethod] + [TestProperty("TreeViewTestSuite", "B")] + public void TreeViewListMultipleSelectionUIATest() + { + using (var setup = new TestSetupHelper("TreeView Tests")) + { + SetContentMode(false); + + UIObject ItemRoot = LabelFirstItem(); + + InputHelper.Tap(ItemRoot); + + ClickButton("LabelItems"); + ClickButton("ToggleSelectionMode"); + + Log.Comment("Retrieve first item as generic UIElement"); + UIObject Item1 = FindElement.ById("Root.1"); + Verify.IsNotNull(Item1, "Verifying that we found a UIElement called Root.1"); + + Item1.SetFocus(); + AutomationElement itemPeer = AutomationElement.FocusedElement; + + var selectionItemPeer = (SelectionItemPattern)itemPeer.GetCurrentPattern(SelectionItemPattern.Pattern); + var treeViewListPeer = selectionItemPeer.Current.SelectionContainer; + + var multipleSelectionPattern = (SelectionPattern)treeViewListPeer.GetCurrentPattern(SelectionPattern.Pattern); + Verify.IsNotNull(multipleSelectionPattern); + Verify.IsTrue(multipleSelectionPattern.Current.CanSelectMultiple); + Verify.IsFalse(multipleSelectionPattern.Current.IsSelectionRequired); + var elements = multipleSelectionPattern.Current.GetSelection(); + Verify.IsNotNull(elements); + Verify.AreEqual(0, elements.Length); + } + } + [TestMethod] [TestProperty("TreeViewTestSuite", "B")] [TestProperty("Platform", "Desktop")] diff --git a/dev/TreeView/TreeViewListAutomationPeer.cpp b/dev/TreeView/TreeViewListAutomationPeer.cpp index 4634396dda..9248ab6283 100644 --- a/dev/TreeView/TreeViewListAutomationPeer.cpp +++ b/dev/TreeView/TreeViewListAutomationPeer.cpp @@ -33,7 +33,8 @@ winrt::com_array TreeViewListAutomationPeer::DropEffects() winrt::IInspectable TreeViewListAutomationPeer::GetPatternCore(winrt::PatternInterface const& patternInterface) { - if (patternInterface == winrt::PatternInterface::DropTarget) + if (patternInterface == winrt::PatternInterface::DropTarget || + (patternInterface == winrt::PatternInterface::Selection && IsMultiselect())) { return *this; } @@ -44,4 +45,26 @@ winrt::IInspectable TreeViewListAutomationPeer::GetPatternCore(winrt::PatternInt winrt::AutomationControlType TreeViewListAutomationPeer::GetAutomationControlTypeCore() { return winrt::AutomationControlType::Tree; -} \ No newline at end of file +} + +// ISelectionProvider +bool TreeViewListAutomationPeer::CanSelectMultiple() +{ + return IsMultiselect()? true: __super::CanSelectMultiple(); +} + +bool TreeViewListAutomationPeer::IsSelectionRequried() +{ + return IsMultiselect()? false : __super::CanSelectMultiple(); +} + +winrt::com_array TreeViewListAutomationPeer::GetSelection() +{ + // The selected items might be collapsed, virtualized, so getting an accurate list of selected items is not possible. + return winrt::com_array(); +} + +bool TreeViewListAutomationPeer::IsMultiselect() +{ + return winrt::get_self(Owner().as())->IsMultiselect(); +} diff --git a/dev/TreeView/TreeViewListAutomationPeer.h b/dev/TreeView/TreeViewListAutomationPeer.h index 871d653599..310f395591 100644 --- a/dev/TreeView/TreeViewListAutomationPeer.h +++ b/dev/TreeView/TreeViewListAutomationPeer.h @@ -9,7 +9,8 @@ class TreeViewListAutomationPeer : public ReferenceTracker< TreeViewListAutomationPeer, winrt::implementation::TreeViewListAutomationPeerT, - winrt::IDropTargetProvider> + winrt::IDropTargetProvider, + winrt::ISelectionProvider> { public: TreeViewListAutomationPeer(winrt::TreeViewList const& owner); @@ -21,7 +22,15 @@ class TreeViewListAutomationPeer : // IItemsControlAutomationPeerOverrides2 winrt::ItemAutomationPeer OnCreateItemAutomationPeer(winrt::IInspectable const& item); - //DropTargetProvider methods + // IDropTargetProvider winrt::hstring DropEffect(); winrt::com_array DropEffects(); + + // ISelectionProvider + bool CanSelectMultiple(); + bool IsSelectionRequried(); + winrt::com_array GetSelection(); + +private: + bool IsMultiselect(); }; From 95168e0a88be6f4c9e345455a9c58b990eaaf365 Mon Sep 17 00:00:00 2001 From: UXP Controls Automated Porting System Date: Tue, 22 Jan 2019 13:42:37 -0800 Subject: [PATCH 2/3] cr fixes --- dev/TreeView/TreeViewItem.xaml | 33 +++++++++++++++++---- dev/TreeView/TreeViewListAutomationPeer.cpp | 2 +- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/dev/TreeView/TreeViewItem.xaml b/dev/TreeView/TreeViewItem.xaml index 8de244c834..9a25161cca 100644 --- a/dev/TreeView/TreeViewItem.xaml +++ b/dev/TreeView/TreeViewItem.xaml @@ -341,7 +341,13 @@ - + - - - + + + TreeViewListAutomationPeer::GetSelection() { // The selected items might be collapsed, virtualized, so getting an accurate list of selected items is not possible. - return winrt::com_array(); + return {}; } bool TreeViewListAutomationPeer::IsMultiselect() From 08ff9988a7beb281669149b5be92e6ea3993619c Mon Sep 17 00:00:00 2001 From: UXP Controls Automated Porting System Date: Tue, 22 Jan 2019 13:59:27 -0800 Subject: [PATCH 3/3] make checkbox and chevron raw in rs1 style --- dev/TreeView/TreeViewItem_rs1.xaml | 54 ++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/dev/TreeView/TreeViewItem_rs1.xaml b/dev/TreeView/TreeViewItem_rs1.xaml index 4d266298d2..066585cc23 100644 --- a/dev/TreeView/TreeViewItem_rs1.xaml +++ b/dev/TreeView/TreeViewItem_rs1.xaml @@ -252,32 +252,50 @@ - + - + Background="{ThemeResource SystemControlBackgroundAccentBrush}" + BorderThickness="2" + BorderBrush="{ThemeResource SystemControlBackgroundChromeWhiteBrush}"> + - - + +