From f66d9c82096d3d4fb5e64a2c5c34177a0d070f15 Mon Sep 17 00:00:00 2001 From: Thyagarajan Balakrishnan Date: Fri, 13 Jan 2012 11:31:24 +0200 Subject: [PATCH] TDriver failure workaround RevBy: Marek Ruszczak --- .../harmattan/testscripts/get-coordinates.rb | 44 +++++++++++++------ tests/harmattan/testscripts/test-perf.rb | 5 ++- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/tests/harmattan/testscripts/get-coordinates.rb b/tests/harmattan/testscripts/get-coordinates.rb index fe8a818..053a16d 100755 --- a/tests/harmattan/testscripts/get-coordinates.rb +++ b/tests/harmattan/testscripts/get-coordinates.rb @@ -66,7 +66,7 @@ end pos = 0 appName=options[:application] -sut = TDriver.sut(:Id=> 'sut_qt_maemo') +@sut = TDriver.sut(:Id=> 'sut_qt_maemo') # Check if TDriver can attach to meegotouch instance. # If not, this might be caused because MtHome is started @@ -75,7 +75,7 @@ sut = TDriver.sut(:Id=> 'sut_qt_maemo') @meegoHome = nil begin - @meegoHome = sut.application(:name => 'meegotouchhome') + @meegoHome = @sut.application(:name => 'meegotouchhome') puts "Meegotouchhome found" rescue MobyBase::TestObjectNotFoundError @@ -129,26 +129,44 @@ if options[:grid] exit 0; end -@meegoHome = sut.application(:name => 'meegotouchhome') - - -sleep(2) +def swipe(direction) + puts "swiping #{direction.to_s}" + glass = @meegoHome.SwipePannableViewport( :name => 'SwipePage' ).MWidget( :name => 'glass' ) + glass.gesture(direction, 1, 350) +end -if @meegoHome.test_object_exists?(:text => appName) - icon = @meegoHome.SwipeLauncherButton(:text => appName) +def get_pos(app) + icon = @meegoHome.SwipeLauncherButton(:text => app) + icon.refresh #refreshing icon attributes + swipe(:Down) if icon.attribute('visibleOnScreen') == 'false' #swiping also refreshes attributes while icon.attribute('visibleOnScreen') == 'false' || icon.attribute('y').to_i > 400 - @meegoHome.SwipePannableViewport( :name => 'SwipePage' ).MWidget( :name => 'glass' ).gesture(:Up, 1, 350) + swipe(:Up) sleep(0.2) icon.refresh end - xpos = @meegoHome.SwipeLauncherButton(:text => appName).attribute('x') - xpos = xpos.to_i + 59 - ypos = @meegoHome.SwipeLauncherButton(:text => appName).attribute('y') - ypos = ypos.to_i + 58 + xpos = icon.attribute('x').to_i + 59 + ypos = icon.attribute('y').to_i + 58 @pos = "#{xpos}x#{ypos}" puts @pos +end + +@meegoHome = @sut.application(:name => 'meegotouchhome') +sleep(1) + +if @meegoHome.test_object_exists?(:text => appName) + get_pos(appName) + exit 0 #exit gracefully +end + +puts "initializing again" +@sut = TDriver.sut(:Id=> 'sut_qt_maemo') +@meegoHome = @sut.application(:name => 'meegotouchhome') + +puts "check object again" +if @meegoHome.test_object_exists?(:text => appName) + get_pos(appName) exit 0 #exit gracefully else #icon does not exist diff --git a/tests/harmattan/testscripts/test-perf.rb b/tests/harmattan/testscripts/test-perf.rb index e470df7..69b6bdd 100755 --- a/tests/harmattan/testscripts/test-perf.rb +++ b/tests/harmattan/testscripts/test-perf.rb @@ -299,8 +299,9 @@ class TC_PerformanceTests < Test::Unit::TestCase else #Check the system load is under 0.1 waitload(0.1) - @pos = `#{GET_COORDINATES_SCRIPT} -a #{@options[:application]}` - @pos = @pos.split("\n")[-1] + op = `#{GET_COORDINATES_SCRIPT} -a #{@options[:application]}` + print_debug("#{op}") + @pos = op.split("\n")[-1] print_debug ("Co-ordinates: #{@pos}") x_val = Integer(@pos.split("x")[0]) y_val = Integer(@pos.split("x")[1])