diff --git a/src/TestApplications/WindowsFormsTestApplication/Form1.Designer.cs b/src/TestApplications/WindowsFormsTestApplication/Form1.Designer.cs index d6763113..fe3ecbd4 100644 --- a/src/TestApplications/WindowsFormsTestApplication/Form1.Designer.cs +++ b/src/TestApplications/WindowsFormsTestApplication/Form1.Designer.cs @@ -29,12 +29,12 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.TreeNode treeNode1 = new System.Windows.Forms.TreeNode("Grand Child"); - System.Windows.Forms.TreeNode treeNode2 = new System.Windows.Forms.TreeNode("Child", new System.Windows.Forms.TreeNode[] { - treeNode1}); - System.Windows.Forms.TreeNode treeNode3 = new System.Windows.Forms.TreeNode("Root", new System.Windows.Forms.TreeNode[] { - treeNode2}); - System.Windows.Forms.TreeNode treeNode4 = new System.Windows.Forms.TreeNode("Main"); + System.Windows.Forms.TreeNode treeNode5 = new System.Windows.Forms.TreeNode("Grand Child"); + System.Windows.Forms.TreeNode treeNode6 = new System.Windows.Forms.TreeNode("Child", new System.Windows.Forms.TreeNode[] { + treeNode5}); + System.Windows.Forms.TreeNode treeNode7 = new System.Windows.Forms.TreeNode("Root", new System.Windows.Forms.TreeNode[] { + treeNode6}); + System.Windows.Forms.TreeNode treeNode8 = new System.Windows.Forms.TreeNode("Main"); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1)); this.ScenariosPane = new System.Windows.Forms.GroupBox(); this.ReverseTabOrderButton = new System.Windows.Forms.Button(); @@ -54,9 +54,7 @@ private void InitializeComponent() this.LinkLabel = new System.Windows.Forms.LinkLabel(); this.ControlsTab = new System.Windows.Forms.TabControl(); this.ListControlsTab = new System.Windows.Forms.TabPage(); - this.listControls1 = new WindowsFormsTestApplication.ListControls(); this.InputControlsTab = new System.Windows.Forms.TabPage(); - this.inputControls1 = new WindowsFormsTestApplication.InputControls(); this.OtherControlsTab = new System.Windows.Forms.TabPage(); this.AddNode = new System.Windows.Forms.Button(); this.TreeView = new System.Windows.Forms.TreeView(); @@ -75,6 +73,8 @@ private void InitializeComponent() this.alive = new System.Windows.Forms.DataGridViewCheckBoxColumn(); this.display = new System.Windows.Forms.DataGridViewButtonColumn(); this.details = new System.Windows.Forms.DataGridViewLinkColumn(); + this.PropertyGridTab = new System.Windows.Forms.TabPage(); + this.PropertyGrid = new System.Windows.Forms.PropertyGrid(); this.ToolStrip2 = new System.Windows.Forms.ToolStrip(); this.ToolStrip1 = new System.Windows.Forms.ToolStrip(); this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); @@ -99,8 +99,9 @@ private void InitializeComponent() this.toolStripSplitButton = new System.Windows.Forms.ToolStripSplitButton(); this.splitButtonToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripProgressBar2 = new System.Windows.Forms.ToolStripProgressBar(); - this.PropertyGridTab = new System.Windows.Forms.TabPage(); - this.PropertyGrid = new System.Windows.Forms.PropertyGrid(); + this.listControls1 = new WindowsFormsTestApplication.ListControls(); + this.inputControls1 = new WindowsFormsTestApplication.InputControls(); + this.DataGridControl = new System.Windows.Forms.DataGridView(); this.ScenariosPane.SuspendLayout(); this.ControlsTab.SuspendLayout(); this.ListControlsTab.SuspendLayout(); @@ -111,10 +112,11 @@ private void InitializeComponent() this.PanelWithText.SuspendLayout(); this.DataGridTab.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.DataGrid)).BeginInit(); + this.PropertyGridTab.SuspendLayout(); this.ToolStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.statusStrip.SuspendLayout(); - this.PropertyGridTab.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.DataGridControl)).BeginInit(); this.SuspendLayout(); // // ScenariosPane @@ -303,13 +305,6 @@ private void InitializeComponent() this.ListControlsTab.Text = "List Controls"; this.ListControlsTab.UseVisualStyleBackColor = true; // - // listControls1 - // - this.listControls1.Location = new System.Drawing.Point(20, 3); - this.listControls1.Name = "listControls1"; - this.listControls1.Size = new System.Drawing.Size(260, 204); - this.listControls1.TabIndex = 0; - // // InputControlsTab // this.InputControlsTab.Controls.Add(this.inputControls1); @@ -321,13 +316,6 @@ private void InitializeComponent() this.InputControlsTab.Text = "Input Controls"; this.InputControlsTab.UseVisualStyleBackColor = true; // - // inputControls1 - // - this.inputControls1.Location = new System.Drawing.Point(6, 6); - this.inputControls1.Name = "inputControls1"; - this.inputControls1.Size = new System.Drawing.Size(618, 286); - this.inputControls1.TabIndex = 0; - // // OtherControlsTab // this.OtherControlsTab.Controls.Add(this.AddNode); @@ -362,17 +350,17 @@ private void InitializeComponent() // this.TreeView.Location = new System.Drawing.Point(271, 14); this.TreeView.Name = "TreeView"; - treeNode1.Name = "GrandChild"; - treeNode1.Text = "Grand Child"; - treeNode2.Name = "ChildNode"; - treeNode2.Text = "Child"; - treeNode3.Name = "RootNode"; - treeNode3.Text = "Root"; - treeNode4.Name = "Main"; - treeNode4.Text = "Main"; + treeNode5.Name = "GrandChild"; + treeNode5.Text = "Grand Child"; + treeNode6.Name = "ChildNode"; + treeNode6.Text = "Child"; + treeNode7.Name = "RootNode"; + treeNode7.Text = "Root"; + treeNode8.Name = "Main"; + treeNode8.Text = "Main"; this.TreeView.Nodes.AddRange(new System.Windows.Forms.TreeNode[] { - treeNode3, - treeNode4}); + treeNode7, + treeNode8}); this.TreeView.Size = new System.Drawing.Size(199, 96); this.TreeView.TabIndex = 16; // @@ -446,6 +434,7 @@ private void InitializeComponent() // // DataGridTab // + this.DataGridTab.Controls.Add(this.DataGridControl); this.DataGridTab.Controls.Add(this.DataGrid); this.DataGridTab.Location = new System.Drawing.Point(4, 22); this.DataGridTab.Name = "DataGridTab"; @@ -466,7 +455,7 @@ private void InitializeComponent() this.details}); this.DataGrid.Location = new System.Drawing.Point(6, 6); this.DataGrid.Name = "DataGrid"; - this.DataGrid.Size = new System.Drawing.Size(677, 289); + this.DataGrid.Size = new System.Drawing.Size(677, 130); this.DataGrid.TabIndex = 10; // // name @@ -500,6 +489,24 @@ private void InitializeComponent() this.details.Name = "details"; this.details.Text = "More.."; // + // PropertyGridTab + // + this.PropertyGridTab.Controls.Add(this.PropertyGrid); + this.PropertyGridTab.Location = new System.Drawing.Point(4, 22); + this.PropertyGridTab.Name = "PropertyGridTab"; + this.PropertyGridTab.Padding = new System.Windows.Forms.Padding(3); + this.PropertyGridTab.Size = new System.Drawing.Size(689, 298); + this.PropertyGridTab.TabIndex = 4; + this.PropertyGridTab.Text = "Property Grid"; + this.PropertyGridTab.UseVisualStyleBackColor = true; + // + // PropertyGrid + // + this.PropertyGrid.Location = new System.Drawing.Point(6, 6); + this.PropertyGrid.Name = "PropertyGrid"; + this.PropertyGrid.Size = new System.Drawing.Size(251, 286); + this.PropertyGrid.TabIndex = 1; + // // ToolStrip2 // this.ToolStrip2.Location = new System.Drawing.Point(0, 24); @@ -695,23 +702,27 @@ private void InitializeComponent() this.toolStripProgressBar2.Size = new System.Drawing.Size(100, 16); this.toolStripProgressBar2.Value = 50; // - // PropertyGridTab + // listControls1 // - this.PropertyGridTab.Controls.Add(this.PropertyGrid); - this.PropertyGridTab.Location = new System.Drawing.Point(4, 22); - this.PropertyGridTab.Name = "PropertyGridTab"; - this.PropertyGridTab.Padding = new System.Windows.Forms.Padding(3); - this.PropertyGridTab.Size = new System.Drawing.Size(689, 298); - this.PropertyGridTab.TabIndex = 4; - this.PropertyGridTab.Text = "Property Grid"; - this.PropertyGridTab.UseVisualStyleBackColor = true; + this.listControls1.Location = new System.Drawing.Point(6, 19); + this.listControls1.Name = "listControls1"; + this.listControls1.Size = new System.Drawing.Size(260, 204); + this.listControls1.TabIndex = 0; // - // PropertyGrid + // inputControls1 // - this.PropertyGrid.Location = new System.Drawing.Point(6, 6); - this.PropertyGrid.Name = "PropertyGrid"; - this.PropertyGrid.Size = new System.Drawing.Size(251, 286); - this.PropertyGrid.TabIndex = 1; + this.inputControls1.Location = new System.Drawing.Point(6, 6); + this.inputControls1.Name = "inputControls1"; + this.inputControls1.Size = new System.Drawing.Size(618, 286); + this.inputControls1.TabIndex = 0; + // + // DataGridControl + // + this.DataGridControl.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.DataGridControl.Location = new System.Drawing.Point(6, 142); + this.DataGridControl.Name = "DataGridControl"; + this.DataGridControl.Size = new System.Drawing.Size(677, 150); + this.DataGridControl.TabIndex = 11; // // Form1 // @@ -739,13 +750,14 @@ private void InitializeComponent() this.PanelWithText.PerformLayout(); this.DataGridTab.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.DataGrid)).EndInit(); + this.PropertyGridTab.ResumeLayout(false); this.ToolStrip1.ResumeLayout(false); this.ToolStrip1.PerformLayout(); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); this.statusStrip.ResumeLayout(false); this.statusStrip.PerformLayout(); - this.PropertyGridTab.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.DataGridControl)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -818,6 +830,7 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar2; private System.Windows.Forms.TabPage PropertyGridTab; private System.Windows.Forms.PropertyGrid PropertyGrid; + private System.Windows.Forms.DataGridView DataGridControl; } } diff --git a/src/TestApplications/WindowsFormsTestApplication/Form1.cs b/src/TestApplications/WindowsFormsTestApplication/Form1.cs index f936113a..c90894a2 100644 --- a/src/TestApplications/WindowsFormsTestApplication/Form1.cs +++ b/src/TestApplications/WindowsFormsTestApplication/Form1.cs @@ -21,6 +21,19 @@ public Form1() TreeView.Nodes.Add(treeViewItem); PopulateDataGrid(); PropertyGrid.SelectedObject = new BasicTypes("str", false, 6, 1.2f); + DataGridControl.DataSource = TestItems; + } + + public TestItem[] TestItems + { + get + { + return new[]{ + new TestItem {Id = 1, Contents = "Item1", Description = "Simple item 1"}, + new TestItem {Id = 2, Contents = "Item2", Description = ""}, + new TestItem {Id = 3, Contents = "Item3"} + }; + } } private void GetMultiple_Click(object sender, System.EventArgs e) diff --git a/src/TestApplications/WindowsFormsTestApplication/Form1.resx b/src/TestApplications/WindowsFormsTestApplication/Form1.resx index c3669cce..6cf7f4dc 100644 --- a/src/TestApplications/WindowsFormsTestApplication/Form1.resx +++ b/src/TestApplications/WindowsFormsTestApplication/Form1.resx @@ -120,6 +120,9 @@ 17, 17 + + 17, 17 + @@ -345,6 +348,21 @@ True + + True + + + True + + + True + + + True + + + True + 829, 17 diff --git a/src/TestApplications/WindowsFormsTestApplication/TestItem.cs b/src/TestApplications/WindowsFormsTestApplication/TestItem.cs new file mode 100644 index 00000000..c386bdd1 --- /dev/null +++ b/src/TestApplications/WindowsFormsTestApplication/TestItem.cs @@ -0,0 +1,9 @@ +namespace WindowsFormsTestApplication +{ + public class TestItem + { + public int Id { get; set; } + public string Contents { get; set; } + public string Description { get; set; } + } +} \ No newline at end of file diff --git a/src/TestApplications/WindowsFormsTestApplication/WindowsFormsTestApplication.csproj b/src/TestApplications/WindowsFormsTestApplication/WindowsFormsTestApplication.csproj index f969b0be..5e5a479c 100644 --- a/src/TestApplications/WindowsFormsTestApplication/WindowsFormsTestApplication.csproj +++ b/src/TestApplications/WindowsFormsTestApplication/WindowsFormsTestApplication.csproj @@ -120,6 +120,7 @@ WindowWithScrollbars.cs + CustomUIItemScenario.cs diff --git a/src/TestApplications/WpfTestApplication/HelpClasses.cs b/src/TestApplications/WpfTestApplication/HelpClasses.cs new file mode 100644 index 00000000..5b99e683 --- /dev/null +++ b/src/TestApplications/WpfTestApplication/HelpClasses.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; + +namespace WpfTestApplication +{ + public class TestItem + { + public int Id { get; set; } + public string Contents { get; set; } + public string Description { get; set; } + } +} diff --git a/src/TestApplications/WpfTestApplication/MainWindow.xaml b/src/TestApplications/WpfTestApplication/MainWindow.xaml index 580c3b25..9050d34a 100644 --- a/src/TestApplications/WpfTestApplication/MainWindow.xaml +++ b/src/TestApplications/WpfTestApplication/MainWindow.xaml @@ -80,6 +80,9 @@ + + + diff --git a/src/TestApplications/WpfTestApplication/MainWindow.xaml.cs b/src/TestApplications/WpfTestApplication/MainWindow.xaml.cs index 4d96ab3d..3ab913ed 100644 --- a/src/TestApplications/WpfTestApplication/MainWindow.xaml.cs +++ b/src/TestApplications/WpfTestApplication/MainWindow.xaml.cs @@ -158,5 +158,17 @@ private void ClickMe_OnClick(object sender, RoutedEventArgs e) { AutomationProperties.SetHelpText(this, "Click Me Clicked"); } + + public TestItem[] TestItems + { + get + { + return new[]{ + new TestItem {Id = 1, Contents = "Item1", Description = "Simple item 1"}, + new TestItem {Id = 2, Contents = "Item2", Description = ""}, + new TestItem {Id = 3, Contents = "Item3"} + }; + } + } } } diff --git a/src/TestApplications/WpfTestApplication/WpfTestApplication.csproj b/src/TestApplications/WpfTestApplication/WpfTestApplication.csproj index 25ad1f82..ae5398f4 100644 --- a/src/TestApplications/WpfTestApplication/WpfTestApplication.csproj +++ b/src/TestApplications/WpfTestApplication/WpfTestApplication.csproj @@ -123,6 +123,7 @@ HorizontalGridSplitter.xaml + ListControls.xaml diff --git a/src/TestStack.White.UITests/ControlTests/DataGridTests.cs b/src/TestStack.White.UITests/ControlTests/DataGridTests.cs new file mode 100644 index 00000000..683bfeda --- /dev/null +++ b/src/TestStack.White.UITests/ControlTests/DataGridTests.cs @@ -0,0 +1,65 @@ +using System.Collections.Generic; +using TestStack.White.UIItems; +using TestStack.White.UIItems.Finders; +using TestStack.White.UIItems.TableItems; +using Xunit; + +namespace TestStack.White.UITests.ControlTests +{ + public class DataGridTests : WhiteTestBase + { + protected ListView DataGridWpfUnderTest { get; set; } + protected Table DataGridWinFormsUnderTest { get; set; } + + protected override void ExecuteTestRun(WindowsFramework framework) + { + SelectDataGridTab(); + if (framework == WindowsFramework.Wpf) + { + DataGridWpfUnderTest = MainWindow.Get(SearchCriteria.ByAutomationId("DataGridControl")); + RunTest(CanGetAllItemsWpf); + RunTest(CanGetCellWpf); + } + else if (framework == WindowsFramework.WinForms) + { + DataGridWinFormsUnderTest = MainWindow.Get(SearchCriteria.ByAutomationId("DataGridControl")); + RunTest(CanGetAllItemsWinforms); + } + } + + void CanGetAllItemsWpf() + { + var rows = DataGridWpfUnderTest.Rows; + Assert.Equal(3, rows.Count); + var row1 = rows.Get(0); + Assert.Equal(3, row1.Cells.Count); + Assert.Equal("1", row1.Cells[0].Text); + Assert.Equal("Item1", row1.Cells[1].Text); + Assert.Contains("Simple", row1.Cells[2].Text); + } + + void CanGetCellWpf() + { + Assert.Equal("Item1", DataGridWpfUnderTest.Cell("Contents", 0).Text); + Assert.Equal("Item2", DataGridWpfUnderTest.Cell("Contents", 1).Text); + Assert.Equal("Item3", DataGridWpfUnderTest.Cell("Contents", 2).Text); + } + + void CanGetAllItemsWinforms() + { + var rows = DataGridWinFormsUnderTest.Rows; + Assert.Equal(3, rows.Count); + var row1 = rows[0]; + Assert.Equal(3, row1.Cells.Count); + Assert.Equal("1", row1.Cells[0].Value); + Assert.Equal("Item1", row1.Cells[1].Value); + Assert.Contains("Simple", (string)row1.Cells[2].Value); + } + + protected override IEnumerable SupportedFrameworks() + { + yield return WindowsFramework.WinForms; + yield return WindowsFramework.Wpf; + } + } +} diff --git a/src/TestStack.White.UITests/ControlTests/WPF/DataGridTests.cs b/src/TestStack.White.UITests/ControlTests/WPF/DataGridTests.cs new file mode 100644 index 00000000..b71571aa --- /dev/null +++ b/src/TestStack.White.UITests/ControlTests/WPF/DataGridTests.cs @@ -0,0 +1,51 @@ +using System.Collections.Generic; +using NUnit.Framework; +using TestStack.White.UITests.Infrastructure; +using White.Core.UIItems; +using White.Core.UIItems.Finders; +using White.Core.UIItems.WPFUIItems; + +namespace TestStack.White.UITests.ControlTests.WPF +{ + public class DataGridTests : WhiteTestBase + { + protected ListView DataGridUnderTest { get; set; } + protected ListView DataGridFromCustomControlUnderTest { get; set; } + + protected override void RunTest(WindowsFramework framework) + { + DataGridUnderTest = MainWindow.Get(SearchCriteria.ByAutomationId("DataGridControl")); + var customControl = MainWindow.Get(SearchCriteria.ByAutomationId("CustomDataGridControl")) as UIItem; + DataGridFromCustomControlUnderTest = customControl.Get(SearchCriteria.ByAutomationId("DataGridControl")); + + RunTest(() => CanGetAllItems(DataGridUnderTest)); + RunTest(() => CanGetAllItems(DataGridFromCustomControlUnderTest)); + RunTest(() => CanGetCell(DataGridUnderTest)); + RunTest(() => CanGetCell(DataGridFromCustomControlUnderTest)); + } + + void CanGetAllItems(ListView dataGridUnderTest) + { + var rows = dataGridUnderTest.Rows; + Assert.AreEqual(3, rows.Count); + var row1 = rows.Get(0); + Assert.AreEqual(3, row1.Cells.Count); + Assert.AreEqual("1", row1.Cells[0].Text); + Assert.AreEqual("Item1", row1.Cells[1].Text); + StringAssert.Contains("Simple", row1.Cells[2].Text); + } + + void CanGetCell(ListView dataGridUnderTest) + { + var cell = dataGridUnderTest.Cell("Contents", 0); + Assert.AreEqual("Item1", cell.Text); + Assert.AreEqual("Item2", dataGridUnderTest.Cell("Contents", 1).Text); + Assert.AreEqual("Item3", dataGridUnderTest.Cell("Contents", 2).Text); + } + + protected override IEnumerable SupportedFrameworks() + { + yield return WindowsFramework.Wpf; + } + } +} diff --git a/src/TestStack.White.UITests/MessageBoxTest2.cs b/src/TestStack.White.UITests/MessageBoxTest2.cs new file mode 100644 index 00000000..ae9b10a9 --- /dev/null +++ b/src/TestStack.White.UITests/MessageBoxTest2.cs @@ -0,0 +1,32 @@ +using NUnit.Framework; +using White.Core.UIItems; +using White.Core.UIItems.Finders; +using White.Core.UIItems.WindowItems; +using White.Core.UITests.Testing; + +namespace White.Core.UITests +{ + [TestFixture, WinFormCategory, WPFCategory] + public class MessageBoxTest : ControlsActionTest + { + [Test] + public void CloseMessageBoxTest() + { + Window.Get