calendarwidgetplugin/tsrc/matti_testcases/Calendar_widget_tests.rb
changeset 0 db1bf15cefff
child 2 a4a7966c042b
equal deleted inserted replaced
-1:000000000000 0:db1bf15cefff
       
     1 #/*
       
     2 #* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 #* All rights reserved.
       
     4 #* This component and the accompanying materials are made available
       
     5 #* under the terms of "Eclipse Public License v1.0"
       
     6 #* which accompanies this distribution, and is available
       
     7 #* at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 #*
       
     9 #* Initial Contributors:
       
    10 #* Nokia Corporation - initial contribution.
       
    11 #*
       
    12 #* Contributors:
       
    13 #*
       
    14 #* Description: Calendar widget MATTI test cases
       
    15 #*
       
    16 #*/
       
    17 
       
    18 # require needed Ruby, MATTI and Orbit files
       
    19 require 'test/unit'
       
    20 require 'matti'
       
    21 require 'date'
       
    22 #require 'parsedate'
       
    23 #require 'OrbitBehaviours'
       
    24 include MobyBase 
       
    25 include MobyUtil
       
    26 include MattiVerify 
       
    27 @@z_index = ""
       
    28 
       
    29 Parameter.instance.load_parameters_xml(File.expand_path(File.dirname(__FILE__)) + '/testdata/calendar_widget_test_script_parameters.xml') 
       
    30     
       
    31 class TestClassCalendarWidget < Test::Unit::TestCase
       
    32     
       
    33 
       
    34 ##  def initialize (args)
       
    35 ##	super(args)
       
    36 ##	@sut = MATTI.sut(:Id => 'sut_s60_qt')
       
    37 ##	#@sut = MATTI.sut(:Id => 's60')
       
    38 ##	begin		
       
    39 ##		#check_phone_date
       
    40 ##		#check_phone_time
       
    41 ##		#if @sut.application.test_object_exists?("HbTextItem", {:text => 'Continue', :__timeout => 2})
       
    42 ##		#	@sut.application( :name => 'ftulanguage' ).HbTextItem(:text => 'Continue').tap
       
    43 ##		#end
       
    44 ##		#@sut.press_key(:kEnd)
       
    45 ##		@sut.application( :name => 'qttasserver' ).press_key(:kApp)
       
    46 ##	rescue Exception => ex
       
    47 ##		puts "INITIALIZE FAILED. ERROR:"
       
    48 ##		puts ex.message
       
    49 ##		puts "*************************"
       
    50 ##	end
       
    51 ##  end
       
    52   def initialize (args)
       
    53 	super(args)
       
    54 	# MANDATORY DEFINITION: Define device "suts" which are used in testing, remember defined [ut] name in matti_parameters.xml
       
    55 	@sut = MATTI.sut(:Id => 'sut_s60_qt')
       
    56 	#to see if there is some widgets on the screen
       
    57 	retry_count = 0
       
    58 	begin
       
    59 		if @sut.application.test_object_exists?("HbTextItem", {:text => 'Continue', :__timeout => 2})
       
    60 			@sut.application( :name => 'ftulanguage' ).HbTextItem(:text => 'Continue').tap
       
    61 		end
       
    62 		if @@z_index == ""
       
    63 			@@z_index = -1
       
    64 			begin
       
    65 				if @sut.application(:name => 'hsapplication').test_object_exists?("HsDialerWidget", {:__timeout => 2})
       
    66 				@@z_index += 1
       
    67 				end
       
    68 				if @sut.application(:name => 'hsapplication').test_object_exists?("HsClockWidget", {:__timeout => 2})
       
    69 				@@z_index += 1
       
    70 				end
       
    71 				if @sut.application(:name => 'hsapplication').test_object_exists?("FtuHSWidget", {:__timeout => 2})
       
    72 				@@z_index += 1
       
    73 				end
       
    74 			rescue
       
    75 				retry
       
    76 			end
       
    77 		end
       
    78     rescue Exception => ex
       
    79 		puts "INITIALIZE FAIL. Lets try again..."
       
    80 		if retry_count <= 10
       
    81 			retry_count = retry_count +1
       
    82 			retry
       
    83 		else
       
    84 			puts "INITIALIZE FAILED. ERROR:"
       
    85 			puts ex.message
       
    86 			puts "*************************"
       
    87 		end
       
    88 	end
       
    89   #@real_phone_number = "02722990"
       
    90   #@widget_name = "Contact widget."
       
    91   #@@contact_array = Array.new() 
       
    92   end 
       
    93   
       
    94   def teardown
       
    95 	puts "teardown actions"
       
    96 	begin
       
    97 		app = @sut.application.executable_name
       
    98 		app_name = app.split(".exe")[0].to_s
       
    99 		app_name = (app_name == 'tsapplication') ? 'hsapplication' : app_name
       
   100 		if @sut.application(:name => app_name).test_object_exists?("HbIconItem", {:iconName => 'qtg_mono_applications_all', :__timeout => 2})
       
   101 			navigate_to_first_homescreen
       
   102 			if @sut.application(:name => app_name).test_object_exists?("HbWidget",{:name => 'CalendarWidget'}) then
       
   103 				remove_calendar_widget_from_homescreen(0)
       
   104 			end
       
   105 			delete_calendar_events(@sut.application(:name => app_name))
       
   106 		else
       
   107 			app = @sut.application.executable_name
       
   108 			app_name = app.split(".exe")[0].to_s
       
   109 			app_name = (app_name == 'tsapplication') ? 'hsapplication' : app_name
       
   110 			if @sut.application(:name => app_name).test_object_exists?("HbIconItem", {:iconName => 'qtg_mono_back', :__timeout => 2})
       
   111 				@sut.application(:name => app_name).HbIconItem(:iconName => 'qtg_mono_back').tap
       
   112 				sleep 2
       
   113 			end
       
   114 			app = @sut.application.executable_name
       
   115 			app_name = app.split(".exe")[0].to_s
       
   116 			app_name = (app_name == 'tsapplication') ? 'hsapplication' : app_name
       
   117 			if @sut.application(:name => app_name).test_object_exists?("HbTextItem", {:text => 'Close', :__timeout => 2})
       
   118 				@sut.application(:name => app_name).HbTextItem(:text => 'Close').tap
       
   119 				sleep 1
       
   120 			end
       
   121 			app = @sut.application.executable_name
       
   122 			app_name = app.split(".exe")[0].to_s
       
   123 			app_name = (app_name == 'tsapplication') ? 'hsapplication' : app_name
       
   124 			if @sut.application(:name => app_name).test_object_exists?("HbIconItem", {:iconName => 'qtg_mono_back', :__timeout => 2})
       
   125 				@sut.application(:name => app_name).HbIconItem(:iconName => 'qtg_mono_back').tap
       
   126 				sleep 2
       
   127 			end
       
   128 			app = @sut.application.executable_name
       
   129 			app_name = app.split(".exe")[0].to_s
       
   130 			app_name = (app_name == 'tsapplication') ? 'hsapplication' : app_name
       
   131 			navigate_to_first_homescreen
       
   132 			if @sut.application(:name => app_name).test_object_exists?("HbWidget",{:name => 'CalendarWidget'}) then
       
   133 				remove_calendar_widget_from_homescreen(0)
       
   134 			end
       
   135 			delete_calendar_events(@sut.application(:name => app_name))
       
   136 		end
       
   137 	rescue Exception => ex
       
   138 		puts "TEARDOWN FAILED. ERROR:"
       
   139 		puts ex.message
       
   140 		puts "*************************"
       
   141 		begin
       
   142 			#did MATTI found wrong application
       
   143 			app = @sut.application.executable_name
       
   144 			app_name = app.split(".exe")[0].to_s
       
   145 			if app_name == 'tsapplication'
       
   146 				puts "MATTI get wrong application in UI (" + app_name +"). Start rebooting...!!!!"
       
   147 				@sut.reset
       
   148 				puts "Reboot is done!!"
       
   149 				app_name = @sut.application.executable_name.split(".exe")[0].to_s
       
   150 				puts "Application on the screen is " + app_name
       
   151 				#lets see that there is not any calendar widget on the homescreen
       
   152 				navigate_to_first_homescreen
       
   153 				if @sut.application(:name => app_name).test_object_exists?("HbWidget",{:name => 'CalendarWidget'}) then
       
   154 					remove_calendar_widget_from_homescreen(0)
       
   155 				end
       
   156 				delete_calendar_events(@sut.application(:name => app_name))
       
   157 			end
       
   158 		rescue Exception => e
       
   159 			puts "TEARDOWN BEGIN-RESCUE FAILED. ERROR:"
       
   160 			puts e.message
       
   161 			puts "*************************"
       
   162 		end
       
   163 	end		
       
   164 	#begin
       
   165 	#	navigate_to_first_homescreen
       
   166 	#	if @sut.application(:name => 'hsapplication').test_object_exists?("HbWidget",{:name => 'CalendarWidget'}) then
       
   167 	#		remove_calendar_widget_from_homescreen
       
   168 	#	end
       
   169 	#rescue
       
   170 	#end 
       
   171 	#delete_calendar_events(@sut.application(:name => 'hsapplication'))
       
   172   end # teardown
       
   173   
       
   174   def add_calendar_widget_to_homescreen(app, browse_to_list)
       
   175 	#selects calendar widget from applications-menu and adds it to home screen
       
   176 	#Lets calculate, how many application list items there is seen
       
   177 
       
   178 	identificator = TestObjectIdentificator.new(:type => :HsListViewItem)
       
   179 	xml =  app.HbListView( :name => 'allAppsListView' ).xml_data 
       
   180 	element_set = xml.xpath( xpath = identificator.get_xpath_to_identify( xml ) ) 
       
   181 	item_count = element_set.size
       
   182 	#puts "item_count = ",item_count
       
   183 	item_index = 4
       
   184 	#lets check if calendar widget is visible on display. If not, we flick until we get it visible
       
   185 	while item_index < item_count
       
   186 		if app.test_object_exists?("HbTextItem",{:text => 'CalendarWidget',:visibleOnScreen => 'true'}) then
       
   187 			#app.HbTextItem(:__index => item_index-1).tap_down
       
   188 			#app.HbTextItem(:__index => item_index-1).flick(:Up)
       
   189 			#app.HbListViewItem(:text => 'Bedrock').gesture(:Up,1,450,:Left,true)
       
   190 			if browse_to_list == 'longpressHS' then
       
   191 				app.HbTextItem(:text => 'CalendarWidget').tap
       
   192 			else
       
   193 				app.HbTextItem(:text => 'CalendarWidget').tap
       
   194 				app.HbTextItem( :text => 'Add to Home screen' ).tap
       
   195 				app.HbIconItem(:iconName => 'qtg_mono_back').tap
       
   196 			end
       
   197 			break
       
   198 		else
       
   199 			#app.HbTextItem(:__index => item_index-1).tap_down
       
   200 			#app.HbListViewItem(:__index => item_index-1).flick(:Up)
       
   201 			app.HsListViewItem(:__index => item_index-1).gesture(:Up,1,550,{:Left,true})
       
   202 		end
       
   203 		item_index +=2
       
   204 		if item_index >= item_count then
       
   205 			identificator = TestObjectIdentificator.new(:type => :HsListViewItem) 
       
   206 			xml =  app.HbListView(:__index => 0).xml_data 
       
   207 			element_set = xml.xpath( xpath = identificator.get_xpath_to_identify( xml ) ) 
       
   208 			item_count = element_set.size
       
   209 			#puts "item_count = ",item_count
       
   210 			item_index = 4
       
   211 		end
       
   212 	end
       
   213 
       
   214 	if browse_to_list != 'longpressHS' then
       
   215 		app.HbIconItem(:iconName => 'qtg_mono_back').tap
       
   216 	end
       
   217 	#verify, that there exists calendar widget in homescreen
       
   218 	#verify(){app.HbWidget( :name => 'CalendarWidget' )}
       
   219   end
       
   220   
       
   221     ########################################################################################################################################
       
   222 	#
       
   223 	#	remove_calendar_widget_from_homescreen
       
   224 	#
       
   225 	#	description:
       
   226 	#		This function emoves calendar widget from homescreen
       
   227 	#
       
   228 	#	preconditions: 
       
   229 	#		-Phone is in homescreen and there is calendar widget in HS
       
   230 	#	parameters:
       
   231 	#		hs_pagenumber:	Number of the homescreen page (0, 1 or 2)
       
   232 	#
       
   233 	#	created: Jarno Mäkelä
       
   234 	#	creation date: 17-May-2010
       
   235 	#
       
   236 	########################################################################################################################################
       
   237 	
       
   238   def remove_calendar_widget_from_homescreen(hs_pagenumber)
       
   239 	app = @sut.application(:name => 'hsapplication')
       
   240 	#verify(){@sut.application.HbIconItem(:iconName => 'hs_applib_button.png')}
       
   241 	#verify(){app.HbWidget( :name => 'CalendarWidget' )}
       
   242 	#find correct widget host object
       
   243 	calendar_widget_object = app.HsPage(:__index => hs_pagenumber).find(:name => 'CalendarWidget')
       
   244 	#app.HsPage(:__index => hs_pagenumber).HsWidgetHost.HsCalendarWidget.HbWidget( :name => 'CalendarWidget' ).tap_down
       
   245 	calendar_widget_object.tap_down
       
   246 	#app.HbWidget( :name => 'controlLayer' ).HsWidgetHost.HbWidget( :name => 'CalendarWidget' ).tap_down
       
   247 	#app.HbWidget( :name => 'controlLayer' ).HsWidgetHost.HbWidget( :name => 'CalendarWidget' ).drag_to_object(app.HsTrashBinWidget( :name => 'trashBin' ))
       
   248 	calendar_widget_object = app.HbWidget( :name => 'controlLayer' ).find(:name => 'CalendarWidget')
       
   249 	calendar_widget_object.drag_to_object(app.HsTrashBinWidget( :name => 'trashBin' ))
       
   250   end
       
   251   
       
   252     ########################################################################################################################################
       
   253 	#
       
   254 	#	create_calendar_event
       
   255 	#
       
   256 	#	description:
       
   257 	#		This function creates calendar event via fixture  
       
   258 	#
       
   259 	#	preconditions: 
       
   260 	#
       
   261 	#	parameters:
       
   262 	#		-subject:			subject of the meeting
       
   263 	#		-start_day:	    	start day of the meeting
       
   264 	#		-start_month:		start month of the meeting
       
   265 	#		-start_year:		start year of the meeting
       
   266 	#		-start_hour:		start hour of the meeting
       
   267 	#		-start_minute:		start minute of the meeting
       
   268 	#		-duration_days: 	duration of the days, that meeting is lasting
       
   269 	#		-duration_hours:	duration of the hours, that meeting is lasting
       
   270 	#		-duration_minutes:	duration of the minutes, that meeting is lasting
       
   271 	#
       
   272 	#	return value:
       
   273 	#		-time_to_verify:	time, that is supposed to be in the calendar widget (Format: hh:mm-hh:mm or hh:mm (am/pm)-hh:mm (am/pm))
       
   274 	#
       
   275 	#	created: Jarno Mäkelä
       
   276 	#	creation date: 17-May-2010
       
   277 	#
       
   278 	########################################################################################################################################
       
   279 	
       
   280   def create_calendar_event(app, subject,start_day, start_month, start_year, start_hour, start_minute, duration_days, duration_hours, duration_minutes)
       
   281 	#Creates calendar event
       
   282 	#let's calculate the real values of start date. In parameters, eg. the day value can exceed 31, so we need to change month and set day
       
   283 	#to 1. Same calculation needed for other parameter values
       
   284 	start_date = calculate_date(start_day, start_month, start_year, start_hour, start_minute)
       
   285 	puts "start_date:",start_date.to_s
       
   286 	start_time_split = (start_date.to_s).split
       
   287 	start_time = start_time_split[1]
       
   288 	start_time_to_verify = start_time[0..4]
       
   289 	puts "start_time_to_verify:",start_time_to_verify
       
   290 	end_date = calculate_date(start_day+duration_days, start_month, start_year, start_hour+duration_hours, start_minute+duration_minutes)
       
   291 	puts "end_date:",end_date.to_s
       
   292 	end_time_split = (end_date.to_s).split
       
   293 	end_time = end_time_split[1]
       
   294 	end_time_to_verify = end_time[0..4]
       
   295 	puts "end_time_to_verify:",end_time_to_verify
       
   296 	if @hourformat_12 == true then
       
   297 		#12 hour time used
       
   298 		time_to_verify = convert_time_to_12hour_format(start_time_to_verify)+'-'+convert_time_to_12hour_format(end_time_to_verify)
       
   299 	else
       
   300 		#24 hour time used
       
   301 		time_to_verify = start_time_to_verify+'-'+end_time_to_verify
       
   302 	end
       
   303 	tmp_id = app.id
       
   304 	tmp = @sut.execution_order
       
   305 	@sut.execution_order = ['S60']
       
   306 	app.apply_behaviour!( :name => 'S60Fixture' )
       
   307 	app.set_application_id(app.attribute('applicationUid'));
       
   308 	response = app.fixture('tapi_calendar_fixture', 'add_meeting', {:description =>  subject, :start_date => start_date, :end_date => end_date})
       
   309 	@sut.execution_order = tmp
       
   310 	app.apply_behaviour!( :name => 'QtFixture' ) 
       
   311 	app.set_application_id(tmp_id)
       
   312 	response
       
   313 	#let's put date if event is in other future day than today
       
   314 	if start_day > @day.to_i then
       
   315 	   start_date = start_time_split[0]
       
   316 	   month_text = case start_date[3..4]
       
   317 			when "01" then "Jan"
       
   318 			when "02" then "Feb"
       
   319 			when "03" then "Mar"
       
   320 			when "04" then "Apr"
       
   321 			when "05" then "May"
       
   322 			when "06" then "Jun"
       
   323 			when "07" then "Jul"
       
   324 			when "08" then "Aug"
       
   325 			when "09" then "Sep"
       
   326 			when "10" then "Oct"
       
   327 			when "11" then "Nov"
       
   328 			when "12" then "Dec"
       
   329 		end
       
   330 		puts "time_to_verify:", start_date[0..1]+' '+month_text+' '+time_to_verify
       
   331 		return start_date[0..1]+' '+month_text+' '+time_to_verify
       
   332 	else
       
   333 		puts "time_to_verify:", time_to_verify
       
   334 		return time_to_verify
       
   335 	end
       
   336 	#sut = MATTI.sut(:Id => 's60')
       
   337 	#app = sut.run(:name => "HtiAdmin.exe")
       
   338 	#app.fixture('tapi_calendar_fixture', 'add_meeting', {:description =>  subject, :start_date => '17-05-2010 15:00:00', :end_date => '17-05-2010 16:00:00'})
       
   339 	#app.fixture('tapi_calendar_fixture', 'add_meeting', {:description =>  subject, :start_date => start_date, :end_date => end_date})
       
   340 	#app.close()
       
   341   end
       
   342   
       
   343     ########################################################################################################################################
       
   344 	#
       
   345 	#	convert_time_to_12hour_format
       
   346 	#
       
   347 	#	description:
       
   348 	#		This function converts 24 hour time to 12 hour time format
       
   349 	#
       
   350 	#	preconditions: 
       
   351 	#
       
   352 	#	parameters:
       
   353 	#		-conv_timestr:				time string that is needed to convert
       
   354 	#
       
   355 	#	return value:
       
   356 	#		correctly converted time string
       
   357 	#
       
   358 	#	created: Jarno Mäkelä
       
   359 	#	creation date: 25-May-2010
       
   360 	#
       
   361 	########################################################################################################################################
       
   362 	
       
   363   def convert_time_to_12hour_format(conv_timestr)
       
   364 	#let's first check the hour
       
   365 	hour = conv_timestr[0..1].to_i
       
   366 	#puts "hour:", hour
       
   367 	if hour >= 12 then
       
   368 		if hour == 12 then
       
   369 			return hour.to_s+':'+conv_timestr[3..4]+' pm'
       
   370 		else
       
   371 			hour = hour -12
       
   372 			if hour < 10 then
       
   373 				return '0'+hour.to_s+':'+conv_timestr[3..4]+' pm'
       
   374 			else
       
   375 				return hour.to_s+':'+conv_timestr[3..4]+' pm'
       
   376 			end
       
   377 		end
       
   378 	else
       
   379 		if hour == 0 then
       
   380 			hour = 12
       
   381 			return hour.to_s+':'+conv_timestr[3..4]+' am'
       
   382 		elsif hour < 10 then
       
   383 			return '0'+hour.to_s+':'+conv_timestr[3..4]+' am'
       
   384 		else
       
   385 			return hour.to_s+':'+conv_timestr[3..4]+' am'
       
   386 		end
       
   387 	end
       
   388   end
       
   389   
       
   390     ########################################################################################################################################
       
   391 	#
       
   392 	#	delete_calendar_events
       
   393 	#
       
   394 	#	description:
       
   395 	#		This function deletes all calendar events via fixture  
       
   396 	#
       
   397 	#	preconditions: 
       
   398 	#
       
   399 	#	parameters:
       
   400 	#		-app:				application needed
       
   401 	#
       
   402 	#	created: Jarno Mäkelä
       
   403 	#	creation date: 19-May-2010
       
   404 	#
       
   405 	########################################################################################################################################
       
   406 	
       
   407   def delete_calendar_events(app)
       
   408 	tmp_id = app.id
       
   409 	tmp = @sut.execution_order
       
   410 	@sut.execution_order = ['S60']
       
   411 	app.apply_behaviour!( :name => 'S60Fixture' )
       
   412 	app.set_application_id(app.attribute('applicationUid'));
       
   413 	response = app.fixture('tapi_calendar_fixture', 'delete_all', {})
       
   414 	@sut.execution_order = tmp
       
   415 	app.apply_behaviour!( :name => 'QtFixture' ) 
       
   416 	app.set_application_id(tmp_id)
       
   417 	response
       
   418   end
       
   419   
       
   420   def create_calendar_event_via_calendar(subject)
       
   421 	#Creates calendar event
       
   422 	cal_app = @sut.run(:name => "calendar.exe")
       
   423 	cal_app.HbIconItem(:iconName => 'qtg_mono_options_menu').tap
       
   424 	cal_app.HbTextItem(:text => 'New event')
       
   425 	#Add the subject
       
   426 	cal_app.HbDataFormViewItem(:__index =>0).HbWidget.tap
       
   427 	cal_app.HbDataFormViewItem(:__index =>0).HbWidget.type_text(subject)
       
   428 	cal_app.HbTextItem(:text => 'Subject').tap
       
   429 	#Add start time
       
   430 	cal_app.CalenEditorCustomItem(:__index=>0).HbWidget.HbPushButton(:__index=>0).tap
       
   431 	
       
   432   end
       
   433   
       
   434     ########################################################################################################################################
       
   435 	#
       
   436 	#	check_phone_date
       
   437 	#
       
   438 	#	description:
       
   439 	#		This function checks the date of phone 
       
   440 	#
       
   441 	#	preconditions: 
       
   442 	#
       
   443 	#	parameters:
       
   444 	#		
       
   445 	#
       
   446 	#	created: Jarno Mäkelä
       
   447 	#	creation date: 18-May-2010
       
   448 	#
       
   449 	########################################################################################################################################
       
   450 	
       
   451   def check_phone_date
       
   452 	#Temporarily lets assume, that phone date is same as current real time, since clock application crashes in phone
       
   453 	clock_app = @sut.run(:name => "clock.exe")
       
   454 	date = clock_app.HbLabel( :name => 'dateLabel' ).HbTextItem.attribute("text")
       
   455 	#date = Time.now
       
   456 	puts "date is: ",date
       
   457 	#parse day,month and year
       
   458 	@day = date[4..5]
       
   459 	#@day = (date.day).to_s
       
   460 	#if @day.to_i < 10 then
       
   461 		#@day = '0'+ (date.day).to_s
       
   462 	#end
       
   463 	puts "day:", @day
       
   464 	@month = date[7..8]
       
   465 	#@month = (date.month).to_s
       
   466 	#if @month.to_i < 10 then
       
   467 	#	@month = '0'+ (date.month).to_s
       
   468 	#end
       
   469 	puts "month:", @month
       
   470 	@year = date[10..13]
       
   471 	#@year = (date.year).to_s
       
   472 	puts "year:",@year
       
   473 	clock_app.close
       
   474   end
       
   475   
       
   476     ########################################################################################################################################
       
   477 	#
       
   478 	#	check_phone_time
       
   479 	#
       
   480 	#	description:
       
   481 	#		This function checks the time of phone 
       
   482 	#
       
   483 	#	preconditions: 
       
   484 	#
       
   485 	#	parameters:
       
   486 	#		
       
   487 	#
       
   488 	#	created: Jarno Mäkelä
       
   489 	#	creation date: 18-May-2010
       
   490 	#
       
   491 	########################################################################################################################################
       
   492 	
       
   493   def check_phone_time
       
   494 	app = @sut.application(:name => 'hsapplication')
       
   495 	time = app.HbStatusBar.HbTextItem.attribute("text")
       
   496 	puts "time is: ",time
       
   497 	#parse hour and minute
       
   498 	@hour = time[0..1]
       
   499 	temp_hour = @hour.to_i
       
   500 	if time.index('pm') != nil
       
   501 		if temp_hour != 12 then
       
   502 			temp_hour = temp_hour +12
       
   503 		end
       
   504 	end
       
   505 	if time.index('am') != nil || time.index('pm') != nil then
       
   506 		@hourformat_12 = true
       
   507 	else
       
   508 		@hourformat_12 = false
       
   509 	end
       
   510 	@hour = temp_hour.to_s
       
   511 	puts "hour:", @hour
       
   512 	@minute = time[3..4]
       
   513 	puts "minute:", @minute
       
   514   end
       
   515   
       
   516     ########################################################################################################################################
       
   517 	#
       
   518 	#	calculate_date
       
   519 	#
       
   520 	#	description:
       
   521 	#		This function calculates the correct date from unchecked date values
       
   522 	#
       
   523 	#	preconditions: 
       
   524 	#
       
   525 	#	parameters:
       
   526 	#		-day: 		unhandled day value
       
   527 	#		-month:		unhandled month value
       
   528 	#		-year: 		unhandled year value
       
   529 	#		-hour: 		unhandled hour value
       
   530 	#		-minute: 	unhandled minute value
       
   531 	#
       
   532 	#	return value:
       
   533 	#		handled date string in fixture needed format (dd-mm-yyyy hh:mm:00)
       
   534 	#
       
   535 	#	created: Jarno Mäkelä
       
   536 	#	creation date: 18-May-2010
       
   537 	#
       
   538 	########################################################################################################################################
       
   539 	
       
   540   def calculate_date(day, month, year, hour, minute)
       
   541 	#let's check the minute
       
   542 	if(minute >=60) then
       
   543 		minute = minute - 60
       
   544 		hour= hour +1
       
   545 	end
       
   546 	if(hour >=24) then
       
   547 		hour = hour - 24
       
   548 		day = day +1
       
   549 	end
       
   550 	if(day > 31) then
       
   551 		if(month == 1)||(month == 3)||(month == 5)||(month == 7)||(month == 8)||(month == 10)||(month == 12) then
       
   552 			month = month +1
       
   553 			day = day - 31
       
   554 		elsif(month == 4)||(month == 6)||(month == 9)||(month == 11) then
       
   555 			month = month +1
       
   556 			day = day - 30
       
   557 		elsif(month == 2) then
       
   558 			if ( year % 100 != 0 && year % 4 == 0 || year % 400 == 0 ) then
       
   559 				month = month +1
       
   560 				day = day -29
       
   561 			else
       
   562 				month = month +1
       
   563 				day = day - 28
       
   564 			end
       
   565 		end
       
   566 	end
       
   567 	if(month > 12) then
       
   568 		month = month - 12
       
   569 		year = year +1
       
   570 	end
       
   571 	if(day <10) then
       
   572 		returnday = '0'+day.to_s
       
   573 	else
       
   574 		returnday = day.to_s
       
   575 	end
       
   576 	if(month < 10) then
       
   577 		returnmonth = '0' + month.to_s
       
   578 	else
       
   579 		returnmonth = month.to_s
       
   580 	end
       
   581 	if(minute < 10) then
       
   582 		returnminute = '0'+minute.to_s
       
   583 	else
       
   584 		returnminute = minute.to_s
       
   585 	end
       
   586 	if(hour < 10) then
       
   587 		returnhour = '0'+hour.to_s
       
   588 	else
       
   589 		returnhour = hour.to_s
       
   590 	end
       
   591 	
       
   592 	return returnday,'-',returnmonth,'-',year.to_s,' ',returnhour,':',returnminute,':00'
       
   593 	
       
   594   end
       
   595   
       
   596     ########################################################################################################################################
       
   597 	#
       
   598 	#	navigate_to_first_homescreen
       
   599 	#
       
   600 	#	description:
       
   601 	#		This function goes to first homescreen page from anywhere of homescreen pages
       
   602 	#
       
   603 	#	preconditions: 
       
   604 	#		-Phone is in homescreen
       
   605 	#	parameters:
       
   606 	#		None
       
   607 	#
       
   608 	#	created: Jarno Mäkelä
       
   609 	#	creation date: 02-Jun-2010
       
   610 	#
       
   611 	########################################################################################################################################
       
   612 	
       
   613   def navigate_to_first_homescreen
       
   614 	app = @sut.application(:name => 'hsapplication')
       
   615 	if app.HsPageIndicatorItem(:__index =>0).test_object_exists?("HbIconItem",{:iconName => 'qtg_graf_hspage_highlight'}) then
       
   616 		page = 1
       
   617 	elsif app.HsPageIndicatorItem(:__index =>1).test_object_exists?("HbIconItem",{:iconName => 'qtg_graf_hspage_highlight'}) then
       
   618 		page = 2
       
   619 		app.HsPageIndicatorItem(:__index =>1).gesture(:Right,1,170)
       
   620 		if app.HsPageIndicatorItem(:__index =>0).test_object_exists?("HbIconItem",{:iconName => 'qtg_graf_hspage_highlight'}) then
       
   621 			page = 1
       
   622 		else
       
   623 			raise VerificationError ,"ERROR: Cannot go to first home screen", caller
       
   624 		end
       
   625 	else
       
   626 		page = 3
       
   627 		app.HsPageIndicatorItem(:__index =>1).gesture(:Right,1,170)
       
   628 		sleep 1
       
   629 		app.HsPageIndicatorItem(:__index =>1).gesture(:Right,1,170)
       
   630 		if app.HsPageIndicatorItem(:__index =>0).test_object_exists?("HbIconItem",{:iconName => 'qtg_graf_hspage_highlight'}) then
       
   631 			page = 1
       
   632 		else
       
   633 			raise VerificationError ,"ERROR: Cannot go to first home screen", caller
       
   634 		end
       
   635 	end
       
   636   end
       
   637 ################################################################################################################################################
       
   638 ###
       
   639 ###						BAT cases start
       
   640 ###
       
   641 ################################################################################################################################################
       
   642   
       
   643   ##############################################################################################################################################
       
   644   # Calendar widget - Load-Unload widget in HomeScreen 
       
   645   ##############################################################################################################################################
       
   646   #
       
   647   # Purpose of the test is to check, that calendar widget can be load to Homescreen and unload from Homescreen
       
   648   #
       
   649   #	Created at: 17.05.2010
       
   650   #	Created by: Jarno Mäkelä
       
   651   #	Reviewed by: 
       
   652   #
       
   653   #	===	preconditions
       
   654   #	- Device is in Home Screen
       
   655   # - Some events in Calendar.
       
   656   #
       
   657   #	===	params
       
   658   #	none
       
   659   #
       
   660   ############################################################################################################################################
       
   661   
       
   662   def _test_calendar_widget_load_unload_widget_in_HomeScreen
       
   663 	#running_round = 1
       
   664 	#max_running_rounds = 2
       
   665 	#begin
       
   666 		#Preconditions:
       
   667 		#Device is in Homescreen
       
   668 		app = @sut.application(:name => 'hsapplication')
       
   669 		navigate_to_first_homescreen
       
   670 		verify(){app.HbIconItem(:iconName => 'qtg_mono_applications_all')}
       
   671 		#Some events in calendar
       
   672 		check_phone_date
       
   673 		check_phone_time
       
   674 		create_calendar_event(app, 'Meeting 1',@day.to_i+1,@month.to_i,@year.to_i,@hour.to_i+1,@minute.to_i,0,1,0)
       
   675 		create_calendar_event(app, 'Meeting 2',@day.to_i+2,@month.to_i,@year.to_i,@hour.to_i-2,@minute.to_i,0,1,0)
       
   676 		#Step 1:Tap application list button in the upper right corner of Home Screen
       
   677 		app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
       
   678 		#step 2: Select 'add to homescreen' by longpressing 'Calendar Widget' in the catalog list
       
   679 		add_calendar_widget_to_homescreen(app,'AppListButton')
       
   680 		#step 2 expected: Calendar widget is added to Home Screen.
       
   681 		day_to_verify = @day.to_i
       
   682 		#puts "day_to_verify =", day_to_verify
       
   683 		verify(){app.HbTextItem(:text => day_to_verify)}
       
   684 		#Calendar widget content contains "No event for next 7 days"
       
   685 		#verify(){app.HbTextItem(:text => 'No events for next 7 days')}
       
   686 		#Verify, that reminder icon in widget is not shown
       
   687 		#if not(app.test_object_exists?("HbIconItem",{:iconName => 'images/bell.PNG'})) then
       
   688 		#	raise VerificationError ,"ERROR: There is not reminder icon in calendar widget, when it should be there", caller
       
   689 		#end
       
   690 		#Step 3 and Step4:Remove calendar widget from display
       
   691 		remove_calendar_widget_from_homescreen(0)
       
   692 		delete_calendar_events(app)
       
   693 	#rescue
       
   694 	#	if (running_round < max_running_rounds) then
       
   695     #       running_round = running_round + 1
       
   696     #        puts "Some error came during run. Lets try again"
       
   697     #        teardown
       
   698 	#		retry
       
   699     #    else
       
   700     #        puts "Test failed"
       
   701     #        raise
       
   702     #    end
       
   703 	#end #rescue	
       
   704   end
       
   705   
       
   706   ##############################################################################################################################################
       
   707   # Calendar widget - One all day event and one other timed event overlapping 
       
   708   ##############################################################################################################################################
       
   709   #
       
   710   # Purpose of this test case ist to verify that "overlapping events" information will be shown on widget, when there is one all day event and 
       
   711   # one timed event overlapping. Also when removing timed event, only all dau event is shown in calendar widget
       
   712   #
       
   713   #	Created at: 17.05.2010
       
   714   #	Created by: Jarno Mäkelä
       
   715   #	Reviewed by: 
       
   716   #
       
   717   #	===	preconditions
       
   718   #	- Device is in Home Screen.
       
   719   # - Calendar widget is added to Home Screen.
       
   720   # - One all day event and one timed event happens few hours after current phone time at today in Calendar.
       
   721   #
       
   722   #	===	params
       
   723   #	none
       
   724   #
       
   725   ############################################################################################################################################
       
   726   
       
   727   def _test_calendar_widget_one_all_day_event_and_one_other_timed_event_overlapping
       
   728 	
       
   729   end
       
   730   
       
   731   ##############################################################################################################################################
       
   732   # Calendar widget - one event today, one event tomorrow 
       
   733   ##############################################################################################################################################
       
   734   #
       
   735   # Purpose of the test is to check, that when there is one event today and one event tomorrow, calendar widget shows only the today's event.
       
   736   #
       
   737   #	Created at: 17.05.2010
       
   738   #	Created by: Jarno Mäkelä
       
   739   #	Reviewed by: 
       
   740   #
       
   741   #	===	preconditions
       
   742   #	- Device is in Home Screen.
       
   743   # - Calendar widget is added to Home Screen.
       
   744   # - One event happens few hours after current phone time at today and one event at tomorrow in Calendar.
       
   745   #
       
   746   #	===	params
       
   747   #	none
       
   748   #
       
   749   ############################################################################################################################################
       
   750   
       
   751   def _test_calendar_widget_one_event_today_one_event_tomorrow
       
   752 	#running_round = 1
       
   753 	#max_running_rounds = 2
       
   754 	#begin
       
   755 		#Preconditions:
       
   756 		#Device is in Homescreen
       
   757 		app = @sut.application(:name => 'hsapplication')
       
   758 		verify(){app.HbIconItem(:iconName => 'qtg_mono_applications_all')}
       
   759 		navigate_to_first_homescreen
       
   760 		#- One event happens few hours after current phone time at today and one event at tomorrow in Calendar.
       
   761 		check_phone_date
       
   762 		check_phone_time
       
   763 		today_time_for_verification = create_calendar_event(app, 'Today meeting',@day.to_i,@month.to_i,@year.to_i,@hour.to_i+3,@minute.to_i,0,1,0)
       
   764 		tomorrow_time_for_verification = create_calendar_event(app, 'Tomorrow meeting',@day.to_i+1,@month.to_i,@year.to_i,@hour.to_i,@minute.to_i,0,1,0)
       
   765 		#-Calendar widget is added to Home Screen.
       
   766 		#Not adding calendar widget, if it already exists there
       
   767 		if not(app.test_object_exists?("HbWidget",{:name => 'CalendarWidget'})) then
       
   768 			#add calendar widget to home screen
       
   769 			app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
       
   770 			add_calendar_widget_to_homescreen(app,'AppListButton')
       
   771 		end
       
   772 		#Step 1:Check Calendar widget.
       
   773 		#app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
       
   774 		#step 1 Expected: - All icons (widget icon and reminder icon) are shown correctly.
       
   775 		#- Only today event is shown in widget as two rows: first row shows the event time and second row shows the event title.
       
   776 		day_to_verify = @day.to_i
       
   777 		verify(){app.HbTextItem(:text => day_to_verify)}
       
   778 		verify(){app.HbLabel( :name => 'upperLabel' ).HbTextItem( :text => today_time_for_verification )}
       
   779 		verify(){app.HbLabel( :name => 'lowerLabel' ).HbTextItem( :text => 'Today meeting' )}
       
   780 		#Verify, that reminder icon in widget is shown
       
   781 		#cannot verify yet, since with calendar fixture only events, that has no reminder, are possible to create
       
   782 		#if not(app.test_object_exists?("HbIconItem",{:iconName => 'images/bell.PNG'})) then
       
   783 		#	raise VerificationError ,"ERROR: There is not reminder icon in calendar widget, when it should be there", caller
       
   784 		#end
       
   785 		
       
   786 		remove_calendar_widget_from_homescreen(0)
       
   787 		delete_calendar_events(app)
       
   788 	#rescue
       
   789 	#	if (running_round < max_running_rounds) then
       
   790     #       running_round = running_round + 1
       
   791     #       puts "Some error came during run. Lets try again"
       
   792     #       teardown
       
   793 	#       retry
       
   794     #    else
       
   795     #       puts "Test failed"
       
   796     #       raise
       
   797     #    end
       
   798 	#end #rescue	
       
   799   end
       
   800   
       
   801   ##############################################################################################################################################
       
   802   # Calendar widget - Overlapping events
       
   803   ##############################################################################################################################################
       
   804   #
       
   805   # Purpose of the test is to check, that when there are overlapping events, there comes information about that in calendar widget and 
       
   806   # when tapping the events, phone goes to calendar agenda view.
       
   807   #
       
   808   #	Created at: 17.05.2010
       
   809   #	Created by: Jarno Mäkelä
       
   810   #	Reviewed by: 
       
   811   #
       
   812   #	===	preconditions
       
   813   #	- Device is in Home Screen.
       
   814   # - Calendar widget is added to Home Screen.
       
   815   # - One event happens few hours after current phone time at today in Calendar.
       
   816   #
       
   817   #	===	params
       
   818   #	none
       
   819   #
       
   820   ############################################################################################################################################
       
   821   
       
   822   def _test_calendar_widget_overlapping_events
       
   823 	running_round = 1
       
   824 	max_running_rounds = 2
       
   825 	begin
       
   826 		#Preconditions:
       
   827 		#Device is in Homescreen
       
   828 		app = @sut.application(:name => 'hsapplication')
       
   829 		verify(){app.HbIconItem(:iconName => 'qtg_mono_applications_all')}
       
   830 		navigate_to_first_homescreen
       
   831 		#- One event happens few hours after current phone time at today in Calendar.
       
   832 		check_phone_date
       
   833 		check_phone_time
       
   834 		today_time_for_verification = create_calendar_event(app, 'Today meeting',@day.to_i,@month.to_i,@year.to_i,@hour.to_i+3,@minute.to_i,0,1,0)
       
   835 		#-Calendar widget is added to Home Screen.
       
   836 		#Not adding calendar widget, if it already exists there
       
   837 		if not(app.test_object_exists?("HbWidget",{:name => 'CalendarWidget'})) then
       
   838 			#add calendar widget to home screen
       
   839 			app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
       
   840 			add_calendar_widget_to_homescreen(app,'AppListButton')
       
   841 		end
       
   842 		#Step 1:Check Calendar widget.
       
   843 		#step 1 Expected: - All icons (widget icon and reminder icon) are shown correctly.
       
   844 		#- Calendar widget shows the event as two rows: first row show the event time and second row shows the event title.
       
   845 		day_to_verify = @day.to_i
       
   846 		verify(){app.HbTextItem(:text => day_to_verify)}
       
   847 		verify(){app.HbLabel( :name => 'upperLabel' ).HbTextItem( :text => today_time_for_verification )}
       
   848 		verify(){app.HbLabel( :name => 'lowerLabel' ).HbTextItem( :text => 'Today meeting' )}
       
   849 		#Verify, that reminder icon in widget is shown
       
   850 		#if not(app.test_object_exists?("HbIconItem",{:iconName => 'images/bell.PNG'})) then
       
   851 		#	raise VerificationError ,"ERROR: There is not reminder icon in calendar widget, when it should be there", caller
       
   852 		#end
       
   853 		
       
   854 		#Step 2:Create another event overlapping the first event in Calendar.
       
   855 		another_time_for_verification = create_calendar_event(app, 'Another today meeting',@day.to_i,@month.to_i,@year.to_i,@hour.to_i+3,@minute.to_i+15,0,1,0)
       
   856 		#Step 3:Return to Home Screen and check Calendar widget.
       
   857 		#Step 3 Expected: - All icons (widget icon and reminder icon) are shown correctly.
       
   858 		#- Calendar widget shows the overlapping information as two rows: first row shows overlapping time and second row shows  text 
       
   859 		#'2 events overlapping'.
       
   860 		if @hourformat_12 == true then
       
   861 			overlapping_time_for_verification = today_time_for_verification[0..7]+'-'+another_time_for_verification[9..16]
       
   862 		else
       
   863 			overlapping_time_for_verification = today_time_for_verification[0..4]+'-'+another_time_for_verification[6..10]
       
   864 		end
       
   865 		puts "overlapping_time_for_verification: ",overlapping_time_for_verification
       
   866 		verify(){app.HbLabel( :name => 'upperLabel' ).HbTextItem( :text => overlapping_time_for_verification )}
       
   867 		verify(){app.HbLabel( :name => 'lowerLabel' ).HbTextItem( :text => '2 events overlapping' )}
       
   868 		#Step 4: Tap the overlapping events part in calendar view
       
   869 		app.HbLabel( :name => 'lowerLabel' ).HbTextItem( :text => '2 events overlapping' ).tap
       
   870 		#Step 4 Expected: - Phone goes to calendar agenda view with  all events visible.
       
   871 		#ToDo
       
   872 		# - The date is same as the event date.
       
   873 		#ToDo
       
   874 		remove_calendar_widget_from_homescreen(0)
       
   875 		delete_calendar_events(app)
       
   876 	rescue
       
   877 		if (running_round < max_running_rounds) then
       
   878            running_round = running_round + 1
       
   879            puts "Some error came during run. Lets try again"
       
   880            teardown
       
   881 	       retry
       
   882         else
       
   883            puts "Test failed"
       
   884            raise
       
   885         end
       
   886 	end #rescue	
       
   887   end
       
   888   
       
   889   ##############################################################################################################################################
       
   890   # Calendar widget - Tapping upcoming event
       
   891   ##############################################################################################################################################
       
   892   #
       
   893   # Purpose of the test is to check, that when tapping upcoming event in calendar widget, calendar agenda view is opened in calendar.
       
   894   #
       
   895   #	Created at: 17.05.2010
       
   896   #	Created by: Jarno Mäkelä
       
   897   #	Reviewed by: 
       
   898   #
       
   899   #	===	preconditions
       
   900   #	- Device is in Home Screen.
       
   901   # - Some events are created in Calendar.
       
   902   # - Calendar widget is added to Home Screen.
       
   903   #
       
   904   #	===	params
       
   905   #	none
       
   906   #
       
   907   ############################################################################################################################################
       
   908   
       
   909   def _test_calendar_widget_tapping_upcoming_event
       
   910 	
       
   911   end
       
   912   
       
   913   ##############################################################################################################################################
       
   914   # Calendar widget - no events
       
   915   ##############################################################################################################################################
       
   916   #
       
   917   # Purpose of the test is to check, that when there are not any events in calendar, calendar widget shows text 'No event for next 7 days'
       
   918   #
       
   919   #	Created at: 10.03.2010
       
   920   #	Created by: Jarno Mäkelä
       
   921   #	Reviewed by: 
       
   922   #
       
   923   #	===	preconditions
       
   924   #	- Device is in Home Screen.
       
   925   # - Calendar widget is added to Home Screen.
       
   926   # - No any events in Calendar.
       
   927   #
       
   928   #	===	params
       
   929   #	none
       
   930   #
       
   931   ############################################################################################################################################
       
   932   
       
   933   def test_calendar_widget_no_events
       
   934 	#running_round = 1
       
   935 	#max_running_rounds = 2
       
   936 	#begin
       
   937 		#preconditions:
       
   938 		#-Device is in Home Screen
       
   939 		app = @sut.application(:name => 'hsapplication')
       
   940 		#verify(){@sut.application(:name => 'hsapplication').HbIconItem(:iconName => 'qtg_mono_applications_all')}
       
   941 		verify(){app.HbIconItem(:iconName => 'qtg_mono_applications_all')}
       
   942 		navigate_to_first_homescreen
       
   943 		#-Calendar widget is added to Home Screen.
       
   944 		#Not adding calendar widget, if it already exists there
       
   945 		if not(app.test_object_exists?("HbWidget",{:name => 'CalendarWidget'})) then
       
   946 			#add calendar widget to home screen
       
   947 			app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
       
   948 			add_calendar_widget_to_homescreen(app,'AppListButton')
       
   949 		end
       
   950 		#ToDo:Checking, that there are no events in calendar
       
   951 	
       
   952 		#step 1: Check Calendar widget
       
   953 		#Verify, that calendar widget shows current date
       
   954 		check_phone_date
       
   955 		month_in_view = case @month
       
   956 			when "01" then "January"
       
   957 			when "02" then "February"
       
   958 			when "03" then "March"
       
   959 			when "04" then "April"
       
   960 			when "05" then "May"
       
   961 			when "06" then "June"
       
   962 			when "07" then "July"
       
   963 			when "08" then "August"
       
   964 			when "09" then "September"
       
   965 			when "10" then "October"
       
   966 			when "11" then "November"
       
   967 			when "12" then "December"
       
   968 		end
       
   969 		day_to_verify = @day.to_i
       
   970 		verify(){app.HbTextItem(:text => day_to_verify)}
       
   971 		verify(){app.HbTextItem(:text => month_in_view)}
       
   972 		#Calendar widget content contains "No event for next 7 days"
       
   973 		verify(){app.HbTextItem(:text => 'No calendar entries today or next 7 days')}
       
   974 	
       
   975 		#Verify, that reminder icon in widget is not shown
       
   976 		if (app.test_object_exists?("HbIconItem",{:iconName => 'images/bell.PNG'})) then
       
   977 			raise VerificationError ,"ERROR: There is reminder icon in calendar widget, when it should not be there", caller
       
   978 		end
       
   979 		#Remove calendar widget from display
       
   980 		remove_calendar_widget_from_homescreen(0)
       
   981 	#rescue
       
   982 	#	if (running_round < max_running_rounds) then
       
   983     #       running_round = running_round + 1
       
   984     #       puts "Some error came during run. Lets try again"
       
   985     #       teardown
       
   986 	#       retry
       
   987     #    else
       
   988     #       puts "Test failed"
       
   989     #       raise
       
   990     #    end
       
   991 	#end #rescue			
       
   992   end #test_calendar_widget_no_events
       
   993 
       
   994   def _test_create_meeting
       
   995 	create_calendar_event_via_calendar('Meeting 1')
       
   996   end
       
   997 
       
   998 ################################################################################################################################################
       
   999 ###
       
  1000 ###						BAT cases end. User story related FuTe cases start
       
  1001 ###
       
  1002 ################################################################################################################################################
       
  1003 
       
  1004   ##############################################################################################################################################
       
  1005   # test_calendar_widget_One_upcoming_event_in_7_day_away_and_one_in_8_day_away
       
  1006   ##############################################################################################################################################
       
  1007   #
       
  1008   # Purpose of the test is to check, that event, that is in 7 day away, can be seen in calendar widget, but event, that is 8 days away 
       
  1009   # cannot be seen in calendar widget.
       
  1010   #
       
  1011   #	Created at: 04.06.2010
       
  1012   #	Created by: Jarno Mäkelä
       
  1013   #	Reviewed by: 
       
  1014   #
       
  1015   #	===	preconditions
       
  1016   #	- Device is in Home Screen.
       
  1017   # - Calendar widget is added to Home Screen.
       
  1018   # - One event at 7 days away and one event at 8 days away in Calendar.
       
  1019   #
       
  1020   #	===	params
       
  1021   #	none
       
  1022   #
       
  1023   ############################################################################################################################################
       
  1024   
       
  1025   def _test_calendar_widget_One_upcoming_event_in_7_day_away_and_one_in_8_day_away
       
  1026 	#running_round = 1
       
  1027 	#max_running_rounds = 2
       
  1028 	#begin
       
  1029 		#preconditions:
       
  1030 		#-Device is in Home Screen
       
  1031 		app = @sut.application(:name => 'hsapplication')
       
  1032 		verify(){app.HbIconItem(:iconName => 'qtg_mono_applications_all')}
       
  1033 		navigate_to_first_homescreen
       
  1034 		#-One event at 7 days away and one event at 8 days away in Calendar
       
  1035 		check_phone_date
       
  1036 		check_phone_time
       
  1037 		seventh_day_time_for_verification = create_calendar_event(app, '7th day meeting',@day.to_i+7,@month.to_i,@year.to_i,@hour.to_i,@minute.to_i,0,1,0)
       
  1038 		eight_day_time_for_verification = create_calendar_event(app, '8th day meeting',@day.to_i+8,@month.to_i,@year.to_i,@hour.to_i,@minute.to_i,0,1,0)
       
  1039 		#-Calendar widget is added to Home Screen.
       
  1040 		#Not adding calendar widget, if it already exists there
       
  1041 		if not(app.test_object_exists?("HbWidget",{:name => 'CalendarWidget'})) then
       
  1042 			#add calendar widget to home screen
       
  1043 			app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
       
  1044 			add_calendar_widget_to_homescreen(app,'AppListButton')
       
  1045 		end
       
  1046 		#step 1: Check Calendar widget
       
  1047 		#step 1 expected:
       
  1048 		#- All icons (widget icon and reminder icon) are shown correctly.
       
  1049 		#Verify, that reminder icon in widget is not shown. Cannot be verified currently, since fixture creating calendar event does not 
       
  1050 		#have reminders
       
  1051 		#if not(app.test_object_exists?("HbIconItem",{:iconName => 'images/bell.PNG'})) then
       
  1052 		#	raise VerificationError ,"ERROR: There is not reminder icon in calendar widget, when it should not be there", caller
       
  1053 		#end
       
  1054 		#- Only event at 7 days away is shown in widget as two rows: first row shows the event date and title, second row shows the text 'No calendar entries today'.
       
  1055 		#Verify, that calendar widget shows current date
       
  1056 		month_in_view = case @month
       
  1057 			when 1 then "January"
       
  1058 			when 2 then "February"
       
  1059 			when 3 then "March"
       
  1060 			when 4 then "April"
       
  1061 			when 5 then "May"
       
  1062 			when 6 then "June"
       
  1063 			when 7 then "July"
       
  1064 			when 8 then "August"
       
  1065 			when 9 then "September"
       
  1066 			when 10 then "October"
       
  1067 			when 11 then "November"
       
  1068 			when 12 then "December"
       
  1069 		end
       
  1070 		day_to_verify = @day.to_i
       
  1071 		verify(){app.HbTextItem(:text => day_to_verify)}
       
  1072 		verify(){app.HbTextItem(:text => month_in_view)}
       
  1073 		#- Only event at 7 days away is shown in widget as two rows: first row shows the event date and title, second row shows the text 'No calendar entries today'.
       
  1074 		seventh_date_for_verification = verify(){app.HbLabel( :name => 'upperLabel' ).HbTextItem( :text => seventh_day_time_for_verification+' 7th day meeting' )}
       
  1075 		#Remove calendar widget from display
       
  1076 		#remove_calendar_widget_from_homescreen(0)
       
  1077 	#rescue
       
  1078 	#	if (running_round < max_running_rounds) then
       
  1079     #       running_round = running_round + 1
       
  1080     #       puts "Some error came during run. Lets try again"
       
  1081     #       teardown
       
  1082 	#       retry
       
  1083     #    else
       
  1084     #       puts "Test failed"
       
  1085     #       raise
       
  1086     #    end
       
  1087 	#end #rescue			
       
  1088   end #test_calendar_widget_One_upcoming_event_in_7_day_away_and_one_in_8_day_away
       
  1089 
       
  1090 ################################################################################################################################################
       
  1091 ###
       
  1092 ###						User story related FuTe cases cases end. NFT cases start
       
  1093 ###
       
  1094 ################################################################################################################################################
       
  1095 
       
  1096   ##############################################################################################################################################
       
  1097   # Calendar widget - NFT - Switch between HS and application library 50 times
       
  1098   ##############################################################################################################################################
       
  1099   #
       
  1100   # The purpose of this test is to verify that calendar widget is shown properly under stress. Calendar widget set on every HS, switch between 
       
  1101   # application library and HS 50 times. After this verify that calendar widget is functioning properly.
       
  1102   #
       
  1103   #	Created at: 28.05.2010
       
  1104   #	Created by: Jarno Mäkelä
       
  1105   #	Reviewed by: 
       
  1106   #
       
  1107   #	===	preconditions
       
  1108   #	- Device is in Home Screen.
       
  1109   # - Some events in Calendar.
       
  1110   # - Calendar widget is added to every Home screen.
       
  1111   #
       
  1112   #	===	params
       
  1113   #	none
       
  1114   #
       
  1115   ############################################################################################################################################
       
  1116   
       
  1117   def _test_Calendar_widget_NFT_Switch_between_HS_and_application_library_50_times
       
  1118 	#running_round = 1
       
  1119 	#max_running_rounds = 2
       
  1120 	#begin
       
  1121 		#preconditions:
       
  1122 		#-Device is in Home Screen
       
  1123 		app = @sut.application(:name => 'hsapplication')
       
  1124 		#- Some events in Calendar.
       
  1125 		check_phone_date
       
  1126 		check_phone_time
       
  1127 		today_time_for_verification = create_calendar_event(app, 'Today meeting',@day.to_i,@month.to_i,@year.to_i,@hour.to_i+3,@minute.to_i,0,1,0)
       
  1128 		tomorrow_time_for_verification = create_calendar_event(app, 'Tomorrow meeting',@day.to_i+1,@month.to_i,@year.to_i,@hour.to_i,@minute.to_i,0,1,0)
       
  1129 		day_after_tomorrow_time_for_verification = create_calendar_event(app, 'Day after tomorrow meeting',@day.to_i+2,@month.to_i,@year.to_i,@hour.to_i+2,@minute.to_i,0,2,0)
       
  1130 		# - Calendar widget is added to every Home screen.
       
  1131 		#let's first navigate to first home screen
       
  1132 		navigate_to_first_homescreen
       
  1133 		#add calendar widget to first home screen
       
  1134 		app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
       
  1135 		add_calendar_widget_to_homescreen(app,'AppListButton')
       
  1136 		#verify the calendar widget
       
  1137 		day_to_verify = @day.to_i
       
  1138 		verify(){app.HsPage(:__index => 0).HsWidgetHost.HsCalendarWidget.HbWidget( :name => 'CalendarWidget' ).HbTextItem(:text => day_to_verify)}
       
  1139 		#go to second homescreen
       
  1140 		app.HsPageIndicatorItem(:__index =>1).gesture(:Left,1,170)
       
  1141 		#add calendar widget to second home screen
       
  1142 		app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
       
  1143 		add_calendar_widget_to_homescreen(app,'AppListButton')
       
  1144 		#verify the calendar widget
       
  1145 		day_to_verify = @day.to_i
       
  1146 		verify(){app.HsPage(:__index => 1).HsWidgetHost.HsCalendarWidget.HbWidget( :name => 'CalendarWidget' ).HbTextItem(:text => day_to_verify)}
       
  1147 		#go to third homescreen
       
  1148 		app.HsPageIndicatorItem(:__index =>1).gesture(:Left,1,170)
       
  1149 		#add calendar widget to third home screen
       
  1150 		app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
       
  1151 		add_calendar_widget_to_homescreen(app,'AppListButton')
       
  1152 		#verify the calendar widget
       
  1153 		day_to_verify = @day.to_i
       
  1154 		verify(){app.HsPage(:__index => 2).HsWidgetHost.HsCalendarWidget.HbWidget( :name => 'CalendarWidget' ).HbTextItem(:text => day_to_verify)}
       
  1155 		#do 50 times
       
  1156 		50.times do
       
  1157 			#step 1: Go to application library
       
  1158 			app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
       
  1159 			#step 1 Expected: Phone goes to application library view
       
  1160 			verify(){app.HbMarqueeItem(:text => 'Applications')}
       
  1161 			#Step 2: Switch to Home Screen and check Calendar widget.
       
  1162 			app.HbIconItem(:iconName => 'qtg_mono_back').tap
       
  1163 			#Step 2 expected: 
       
  1164 			# - Phone goes to Home Screen.
       
  1165 			# - Calendar widget shows the correct information.
       
  1166 		end
       
  1167 		verify(){app.HsPage(:__index => 0).HsWidgetHost.HsCalendarWidget.HbWidget( :name => 'CalendarWidget' ).HbTextItem(:text => day_to_verify)}
       
  1168 		verify(){app.HsPage(:__index => 1).HsWidgetHost.HsCalendarWidget.HbWidget( :name => 'CalendarWidget' ).HbTextItem(:text => day_to_verify)}
       
  1169 		verify(){app.HsPage(:__index => 2).HsWidgetHost.HsCalendarWidget.HbWidget( :name => 'CalendarWidget' ).HbTextItem(:text => day_to_verify)}
       
  1170 		#verify(){app.HbLabel( :name => 'upperLabel' ).HbTextItem( :text => today_time_for_verification )}
       
  1171 		#verify(){app.HbLabel( :name => 'lowerLabel' ).HbTextItem( :text => 'Today meeting' )}
       
  1172 		remove_calendar_widget_from_homescreen(2)
       
  1173 		#Go to second homescreen and remove calendar widget
       
  1174 		app.HsPageIndicatorItem(:__index =>1).gesture(:Right,1,170)
       
  1175 		remove_calendar_widget_from_homescreen(1)
       
  1176 		#Go to first HS and remove calendar widget
       
  1177 		app.HsPageIndicatorItem(:__index =>1).gesture(:Right,1,170)
       
  1178 		remove_calendar_widget_from_homescreen(0)
       
  1179 		delete_calendar_events(app)
       
  1180 	#rescue
       
  1181 	#	if (running_round < max_running_rounds) then
       
  1182     #       running_round = running_round + 1
       
  1183     #       puts "Some error came during run. Lets try again"
       
  1184     #       teardown
       
  1185 	#       retry
       
  1186     #    else
       
  1187     #       puts "Test failed"
       
  1188     #       raise
       
  1189     #    end
       
  1190 	#end #rescue			
       
  1191   end #test_editor_view_new
       
  1192 
       
  1193 end # test class