| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 import re | 8 import re |
| 9 | 9 |
| 10 import pyauto_functional # Must be imported before pyauto | 10 import pyauto_functional # Must be imported before pyauto |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 def testMultipleDownloadsInfobar(self): | 122 def testMultipleDownloadsInfobar(self): |
| 123 """Verify the mutiple downloads infobar.""" | 123 """Verify the mutiple downloads infobar.""" |
| 124 zip_file = 'a_zip_file.zip' | 124 zip_file = 'a_zip_file.zip' |
| 125 html_file = 'download-a_zip_file.html' | 125 html_file = 'download-a_zip_file.html' |
| 126 assert pyauto.PyUITest.IsEnUS() | 126 assert pyauto.PyUITest.IsEnUS() |
| 127 file_url = self.GetFileURLForDataPath('downloads', html_file) | 127 file_url = self.GetFileURLForDataPath('downloads', html_file) |
| 128 match_text = 'This site is attempting to download multiple files. ' \ | 128 match_text = 'This site is attempting to download multiple files. ' \ |
| 129 'Do you want to allow this?' | 129 'Do you want to allow this?' |
| 130 self.NavigateToURL('chrome://downloads') # trigger download manager | 130 self.NavigateToURL('chrome://downloads') # trigger download manager |
| 131 test_utils.RemoveDownloadedTestFile(self, zip_file) | 131 test_utils.RemoveDownloadedTestFile(self, zip_file) |
| 132 pre_download_ids = [x['id'] for x in self.GetDownloadsInfo().Downloads()] |
| 132 self.DownloadAndWaitForStart(file_url) | 133 self.DownloadAndWaitForStart(file_url) |
| 133 # trigger page reload, which triggers the download infobar | 134 # trigger page reload, which triggers the download infobar |
| 134 self.GetBrowserWindow(0).GetTab(0).Reload() | 135 self.GetBrowserWindow(0).GetTab(0).Reload() |
| 135 self.assertTrue(self.WaitForInfobarCount(1)) | 136 self.assertTrue(self.WaitForInfobarCount(1)) |
| 136 tab_info = self._GetTabInfo(0, 0) | 137 tab_info = self._GetTabInfo(0, 0) |
| 137 infobars = tab_info['infobars'] | 138 infobars = tab_info['infobars'] |
| 138 self.assertTrue(infobars, 'Expected the multiple downloads infobar') | 139 self.assertTrue(infobars, 'Expected the multiple downloads infobar') |
| 139 self.assertEqual(1, len(infobars)) | 140 self.assertEqual(1, len(infobars)) |
| 140 self.assertEqual(match_text, infobars[0]['text']) | 141 self.assertEqual(match_text, infobars[0]['text']) |
| 141 self.assertEqual(2, len(infobars[0]['buttons'])) | 142 self.assertEqual(2, len(infobars[0]['buttons'])) |
| 142 self.assertEqual('Allow', infobars[0]['buttons'][0]) | 143 self.assertEqual('Allow', infobars[0]['buttons'][0]) |
| 143 self.assertEqual('Deny', infobars[0]['buttons'][1]) | 144 self.assertEqual('Deny', infobars[0]['buttons'][1]) |
| 144 self.WaitForAllDownloadsToComplete() | 145 self.WaitForAllDownloadsToComplete(pre_download_ids) |
| 145 test_utils.RemoveDownloadedTestFile(self, zip_file) | 146 test_utils.RemoveDownloadedTestFile(self, zip_file) |
| 146 | 147 |
| 147 def testPluginCrashForMultiTabs(self): | 148 def testPluginCrashForMultiTabs(self): |
| 148 """Verify plugin crash infobar shows up only on the tabs using plugin.""" | 149 """Verify plugin crash infobar shows up only on the tabs using plugin.""" |
| 149 non_flash_url = self.GetFileURLForDataPath('english_page.html') | 150 non_flash_url = self.GetFileURLForDataPath('english_page.html') |
| 150 flash_url = self.GetFileURLForDataPath('plugin', 'FlashSpin.swf') | 151 flash_url = self.GetFileURLForDataPath('plugin', 'FlashSpin.swf') |
| 151 # False = Non flash url, True = Flash url | 152 # False = Non flash url, True = Flash url |
| 152 # We have set of these values to compare a flash page and a non-flash page | 153 # We have set of these values to compare a flash page and a non-flash page |
| 153 urls_type = [False, True, False, True, False] | 154 urls_type = [False, True, False, True, False] |
| 154 for count in range(2): | 155 for count in range(2): |
| (...skipping 22 matching lines...) Expand all Loading... |
| 177 self.assertTrue( | 178 self.assertTrue( |
| 178 self.WaitForInfobarCount(1, windex=0, tab_index=i), | 179 self.WaitForInfobarCount(1, windex=0, tab_index=i), |
| 179 msg='Expected crash infobar in tab at index %d' % i) | 180 msg='Expected crash infobar in tab at index %d' % i) |
| 180 infobar = self.GetBrowserInfo()['windows'][0]['tabs'][i]['infobars'] | 181 infobar = self.GetBrowserInfo()['windows'][0]['tabs'][i]['infobars'] |
| 181 self.assertEqual(infobar[0]['type'], 'confirm_infobar') | 182 self.assertEqual(infobar[0]['type'], 'confirm_infobar') |
| 182 self.assertEqual(len(infobar), 1) | 183 self.assertEqual(len(infobar), 1) |
| 183 | 184 |
| 184 | 185 |
| 185 if __name__ == '__main__': | 186 if __name__ == '__main__': |
| 186 pyauto_functional.Main() | 187 pyauto_functional.Main() |
| OLD | NEW |