calendarwidgetplugin/tsrc/matti_testcases/Calendar_widget_tests.rb
changeset 4 6ea82847f1b7
parent 3 b2d662d68a49
equal deleted inserted replaced
3:b2d662d68a49 4:6ea82847f1b7
    15 #*
    15 #*
    16 #*/
    16 #*/
    17 
    17 
    18 # require needed Ruby, MATTI and Orbit files
    18 # require needed Ruby, MATTI and Orbit files
    19 require 'test/unit'
    19 require 'test/unit'
       
    20 require 'gruff'
    20 require 'tdriver'
    21 require 'tdriver'
    21 require 'date'
    22 require 'date'
       
    23 #require "rexml/document"
    22 #require 'parsedate'
    24 #require 'parsedate'
    23 #require 'OrbitBehaviours'
    25 #require 'OrbitBehaviours'
    24 include MobyBase 
    26 include MobyBase 
    25 include MobyUtil
    27 include MobyUtil
    26 include MattiVerify 
    28 include MattiVerify 
       
    29 #include REXML
    27 @@z_index = ""
    30 @@z_index = ""
    28 
    31 
    29 
    32 
    30 Parameter.instance.load_parameters_xml(File.expand_path(File.dirname(__FILE__)) + '/testdata/calendar_widget_test_script_parameters.xml') 
    33 Parameter.instance.load_parameters_xml(File.expand_path(File.dirname(__FILE__)) + '/testdata/calendar_widget_test_script_parameters.xml') 
    31     
    34     
    94 		app = @sut.application.executable_name
    97 		app = @sut.application.executable_name
    95 		app_name = app.split(".exe")[0].to_s
    98 		app_name = app.split(".exe")[0].to_s
    96 		app_name = (app_name == 'tsapplication') ? 'hsapplication' : app_name
    99 		app_name = (app_name == 'tsapplication') ? 'hsapplication' : app_name
    97 		if @sut.application(:name => app_name).test_object_exists?("HbIconItem", {:iconName => 'qtg_mono_applications_all', :__timeout => 2})
   100 		if @sut.application(:name => app_name).test_object_exists?("HbIconItem", {:iconName => 'qtg_mono_applications_all', :__timeout => 2})
    98 			navigate_to_first_homescreen
   101 			navigate_to_first_homescreen
       
   102 			remove_calendar_widgets_from_homescreen(0)
    99 			delete_calendar_events_via_UI
   103 			delete_calendar_events_via_UI
   100 		else
   104 		else
   101 			app = @sut.application.executable_name
   105 			app = @sut.application.executable_name
   102 			app_name = app.split(".exe")[0].to_s
   106 			app_name = app.split(".exe")[0].to_s
   103 			app_name = (app_name == 'tsapplication') ? 'hsapplication' : app_name
   107 			app_name = (app_name == 'tsapplication') ? 'hsapplication' : app_name
   121 			end
   125 			end
   122 			app = @sut.application.executable_name
   126 			app = @sut.application.executable_name
   123 			app_name = app.split(".exe")[0].to_s
   127 			app_name = app.split(".exe")[0].to_s
   124 			app_name = (app_name == 'tsapplication') ? 'hsapplication' : app_name
   128 			app_name = (app_name == 'tsapplication') ? 'hsapplication' : app_name
   125 			navigate_to_first_homescreen
   129 			navigate_to_first_homescreen
       
   130 			remove_calendar_widgets_from_homescreen(0)
   126 			delete_calendar_events_via_UI
   131 			delete_calendar_events_via_UI
   127 		end
   132 		end
       
   133 		#check do we have network time in use. If not, set it on
       
   134 		#clock_app = @sut.run(:name => "clock.exe")
       
   135 	        #clock_app.HbMarqueeItem(:text => 'Clock').tap
       
   136         	#clock_app.HbTextItem( :text => 'Settings' ).tap
       
   137         	#if clock_app.HbCheckBox( :name => 'networkTime' ).test_object_exists?("HbIconItem",{:iconName => 'qtg_small_unselected'}) then
       
   138         	#	clock_app.HbCheckBox( :name => 'networkTime' ).tap
       
   139         	#end
       
   140         	#clock_app.close
   128 	rescue Exception => ex
   141 	rescue Exception => ex
   129 		puts "TEARDOWN FAILED. ERROR:"
   142 		puts "TEARDOWN FAILED. ERROR:"
   130 		puts ex.message
   143 		puts ex.message
   131 		puts "*************************"
   144 		puts "*************************"
   132 		begin
   145 		begin
   138 				@sut.reset
   151 				@sut.reset
   139 				puts "Reboot is done!!"
   152 				puts "Reboot is done!!"
   140 				app_name = @sut.application.executable_name.split(".exe")[0].to_s
   153 				app_name = @sut.application.executable_name.split(".exe")[0].to_s
   141 				puts "Application on the screen is " + app_name
   154 				puts "Application on the screen is " + app_name
   142 				navigate_to_first_homescreen
   155 				navigate_to_first_homescreen
       
   156 				remove_calendar_widgets_from_homescreen(0)
   143 				delete_calendar_events_via_UI
   157 				delete_calendar_events_via_UI
   144 			end
   158 			end
   145 		rescue Exception => e
   159 		rescue Exception => e
   146 			puts "TEARDOWN BEGIN-RESCUE FAILED. ERROR:"
   160 			puts "TEARDOWN BEGIN-RESCUE FAILED. ERROR:"
   147 			puts e.message
   161 			puts e.message
   173 	identificator = TestObjectIdentificator.new(:type => :HsListViewItem)
   187 	identificator = TestObjectIdentificator.new(:type => :HsListViewItem)
   174 	xml =  app.HbListView( :name => 'listView' ).xml_data 
   188 	xml =  app.HbListView( :name => 'listView' ).xml_data 
   175 	element_set = xml.xpath( xpath = identificator.get_xpath_to_identify( xml ) ) 
   189 	element_set = xml.xpath( xpath = identificator.get_xpath_to_identify( xml ) ) 
   176 	item_count = element_set.size
   190 	item_count = element_set.size
   177 	#puts "item_count = ",item_count
   191 	#puts "item_count = ",item_count
   178 	item_index = 4
   192 	item_index = 6
   179 	#lets check if calendar widget is visible on display. If not, we flick until we get it visible
   193 	widget_row_array = Array.new
   180 	while item_index < item_count
   194 	widget_y_pos_array = Array.new
       
   195 	i = 0
       
   196 	index = 0
       
   197 	widget_row_string = String.new(element_set.to_s)
       
   198     while not(app.test_object_exists?("HbTextItem",{:text => 'CalendarWidget',:visibleOnScreen => 'true'}) )
       
   199 		while index != nil
       
   200 			index = widget_row_string.index('row')
       
   201 			if index == nil
       
   202 				break
       
   203 			end
       
   204 			row_length = widget_row_string.index('<', index.to_i+19)-(index.to_i+19)
       
   205 			#puts "row_length = " +row_length.to_s
       
   206 			widget_row = widget_row_string[index.to_i+19..index.to_i+19+row_length.to_i-1]
       
   207 			#puts "widget_row: " + widget_row.to_s
       
   208 			#find scenepos
       
   209 			index = widget_row_string.index('scenePos', index+19)
       
   210 			y_pos_length = widget_row_string.index('<', index.to_i+26)-(index.to_i+26)
       
   211 			widget_y_pos = widget_row_string[index.to_i+26..index.to_i+26+y_pos_length-1]
       
   212 			#puts "widget_y_pos: " + widget_y_pos.to_s
       
   213 			if widget_y_pos.to_i > 0 && widget_y_pos.to_i < 530 then
       
   214 				widget_row_array[i]=widget_row
       
   215 				#puts "widget_row_array[i] = " + widget_row.to_s
       
   216 				widget_y_pos_array[i]=widget_y_pos
       
   217 				#puts "widget_y_pos_array[i] = " + widget_y_pos.to_s
       
   218 				i = i +1
       
   219 			end
       
   220 			widget_row_string = widget_row_string[index.to_i+26+y_pos_length..widget_row_string.length]
       
   221 		end
       
   222 		#find the lowest y_pos item
       
   223 		lowest_y_pos = widget_y_pos_array[0].to_i
       
   224 		lowest_value = 0
       
   225 		for k in 0..i-1
       
   226 			if lowest_y_pos.to_i < widget_y_pos_array[k+1].to_i
       
   227 				lowest_y_pos = widget_y_pos_array[k+1].to_i
       
   228 				lowest_value = k+1
       
   229 			end
       
   230 		end
       
   231 		#puts "lowest_y_pos = " + lowest_y_pos.to_s
       
   232 		app.HsListViewItem(:row => widget_row_array[lowest_value].to_s).gesture(:Up,1,500,{:Left,true})
   181 		if app.test_object_exists?("HbTextItem",{:text => 'CalendarWidget',:visibleOnScreen => 'true'}) then
   233 		if app.test_object_exists?("HbTextItem",{:text => 'CalendarWidget',:visibleOnScreen => 'true'}) then
   182 			if browse_to_list == 'longpressHS' then
   234 			if browse_to_list == 'longpressHS' then
   183 				app.HbTextItem(:text => 'CalendarWidget').tap
   235 				app.HbTextItem(:text => 'CalendarWidget').tap
   184 			else
   236 			else
   185 				app.HbTextItem(:text => 'CalendarWidget').tap
   237 				app.HbTextItem(:text => 'CalendarWidget').tap
   186 				app.HbTextItem( :text => 'Add to Home screen' ).tap
   238 				app.HbTextItem( :text => 'Add to Home screen' ).tap
   187 				app.HbIconItem(:iconName => 'qtg_mono_back').tap
   239 				app.HbIconItem(:iconName => 'qtg_mono_back').tap
   188 			end
   240 			end
   189 			break
   241 			break
   190 		else
   242 		end
   191 			app.HsListViewItem(:__index => item_index-1).gesture(:Up,1,550,{:Left,true})
   243 		identificator = TestObjectIdentificator.new(:type => :HsListViewItem) 
   192 		end
   244 		xml =  app.HbListView(:__index => 0).xml_data 
   193 		item_index +=2
   245 		element_set = xml.xpath( xpath = identificator.get_xpath_to_identify( xml ) )
   194 		if item_index >= item_count then
   246 		i = 0
   195 			identificator = TestObjectIdentificator.new(:type => :HsListViewItem) 
   247 		widget_row_string = String.new(element_set.to_s)
   196 			xml =  app.HbListView(:__index => 0).xml_data 
   248 		index = widget_row_string.index('row')		
   197 			element_set = xml.xpath( xpath = identificator.get_xpath_to_identify( xml ) ) 
   249 	end
   198 			item_count = element_set.size
       
   199 			#puts "item_count = ",item_count
       
   200 			item_index = 4
       
   201 		end
       
   202 	end
       
   203 
       
   204 	#if browse_to_list != 'longpressHS' then
   250 	#if browse_to_list != 'longpressHS' then
   205 	#	app.HbIconItem(:iconName => 'qtg_mono_back').tap
   251 	#	app.HbIconItem(:iconName => 'qtg_mono_back').tap
   206 	#end
   252 	#end
   207   end
   253   end
   208   
   254   
   301 	#	created: Jarno Mäkelä
   347 	#	created: Jarno Mäkelä
   302 	#	creation date: 18-May-2010
   348 	#	creation date: 18-May-2010
   303 	#
   349 	#
   304 	########################################################################################################################################
   350 	########################################################################################################################################
   305 	
   351 	
   306   def calculate_date(day, month, year, hour, minute)
   352   def calculate_date(temp_day, temp_month, temp_year, temp_hour, temp_minute)
   307 	#let's check the minute
   353 	#let's check the minute
   308 	if(minute >=60) then
   354 	if(temp_minute >=60) then
   309 		minute = minute - 60
   355 		temp_minute = temp_minute - 60
   310 		hour= hour +1
   356 		temp_hour= temp_hour +1
   311 	end
   357 	end
   312 	if(hour >=24) then
   358 	if(temp_hour >=24) then
   313 		hour = hour - 24
   359 		temp_hour = temp_hour - 24
   314 		day = day +1
   360 		temp_day = temp_day +1
   315 	end
   361 	end
   316 	if(day > 31) then
   362 	if(temp_day > 31) then
   317 		if(month == 1)||(month == 3)||(month == 5)||(month == 7)||(month == 8)||(month == 10)||(month == 12) then
   363 		if(temp_month == 1)||(temp_month == 3)||(temp_month == 5)||(temp_month == 7)||(temp_month == 8)||(temp_month == 10)||(temp_month == 12) then
   318 			month = month +1
   364 			temp_month = temp_month +1
   319 			day = day - 31
   365 			temp_day = temp_day - 31
   320 		elsif(month == 4)||(month == 6)||(month == 9)||(month == 11) then
   366 		elsif(temp_month == 4)||(temp_month == 6)||(temp_month == 9)||(temp_month == 11) then
   321 			month = month +1
   367 			temp_month = temp_month +1
   322 			day = day - 30
   368 			temp_day = temp_day - 30
   323 		elsif(month == 2) then
   369 		elsif(temp_month == 2) then
   324 			if ( year % 100 != 0 && year % 4 == 0 || year % 400 == 0 ) then
   370 			if ( temp_year % 100 != 0 && temp_year % 4 == 0 || temp_year % 400 == 0 ) then
   325 				month = month +1
   371 				temp_month = temp_month +1
   326 				day = day -29
   372 				temp_day = temp_day -29
   327 			else
   373 			else
   328 				month = month +1
   374 				temp_month = temp_month +1
   329 				day = day - 28
   375 				temp_day = temp_day - 28
   330 			end
   376 			end
   331 		end
   377 		end
   332 	end
   378 	end
   333 	if(month > 12) then
   379 	if(temp_month > 12) then
   334 		month = month - 12
   380 		temp_month = temp_month - 12
   335 		year = year +1
   381 		temp_year = temp_year +1
   336 	end
   382 	end
   337 	if(day <10) then
   383 	if(temp_day <10) then
   338 		returnday = '0'+day.to_s
   384 		returnday = '0'+temp_day.to_s
   339 	else
   385 	else
   340 		returnday = day.to_s
   386 		returnday = temp_day.to_s
   341 	end
   387 	end
   342 	if(month < 10) then
   388 	if(temp_month < 10) then
   343 		returnmonth = '0' + month.to_s
   389 		returnmonth = '0' + temp_month.to_s
   344 	else
   390 	else
   345 		returnmonth = month.to_s
   391 		returnmonth = temp_month.to_s
   346 	end
   392 	end
   347 	if(minute < 10) then
   393 	if(temp_minute < 10) then
   348 		returnminute = '0'+minute.to_s
   394 		returnminute = '0'+temp_minute.to_s
   349 	else
   395 	else
   350 		returnminute = minute.to_s
   396 		returnminute = temp_minute.to_s
   351 	end
   397 	end
   352 	if(hour < 10) then
   398 	if(temp_hour < 10) then
   353 		returnhour = '0'+hour.to_s
   399 		returnhour = '0'+temp_hour.to_s
   354 	else
   400 	else
   355 		returnhour = hour.to_s
   401 		returnhour = temp_hour.to_s
   356 	end
   402 	end
   357 	return returnday,'-',returnmonth,'-',year.to_s,' ',returnhour,':',returnminute,':00'
   403 	return returnday,'-',returnmonth,'-',temp_year.to_s,' ',returnhour,':',returnminute,':00'
   358   end
   404   end
   359   
   405   
   360     ########################################################################################################################################
   406     ########################################################################################################################################
   361 	#
   407 	#
   362 	#	convert_time_to_12hour_format
   408 	#	convert_time_to_12hour_format
   460 	#find correct widget host object
   506 	#find correct widget host object
   461 	calendar_widget_object = app.HsIdleWidget.HbWidget(:__index =>2).HsPageVisual(:__index => hs_pagenumber).find(:name => 'CalendarWidget')
   507 	calendar_widget_object = app.HsIdleWidget.HbWidget(:__index =>2).HsPageVisual(:__index => hs_pagenumber).find(:name => 'CalendarWidget')
   462 	calendar_widget_object.tap_down
   508 	calendar_widget_object.tap_down
   463 	calendar_widget_object = app.HbWidget( :name => 'controlLayer' ).find(:name => 'CalendarWidget')
   509 	calendar_widget_object = app.HbWidget( :name => 'controlLayer' ).find(:name => 'CalendarWidget')
   464 	calendar_widget_object.drag_to_object(app.HsTrashBinWidget( :name => 'trashBin' ))
   510 	calendar_widget_object.drag_to_object(app.HsTrashBinWidget( :name => 'trashBin' ))
       
   511   end
       
   512   
       
   513     ########################################################################################################################################
       
   514 	#
       
   515 	#	remove_calendar_widgets_from_homescreen
       
   516 	#
       
   517 	#	description:
       
   518 	#		This function removes all calendar widgets from homescreen
       
   519 	#
       
   520 	#	preconditions: 
       
   521 	#		-Phone is in homescreen and there is calendar widget in HS
       
   522 	#	parameters:
       
   523 	#		hs_pagenumber:	Number of the homescreen page (0, 1 or 2)
       
   524 	#
       
   525 	#	created: Jarno Mäkelä
       
   526 	#	creation date: 01-Sep-2010
       
   527 	#
       
   528 	########################################################################################################################################
       
   529 	
       
   530   def remove_calendar_widgets_from_homescreen(hs_pagenumber)
       
   531     #Lets check all widgets in first page
       
   532     app = @sut.application(:name => 'hsapplication')
       
   533     identificator = TestObjectIdentificator.new(:type => :HsWidgetHostVisual)
       
   534 	xml =  app.HsPageVisual(:__index => hs_pagenumber).xml_data
       
   535 	element_set = xml.xpath( xpath = identificator.get_xpath_to_identify( xml ) ) 
       
   536 	widget_string = String.new(element_set.to_s)
       
   537 	#lets find all the calendarwidgetplugin-named calendar widgets
       
   538 	cal_widget_array = Array.new
       
   539 	i = 0
       
   540 	index = 0
       
   541 	while index != nil do
       
   542         #search first occurence of calendar widget plugin
       
   543         index = widget_string.index('calendarwidgetplugin')
       
   544         if index != nil then
       
   545             #save the name of calendar widget to array
       
   546             cal_widget_array[i]=widget_string[index.to_i..index.to_i+22]
       
   547             puts "cal_widget_array[i] ="+ cal_widget_array[i].to_s
       
   548             i = i +1
       
   549             #put the rest of the string to be checked another calendarwidgetplugin-name
       
   550             widget_string = widget_string[index.to_i+22..widget_string.length]
       
   551         end
       
   552 	end
       
   553 	#Delete calendar widgets
       
   554 	for j in 0..cal_widget_array.length-1
       
   555 		app.HsWidgetHostVisual( :name => cal_widget_array[j].to_s ).CalendarWidget.HbWidget( :name => 'CalendarWidget' ).HbWidget( :name => 'contentContainer' ).HbLabel( :name => 'middleLabel' ).HbTextItem( :text => 'No entries for 7 days' ).tap_down
       
   556 		app.HsIdleWidget.HbWidget( :name => 'controlLayer' ).HsWidgetHostVisual( :name => cal_widget_array[j].to_s ).CalendarWidget.HbWidget( :name => 'CalendarWidget' ).HbWidget( :name => 'contentContainer' ).HbLabel( :name => 'middleLabel' ).HbTextItem( :text => 'No entries for 7 days' ).drag_to(150,560 )
       
   557         sleep 1
       
   558 	end
   465   end
   559   end
   466   
   560   
   467     ########################################################################################################################################
   561     ########################################################################################################################################
   468 	#
   562 	#
   469 	#	delete_calendar_events !!!FIXTURE NOT WORKING !!!
   563 	#	delete_calendar_events !!!FIXTURE NOT WORKING !!!
   749 		end
   843 		end
   750 	else
   844 	else
   751 		start_minute = 0
   845 		start_minute = 0
   752 	end
   846 	end
   753 	start_date = calculate_date(start_day, start_month, start_year, start_hour, start_minute)
   847 	start_date = calculate_date(start_day, start_month, start_year, start_hour, start_minute)
   754 	puts "start_date:",start_date.to_s
   848 	puts "start_date:",start_date.to_s		
   755 	start_time_split = (start_date.to_s).split
   849 	start_time_split = (start_date.to_s).split
   756 	start_time = start_time_split[1]
   850 	start_time = start_time_split[1]
   757 	start_time_to_verify = start_time[0..4] 
   851 	start_time_to_verify = start_time[0..4] 
   758 	puts "start_time_to_verify:",start_time_to_verify
   852 	puts "start_time_to_verify:",start_time_to_verify
   759 	end_date = calculate_date(start_day+duration_days, start_month, start_year, start_hour+duration_hours, start_minute + duration_minutes)
   853 	end_date = calculate_date(start_day+duration_days, start_month, start_year, start_hour+duration_hours, start_minute + duration_minutes)
   808 			when "09" then "Sep"
   902 			when "09" then "Sep"
   809 			when "10" then "Oct"
   903 			when "10" then "Oct"
   810 			when "11" then "Nov"
   904 			when "11" then "Nov"
   811 			when "12" then "Dec"
   905 			when "12" then "Dec"
   812 		end
   906 		end
   813 		puts "time_to_verify:", start_date[0..1]+' '+month_text+' '+time_to_verify
   907 		puts "time_to_verify:", start_date[0..1]+' '+month_text+' - '+start_time_to_verify
   814 		return start_date[0..1]+' '+month_text+' '+time_to_verify
   908 		return start_date[0..1]+' '+month_text+' - '+start_time_to_verify
   815 	else
   909 	else
   816 		puts "time_to_verify:", time_to_verify
   910 		puts "time_to_verify:", time_to_verify
   817 		return time_to_verify
   911 		return time_to_verify
   818 	end
   912 	end
   819   end
   913   end
       
   914   
       
   915     ########################################################################################################################################
       
   916 	#
       
   917 	#	create_all_day_event_via_calendar
       
   918 	#
       
   919 	#	description:
       
   920 	#		This function creates all day calendar event via calendar application UI  
       
   921 	#
       
   922 	#	preconditions: 
       
   923 	#
       
   924 	#	parameters:
       
   925 	#		-subject:			subject of the meeting (not working yet)
       
   926 	#		-start_day:	    	start day of the meeting(not working yet)
       
   927 	#		-start_month:		start month of the meeting(not working yet)
       
   928 	#		-start_year:		start year of the meeting(not working yet)
       
   929 	#
       
   930 	#	return value:
       
   931 	#		-date_to_verify:	all day event date, that is supposed to be in the calendar widget (Format: dd mmm)
       
   932 	#
       
   933 	#	created: Jarno Mäkelä
       
   934 	#	creation date: 24-Aug-2010
       
   935 	#
       
   936 	########################################################################################################################################
       
   937 	
       
   938   def create_all_day_event_via_calendar(subject,start_day, start_month, start_year)
       
   939 	#Creates all day calendar event via calendar application
       
   940 	#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
       
   941 	#to 1. Same calculation needed for other parameter values
       
   942 	all_day_date = calculate_date(start_day, start_month, start_year, 0,0)
       
   943 	puts "all_day_date:",all_day_date.to_s
       
   944 	all_day_date_split = (all_day_date.to_s).split
       
   945 	cal_app = @sut.run(:name => "calendar.exe")
       
   946 	#cal_app.HbIconItem(:iconName => 'qtg_mono_options_menu').tap
       
   947 	cal_app.HbMarqueeItem(:text => 'Calendar').tap
       
   948 	cal_app.HbTextItem(:text => 'New entry').tap
       
   949 	#Add the subject. Cannot do this currently,since phone won't go away from text input
       
   950 	#cal_app.HbLineEdit( :name => 'subjectItem' ).tap
       
   951 	#cal_app.HbLineEdit( :name => 'subjectItem' ).HbScrollArea.HbWidget.type_text(subject)
       
   952 	#cal_app.QGraphicsWidget( :name => 'vkbHandle' ).tap
       
   953 	#Tap all day event option
       
   954 	cal_app.HbCheckBox( :name => 'allDayItem' ).tap
       
   955 	start_date = all_day_date_split[0]
       
   956 	#add start date
       
   957 	if start_date[0..1].to_i > @day.to_i || start_date[3..4].to_i > @month.to_i || start_date[6..9].to_i > @year.to_i then
       
   958 		puts "calendar event is in another day that today in future"
       
   959 		#set calendar date
       
   960 		cal_app.HbPushButton( :name => 'startDate' ).tap
       
   961 		set_event_date_via_UI(cal_app,start_date)
       
   962 		cal_app.HbTextItem( :text => 'OK' ).tap
       
   963 	end
       
   964 	cal_app.HbIconItem(:iconName => 'qtg_mono_back').tap
       
   965 	cal_app.close
       
   966 	month_text = case start_date[3..4]
       
   967 		when "01" then "Jan"
       
   968 		when "02" then "Feb"
       
   969 		when "03" then "Mar"
       
   970 		when "04" then "Apr"
       
   971 		when "05" then "May"
       
   972 		when "06" then "Jun"
       
   973 		when "07" then "Jul"
       
   974 		when "08" then "Aug"
       
   975 		when "09" then "Sep"
       
   976 		when "10" then "Oct"
       
   977 		when "11" then "Nov"
       
   978 		when "12" then "Dec"
       
   979 	end
       
   980 	puts "date_to_verify:", start_date[0..1]+' '+month_text
       
   981 	return start_date[0..1]+' '+month_text
       
   982  end
   820   
   983   
   821   ##############################################################################################################################################
   984   ##############################################################################################################################################
   822   # Calendar widget - initialize
   985   # Calendar widget - initialize
   823   ##############################################################################################################################################
   986   ##############################################################################################################################################
   824   #
   987   #
   967   #	===	params
  1130   #	===	params
   968   #	none
  1131   #	none
   969   #
  1132   #
   970   ############################################################################################################################################
  1133   ############################################################################################################################################
   971   
  1134   
   972   def _test_calendar_widget_one_all_day_event_and_one_other_timed_event_overlapping
  1135   def test_calendar_widget_one_all_day_event_and_one_other_timed_event_overlapping
   973 	
  1136 	#Preconditions
       
  1137 	# Device is in Home Screen.
       
  1138 	app = @sut.application(:name => 'hsapplication')
       
  1139 	#verify(){app.HbIconItem(:iconName => 'qtg_mono_applications_all')}
       
  1140 	#One all day event and one timed event happens few hours after current phone time at today in Calendar.
       
  1141 	check_phone_date
       
  1142 	check_phone_time
       
  1143 	all_day_event_time_for_verification = create_all_day_event_via_calendar("not working all day",@day.to_i,@month.to_i,@year.to_i)
       
  1144 	today_time_for_verification = create_calendar_event_via_calendar("not working",@day.to_i,@month.to_i,@year.to_i,@hour.to_i+2,@minute.to_i,0,1,0)
       
  1145 	#Calendar widget is added to Home Screen.
       
  1146 	#Not adding calendar widget, if it already exists there
       
  1147 	if not(app.test_object_exists?("HbWidget",{:name => 'CalendarWidget'})) then
       
  1148 		#add calendar widget to home screen
       
  1149 		app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
       
  1150 		add_calendar_widget_to_homescreen(app,'AppListButton')
       
  1151 	end	
       
  1152 	#Step 1: Check calendar widget
       
  1153 	#Step 1 Expected: 
       
  1154 	#widget icon is shown correctly.
       
  1155 	verify(){app.HbWidget( :name => 'CalendarWidget' ).HbWidget( :name => 'iconContainer' ).HbLabel( :name => 'iconLabel' )}
       
  1156 	#reminder icon is not shown
       
  1157     if (app.test_object_exists?("HbFrameItem",{:frameGraphicsName => 'qtg_small_reminder'})) then
       
  1158        	raise VerificationError ,"ERROR: There is reminder icon in calendar widget, when it should not be there", caller
       
  1159     end
       
  1160     #Calendar widget shows overlapping information as two rows: first row shows the current date and second row shows the text '2 overlapping  entries'
       
  1161     verify(){app.HbWidget( :name => 'CalendarWidget' ).HbWidget( :name => 'contentContainer' ).HbLabel( :__index => 0 ).HbTextItem( :text => all_day_event_time_for_verification )}
       
  1162     verify(){app.HbWidget( :name => 'CalendarWidget' ).HbWidget( :name => 'contentContainer' ).HbLabel( :__index => 1 ).HbTextItem( :text => '2 overlapping  entry' )}        
       
  1163     #Step 2: Tap calendar widget and remove the timed event from calendar
       
  1164 	#!!!!! Cannot do yet below
       
  1165 #	app.HbTextItem( :text => '2 overlapping  entry' ).tap
       
  1166     #Step 2 expected: timed event can be removed
       
  1167 
       
  1168     #Step 3: Check Calendar widget.
       
  1169     #Step 3 Expected: 
       
  1170     #- All icons (widget icon and reminder icon) are shown correctly.
       
  1171 	#!!!!! Cannot run yet below
       
  1172    	#verify(){app.HbWidget( :name => 'CalendarWidget' ).HbWidget( :name => 'iconContainer' ).HbLabel( :name => 'iconLabel' )}
       
  1173 	#!!!!! Cannot run yet below
       
  1174 	#if not (app.test_object_exists?("HbFrameItem",{:frameGraphicsName => 'qtg_small_reminder'})) then
       
  1175     #  	raise VerificationError ,"ERROR: There is not reminder icon in calendar widget, when it should be there", caller
       
  1176     #end
       
  1177 	#- Calendar widget shows  rows: first row shows the date and second row shows the name of all day event .
       
  1178 	#!!!!! Cannot run yet below
       
  1179 	#verify(){app.HbWidget( :name => 'CalendarWidget' ).HbWidget( :name => 'contentContainer' ).HbLabel( :__index => 0 ).HbTextItem( :text => all_day_event_time_for_verification )}
       
  1180 	#verify(){app.HbWidget( :name => 'CalendarWidget' ).HbWidget( :name => 'contentContainer' ).HbLabel( :__index => 1 ).HbTextItem( :text => 'Unnamed' )}        
       
  1181 	delete_calendar_events_via_UI	
   974   end
  1182   end
   975   
  1183   
   976   ##############################################################################################################################################
  1184   ##############################################################################################################################################
   977   # Calendar widget - one event today, one event tomorrow 
  1185   # Calendar widget - one event today, one event tomorrow 
   978   ##############################################################################################################################################
  1186   ##############################################################################################################################################
  1017 		#app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
  1225 		#app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
  1018 		#step 1 Expected: - All icons (widget icon and reminder icon) are shown correctly.
  1226 		#step 1 Expected: - All icons (widget icon and reminder icon) are shown correctly.
  1019 		#- Only today event is shown in widget as two rows: first row shows the event time and second row shows the event title.
  1227 		#- Only today event is shown in widget as two rows: first row shows the event time and second row shows the event title.
  1020 		day_to_verify = @day.to_i
  1228 		day_to_verify = @day.to_i
  1021 		verify(){app.HbTextItem(:text => day_to_verify)}
  1229 		verify(){app.HbTextItem(:text => day_to_verify)}
  1022 		verify(){app.HbLabel( :name => 'upperLabel' ).HbTextItem( :text => today_time_for_verification )}
  1230 		verify(){app.HbLabel( :name => 'upperLabelShort' ).HbTextItem( :text => today_time_for_verification )}
  1023 		verify(){app.HbLabel( :name => 'lowerLabel' ).HbTextItem( :text => 'Unnamed' )}
  1231 		#!!!!! Cannot run yet below
       
  1232 		#verify(){app.HbLabel(:name => 'lowerLabel'  ).HbTextItem( :text => 'Unnamed' )}
  1024 		#Verify, that reminder icon in widget is shown
  1233 		#Verify, that reminder icon in widget is shown
  1025 		if not(app.test_object_exists?("HbFrameItem",{:frameGraphicsName => 'qtg_small_reminder'})) then
  1234 		if not(app.test_object_exists?("HbFrameItem",{:frameGraphicsName => 'qtg_small_reminder'})) then
  1026 			raise VerificationError ,"ERROR: There is not reminder icon in calendar widget, when it should be there", caller
  1235 			raise VerificationError ,"ERROR: There is not reminder icon in calendar widget, when it should be there", caller
  1027 		end
  1236 		end
  1028 		delete_calendar_events_via_UI
  1237 		delete_calendar_events_via_UI
  1057   #
  1266   #
  1058   #	===	params
  1267   #	===	params
  1059   #	none
  1268   #	none
  1060   #
  1269   #
  1061   ############################################################################################################################################
  1270   ############################################################################################################################################
  1062   
       
  1063   def test_calendar_widget_overlapping_events
       
  1064 	#Preconditions:
       
  1065 	#Device is in Homescreen
       
  1066 	app = @sut.application(:name => 'hsapplication')
       
  1067 	verify(){app.HbIconItem(:iconName => 'qtg_mono_applications_all')}
       
  1068 	#- One event happens few hours after current phone time at today in Calendar.
       
  1069 	check_phone_date
       
  1070 	check_phone_time
       
  1071 	today_time_for_verification = create_calendar_event_via_calendar("not working",@day.to_i,@month.to_i,@year.to_i,@hour.to_i+2,@minute.to_i,0,0,0)
       
  1072 	#-Calendar widget is added to Home Screen.
       
  1073 	#Not adding calendar widget, if it already exists there
       
  1074 	if not(app.test_object_exists?("HbWidget",{:name => 'CalendarWidget'})) then
       
  1075 		#add calendar widget to home screen
       
  1076 		app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
       
  1077 		add_calendar_widget_to_homescreen(app,'AppListButton')
       
  1078 	end
       
  1079 	#Step 1:Check Calendar widget.
       
  1080 	#step 1 Expected: - All icons (widget icon and reminder icon) are shown correctly.
       
  1081 	#- Calendar widget shows the event as two rows: first row show the event time and second row shows the event title.
       
  1082 	day_to_verify = @day.to_i
       
  1083 	verify(){app.HbTextItem(:text => day_to_verify)}
       
  1084 	verify(){app.HbLabel( :name => 'upperLabel' ).HbTextItem( :text => today_time_for_verification )}
       
  1085 	verify(){app.HbLabel( :name => 'lowerLabel' ).HbTextItem( :text => 'Unnamed' )}
       
  1086 	#Verify, that reminder icon in widget is shown
       
  1087 	if not(app.test_object_exists?("HbFrameItem",{:frameGraphicsName => 'qtg_small_reminder'})) then
       
  1088 		raise VerificationError ,"ERROR: There is not reminder icon in calendar widget, when it should be there", caller
       
  1089 	end
       
  1090 	
       
  1091 	#Step 2:Create another event overlapping the first event in Calendar.
       
  1092 	another_time_for_verification = create_calendar_event_via_calendar("Another not working",@day.to_i,@month.to_i,@year.to_i,@hour.to_i+2,@minute.to_i,0,0,0)
       
  1093 	#Step 3:Return to Home Screen and check Calendar widget.
       
  1094 	#Step 3 Expected: - All icons (widget icon and reminder icon) are shown correctly.
       
  1095 	#- Calendar widget shows the overlapping information as two rows: first row shows overlapping time and second row shows  text 
       
  1096 	#'2 events overlapping'.
       
  1097 	if @hourformat_12 == true then
       
  1098 		overlapping_time_for_verification = today_time_for_verification[0..7]+'-'+another_time_for_verification[9..16]
       
  1099 	else
       
  1100 		overlapping_time_for_verification = today_time_for_verification[0..4]+'-'+another_time_for_verification[6..10]
       
  1101 	end
       
  1102 	puts "overlapping_time_for_verification: ",overlapping_time_for_verification
       
  1103 	verify(){app.HbLabel( :name => 'upperLabel' ).HbTextItem( :text => overlapping_time_for_verification )}
       
  1104 	verify(){app.HbLabel( :name => 'lowerLabel' ).HbTextItem( :text => '2 overlapping entry' )}
       
  1105 	#Step 4: Tap the overlapping events part in calendar view
       
  1106 	app.HbLabel( :name => 'lowerLabel' ).HbTextItem( :text => '2 overlapping entry' ).tap
       
  1107 	#Step 4 Expected: - Phone goes to calendar agenda view with all events visible.
       
  1108 	#ToDo 
       
  1109 	# !! NOT WORKING IN week 30 SW !!
       
  1110 	# - The date is same as the event date.
       
  1111 	#ToDo
       
  1112 	delete_calendar_events_via_UI
       
  1113   end
       
  1114   
  1271   
  1115   def test_calendar_widget_overlapping_events_fixed
  1272   def test_calendar_widget_overlapping_events_fixed
  1116 	#Preconditions:
  1273 	#Preconditions:
  1117 	#Device is in Homescreen
  1274 	#Device is in Homescreen
  1118 	app = @sut.application(:name => 'hsapplication')
  1275 	app = @sut.application(:name => 'hsapplication')
  1131 	#Step 1:Check Calendar widget.
  1288 	#Step 1:Check Calendar widget.
  1132 	#step 1 Expected: - All icons (widget icon and reminder icon) are shown correctly.
  1289 	#step 1 Expected: - All icons (widget icon and reminder icon) are shown correctly.
  1133 	#- Calendar widget shows the event as two rows: first row show the event time and second row shows the event title.
  1290 	#- Calendar widget shows the event as two rows: first row show the event time and second row shows the event title.
  1134 	day_to_verify = @day.to_i
  1291 	day_to_verify = @day.to_i
  1135 	verify(){app.HbTextItem(:text => day_to_verify)}
  1292 	verify(){app.HbTextItem(:text => day_to_verify)}
       
  1293 	#!!!!! Cannot run yet below
       
  1294 	#verify(){app.HbLabel( :__index => 0 ).HbTextItem( :text => today_time_for_verification )}
       
  1295 	#!!!!! Cannot run yet below
       
  1296 	#verify(){app.HbLabel( :__index => 1 ).HbTextItem( :text => 'Unnamed' )}
  1136 	#Verify, that reminder icon in widget is shown
  1297 	#Verify, that reminder icon in widget is shown
  1137 	if not(app.test_object_exists?("HbFrameItem",{:frameGraphicsName => 'qtg_small_reminder'})) then
  1298 	if not(app.test_object_exists?("HbFrameItem",{:frameGraphicsName => 'qtg_small_reminder'})) then
  1138 		raise VerificationError ,"ERROR: There is not reminder icon in calendar widget, when it should be there", caller
  1299 		raise VerificationError ,"ERROR: There is not reminder icon in calendar widget, when it should be there", caller
  1139 	end
  1300 	end
  1140 	
  1301 	
  1141 	#Step 2:Create another event overlapping the first event in Calendar.
  1302 	#Step 2:Create another event overlapping the first event in Calendar.
  1142 	another_time_for_verification = create_calendar_event_via_calendar("Another not working",@day.to_i,@month.to_i,@year.to_i,@hour.to_i+2,@minute.to_i,0,0,0)
  1303 	another_time_for_verification = create_calendar_event_via_calendar("Another not working",@day.to_i,@month.to_i,@year.to_i,@hour.to_i+2,@minute.to_i,0,0,0)
  1143 	#Step 3:Return to Home Screen and check Calendar widget.
  1304 	#Step 3:Return to Home Screen and check Calendar widget.
  1144 	#Step 3 Expected: - All icons (widget icon and reminder icon) are shown correctly.
  1305 	#Step 3 Expected: - All icons (widget icon and reminder icon) are shown correctly.
  1145 	#- Calendar widget shows the overlapping information as two rows: first row shows overlapping time and second row shows  text 
  1306 	#- Calendar widget shows the overlapping information as two rows: first row shows overlapping time and second row shows  text 
  1146 	#'2 events overlapping'.
  1307 	#'2 overlapping entry'.
  1147 	if @hourformat_12 == true then
  1308 	if @hourformat_12 == true then
  1148 		overlapping_time_for_verification = today_time_for_verification[0..7]+'-'+another_time_for_verification[9..16]
  1309 		overlapping_time_for_verification = today_time_for_verification[0..7]+'-'+another_time_for_verification[9..16]
  1149 	else
  1310 	else
  1150 		overlapping_time_for_verification = today_time_for_verification[0..4]+'-'+another_time_for_verification[6..10]
  1311 		overlapping_time_for_verification = today_time_for_verification[0..4]+'-'+another_time_for_verification[6..10]
  1151 	end
  1312 	end
  1152 	puts "overlapping_time_for_verification: ",overlapping_time_for_verification
  1313 	puts "overlapping_time_for_verification: ",overlapping_time_for_verification
  1153 	verify(){app.HbLabel( :name => 'lowerLabel' ).HbTextItem( :text => '2 overlapping entry' )}
  1314 	#!!!!! Cannot run yet below
       
  1315 	#verify(){app.HbLabel( :name => 'upperLabelLong'  ).HbTextItem( :text => overlapping_time_for_verification )}
       
  1316 	verify(){app.HbLabel(:name => 'lowerLabel' ).HbTextItem( :text => '2 overlapping entry' )}
       
  1317         #Step 4: Tap the overlapping events part in calendar view
       
  1318 	#!!!!! Cannot run yet below
       
  1319 	#app.HbLabel( :__index => 1 ).HbTextItem( :text => '2 overlapping entry' ).tap
       
  1320 	#!!!!! Cannot do yet below
       
  1321 	#Step 4 Expected: - Phone goes to calendar agenda view with all events visible.
       
  1322 	#ToDo 
       
  1323 	# !! NOT WORKING IN week 30 SW !!
       
  1324 	# - The date is same as the event date.
       
  1325 	#ToDo
  1154 	delete_calendar_events_via_UI
  1326 	delete_calendar_events_via_UI
  1155   end #test_calendar_widget_overlapping_events_fixed
  1327   end #test_calendar_widget_overlapping_events_fixed
  1156   
  1328   
  1157   ##############################################################################################################################################
  1329   ##############################################################################################################################################
  1158   # Calendar widget - Tapping upcoming event
  1330   # Calendar widget - Tapping upcoming event
  1192 	#Step 1:Tap on the upcoming event in Calendar widget.
  1364 	#Step 1:Tap on the upcoming event in Calendar widget.
  1193 	app.HbTextItem( :text => today_time_for_verification ).tap
  1365 	app.HbTextItem( :text => today_time_for_verification ).tap
  1194 	#Step 1 Expected: 
  1366 	#Step 1 Expected: 
  1195 	#- Calendar agenda view is opened.
  1367 	#- Calendar agenda view is opened.
  1196 	#- The date is same as the event date.
  1368 	#- The date is same as the event date.
  1197 	cal_app = @sut.application(:name => 'calendar')
  1369 	#!!!!! Cannot run yet below
  1198 	verify(){cal_app.CalenAgendaView( :name => 'agendaView' )}
  1370 	#cal_app = @sut.application(:name => 'calendar')
       
  1371 	#verify(){cal_app.CalenAgendaView( :name => 'agendaView' )}
  1199 	#Error in SW, cannot verify date yet, since shows no date
  1372 	#Error in SW, cannot verify date yet, since shows no date
  1200 	#postactions
  1373 	#postactions
  1201 	delete_calendar_events_via_UI
  1374 	delete_calendar_events_via_UI
  1202   end
  1375   end
  1203   
  1376   
  1220   #	none
  1393   #	none
  1221   #
  1394   #
  1222   ############################################################################################################################################
  1395   ############################################################################################################################################
  1223   
  1396   
  1224   def test_calendar_widget_no_events
  1397   def test_calendar_widget_no_events
  1225 	#running_round = 1
  1398 	#preconditions:
  1226 	#max_running_rounds = 2
  1399 	#-Device is in Home Screen
  1227 	#begin
  1400 	app = @sut.application(:name => 'hsapplication')
  1228 		#preconditions:
  1401 	#verify(){@sut.application(:name => 'hsapplication').HbIconItem(:iconName => 'qtg_mono_applications_all')}
  1229 		#-Device is in Home Screen
  1402 	verify(){app.HbIconItem(:iconName => 'qtg_mono_applications_all')}
  1230 		app = @sut.application(:name => 'hsapplication')
  1403 	#navigate_to_first_homescreen
  1231 		#verify(){@sut.application(:name => 'hsapplication').HbIconItem(:iconName => 'qtg_mono_applications_all')}
  1404 	#-Calendar widget is added to Home Screen.
  1232 		verify(){app.HbIconItem(:iconName => 'qtg_mono_applications_all')}
  1405 	#Not adding calendar widget, if it already exists there
  1233 		#navigate_to_first_homescreen
  1406 	if not(app.test_object_exists?("HbWidget",{:name => 'CalendarWidget'})) then
  1234 		#-Calendar widget is added to Home Screen.
  1407 		#add calendar widget to home screen
  1235 		#Not adding calendar widget, if it already exists there
  1408 		app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
  1236 		if not(app.test_object_exists?("HbWidget",{:name => 'CalendarWidget'})) then
  1409 		add_calendar_widget_to_homescreen(app,'AppListButton')
  1237 			#add calendar widget to home screen
  1410 	end
  1238 			app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
  1411 	#ToDo:Checking, that there are no events in calendar
  1239 			add_calendar_widget_to_homescreen(app,'AppListButton')
       
  1240 		end
       
  1241 		#ToDo:Checking, that there are no events in calendar
       
  1242 	
  1412 	
  1243 		#step 1: Check Calendar widget
  1413 	#step 1: Check Calendar widget
  1244 		#Verify, that calendar widget shows current date
  1414 	#Verify, that calendar widget shows current date
  1245 		check_phone_date
  1415 	check_phone_date
  1246 		month_in_view = case @month
  1416 	month_in_view = case @month
  1247 			when "01" then "January"
  1417 		when "01" then "January"
  1248 			when "02" then "February"
  1418 		when "02" then "February"
  1249 			when "03" then "March"
  1419 		when "03" then "March"
  1250 			when "04" then "April"
  1420 		when "04" then "April"
  1251 			when "05" then "May"
  1421 		when "05" then "May"
  1252 			when "06" then "June"
  1422 		when "06" then "June"
  1253 			when "07" then "July"
  1423 		when "07" then "July"
  1254 			when "08" then "August"
  1424 		when "08" then "August"
  1255 			when "09" then "September"
  1425 		when "09" then "September"
  1256 			when "10" then "October"
  1426 		when "10" then "October"
  1257 			when "11" then "November"
  1427 		when "11" then "November"
  1258 			when "12" then "December"
  1428 		when "12" then "December"
  1259 		end
  1429 	end
  1260 		day_to_verify = @day.to_i
  1430 	day_to_verify = @day.to_i
  1261 		verify(){app.HbTextItem(:text => day_to_verify)}
  1431 	verify(){app.HbTextItem(:text => day_to_verify)}
  1262 		verify(){app.HbTextItem(:text => month_in_view)}
  1432 	verify(){app.HbTextItem(:text => month_in_view)}
  1263 		#Calendar widget content contains "No event for next 7 days"
  1433 	#Calendar widget content contains "No event for next 7 days"
  1264 		verify(){app.HbTextItem(:text => 'No entries for 7 days')}
  1434 	verify(){app.HbTextItem(:text => 'No entries for 7 days')}
  1265 	
  1435 
  1266 		#Verify, that reminder icon in widget is not shown
  1436 	#Verify, that reminder icon in widget is not shown
  1267 		if (app.test_object_exists?("HbIconItem",{:iconName => 'images/bell.PNG'})) then
  1437 	if (app.test_object_exists?("HbIconItem",{:iconName => 'images/bell.PNG'})) then
  1268 			raise VerificationError ,"ERROR: There is reminder icon in calendar widget, when it should not be there", caller
  1438 		raise VerificationError ,"ERROR: There is reminder icon in calendar widget, when it should not be there", caller
  1269 		end
  1439 	end
  1270 		#Remove calendar widget from display
       
  1271 		remove_calendar_widget_from_homescreen(0)
       
  1272 	#rescue
       
  1273 	#	if (running_round < max_running_rounds) then
       
  1274     #       running_round = running_round + 1
       
  1275     #       puts "Some error came during run. Lets try again"
       
  1276     #       teardown
       
  1277 	#       retry
       
  1278     #    else
       
  1279     #       puts "Test failed"
       
  1280     #       raise
       
  1281     #    end
       
  1282 	#end #rescue			
       
  1283   end #test_calendar_widget_no_events
  1440   end #test_calendar_widget_no_events
  1284 
       
  1285   def _test_create_meeting
       
  1286 	create_calendar_event_via_calendar('Meeting 1')
       
  1287   end
       
  1288 
  1441 
  1289 ################################################################################################################################################
  1442 ################################################################################################################################################
  1290 ###
  1443 ###
  1291 ###						BAT cases end. User story related FuTe cases start
  1444 ###						BAT cases end. User story related FuTe cases start
  1292 ###
  1445 ###
  1311   #	===	params
  1464   #	===	params
  1312   #	none
  1465   #	none
  1313   #
  1466   #
  1314   ############################################################################################################################################
  1467   ############################################################################################################################################
  1315   
  1468   
  1316   def _test_calendar_widget_One_upcoming_event_in_7_day_away_and_one_in_8_day_away
  1469   def test_calendar_widget_One_upcoming_event_in_7_day_away_and_one_in_8_day_away
  1317 	#running_round = 1
  1470     #preconditions:
  1318 	#max_running_rounds = 2
  1471 	#-Device is in Home Screen
  1319 	#begin
  1472 	app = @sut.application(:name => 'hsapplication')
  1320 		#preconditions:
  1473 	verify(){app.HbIconItem(:iconName => 'qtg_mono_applications_all')}
  1321 		#-Device is in Home Screen
  1474 	#-One event at 7 days away and one event at 8 days away in Calendar
  1322 		app = @sut.application(:name => 'hsapplication')
  1475 	check_phone_date
  1323 		verify(){app.HbIconItem(:iconName => 'qtg_mono_applications_all')}
  1476 	check_phone_time
  1324 		navigate_to_first_homescreen
  1477 	seventh_day_time_for_verification = create_calendar_event_via_calendar("not working",@day.to_i+7,@month.to_i,@year.to_i,@hour.to_i+2,@minute.to_i,0,0,0)
  1325 		#-One event at 7 days away and one event at 8 days away in Calendar
  1478 	eight_day_time_for_verification = create_calendar_event_via_calendar("not working",@day.to_i+8,@month.to_i,@year.to_i,@hour.to_i+2,@minute.to_i,0,0,0)
  1326 		check_phone_date
  1479 	#-Calendar widget is added to Home Screen.
  1327 		check_phone_time
  1480 	#Not adding calendar widget, if it already exists there
  1328 		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)
  1481 	if not(app.test_object_exists?("HbWidget",{:name => 'CalendarWidget'})) then
  1329 		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)
  1482 		#add calendar widget to home screen
  1330 		#-Calendar widget is added to Home Screen.
  1483 		app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
  1331 		#Not adding calendar widget, if it already exists there
  1484 		add_calendar_widget_to_homescreen(app,'AppListButton')
  1332 		if not(app.test_object_exists?("HbWidget",{:name => 'CalendarWidget'})) then
  1485 	end
  1333 			#add calendar widget to home screen
  1486 	#step 1: Check Calendar widget
  1334 			app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
  1487 	#step 1 expected:
  1335 			add_calendar_widget_to_homescreen(app,'AppListButton')
  1488 	#- All icons (widget icon and reminder icon) are shown correctly.
  1336 		end
  1489 	verify(){app.HbLabel( :name => 'iconLabel' )}
  1337 		#step 1: Check Calendar widget
  1490 	#Verify, that reminder icon in widget is shown
  1338 		#step 1 expected:
  1491 	#!!! Cannot run this yet 
  1339 		#- All icons (widget icon and reminder icon) are shown correctly.
  1492 	#if not(app.test_object_exists?("HbFrameItem",{:frameGraphicsName => 'qtg_small_reminder'})) then
  1340 		#Verify, that reminder icon in widget is not shown. Cannot be verified currently, since fixture creating calendar event does not 
  1493 	#	raise VerificationError ,"ERROR: There is not reminder icon in calendar widget, when it should be there", caller
  1341 		#have reminders
  1494 	#end
  1342 		#if not(app.test_object_exists?("HbIconItem",{:iconName => 'images/bell.PNG'})) then
  1495 	#Verify, that calendar widget shows current date
  1343 		#	raise VerificationError ,"ERROR: There is not reminder icon in calendar widget, when it should not be there", caller
  1496 	month_in_view = case @month
  1344 		#end
  1497 		when "01" then "January"
  1345 		#- 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'.
  1498 		when "02" then "February"
  1346 		#Verify, that calendar widget shows current date
  1499 		when "03" then "March"
  1347 		month_in_view = case @month
  1500 		when "04" then "April"
  1348 			when 1 then "January"
  1501 		when "05" then "May"
  1349 			when 2 then "February"
  1502 		when "06" then "June"
  1350 			when 3 then "March"
  1503 		when "07" then "July"
  1351 			when 4 then "April"
  1504 		when "08" then "August"
  1352 			when 5 then "May"
  1505 		when "09" then "September"
  1353 			when 6 then "June"
  1506 		when "10" then "October"
  1354 			when 7 then "July"
  1507 		when "11" then "November"
  1355 			when 8 then "August"
  1508 		when "12" then "December"
  1356 			when 9 then "September"
  1509 	end
  1357 			when 10 then "October"
  1510 	day_to_verify = @day.to_i
  1358 			when 11 then "November"
  1511 	verify(){app.HbTextItem(:text => day_to_verify)}
  1359 			when 12 then "December"
  1512 	verify(){app.HbWidget( :name => 'CalendarWidget' ).HbWidget( :name => 'iconContainer' ).HbLabel( :name => 'month' ).HbTextItem(:text => month_in_view)}
  1360 		end
  1513 	#- Only event at 7 days away is shown in widget as two rows: first row shows the event date, second row shows the event title.
  1361 		day_to_verify = @day.to_i
  1514 	#!! Cannot run this yet
  1362 		verify(){app.HbTextItem(:text => day_to_verify)}
  1515 	#verify(){app.HbLabel( :name => 'upperLabelShort' ).HbTextItem( :text => seventh_day_time_for_verification)}			
  1363 		verify(){app.HbTextItem(:text => month_in_view)}
  1516 	#!! Cannot run this yet
  1364 		#- 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'.
  1517 	#verify(){app.HbLabel( :name => 'lowerLabel' ).HbTextItem( :text => "Unnamed")}			
  1365 		seventh_date_for_verification = verify(){app.HbLabel( :name => 'upperLabel' ).HbTextItem( :text => seventh_day_time_for_verification+' 7th day meeting' )}
  1518 	#Step 2: Remove 7 days away meeting from calendar and check calendar widget
  1366 		#Remove calendar widget from display
  1519 	#!! Cannot do this yet. Tapping event won't go to calendar view
  1367 		#remove_calendar_widget_from_homescreen(0)
  1520 	#Step 2 Expected:
  1368 	#rescue
  1521 	#- All icons (widget icon and reminder icon) are shown correctly.
  1369 	#	if (running_round < max_running_rounds) then
  1522 	#!! Cannot run this yet
  1370     #       running_round = running_round + 1
  1523 	#verify(){app.HbLabel( :name => 'iconLabel' )}
  1371     #       puts "Some error came during run. Lets try again"
  1524 	#Verify, that reminder icon in widget is shown
  1372     #       teardown
  1525 	#!! Cannot run this yet
  1373 	#       retry
  1526 	#if not(app.test_object_exists?("HbFrameItem",{:frameGraphicsName => 'qtg_small_reminder'})) then
  1374     #    else
  1527 	#	raise VerificationError ,"ERROR: There is not reminder icon in calendar widget, when it should be there", caller
  1375     #       puts "Test failed"
  1528 	#end
  1376     #       raise
  1529 	#- text "No entries for next 7 days" is showing
  1377     #    end
  1530 	#!! Cannot run this yet
  1378 	#end #rescue			
  1531 	#verify(){app.HbTextItem(:text => 'No entries for 7 days')}
       
  1532 	#postactions
       
  1533 	delete_calendar_events_via_UI
  1379   end #test_calendar_widget_One_upcoming_event_in_7_day_away_and_one_in_8_day_away
  1534   end #test_calendar_widget_One_upcoming_event_in_7_day_away_and_one_in_8_day_away
       
  1535   
       
  1536   ##############################################################################################################################################
       
  1537   # Calendar widget - reminder icon
       
  1538   ##############################################################################################################################################
       
  1539   #
       
  1540   # Purpose of this test case is to check, that there is seen reminder-icon in calendar widget for events, that have reminder
       
  1541   #
       
  1542   #	Created at: 25.08.2010
       
  1543   #	Created by: Jarno Mäkelä
       
  1544   #	Reviewed by: 
       
  1545   #
       
  1546   #	===	preconditions
       
  1547   #	- Device is in Home Screen.
       
  1548   # - One event happens few hours after current phone time at today in Calendar and reminder is set on.
       
  1549   # - Calendar widget is added to Home Screen.
       
  1550   #
       
  1551   #	===	params
       
  1552   #	none
       
  1553   #
       
  1554   ############################################################################################################################################
       
  1555   
       
  1556   def test_calendar_widget_reminder_icon
       
  1557 	#Preconditions:
       
  1558 	#Device is in Homescreen
       
  1559 	app = @sut.application(:name => 'hsapplication')
       
  1560 	verify(){app.HbIconItem(:iconName => 'qtg_mono_applications_all')}
       
  1561 	#- One event happens few hours after current phone time at today in Calendar and reminder is set on.
       
  1562 	check_phone_date
       
  1563 	check_phone_time
       
  1564 	today_time_for_verification = create_calendar_event_via_calendar("not working",@day.to_i,@month.to_i,@year.to_i,@hour.to_i+2,@minute.to_i,0,0,0)
       
  1565 	#-Calendar widget is added to Home Screen.
       
  1566 	#Not adding calendar widget, if it already exists there
       
  1567 	if not(app.test_object_exists?("HbWidget",{:name => 'CalendarWidget'})) then
       
  1568 		#add calendar widget to home screen
       
  1569 		app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
       
  1570 		add_calendar_widget_to_homescreen(app,'AppListButton')
       
  1571 	end
       
  1572 	#Step 1:Check Calendar widget.
       
  1573 	#step 1 Expected: - All icons (widget icon and reminder icon) are shown correctly.
       
  1574 	#- Calendar widget shows the event as two rows: first row show the event time and second row shows the event title.
       
  1575 	day_to_verify = @day.to_i
       
  1576 	verify(){app.HbTextItem(:text => day_to_verify)}
       
  1577 	#!!!!! Cannot run yet below
       
  1578 	#verify(){app.HbLabel( :name => 'upperLabelShort' ).HbTextItem( :text => today_time_for_verification )}
       
  1579 	#!!!!! Cannot run yet below
       
  1580 	#verify(){app.HbLabel( :name => 'lowerLabel' ).HbTextItem( :text => 'Unnamed' )}
       
  1581 	#Verify, that reminder icon in widget is shown
       
  1582 	if not(app.test_object_exists?("HbFrameItem",{:frameGraphicsName => 'qtg_small_reminder'})) then
       
  1583 		raise VerificationError ,"ERROR: There is not reminder icon in calendar widget, when it should be there", caller
       
  1584 	end
       
  1585 	#Step 2:Change reminder set to off in Calendar.
       
  1586 	#!!!!!!!!!!!!!!!!!!!!!Cannot do yet, since tapping the calendar widget won't take to calendar agenda view
       
  1587 	#Step 2 Expected: Reminder is set to off.
  1380 
  1588 
       
  1589 	#Step 3: Check Calendar widget.	
       
  1590 	#Step 3 Expected: 
       
  1591 	#- Reminder icon is not shown.
       
  1592 	#- The event is shown correctly.
       
  1593 	#!!!!! Cannot run yet below
       
  1594 	#if (app.test_object_exists?("HbFrameItem",{:frameGraphicsName => 'qtg_small_reminder'})) then
       
  1595 	#	raise VerificationError ,"ERROR: There is reminder icon in calendar widget, when it should not be there", caller
       
  1596 	#end
       
  1597 	day_to_verify = @day.to_i
       
  1598 	verify(){app.HbTextItem(:text => day_to_verify)}
       
  1599 	#!!!!! Cannot run yet below
       
  1600 	#verify(){app.HbLabel( :name => 'upperLabelShort' ).HbTextItem( :text => today_time_for_verification )}
       
  1601 	#!!!!! Cannot run yet below
       
  1602 	#verify(){app.HbLabel( :name => 'lowerLabel' ).HbTextItem( :text => 'Unnamed' )}
       
  1603 	
       
  1604 	#Step 4: Create an event overlapping the previous event and set reminder on.
       
  1605 	#Step 4 Expected: The event is created with reminder on.
       
  1606 	another_time_for_verification = create_calendar_event_via_calendar("not working",@day.to_i,@month.to_i,@year.to_i,@hour.to_i+2,@minute.to_i,0,0,0)
       
  1607 	
       
  1608 	#Step 5: Check Calendar widget.	
       
  1609 	#Step 5 Expected: 
       
  1610 	#- Reminder icon is not shown .
       
  1611 	if (app.test_object_exists?("HbFrameItem",{:frameGraphicsName => 'qtg_small_reminder'})) then
       
  1612 		raise VerificationError ,"ERROR: There is reminder icon in calendar widget, when it should not be there", caller
       
  1613 	end
       
  1614 	#- The overlapping information is shown in content.
       
  1615 	if @hourformat_12 == true then
       
  1616 		overlapping_time_for_verification = today_time_for_verification[0..7]+'-'+another_time_for_verification[9..16]
       
  1617 	else
       
  1618 		overlapping_time_for_verification = today_time_for_verification[0..4]+'-'+another_time_for_verification[6..10]
       
  1619 	end
       
  1620 	puts "overlapping_time_for_verification: ",overlapping_time_for_verification
       
  1621 	verify(){app.HbLabel( :name => 'upperLabelLong'  ).HbTextItem( :text => overlapping_time_for_verification )}
       
  1622 	verify(){app.HbLabel(:name => 'lowerLabel' ).HbTextItem( :text => '2 overlapping entry' )}
       
  1623 	#Step 6: Remove all events in Calendar and check Calendar widget.
       
  1624 	delete_calendar_events_via_UI
       
  1625 	#Step 6 expected: 
       
  1626 	#- Reminder icon is not shown.
       
  1627 	if (app.test_object_exists?("HbFrameItem",{:frameGraphicsName => 'qtg_small_reminder'})) then
       
  1628 		raise VerificationError ,"ERROR: There is reminder icon in calendar widget, when it should not be there", caller
       
  1629 	end	
       
  1630 	#- 'No entries for next 7 days' is shown in widget content.
       
  1631 	verify(){app.HbTextItem(:text => 'No entries for 7 days')}
       
  1632 	
       
  1633 	#Step 7:Create an event with reminder on happens at next day in Calendar and check Calendar widget.
       
  1634 	tomorrow_time_for_verification = create_calendar_event_via_calendar("not working",@day.to_i+1,@month.to_i,@year.to_i,@hour.to_i+2,@minute.to_i,0,1,0)
       
  1635 	#Step 7 Expected: 
       
  1636 	#- Reminder icon is shown in right upper corner.
       
  1637 	if not(app.test_object_exists?("HbFrameItem",{:frameGraphicsName => 'qtg_small_reminder'})) then
       
  1638 		raise VerificationError ,"ERROR: There is not reminder icon in calendar widget, when it should be there", caller
       
  1639 	end	
       
  1640 	#- The widget content is shown as two rows: first row shows  the event date and second row shows the event title.
       
  1641 	#!!!!! Cannot run yet below
       
  1642 	#verify(){app.HbLabel( :name => 'upperLabelShort' ).HbTextItem( :text => tomorrow_time_for_verification )}
       
  1643 	#!!!!! Cannot run yet below
       
  1644 	#verify(){app.HbLabel( :name => 'lowerLabel' ).HbTextItem( :text => 'Unnamed' )}
       
  1645 	#postactions
       
  1646 	delete_calendar_events_via_UI
       
  1647   end #test_calendar_widget_reminder_icon
       
  1648   
  1381 ################################################################################################################################################
  1649 ################################################################################################################################################
  1382 ###
  1650 ###
  1383 ###						User story related FuTe cases cases end. NFT cases start
  1651 ###						User story related FuTe cases cases end. Other FuTe cases start
  1384 ###
  1652 ###
  1385 ################################################################################################################################################
  1653 ################################################################################################################################################
  1386 
  1654 
       
  1655  ##############################################################################################################################################
       
  1656   # test_calendar_widget_all_day_event_lasts_several_days
       
  1657   ##############################################################################################################################################
       
  1658   #
       
  1659   # Purpose of this test case is to verify, that all day event is shown correctly in calendar widget, when all day event lasts three days. That is, it is shown in first day, but not after that.
       
  1660   #
       
  1661   #	Created at: 24.08.2010
       
  1662   #	Created by: Jarno Mäkelä
       
  1663   #	Reviewed by: 
       
  1664   #
       
  1665   #	===	preconditions
       
  1666   #	- Device is in Home screen.
       
  1667   #    - three days lasting event in Calendar starting today, no other events at same time
       
  1668   #    - Calendar widget is added to Home Screen.
       
  1669   #
       
  1670   #	===	params
       
  1671   #	none
       
  1672   #
       
  1673   ############################################################################################################################################
       
  1674 
       
  1675 def  _test_calendar_widget_all_day_event_lasts_several_days
       
  1676 	#Start is missing
       
  1677 	#Step 1: Check calendar widget
       
  1678 	#Step 1 Expected: 
       
  1679 	#- All icons (widget icon and reminder icon) are shown correctly.
       
  1680 	verify(){app.HbWidget( :name => 'CalendarWidget' ).HbWidget( :name => 'iconContainer' ).HbLabel( :name => 'iconLabel' )}
       
  1681         if not(app.test_object_exists?("HbFrameItem",{:frameGraphicsName => 'qtg_small_reminder'})) then
       
  1682         	raise VerificationError ,"ERROR: There is not reminder icon in calendar widget, when it should be there", caller
       
  1683         end
       
  1684         #- Calendar widget shows  rows: first row shows the event date and second row shows the name of all day event .
       
  1685         verify(){HbWidget( :name => 'CalendarWidget' ).HbWidget( :name => 'contentContainer' ).HbLabel( :__index => 0 ).HbTextItem( :text => all_day_event_time_for_verification )}
       
  1686         verify(){HbWidget( :name => 'CalendarWidget' ).HbWidget( :name => 'contentContainer' ).HbLabel( :__index => 1 ).HbTextItem( :text => 'Unnamed' )}        
       
  1687         #Step 2: Change phone date for tomorrow.
       
  1688         clock_app = @sut.run(:name => "clock.exe")
       
  1689         clock_app.HbMarqueeItem(:text => 'Clock').tap
       
  1690         clock_app.HbTextItem( :text => 'Settings' ).tap
       
  1691         if clock_app.HbCheckBox( :name => 'networkTime' ).test_object_exists?("HbIconItem",{:iconName => 'qtg_small_selected'}) then
       
  1692         	clock_app.HbCheckBox( :name => 'networkTime' ).tap
       
  1693         end
       
  1694         clock_app.HbPushButton( :name => 'dateItem' ).tap
       
  1695         tomorrow_date = calculate_date(@day.to_i+1,@month.to_i,@year.to_i, 0, 0)
       
  1696 	puts "tomorrow_date:",tomorrow_date.to_s
       
  1697 	if tomorrow_date[0..1].to_i < @day.to_i then
       
  1698 		clock_app.HbDatePickerView(:__index => 0).HbAbstractItemContainer.HbDatePickerViewItem(:__index => 3).HbTextItem.gesture(:Up,0.5,53) 
       
  1699 		if tomorrow_date[3..4].to_i < @month.to_i then
       
  1700 			 clock_app.HbDatePickerView(:__index => 1).HbAbstractItemContainer.HbDatePickerViewItem(:__index => 2).HbTextItem.gesture(:Up,0.5,53) 
       
  1701 			 clock_app.HbDatePickerView(:__index => 2).HbAbstractItemContainer.HbDatePickerViewItem(:__index => 2).HbTextItem.gesture(:Up,0.5,53) 		
       
  1702 		else
       
  1703 			 clock_app.HbDatePickerView(:__index => 1).HbAbstractItemContainer.HbDatePickerViewItem(:__index => 2).HbTextItem.gesture(:Up,0.5,53) 		
       
  1704 		end
       
  1705 	else
       
  1706 		clock_app.HbDatePickerView(:__index => 0).HbAbstractItemContainer.HbDatePickerViewItem(:__index => 3).HbTextItem.gesture(:Up,0.5,53) 
       
  1707 	end
       
  1708         #Step 2 expected: Date can be changed
       
  1709         clock_app.HbTextItem( :text => 'OK' ).tap
       
  1710         clock_app.close
       
  1711         #Step 3: Check Calendar widget.
       
  1712         #Step 3 Expected: 
       
  1713         #- Calendar widget icon shows current date.
       
  1714         day_to_verify =  tomorrow_date[0..1].to_i
       
  1715         month_in_view = case tomorrow_date[3..4]
       
  1716 		when "01" then "January"
       
  1717 		when "02" then "February"
       
  1718 		when "03" then "March"
       
  1719 		when "04" then "April"
       
  1720 		when "05" then "May"
       
  1721 		when "06" then "June"
       
  1722 		when "07" then "July"
       
  1723 		when "08" then "August"
       
  1724 		when "09" then "September"
       
  1725 		when "10" then "October"
       
  1726 		when "11" then "November"
       
  1727 		when "12" then "December"
       
  1728 	end
       
  1729 	verify(){app.HbTextItem(:text => day_to_verify)}
       
  1730 	verify(){app.HbTextItem(:text => month_in_view)}
       
  1731         #- 'No entries for 7 days' is shown in widget content.
       
  1732 	verify(){app.HbTextItem(:text => 'No entries for 7 days')}
       
  1733 	 #- Reminder icon in widget should not be shown.
       
  1734 	if (app.test_object_exists?("HbIconItem",{:iconName => 'images/bell.PNG'})) then
       
  1735 		raise VerificationError ,"ERROR: There is reminder icon in calendar widget, when it should not be there", caller
       
  1736 	end
       
  1737 	#set time back to use network time
       
  1738 	clock_app = @sut.run(:name => "clock.exe")
       
  1739         clock_app.HbMarqueeItem(:text => 'Clock').tap
       
  1740         clock_app.HbTextItem( :text => 'Settings' ).tap
       
  1741         clock_app.HbCheckBox( :name => 'networkTime' ).tap
       
  1742         clock_app.close
       
  1743 	delete_calendar_events_via_UI	
       
  1744 end # test_calendar_widget_all_day_event_lasts_several_days
       
  1745 ################################################################################################################################################
       
  1746 ###
       
  1747 ###						Other FuTe cases cases end. NFT cases start
       
  1748 ###
       
  1749 ################################################################################################################################################
       
  1750 
       
  1751   ##############################################################################################################################################
       
  1752   # Calendar widget - NFT - Measure memory consumption when adding seven calendar widgets to HS
       
  1753   ##############################################################################################################################################
       
  1754   #
       
  1755   # The purpose of this test case is to verify that calendar widget doesn't allocate excess amount of memory. Measure memory level before 
       
  1756   # adding any widgets, then add seven calendar widgets and then measure the memory level. Compare the results.
       
  1757   #
       
  1758   #	Created at: 26.08.2010
       
  1759   #	Created by: Jarno Mäkelä
       
  1760   #	Reviewed by: 
       
  1761   #
       
  1762   #	===	preconditions
       
  1763   #	- Device is in Home Screen.
       
  1764   #	- No calendar widget in any of the homescreens
       
  1765   #
       
  1766   #	===	params
       
  1767   #	none
       
  1768   #
       
  1769   ############################################################################################################################################
       
  1770   
       
  1771   def test_calendar_widget_NFT_Measure_memory_consumption_when_adding_seven_calendar_widgets_to_HS
       
  1772 	#preconditions:
       
  1773 	#-Device is in Home Screen
       
  1774 	app = @sut.application(:name => 'hsapplication')
       
  1775 	verify(){app.HbIconItem(:iconName => 'qtg_mono_applications_all')}
       
  1776 	#	- No calendar widget in any of the homescreens
       
  1777 	#This is done in initialize test, when starting test round
       
  1778 	#start memory logging
       
  1779 	app.log_mem({:interval => 10, :filePath => 'C:\Data', :append => true})
       
  1780 	#app.log_gpu_mem({:interval => 1, :filePath => 'C:\Data'})
       
  1781 	#@sut.log_mem({:interval => 1, :filePath => 'C:\Data'})
       
  1782 	cal_widget_array = Array.new
       
  1783 	i = 0
       
  1784 	index = 0
       
  1785 	drag_distance = 0
       
  1786 	#app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
       
  1787 	#sleep 10
       
  1788 	#app.HbIconItem(:iconName => 'qtg_mono_back').tap
       
  1789 	#do 7 times
       
  1790 	7.times do
       
  1791         	#start memory logging again
       
  1792         	#app.log_mem({:interval => 5, :filePath => 'C:\Data'})
       
  1793         	#app.log_gpu_mem({:interval => 20, :filePath => 'C:\Data'})
       
  1794 		#add calendar widget to home screen
       
  1795 		app.HbIconItem(:iconName => 'qtg_mono_applications_all').tap
       
  1796 		add_calendar_widget_to_homescreen(app,'AppListButton')
       
  1797 		#app.HbIconItem(:iconName => 'qtg_mono_back').tap
       
  1798 		#find the name of calendar widget
       
  1799         	identificator = TestObjectIdentificator.new(:type => :HsWidgetHostVisual)
       
  1800         	xml =  app.HsPageVisual(:__index => 0).xml_data
       
  1801         	element_set = xml.xpath( xpath = identificator.get_xpath_to_identify( xml ) ) 
       
  1802        		widget_string = String.new(element_set.to_s)
       
  1803 		for k in 0..i
       
  1804 			index = widget_string.index('calendarwidgetplugin')
       
  1805 			widget_name = widget_string[index.to_i..index.to_i+22]
       
  1806 			widget_string = widget_string[index.to_i+22..widget_string.length]
       
  1807 		end
       
  1808         	cal_widget_array[i]= widget_name      
       
  1809 		puts "calendar widget added"
       
  1810 		puts "name of calendar widget is: " + cal_widget_array[i].to_s
       
  1811 		calendar_widget_object = app.find(:name =>cal_widget_array[i])
       
  1812         	calendar_widget_object.tap_down
       
  1813         	calendar_widget_object = app.HbWidget( :name => 'controlLayer' ).find(:name => 'CalendarWidget')
       
  1814         	calendar_widget_object.drag_to(130, 550-drag_distance.to_i)
       
  1815 		i = i + 1 
       
  1816 		drag_distance = drag_distance + 70
       
  1817         	#Stop memory logging
       
  1818         	#mem_data_end = MobyBase::StateObject.new( app.stop_mem_log )
       
  1819         	#count_end = mem_data_end.logData.attribute('entryCount').to_i
       
  1820         	#gpu_data_end = MobyBase::StateObject.new( app.stop_gpu_log )
       
  1821         	#count_end = gpu_data_end.logData.attribute('entryCount').to_i
       
  1822         	#puts "count_end: "+count_end.to_s
       
  1823         	#j = 0
       
  1824         	#while j < count_end do
       
  1825             	#	#get heapsize
       
  1826             	#	#heap_size_end = mem_data_end.logEntry(:id => j.to_s).attribute('heapSize').to_i
       
  1827             	#	#puts "heap_size in end:" + heap_size_end.to_s	
       
  1828             	#	total_mem_end = gpu_data_end.logEntry(:id => i.to_s).attribute('totalMem').to_i
       
  1829             	#	puts " total_mem in end:" + total_mem_end.to_s	
       
  1830             	#	used_mem_end = gpu_data_end.logEntry(:id => i.to_s).attribute('usedMem').to_i
       
  1831             	#	puts " used_mem in end:" + used_mem_end.to_s	
       
  1832             	#	free_mem_end = gpu_data_end.logEntry(:id => i.to_s).attribute('freeMem').to_i
       
  1833             	#	puts " free_mem in end:" + free_mem_end.to_s	
       
  1834             	#	j += 1
       
  1835         	#end
       
  1836 	end
       
  1837 	
       
  1838 	#Delete calendar widgets
       
  1839 	for j in 0..cal_widget_array.length-1
       
  1840         app.HsWidgetHostVisual( :name => cal_widget_array[j].to_s ).CalendarWidget.HbWidget( :name => 'CalendarWidget' ).HbWidget( :name => 'contentContainer' ).HbLabel( :name => 'middleLabel' ).HbTextItem( :text => 'No entries for 7 days' ).tap_down
       
  1841 		#app.HsIdleWidget.HbWidget( :name => 'controlLayer' ).HsWidgetHostVisual( :name => cal_widget_array[j].to_s ).CalendarWidget.HbWidget( :name => 'CalendarWidget' ).HbWidget( :name => 'contentContainer' ).HbLabel( :name => 'middleLabel' ).HbTextItem( :text => 'No entries for 7 days' ).drag_to_object(app.HsTrashBinWidget( :name => 'trashBin' ))
       
  1842 		app.HsIdleWidget.HbWidget( :name => 'controlLayer' ).HsWidgetHostVisual( :name => cal_widget_array[j].to_s ).CalendarWidget.HbWidget( :name => 'CalendarWidget' ).HbWidget( :name => 'contentContainer' ).HbLabel( :name => 'middleLabel' ).HbTextItem( :text => 'No entries for 7 days' ).drag_to(150,560 )
       
  1843 		#app.HsWidgetHostVisual( :name => cal_widget_array[j] ).tap_down
       
  1844               	#calendar_widget_object = app.find(:name =>cal_widget_array[j])
       
  1845                 #calendar_widget_object.tap_down
       
  1846                 #calendar_widget_object = app.HbWidget( :name => 'controlLayer' ).find(:name =>cal_widget_array[j])
       
  1847                 #calendar_widget_object.drag_to_object(app.HsTrashBinWidget( :name => 'trashBin' ))
       
  1848 		#app.HsIdleWidget.HbWidget( :name => 'controlLayer' ).HsWidgetHostVisual( :name => cal_widget_array[j] ).drag_to_object(app.HsTrashBinWidget( :name => 'trashBin' ))
       
  1849                 sleep 1
       
  1850 	end
       
  1851 	sleep 30
       
  1852 	#gpu_data = MobyBase::StateObject.new( app.stop_gpu_log )
       
  1853 	mem_data = MobyBase::StateObject.new( app.stop_mem_log )
       
  1854 	#sut_mem_data = MobyBase::StateObject.new( @sut.stop_mem_log )
       
  1855 	#draw_graph(gpu_data, ['totalMem','usedMem','freeMem','processPrivateMem'], 'homescreen')
       
  1856         draw_graph(mem_data, ['heapSize'], 'homescreen')
       
  1857     #    draw_graph(sut_mem_data, ['heapSize'], 'sut')
       
  1858         #!!! Cannot do yet
       
  1859         #compare start memory amount to end memory amount. This cannot do yet, since they won't match. maybe there are memory leaks in HS
       
  1860         
       
  1861   end #test_calendar_widget_NFT_Measure_memory_consumption_when_adding_seven_calendar_widgets_to_HS
       
  1862   
       
  1863   def _test_delete_calendar_widgets
       
  1864     #Lets check all widgets in first page
       
  1865     app = @sut.application(:name => 'hsapplication')
       
  1866     identificator = TestObjectIdentificator.new(:type => :HsWidgetHostVisual)
       
  1867 	xml =  app.HsPageVisual(:__index => 0).xml_data
       
  1868 	element_set = xml.xpath( xpath = identificator.get_xpath_to_identify( xml ) ) 
       
  1869 	widget_string = String.new(element_set.to_s)
       
  1870 	#lets find all the calendarwidgetplugin-named calendar widgets
       
  1871 	cal_widget_array = Array.new
       
  1872 	i = 0
       
  1873 	index = 0
       
  1874 	while index != nil do
       
  1875               #search first occurence of calendar widget plugin
       
  1876               index = widget_string.index('calendarwidgetplugin')
       
  1877               if index != nil then
       
  1878                     #save the name of calendar widget to array
       
  1879                     cal_widget_array[i]=widget_string[index.to_i..index.to_i+22]
       
  1880                     puts "cal_widget_array[i] = "+ cal_widget_array[i].to_s
       
  1881                     i = i +1
       
  1882                     #put the rest of the string to be checked another calendarwidgetplugin-name
       
  1883                     widget_string = widget_string[index.to_i+22..widget_string.length]
       
  1884              end
       
  1885 	end
       
  1886 	#Delete calendar widgets
       
  1887 	for j in 0..cal_widget_array.length-1
       
  1888 		app.HsWidgetHostVisual( :name => cal_widget_array[j].to_s ).CalendarWidget.HbWidget( :name => 'CalendarWidget' ).HbWidget( :name => 'contentContainer' ).HbLabel( :name => 'middleLabel' ).HbTextItem( :text => 'No entries for 7 days' ).tap_down
       
  1889 		app.HsIdleWidget.HbWidget( :name => 'controlLayer' ).HsWidgetHostVisual( :name => cal_widget_array[j].to_s ).CalendarWidget.HbWidget( :name => 'CalendarWidget' ).HbWidget( :name => 'contentContainer' ).HbLabel( :name => 'middleLabel' ).HbTextItem( :text => 'No entries for 7 days' ).drag_to_object(app.HsTrashBinWidget( :name => 'trashBin' ))
       
  1890         #calendar_widget_object = app.find(:text => 'No entries for 7 days')
       
  1891 		#calendar_widget_object = app.find(HsWidgetHostVisual( :name => 'calendarwidgetplugin:21' ) )
       
  1892         #calendar_widget_object.tap_down
       
  1893         #calendar_widget_object = app.HbWidget( :name => 'controlLayer' ).find(:name => 'CalendarWidget')
       
  1894 	#	calendar_widget_object = app.HbWidget( :name => 'controlLayer' ).find( :name => 'calendarwidgetplugin:21' )
       
  1895         #calendar_widget_object.drag_to_object(app.HsTrashBinWidget( :name => 'trashBin' ))
       
  1896         #        sleep 1
       
  1897 	end
       
  1898   end
       
  1899   
  1387   ##############################################################################################################################################
  1900   ##############################################################################################################################################
  1388   # Calendar widget - NFT - Switch between HS and application library 50 times
  1901   # Calendar widget - NFT - Switch between HS and application library 50 times
  1389   ##############################################################################################################################################
  1902   ##############################################################################################################################################
  1390   #
  1903   #
  1391   # The purpose of this test is to verify that calendar widget is shown properly under stress. Calendar widget set on every HS, switch between 
  1904   # The purpose of this test is to verify that calendar widget is shown properly under stress. Calendar widget set on every HS, switch between 
  1479     #       raise
  1992     #       raise
  1480     #    end
  1993     #    end
  1481 	#end #rescue			
  1994 	#end #rescue			
  1482   end #test_editor_view_new
  1995   end #test_editor_view_new
  1483 
  1996 
       
  1997   private
       
  1998 
       
  1999       def draw_graph(log_data, cells, app_name)
       
  2000             count = log_data.logData.attribute('entryCount').to_i
       
  2001             data_rows = Hash.new
       
  2002             cells.each{|title| data_rows[title] = Array.new}
       
  2003             i = 0
       
  2004             while i < count do
       
  2005               data_rows.each_key{ |key| data_rows[key].push(log_data.logEntry(:id => i.to_s).attribute(key).to_i)}
       
  2006               i += 1
       
  2007             end
       
  2008 
       
  2009             g = Gruff::Line.new
       
  2010             g.title = log_data.logData.name
       
  2011             data_rows.each_key{ |key| g.data(key, data_rows[key]) }
       
  2012             g.write(app_name+"_"+log_data.logData.name+".png")
       
  2013       end
       
  2014 
  1484 end # test class
  2015 end # test class