Commit 4a72c8e2 authored by Marc Duez's avatar Marc Duez

interface : watir test , better setup and teardown

parent cf884e08
......@@ -6,36 +6,47 @@ require 'minitest/autorun'
class TestBrowser < MiniTest::Unit::TestCase
#OMG i'm so ashamed ( best function name ever !)
i_suck_and_my_tests_are_order_dependent!
#i_suck_and_my_tests_are_order_dependent!
$flag = nil
$c = 0
$max_test = 9
def test_01_start
begin
folder_path = Dir.pwd
$index_path = 'file://' + folder_path + '/../index.html'
$data_path = folder_path + '/test.data'
#$b = Watir::Browser.new :firefox
$b = Watir::Browser.new :chrome
$b.goto $index_path
assert ($b.text.include? "Vidjil"), ">> fail to start Vidjil browser"
# close the welcoming popup
$b.div(:id => 'popup-msg').button(:text => 'start').click
def setup
unless $flag
begin
folder_path = Dir.pwd
$index_path = 'file://' + folder_path + '/../index.html'
$data_path = folder_path + '/test.data'
#$b = Watir::Browser.new :firefox
$b = Watir::Browser.new :chrome
$b.goto $index_path
assert ($b.text.include? "Vidjil"), ">> fail to start Vidjil browser"
# close the welcoming popup
$b.div(:id => 'popup-msg').button(:text => 'start').click
# select data file
$b.div(:id => 'file_menu').file_field(:name,"json").set($data_path)
$b.div(:id => 'file_menu').button(:text => 'start').click
assert ($b.text.include? "test.data"), ">> fail to load data"
rescue
assert (false), "missing element to run test_02_load \n"
# select data file
$b.div(:id => 'file_menu').file_field(:name,"json").set($data_path)
$b.div(:id => 'file_menu').button(:text => 'start').click
assert ($b.text.include? "test.data"), ">> fail to load data"
rescue
assert (false), "missing element to run test_setup \n"
end
$flag = true
end
#unselect
$b.execute_script("m.resetClones()")
$b.element(:id => "visu_back" ).click
$c = $c + 1
end
def test_02_init
def test_01_init
begin
list = $b.div(:id => 'listClones')
......@@ -44,12 +55,12 @@ class TestBrowser < MiniTest::Unit::TestCase
assert ( $b.element(:id => "polyline0" ).exists?), ">>fail init : clone 0 missing in graph"
assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '64.750%' ) , ">>fail init : wrong clone size "
rescue
assert (false), "missing element to run test_02_init \n"
assert (false), "missing element to run test_01_init \n"
end
end
def test_03_focus
def test_02_focus
begin
#test hover a clone in the list
......@@ -68,12 +79,12 @@ class TestBrowser < MiniTest::Unit::TestCase
#watir unable to do hover/click on svg path
rescue
assert (false), "missing element to run test_03_focus \n"
assert (false), "missing element to run test_02_focus \n"
end
end
def test_04_select
def test_03_select
begin
#test select a clone in the list
......@@ -104,12 +115,12 @@ class TestBrowser < MiniTest::Unit::TestCase
assert ( list.li(:id => '0' ).class_name == "list" )
rescue
assert (false), "missing element to run test_04_select \n"
assert (false), "missing element to run test_03_select \n"
end
end
def test_05_cluster
def test_04_cluster
begin
list = $b.div(:id => 'listClones')
$b.execute_script("m.clusterBy('V')")
......@@ -122,12 +133,12 @@ class TestBrowser < MiniTest::Unit::TestCase
assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '64.750%' ) , ">> fail reset cluster : wrong clone size "
rescue
assert (false), "missing element to run test_05_cluster \n"
assert (false), "missing element to run test_04_cluster \n"
end
end
def test_06_normalize
def test_05_normalize
begin
list = $b.div(:id => 'listClones')
$b.execute_script("m.normalization_switch(true)")
......@@ -136,12 +147,12 @@ class TestBrowser < MiniTest::Unit::TestCase
$b.execute_script("m.normalization_switch(false)")
assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '64.750%' ) , ">> fail normalize off : wrong clone size "
rescue
assert (false), "missing element to run test_06_normalize \n"
assert (false), "missing element to run test_05_normalize \n"
end
end
def test_07_displayTop
def test_06_displayTop
begin
list = $b.div(:id => 'listClones')
$b.execute_script("m.displayTop(100)")
......@@ -151,12 +162,12 @@ class TestBrowser < MiniTest::Unit::TestCase
assert ( not list.li(:id => '120' ).visible? ) , ">> fail display : this clone shouldn't be visible"
rescue
assert (false), "missing element to run test_07_displayTop \n"
assert (false), "missing element to run test_06_displayTop \n"
end
end
def test_08_merge
def test_07_merge
begin
list = $b.div(:id => 'listClones')
#select 3 clones
......@@ -174,12 +185,12 @@ class TestBrowser < MiniTest::Unit::TestCase
assert ( list.li(:id => '0' ).span(:class => 'sizeBox').text == '64.750%' ) , ">> fail unclustering : wrong clone size "
rescue
assert (false), "missing element to run test_08_merge \n"
assert (false), "missing element to run test_07_merge \n"
end
end
def test_09_imgt
def test_08_imgt
begin
list = $b.div(:id => 'listClones')
#select 3 clones
......@@ -197,12 +208,12 @@ class TestBrowser < MiniTest::Unit::TestCase
$b.window(:title => "Vidjil").use
rescue
assert (false), "missing element to run test_09_imgt \n"
assert (false), "missing element to run test_08_imgt \n"
end
end
def test_10_igBlast
def test_09_igBlast
begin
list = $b.div(:id => 'listClones')
#select 3 clones
......@@ -220,23 +231,16 @@ class TestBrowser < MiniTest::Unit::TestCase
$b.window(:title => "Vidjil").use
rescue
assert (false), "missing element to run test_10_igBlast \n"
assert (false), "missing element to run test_09_igBlast \n"
end
end
#bug with ruby 1.9.3
#MiniTest::Unit.after_tests { $b.close }
def teardown
#unselect
$b.execute_script("m.resetClones()")
$b.element(:id => "visu_back" ).click
end
def test_99_end
begin
#$b.close
rescue
assert (false), "missing element to run test_99_end \n"
if ( $c == $max_test)
$b.close
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment