Class: MobyUtil::Widget

Inherits:
Object
  • Object
show all
Defined in:
lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/widget.rb

Class Method Summary collapse

Class Method Details

.tap_updown_object(tap_params, y, button, identity, command_name) ⇒ Object

Common method, tap up or down



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/util/widget.rb', line 26

def self.tap_updown_object(tap_params, y, button, identity, command_name)
  begin
    behavior_name = command_name == 'MousePress' ? 'tap_down_object' : 'tap_up_object'
    if tap_params.kind_of? Hash
      x = tap_params[:x].nil? ?  -1 : tap_params[:x]
      y = tap_params[:y].nil? ? -1 : tap_params[:y]
      button = tap_params[:button].nil? ? (:Left) : tap_params[:button]
      use_tap_screen = tap_params[:use_tap_screen] == true ? 'true' : 
        $parameters[ @sut.id][ :use_tap_screen, 'false']
    else
      x = tap_params
      use_tap_screen = $parameters[ @sut.id ][ :use_tap_screen, 'false' ]
    end

    raise ArgumentError.new( "Coordinate x:#{x} x_abs:#{x} outside object." ) unless (x <= attribute('width').to_i and x >= 0)
    raise ArgumentError.new( "Coordinate y:#{y} y_abs:#{y} outside object." ) unless (y <= attribute('height').to_i and y >= 0)

    command = command_params #in qt_behaviour
    command.command_name(command_name)

    x_tap = attribute('x_absolute').to_i + x.to_i
    y_tap = attribute('y_absolute').to_i + y.to_i

    mouse_move = @sut.parameter[:in_tap_move_pointer]
    mouse_move = 'false' unless mouse_move

    params = { 'x'=>x_tap.to_s, 'y' => y_tap.to_s, 'button' => @@_buttons_map[button], 'mouseMove'=>mouse_move }
    # use coordinates
    params['useCoordinates'] = 'true'
    params['useTapScreen'] = use_tap_screen
    command.command_params(params)

    @sut.execute_command(command)			

  rescue Exception => e

    $logger.behaviour "FAIL;Failed #{behavior_name} with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};#{behavior_name};"
    raise e

  end

  $logger.behaviour "PASS;Operation #{behavior_name} executed successfully with x \"#{x}\", y \"#{y}\", button \"#{button.to_s}\".;#{identity};#{behavior_name};"

  nil


  
end