Fix non-deterministic user acceptance tests

This commit is contained in:
Thibault Jouan 2015-04-21 13:38:34 +00:00
parent 47bc9c9da2
commit 730527b836
6 changed files with 23 additions and 21 deletions

View File

@ -8,5 +8,5 @@ Feature: layout client management
Then the window must be mapped
Scenario: focuses new client window
When a window requests to be mapped
When a window is mapped
Then the window must be focused

View File

@ -30,6 +30,6 @@ Feature: layout protocol
Scenario: tells the layout to unmanage a client with #remove message
Given uhwm is running with options -v -r./layout -l Layout
And a window is managed
And a window is mapped
When the window is unmapped
Then the output must contain "testing_#remove_XClient/default"

View File

@ -2,8 +2,8 @@ Feature: layout client unmanagement
Background:
Given uhwm is running
And a first window is managed
And a second window is managed
And a first window is mapped
And a second window is mapped
Scenario: maps another window
When the second window is unmapped

View File

@ -2,10 +2,10 @@ Feature: manager client unmanagement
Background:
Given uhwm is running
And a window is managed
And a window is mapped
Scenario: logs when a new client is unmanaged
When the window requests to be unmapped
When the window is unmapped
Then the output must match /unmanag.+xclient/i
Scenario: unmanages client on destroy notify X events

View File

@ -1,7 +1,8 @@
Given /^a(?:\s(\w+))? window is managed$/ do |ident|
ident ||= :default
Given /^a(?:\s(\w+))? window is mapped$/ do |ident|
x_client(ident).map.sync
uhwm_wait_output /manag.+#{x_client(ident).name}/i
timeout_until 'window not mapped after %d seconds' do
x_window_map_state(x_client(ident).window_id) == 'IsViewable'
end
end
When /^I press the ([^ ]+) keys?$/ do |keys|
@ -16,14 +17,11 @@ When /^a window requests to be mapped (\d+) times$/ do |times|
x_client.map times: times.to_i
end
When /^the window requests to be unmapped$/ do
x_client.unmap.sync
end
When /^the(?:\s(\w+))? window is unmapped$/ do |ident|
ident ||= :default
x_client(ident).unmap.sync
uhwm_wait_output /unmanag.+#{x_client(ident).name}/i
timeout_until 'window not unmapped after %d seconds' do
x_window_map_state(x_client(ident).window_id) == 'IsUnMapped'
end
end
When /^the window is destroyed$/ do
@ -36,12 +34,15 @@ Then /^it must connect to X display$/ do
end
Then /^the(?:\s(\w+))? window must be mapped$/ do |ident|
ident ||= :default
expect(x_window_map_state x_client(ident).window_id).to eq 'IsViewable'
timeout_until 'window not mapped after %d seconds' do
x_window_map_state(x_client(ident).window_id) == 'IsViewable'
end
end
Then /^the window must be focused$/ do
expect(x_focused_window_id).to eq x_client.window_id
timeout_until 'window not focused after %d seconds' do
x_focused_window_id == x_client.window_id
end
end
Then /^the input event mask must include (.+)$/ do |mask|

View File

@ -64,7 +64,8 @@ module Uh
@other_wm
end
def x_client ident = :default
def x_client ident = nil
ident ||= :default
@x_clients ||= {}
@x_clients[ident] ||= XClient.new(ident)
end
@ -103,7 +104,7 @@ module Uh
private
def timeout_until
def timeout_until message = 'condition not met after %d seconds'
timeout = ENV.key?('UHWMTEST_TIMEOUT') ?
ENV['UHWMTEST_TIMEOUT'].to_i :
TIMEOUT_DEFAULT
@ -114,7 +115,7 @@ module Uh
end
end
rescue Timeout::Error
fail TimeoutError.new('execution expired', timeout)
fail TimeoutError.new(message % timeout, timeout)
end