def test_transaction_multithread
th_grp = ThreadGroup.new
ready_to_start = false
@number_of_threads.times{|nth|
th_grp.add Thread.new{
until (ready_to_start)
end
count = 0
@ntries.times do
@running_context.transaction(@driver2[nth]) {
assert_equal(@driver2[nth], @running_context.driver)
@running_context.set_page_context('Foo:0', @foo_page_context2[nth])
assert_equal(@foo_page_context2[nth], @running_context.page_context('Foo:0'))
@running_context.set_page_context('Bar:0', @bar_page_context2[nth])
assert_equal(@bar_page_context2[nth], @running_context.page_context('Bar:0'))
assert_equal(@foo_page_context2[nth], @running_context.page_context('Foo:0'))
@running_context.call_reset('Foo')
@running_context.call_reset('Bar')
@running_context.call_reset('Baz')
1.times{ @running_context.call_count('Foo') }
2.times{ @running_context.call_count('Bar') }
3.times{ @running_context.call_count('Baz') }
assert_equal(0, @running_context.call_index('Foo'))
assert_equal(1, @running_context.call_index('Bar'))
assert_equal(2, @running_context.call_index('Baz'))
@running_context.call_reset('Foo')
@running_context.call_reset('Bar')
@running_context.call_reset('Baz')
3.times{ @running_context.call_count('Foo') }
1.times{ @running_context.call_count('Bar') }
2.times{ @running_context.call_count('Baz') }
assert_equal(2, @running_context.call_index('Foo'))
assert_equal(0, @running_context.call_index('Bar'))
assert_equal(1, @running_context.call_index('Baz'))
@running_context.curr_widget = "Foo.#{nth}"
assert_equal("Foo.#{nth}", @running_context.curr_widget)
count += 1
}
end
assert_equal(@ntries, count)
}
}
ready_to_start = true
for thread in th_grp.list
thread.join
end
end