237
234
recent_urls = new_tab_page.get_top_sites_list().get_urls()
238
235
self.assertCountEqual(recent_urls, expected_recent_urls)
240
def test_download_image(self):
241
"""Test to download an image from internet an save it locally"""
242
img = test_data.get('ubuntu_img')
244
# check there are no files in download folder
246
len(fs.recursive_files_in_dir(fs.DIR_HOME_CACHE_GALLERY)), 0)
248
# Go to page with the picture to download
249
self.browser.go_to_url(test_data.get('page3').entered_url)
250
self.browser.wait_until_page_loaded(test_data.get('page3').actual_url)
252
# Click on the picture
253
webview = self.browser.get_current_webview()
254
self.browser.pointing_device.move_to_object(webview)
255
self.browser.pointing_device.move(self.browser.pointing_device.x,
256
self.browser.pointing_device.y / 2)
257
self.browser.pointing_device.click(press_duration=3)
259
# Select to save the image
260
save_image = self.browser.get_popover_foreground_dialog_item(
262
self.browser.pointing_device.click_object(save_image)
264
# Choose open in application option
265
options = self.browser.get_download_options_dialog()
266
options.choose_application()
268
# Pick the gallery to see the picture after it is downlaoded
269
picker = self.browser.get_open_with_dialog()
270
picker.pick_gallery()
272
# Wait for download complete notification
273
notification = self.get_download_notification()
275
# The downlod has completed, get the file path of the downloaded file
276
download_path = fs.recursive_files_in_dir(fs.DIR_HOME_CACHE_GALLERY)[0]
277
# Validates the file is the same as the original
278
actual_sha1 = fs.calculate_file_sha1(download_path)
279
self.assertEqual(img.sha1, actual_sha1)
281
# Validates the file downloaded is moved to Pictures when opened
283
downloaded_file = os.path.join(
284
fs.DIR_HOME_PICTURES_IMPORTED, img.file_name)
285
self.assertTrue(wait_until(os.path.isfile, downloaded_file))
287
# Validate the gallery-app is displaying the downloaded image
288
events_view = gallery.get_gallery_events_view()
289
self.assertTrue(events_view.is_image_displayed(img.file_name))
291
# check the displayed image matches the reference image
293
images.image_files_equal(
294
downloaded_file, REFERENCE_DOWNLOAD_IMAGE))
296
237
def _assert_find_in_page_item_not_visible_in_drawer(self):
297
238
"""Open the drawer and ensure 'Find in page' item is not visible."""
298
239
self.browser.open_drawer()
552
497
self.shell.is_indicator_item_hidden(TRANSFER_INDICATOR),
553
498
Eventually(Equals(True)))
500
def test_download_file_supported_by_currently_installed_apps(self):
502
1. Open web browser and open a url to a file, for which an associated
503
app is already installed on the device
504
2. Wait for the download prompt to appear and tap on
505
'Choose application' and select 'Media Player' on the next screen
506
3. Tap on 'Open' button in the 'Download Complete' dialog and ensure
507
the newly downloaded file starts playing in the media player
509
self.browser.go_to_url(data.urls.download3.url)
511
options = self.browser.get_download_options_dialog()
512
options.choose_application()
514
picker = self.browser.get_open_with_dialog()
515
picker.pick_media_player()
518
self.shell.is_indicator_item_hidden(TRANSFER_INDICATOR),
519
Eventually(Equals(False)))
521
# Wait for download complete notification
522
notification = self.get_download_notification()
525
player = mediaplayer.get_media_player_proxy().player
526
self.assertTrue(player.playing)
528
def test_download_image(self):
529
"""Test to download an image from internet an save it locally"""
530
img = test_data.get('ubuntu_img')
532
# check there are no files in download folder
534
len(fs.recursive_files_in_dir(fs.DIR_HOME_CACHE_GALLERY)), 0)
536
# Go to page with the picture to download
537
self.browser.go_to_url(test_data.get('page3').entered_url)
538
self.browser.wait_until_page_loaded(test_data.get('page3').actual_url)
540
# Click on the picture
541
webview = self.browser.get_current_webview()
542
self.browser.pointing_device.move_to_object(webview)
543
self.browser.pointing_device.move(self.browser.pointing_device.x,
544
self.browser.pointing_device.y / 2)
545
self.browser.pointing_device.click(press_duration=3)
547
# Select to save the image
548
save_image = self.browser.get_popover_foreground_dialog_item(
550
self.browser.pointing_device.click_object(save_image)
552
# Choose open in application option
553
options = self.browser.get_download_options_dialog()
554
options.choose_application()
556
# Pick the gallery to see the picture after it is downlaoded
557
picker = self.browser.get_open_with_dialog()
558
picker.pick_gallery()
560
# Wait for download complete notification
561
notification = self.get_download_notification()
563
# The downlod has completed, get the file path of the downloaded file
564
download_path = fs.recursive_files_in_dir(fs.DIR_HOME_CACHE_GALLERY)[0]
565
# Validates the file is the same as the original
566
actual_sha1 = fs.calculate_file_sha1(download_path)
567
self.assertEqual(img.sha1, actual_sha1)
569
# Validates the file downloaded is moved to Pictures when opened
571
downloaded_file = os.path.join(
572
fs.DIR_HOME_PICTURES_IMPORTED, img.file_name)
573
self.assertTrue(wait_until(os.path.isfile, downloaded_file))
575
# Validate the gallery-app is displaying the downloaded image
576
events_view = gallery.get_gallery_events_view()
577
self.assertTrue(events_view.is_image_displayed(img.file_name))
579
# check the displayed image matches the reference image
581
images.image_files_equal(
582
downloaded_file, REFERENCE_DOWNLOAD_IMAGE))
556
585
class DownloadsHistoryWithBrowserSystemTest(base_webbrowser.WebBrowserBase):