Module: MobyController::QT::Application

Includes:
Abstraction, MobyUtil::MessageComposer
Defined in:
lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb

Instance Method Summary collapse

Methods included from MobyUtil::MessageComposer

#close_message, #encode_string, #hash_to_attributes, #make_filters, #make_fixture_message, #make_parametrized_message, #make_xml_message, #run_message, #state_message

Instance Method Details

#executeObject

Execute the command Sends the message to the device using the @sut_adapter (see base class)

params

returns

raises

ArgumentError: raised if unsupported command type



180
181
182
183
184
185
186
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb', line 180

def execute
    
  message, return_response_crc = make_message

  @sut_adapter.send_service_request( message, return_response_crc ) if message    

end

#make_messageObject

create message to be sent sut SUT adapter - returns [ “message_body”, boolean ]



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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/testability-driver-plugins/testability-driver-qt-sut-plugin/controllers/application.rb', line 31

def make_message

  return_response_crc = false

  case @_command
  
    # application ui state
    when  :State        

      command_xml = state_message

      return_response_crc = true
    
    # launch application
    when :Run
    
      command_xml = run_message

    # close
    when :Close
    
      command_xml = close_message

    # close qttas
    when :CloseQttas

      command_xml = make_xml_message( { :service => 'closeApplication' }, 'Close', { 'uid' => '0' } )

    # kill application
    when :Kill

      command_xml = make_xml_message( { :service => 'closeApplication' }, 'Kill', { 'uid' => @_application_uid } )

    # list applications          
    when :ListApps

      service_details = { 
        :service => 'listApps', 
        :name => @_application_name, 
        :id => @_application_uid 
      }

      command_xml = make_xml_message( service_details, 'listApps', nil )

    # list applications          
    when :ListRunningProcesses

      service_details = { 
        :service => 'listRunningProcesses', 
        :name => @_application_name, 
        :id => @_application_uid 
      }

      command_xml = make_xml_message( service_details, 'listRunningProcesses', nil )

    # list started applications          
    when :ListStartedApps

      service_details = { 
        :service => 'startedApps', 
        :name => @_application_name, 
        :id => @_application_uid 
      }

      command_xml = make_xml_message( service_details, 'startedApps', nil )

    # shell command
    when :Shell

      command_xml = make_xml_message( { :service => 'shellCommand' }, 'shellCommand', @_flags, @_application_name )

    # kill all application started by agent_qt
    when :KillAll

      command_xml = make_xml_message( { :service => 'kill' }, 'Kill', nil )

    # tap screen
    when :TapScreen

      command_xml = make_xml_message( { :service =>'tapScreen' }, 'TapScreen', params)

    # bring application to foreground
    when :BringToForeground

      command_xml = make_xml_message( { :service => 'bringToForeground' }, 'BringToForeground', { 'pid' => @_application_uid } )
    
    # system info
    when :SystemInfo

      command_xml = make_xml_message( { :service => 'systemInfo' }, 'systemInfo', nil)
    
    # start process memory logging
    when :ProcessMemLoggingStart
    
      parameters = {
        'thread_name' => @_application_name, 
        'file_name' => @_flags[ :file_name ],
        'timestamp' => @_flags[ :timestamp ],
        'interval_s' => @_flags[ :interval_s ]
      }

      command_xml = make_xml_message( { :service => 'resourceLogging' }, 'ProcessMemLoggingStart', parameters )

    # stop process memory logging
    when :ProcessMemLoggingStop

      parameters = {
        'thread_name' => @_application_name,
        'return_data' => @_flags[ :return_data ]
      }

      command_xml = make_xml_message( { :service =>'resourceLogging' }, 'ProcessMemLoggingStop', parameters )

    # start CPU load generating
    when :CpuLoadStart

      parameters = {
        'cpu_load' => @_flags[ :cpu_load ]
      }

      command_xml = make_xml_message( { :service => 'resourceLogging' }, 'CpuLoadStart', parameters )

    # stop CPU load generating
    when :CpuLoadStop
    
      command_xml = make_xml_message( { :service => 'resourceLogging' }, 'CpuLoadStop', nil )

    # list application -- raises exception??
    #when :List

      #raise ArgumentError, "Unknown command! #{ @_command.to_s }"
      
  else
  
    # unknown command
    raise ArgumentError, "Unknown command! #{ @_command.to_s }"
    
  end

  [ Comms::MessageGenerator.generate( command_xml ), return_response_crc ]

end