소스 검색

Added more failing TreeViewTests.

Steven Kirk 6 년 전
부모
커밋
07a625d489
1개의 변경된 파일60개의 추가작업 그리고 2개의 파일을 삭제
  1. 60 2
      tests/Avalonia.Controls.UnitTests/TreeViewTests.cs

+ 60 - 2
tests/Avalonia.Controls.UnitTests/TreeViewTests.cs

@@ -749,7 +749,6 @@ namespace Avalonia.Controls.UnitTests
             {
                 Template = CreateTreeViewTemplate(),
                 Items = tree,
-                ItemTemplate = new FuncDataTemplate<string>(x => new TextBlock { Width = 20, Height = 10 }),
                 SelectionMode = SelectionMode.Multiple,
             };
 
@@ -777,7 +776,6 @@ namespace Avalonia.Controls.UnitTests
             {
                 Template = CreateTreeViewTemplate(),
                 Items = tree,
-                ItemTemplate = new FuncDataTemplate<string>(x => new TextBlock { Width = 20, Height = 10 }),
                 SelectionMode = SelectionMode.Multiple,
             };
 
@@ -806,6 +804,66 @@ namespace Avalonia.Controls.UnitTests
             Assert.Equal(1, target.SelectedItems.Count);
         }
 
+        [Fact]
+        public void Shift_Right_Click_Should_Not_Select_Mutiple()
+        {
+            var tree = CreateTestTreeData();
+            var target = new TreeView
+            {
+                Template = CreateTreeViewTemplate(),
+                Items = tree,
+                SelectionMode = SelectionMode.Multiple,
+            };
+
+            var visualRoot = new TestRoot();
+            visualRoot.Child = target;
+
+            CreateNodeDataTemplate(target);
+            ApplyTemplates(target);
+            target.ExpandSubTree((TreeViewItem)target.Presenter.Panel.Children[0]);
+
+            var rootNode = tree[0];
+            var from = rootNode.Children[0];
+            var to = rootNode.Children[1];
+            var fromContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(from);
+            var toContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(to);
+
+            _mouse.Click(fromContainer);
+            _mouse.Click(toContainer, MouseButton.Right, modifiers: InputModifiers.Shift);
+
+            Assert.Equal(1, target.SelectedItems.Count);
+        }
+
+        [Fact]
+        public void Ctrl_Right_Click_Should_Not_Select_Mutiple()
+        {
+            var tree = CreateTestTreeData();
+            var target = new TreeView
+            {
+                Template = CreateTreeViewTemplate(),
+                Items = tree,
+                SelectionMode = SelectionMode.Multiple,
+            };
+
+            var visualRoot = new TestRoot();
+            visualRoot.Child = target;
+
+            CreateNodeDataTemplate(target);
+            ApplyTemplates(target);
+            target.ExpandSubTree((TreeViewItem)target.Presenter.Panel.Children[0]);
+
+            var rootNode = tree[0];
+            var from = rootNode.Children[0];
+            var to = rootNode.Children[1];
+            var fromContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(from);
+            var toContainer = (TreeViewItem)target.ItemContainerGenerator.Index.ContainerFromItem(to);
+
+            _mouse.Click(fromContainer);
+            _mouse.Click(toContainer, MouseButton.Right, modifiers: InputModifiers.Control);
+
+            Assert.Equal(1, target.SelectedItems.Count);
+        }
+
         private void ApplyTemplates(TreeView tree)
         {
             tree.ApplyTemplate();