Skip to content

Commit

Permalink
Improve widget matching
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Nov 17, 2017
1 parent 4308b1f commit 8d4a6bd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion features/repository_add_new_repo.feature
Expand Up @@ -31,7 +31,7 @@ Feature: To install the 3rd party packages I must be able to add a new package

When I click button "Cancel"
Then a popup should be displayed
And the "Abort the repository configuration?" label should be displayed
And the label including "Abort the repository configuration?" should be displayed

Then I click button "Yes"
And I wait for the application to finish
Expand Down
29 changes: 22 additions & 7 deletions features/step_definitions/ui_test_steps.rb
Expand Up @@ -81,29 +81,44 @@ def timed_retry(seconds, &block)
end
end

Then(/^the dialog heading should be "(.*)"(?: in (\d+) seconds)?$/) do |heading, seconds|
WIDGET_MAPPING = {
"label" => "YLabel",
"checkbox" => "YCheckBox",
"check box" => "YCheckBox",
"radiobutton" => "YRadioButton",
"radio button" => "YRadioButton",
"pushbutton" => "YPushButton",
"push button" => "YPushButton",
"button" => "YPushButton",
}

TIMEOUT_REGEXP = "(?: in (\\d+) seconds)?"

WIDGET_REGEXP = "(widget|label|check(?: )?box|radio(?: )?button|(?:push(?: )?)?button) "

Then(/^the dialog heading should be "(.*)"#{TIMEOUT_REGEXP}$/) do |heading, seconds|
timed_retry(seconds) do
read_widget(type: "YWizard")["debug_label"] == heading
end
end

Then(/^(?:the )?"(.*)" (exact |matching |)label should be displayed(?: in (\d+) seconds)?$/) \
do |label, match, seconds|
Then(/^(?:a |the )?#{WIDGET_REGEXP}(?:having )?(matching |including |)"(.*)"(label )? should be displayed#{TIMEOUT_REGEXP}$/) \
do |type, match, label, label_type, seconds|
timed_retry(seconds) do
widgets = read_widgets(type: "YLabel")
widgets = read_widgets(type: WIDGET_MAPPING[type])

case match
when "exact"
when ""
!with_label(widgets, label).empty?
when "matching "
!matching_label(widgets, label).empty?
when ""
when "including "
!including_label(widgets, label).empty?
end
end
end

Then(/^(?:a )popup should be displayed(?: in (\d+) seconds)?$/) do |seconds|
Then(/^(?:a )popup should be displayed#{TIMEOUT_REGEXP}$/) do |seconds|
timed_retry(seconds) do
read_widget(type: "YDialog")["type"] == "popup"
end
Expand Down

0 comments on commit 8d4a6bd

Please sign in to comment.