Skip to content

Commit

Permalink
Merge pull request #91 from Omenia/listview-doubleclick
Browse files Browse the repository at this point in the history
New and renamed keywords for ListView
  • Loading branch information
eeromakiesko authored Feb 11, 2019
2 parents 70bac3d + da7b377 commit 1fda5de
Show file tree
Hide file tree
Showing 5 changed files with 235 additions and 92 deletions.
76 changes: 58 additions & 18 deletions UIAutomationTest/TestWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,46 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="UI Automation Test Window" Height="750" WindowStartupLocation="CenterScreen">
<Window.Resources>
<XmlDataProvider x:Key="MockList" XPath="/MockObjects/*" >
<x:XData >
<XmlDataProvider x:Key="MockList" XPath="/MockObjects/*" >
<x:XData>
<MockObjects xmlns="">
<MockObject Title="Robinson Crusoe" />
<MockObject Title="Bible" />
<MockObject Title="The Art of Computer Programming" />
</MockObjects>
</x:XData>
</XmlDataProvider>
<XmlDataProvider x:Key="MockList2" XPath="/MockObjects/*" >
<x:XData >
<XmlDataProvider x:Key="MockList2" XPath="/MockObjects/*" >
<x:XData>
<MockObjects xmlns="">
<MockObject Author="Daniel Defoe" Title="Robinson Crusoe" Category="Fiction"/>
<MockObject Author="Various Artists" Title="Bible" Category="Religious" />
<MockObject Author="Donald Knuth" Title="The Art of Computer Programming" Category="Science" />
</MockObjects>
</x:XData>
</XmlDataProvider>
<XmlDataProvider x:Key="BirdList" XPath="/MockObjects/*" >
<x:XData>
<MockObjects xmlns="">
<MockObject Name="Budgerigar" Scientific="Melopsittacus undulatus"/>
<MockObject Name="Common raven" Scientific="Corvus corax"/>
<MockObject Name="Dodo" Scientific="Raphus cucullatus"/>
</MockObjects>
</x:XData>
</XmlDataProvider>
</Window.Resources>
<Grid Margin="0,0,-5,0">
<Grid>
<Grid.Resources>
<Style TargetType="{x:Type TreeViewItem}">
<EventSetter Event="Selected" Handler="treeNodeSelect"/>
<EventSetter Event="MouseDoubleClick" Handler="treeNodeDoubleClick"/>
<EventSetter Event="MouseRightButtonDown" Handler="treeNodeRightClick"/>
<EventSetter Event="Expanded" Handler="treeNodeExpanded"/>
</Style>
<Style TargetType="{x:Type DataGridCell}">
<EventSetter Event="MouseRightButtonDown" Handler="dataGridCellRightClick"/>
<EventSetter Event="Selected" Handler="dataGridCellSelect"/>
</Style>
</Grid.Resources>

<ScrollViewer>
<TabControl AutomationProperties.AutomationId="tabControl" Grid.ColumnSpan="2" Margin="0,0,0,0.2">
<TabControl AutomationProperties.AutomationId="tabControl" Grid.ColumnSpan="2">
<TabItem Header="Tab1">
<StackPanel>
<Grid>
Expand Down Expand Up @@ -140,10 +146,10 @@
</StackPanel>
</TabItem>
<TabItem Header="Tab2">
<StackPanel Orientation="Vertical">
<StackPanel>
<Label Name="selectionIndicatorLabel">nothing selected</Label>
<Label Name="cursorPosition"
MouseMove="cursorPositionShow"></Label>
MouseMove="cursorPositionShow">move mouse</Label>
<ToolBar AutomationProperties.AutomationId="tools">
<Button Click="toolStripButtonClick">Toolstrip button 1</Button>
<Button Click="toolStripButtonClick">Toolstrip button 2</Button>
Expand All @@ -154,6 +160,13 @@
ItemsSource="{Binding Mode=Default, XPath=/MockObjects/MockObject}"
AutoGenerateColumns="False"
IsReadOnly="True">
<DataGrid.Resources>
<Style TargetType="DataGridRow">
<EventSetter Event="MouseDoubleClick" Handler="datagridRowDoubleClick"/>
<EventSetter Event="MouseRightButtonUp" Handler="dataGridRowRightClick"/>
<EventSetter Event="Selected" Handler="dataGridRowSelect"/>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Header="Title" Binding="{Binding XPath=@Title}" Width="*" />
</DataGrid.Columns>
Expand All @@ -172,23 +185,31 @@
<DataGrid AutomationProperties.AutomationId="list_view2"
ItemsSource="{Binding Mode=Default, XPath=/MockObjects/MockObject}"
AutoGenerateColumns="False"
IsReadOnly="True">
IsReadOnly="True"
SelectionUnit="Cell">
<DataGrid.Resources>
<Style TargetType="{x:Type DataGridCell}">
<EventSetter Event="MouseRightButtonUp" Handler="dataGridCellRightClick"/>
<EventSetter Event="MouseDoubleClick" Handler="dataGridCellDoubleClick"/>
<EventSetter Event="Selected" Handler="dataGridCellSelect"/>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Header="Author" Binding="{Binding XPath=@Author}" Width="Auto" />
<DataGridTextColumn Header="Title" Binding="{Binding XPath=@Title}" Width="Auto" />
<DataGridTextColumn Header="Category" Binding="{Binding XPath=@Category}" Width="Auto" />
<DataGridTextColumn Header="Author" Binding="{Binding XPath=@Author}" Width="*" />
<DataGridTextColumn Header="Title" Binding="{Binding XPath=@Title}" Width="*" />
<DataGridTextColumn Header="Category" Binding="{Binding XPath=@Category}" Width="*" />
</DataGrid.Columns>
</DataGrid>
</Grid>
<TreeView AutomationProperties.AutomationId="tree" Margin="0,0,0,0" Height="Auto">
<TreeView AutomationProperties.AutomationId="tree">
<TreeViewItem Header="Tree node 1">
<TreeViewItem Header="Tree node 1.1" />
<TreeViewItem Header="Tree node 1.2">
<TreeViewItem Header="Tree node 1.2.1" />
</TreeViewItem>
</TreeViewItem>
</TreeView>
<Grid Height="Auto" Margin="0,10,0,10">
<Grid Height="Auto">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"></ColumnDefinition>
<ColumnDefinition Width="100"></ColumnDefinition>
Expand All @@ -214,6 +235,25 @@
>
</Button>
</Grid>
<DockPanel>
<DataGrid DataContext="{Binding Source={StaticResource BirdList}}"
AutomationProperties.AutomationId="birds"
ItemsSource="{Binding Mode=Default, XPath=/MockObjects/MockObject}"
AutoGenerateColumns="False"
IsReadOnly="True">
<DataGrid.Resources>
<Style TargetType="DataGridRow">
<EventSetter Event="MouseDoubleClick" Handler="datagridRowDoubleClick"/>
<EventSetter Event="MouseRightButtonUp" Handler="dataGridRowRightClick"/>
<EventSetter Event="Selected" Handler="dataGridRowSelect"/>
</Style>
</DataGrid.Resources>
<DataGrid.Columns>
<DataGridTextColumn Header="Bird" Binding="{Binding XPath=@Name}" Width="100" />
<DataGridTextColumn Header="Scientific name" Binding="{Binding XPath=@Scientific}" Width="*" />
</DataGrid.Columns>
</DataGrid>
</DockPanel>
</StackPanel>
</TabItem>
</TabControl>
Expand Down
32 changes: 24 additions & 8 deletions UIAutomationTest/TestWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ private void menuAboutClick(object sender, RoutedEventArgs e)
MessageBox.Show(text, title, button);
}



private void treeNodeSelect(object sender, RoutedEventArgs e)
{
treeNodeEvent(sender, e, "selected");
Expand Down Expand Up @@ -140,6 +138,27 @@ private void toolStripButtonEvent(object sender, RoutedEventArgs e, string messa

}

private void datagridRowDoubleClick(object sender, RoutedEventArgs e)
{
dataGridRowEvent(sender, "double clicked");
}

private void dataGridRowSelect(object sender, RoutedEventArgs e)
{
dataGridRowEvent(sender, "selected");
}

private void dataGridRowRightClick(object sender, RoutedEventArgs e)
{
dataGridRowEvent(sender, "right clicked");
}

private void dataGridRowEvent(object sender, string message)
{
DataGridRow row = sender as DataGridRow;
selectionIndicatorLabel.Content = "Row " + row.GetIndex().ToString() + " " + message;
}

private void popupItemClick(object sender, RoutedEventArgs e)
{
MessageBox.Show("Delete not allowed");
Expand Down Expand Up @@ -172,7 +191,7 @@ private void dataGridCellEvent(object sender, RoutedEventArgs e, string message)
TextBlock cellText = node.Content as TextBlock;
if (node != null)
{
selectionIndicatorLabel.Content = cellText.Text + " " + message;
selectionIndicatorLabel.Content = cellText.Text + " " + message;
}
e.Handled = true;

Expand All @@ -189,8 +208,7 @@ private async void alertSlow(object sender, RoutedEventArgs e)
await TaskEx.Delay(5000);
selectionIndicatorLabel.Content = "Slow alert occurred";
}



private void eventLabelRightDown(object sender, RoutedEventArgs e)
{
labelEvent(sender, e, "right button down");
Expand Down Expand Up @@ -219,8 +237,7 @@ private void labelEvent(object sender, RoutedEventArgs e, string message)
{
selectionIndicatorLabel.Content = message;
}



private void eventTestButtonRightClick(object sender, RoutedEventArgs e)
{
testButtonEvent(sender, e, "right clicked");
Expand All @@ -243,6 +260,5 @@ private void cursorPositionShow(object sender, MouseEventArgs e)
Point pnt = e.GetPosition(this);
cursorPosition.Content = pnt.ToString();
}

}
}
65 changes: 45 additions & 20 deletions atests/feature_tests/listview.robot
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ Suite Teardown Select Tab Page tabControl Tab1
Row Verification
Listview Row Should Contain list_view2 Title Bible ligious
Listview Row Should Not Contain list_view2 Title Robinson Crusoe Scienc
Listview Row In Index Should Contain list_view2 2 Programming
Listview Row In Index Should Not Contain list_view2 1 Donald
Listview Row At Index Should Contain list_view2 2 Programming
Listview Row At Index Should Not Contain list_view2 1 Donald

Cell Verification
Listview Cell Text Should Be list_view2 Title 2 The Art of Computer Programming
Listview Cell Text Should Not Be list_view2 Title 2 Robinson Crusoe
Listview Cell Text In Index Should Be list_view2 2 1 The Art of Computer Programming
Listview Cell Text In Index Should Not Be list_view2 2 1 Robinson Crusoe
Listview Cell Text At Index Should Be list_view2 2 1 The Art of Computer Programming
Listview Cell Text At Index Should Not Be list_view2 2 1 Robinson Crusoe

Listview Cell Should Contain list_view2 Title 2 omputer P
Listview Cell Should Not Contain list_view2 Title 2 obinson
Listview Cell In Index Should Contain list_view2 2 1 omputer
Listview Cell In Index Should Not Contain list_view2 2 1 obinson
Listview Cell At Index Should Contain list_view2 2 1 omputer
Listview Cell At Index Should Not Contain list_view2 2 1 obinson

Unsuccessful Row Verification
Run Keyword And Expect Error Row defined by cell 'Title'='Bible' did not contain text 'abcd'
... Listview Row Should Contain list_view2 Title Bible abcd
Run Keyword And Expect Error Row defined by cell 'Title'='Robinson Crusoe' should not have contained text 'Fiction'
... Listview Row Should Not Contain list_view2 Title Robinson Crusoe Fiction
Run Keyword And Expect Error Row 2 did not contain text 'abcd'
... Listview Row In Index Should Contain list_view2 2 abcd
... Listview Row At Index Should Contain list_view2 2 abcd
Run Keyword And Expect Error Row 1 should not have contained text 'igious'
... Listview Row In Index Should Not Contain list_view2 1 igious
... Listview Row At Index Should Not Contain list_view2 1 igious

Unsuccessful Cell Verification
Run Keyword And Expect Error Cell text should have been 'Hello', found 'The Art of Computer Programming'
Expand All @@ -40,10 +40,10 @@ Unsuccessful Cell Verification
... Listview Cell Text Should Not Be list_view2 Title 2 The Art of Computer Programming

Run Keyword And Expect Error Cell (2, 1) text should have been 'Hello', found 'The Art of Computer Programming'
... Listview Cell Text In Index Should Be list_view2 2 1 Hello
... Listview Cell Text At Index Should Be list_view2 2 1 Hello

Run Keyword And Expect Error Cell (2, 1) text should not have been 'The Art of Computer Programming'
... Listview Cell Text In Index Should Not Be list_view2 2 1 The Art of Computer Programming
... Listview Cell Text At Index Should Not Be list_view2 2 1 The Art of Computer Programming

Run Keyword And Expect Error Cell did not contain text 'obinson'
... Listview Cell Should Contain list_view2 Title 2 obinson
Expand All @@ -52,10 +52,10 @@ Unsuccessful Cell Verification
... Listview Cell Should Not Contain list_view2 Title 2 omputer

Run Keyword And Expect Error Cell (2, 1) did not contain text 'obinson'
... Listview Cell In Index Should Contain list_view2 2 1 obinson
... Listview Cell At Index Should Contain list_view2 2 1 obinson

Run Keyword And Expect Error Cell (2, 1) should not have contained text 'omputer'
... Listview Cell In Index Should Not Contain list_view2 2 1 omputer
... Listview Cell At Index Should Not Contain list_view2 2 1 omputer

Get Text From ListView
${expected} Create List Donald Knuth The Art of Computer Programming Science
Expand All @@ -72,16 +72,41 @@ Get Text From ListView
${actual} Get Listview Cell Text By Index list_view2 2 2
Should Be Equal ${actual} Science

ListView Select
Select ListView Row By Index list_view 1
Bible Should Be Selected
Select Listview Row
Select ListView Row By Index birds 1
Row 1 Should Be Selected
Select ListView Row By Index list_view 2
The Art of Computer Programming Should Be Selected
Row 2 Should Be Selected
Select ListView Row list_view Title Robinson Crusoe
Robinson Crusoe Should Be Selected

ListView Right Click
Row 0 Should Be Selected

Select Listview Cell
Select Listview Cell list_view2 Author 1
Various Artists Should Be Selected
Select Listview Cell By Index list_view2 2 2
Science Should Be Selected

Right Click Listview Row
# click twice because first click selects the row
Repeat Keyword 2 Right Click Listview Row birds Bird Dodo
Row 2 Should Be Right Clicked
Repeat Keyword 2 Right Click Listview Row By Index birds 0
Row 0 Should Be Right Clicked

Right Click Listview Cell
Repeat Keyword 2 Right Click Listview Cell list_view2 Title 1
Bible Should Be Right Clicked
Repeat Keyword 2 Right Click Listview Cell list_view2 Author 0
Repeat Keyword 2 Right Click Listview Cell By Index list_view2 0 0
Daniel Defoe Should Be Right Clicked

Double Click Listview Row
Double Click ListView Row birds Bird Dodo
Row 2 Should Be Double Clicked
Double Click ListView Row By Index birds 1
Row 1 Should Be Double Clicked

Double Click Listview Cell
Double Click Listview Cell list_view2 Author 2
Donald Knuth Should Be Double Clicked
Double Click Listview Cell By Index list_view2 0 2
Fiction Should Be Double Clicked
11 changes: 5 additions & 6 deletions src/WhiteLibrary/keywords/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,18 @@ def get_white_double_click_interval(self):
def set_white_drag_step_count(self, value):
"""Sets DragStepCount for White
``value`` is integer. DragStepCount defines how many steps White Teststack uses to move dragged object to the destination.
With default value 1 the dragged object is moved instantly in a single step from start to destination.
``value`` is the DragStepCount value as integer.
DragStepCount defines how many steps White uses to move dragged object to the destination.
With default value 1 the dragged object is moved instantly in a single step from start to destination.
"""

CoreAppXmlConfiguration.Instance.DragStepCount = int(value)
logger.info("White DragStepCount set to" + str(CoreAppXmlConfiguration.Instance.DragStepCount))
return CoreAppXmlConfiguration.Instance.DragStepCount

@keyword
def get_white_drag_step_count(self):
"""Gets DragStepCount for White Teststack
"""
"""Returns DragStepCount value of White."""
return CoreAppXmlConfiguration.Instance.DragStepCount

def _get_timestr_in_milliseconds(self, time_string):
Expand Down
Loading

0 comments on commit 1fda5de

Please sign in to comment.