<commit_before>############################################################################
## 
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 
## All rights reserved. 
## Contact: Nokia Corporation (<EMAIL>) 
## 
## This file is part of TDriver. 
## 
## If you have questions regarding the use of this file, please contact 
## Nokia at <EMAIL> . 
## 
## This library is free software; you can redistribute it and/or 
## modify it under the terms of the GNU Lesser General Public 
## License version 2.1 as published by the Free Software Foundation 
## and appearing in the file LICENSE.LGPL included in the packaging 
## of this file. 
## 
############################################################################

module MobyBehaviour

	module QT

		module Action

			include MobyBehaviour::QT::Behaviour

			# Hover over an action
			# ==raises
			# TestObjectNotFoundError:: If this application is not the foreground application on the device under test.    
			def hover( refresh = false )

				begin

					command = command_params #in qt_behaviour
					command.object_type( :Action )
					command.command_name( 'Hover' )
					command.object_id( @parent.id )
					command.command_params( 'id' => id )
					@sut.execute_command( command )
					self.force_refresh({:id => get_application_id}) if refresh   

				rescue Exception => e

					MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed hover with refresh \"#{ refresh.to_s }\".;#{ identity };hover;"
					Kernel::raise e

				end

				MobyUtil::Logger.instance.log "behaviour" , "PASS;Hover operation executed successfully with refresh \"#{ refresh.to_s }\".;#{ identity };hover;"
				nil
			end

			# Trigger an action
			# ==raises
			# TestObjectNotFoundError:: If this application is not the foreground application on the device under test.    
			def trigger( refresh = false )

				begin
					command = command_params #in qt_behaviour
					command.object_type( :Action )
					command.command_name( 'Trigger' )
					command.object_id( @parent.id )<commit_msg>Added documentation comments to action.rb.<commit_after>############################################################################
## 
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 
## All rights reserved. 
## Contact: Nokia Corporation (<EMAIL>) 
## 
## This file is part of TDriver. 
## 
## If you have questions regarding the use of this file, please contact 
## Nokia at <EMAIL> . 
## 
## This library is free software; you can redistribute it and/or 
## modify it under the terms of the GNU Lesser General Public 
## License version 2.1 as published by the Free Software Foundation 
## and appearing in the file LICENSE.LGPL included in the packaging 
## of this file. 
## 
############################################################################

module MobyBehaviour

	module QT
	
		# == description
		# This module contains behaviours specific to actions
		#
		# == behaviour
		# QtAction
		#
		# == requires
		# *
		#
		# == input_type
		# touch
		#
		# == sut_type
		# qt
		#
		# == sut_version
		# *
		#
		# == objects
		# QAction
		#
		module Action

			include MobyBehaviour::QT::Behaviour

			# == description
			# Hover over an action inside a visible widget.
			#
			# == arguments
			# refresh
			#  Boolean
			#   description: is refresh done after trigger command
			#   example: true
			#   default: false
			#
			# == returns
			# nil
			#    
			# == info
			#  Hover is done by determining action's coordinates inside parent widget and moving mouse coursor there.
			#  Therefore, the parent object in script must be a visible widget containing that action.
			#  For example, a menu must be opened first, before actions inside the menu can be hovered.
			#  \nNOTE: Moving mouse cursor over action's position may not do anything,
			#  unless test application window is topmost, or at least not obscured by other windows.
			#  This can be a problem especially when testing desktop applications on Windows 7.
			#  \nIMPORTANT: In future this method may be changed to call hover slot of QAction instead of using mouse, 
			#  or deprecated and replace by a new method of different name better describing that this uses mouse.
			
			def hover( refresh = false )

				begin

					command = command_params #in qt_behaviour
					command.object_type( :Action )
					command.command_name( 'Hover' )
					command.object_id( @parent.id )
					command.command_params( 'id' => id )
					@sut.execute_command( command )
					self.force_refresh({:id => get_application_id}) if refresh

				rescue Exception => e

					MobyUtil::Logger.instance.log "behaviour" , "FAIL;Failed hover with refresh \"#{ refresh.to_s }\".;#{ identity };hover;"
					Kernel::raise e

				end

				MobyUtil::Logger.instance.log "behaviour" , "PASS;Hover operation executed successfully with refresh \"#{ refresh.to_s }\".;#{ identity };hover;"
				nil
			end

			# == description
			# Activate action inside a visible widget.
			#
			# == arguments
			# refresh
			#  Boolean
			#   description: is refresh done after trigger command
			#   example: true
			#   default: false
			#
			# == returns
			# nil
			# 
			# == exceptions
			# *
			#   no special exceptions, may throw any exception
			#    
			# == info
			#  Trigger is done by determining action's coordinates inside parent widget and doing mouse down + mouse up there.
			#  Therefore, the parent object in script must be a visible widget containing that action.
			#  For example, a menu must be opened first, before actions inside the menu can be triggered.
			#  \nIMPORTANT: In future this method may be changed to call trigger slot of QAction instead of using mouse,
			#  or deprecated and replace by a differently named method better describing that this uses mouse.

			def trigger( refresh = false )

				begin
					command = command_params #in qt_behaviour
					command.object_type( :Action )
					command.command_name( 'Trigger' )
					command.object_id( @parent.id )
{'fraction_non_alphanumeric': 0.13437551970730086, 'fraction_numerical': 0.002161982371528355, 'mean_word_length': 3.289586305278174, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4267931', 'n_tokens_mistral': 1981, 'n_tokens_neox': 1612, 'n_words': 627}