| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env 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 | 6 |
| 7 """ | 7 """ |
| 8 Stess Tests for Google Chrome. | 8 Stess Tests for Google Chrome. |
| 9 | 9 |
| 10 This script runs 4 different stress tests: | 10 This script runs 4 different stress tests: |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 for process in self.GetBrowserInfo()['child_processes']: | 152 for process in self.GetBrowserInfo()['child_processes']: |
| 153 if process['type'] == 'Plug-in' and \ | 153 if process['type'] == 'Plug-in' and \ |
| 154 re.search(plugin_name, process['name']): | 154 re.search(plugin_name, process['name']): |
| 155 return process['pid'] | 155 return process['pid'] |
| 156 return None | 156 return None |
| 157 | 157 |
| 158 def _CloseAllTabs(self): | 158 def _CloseAllTabs(self): |
| 159 """Close all but one tab in first window.""" | 159 """Close all but one tab in first window.""" |
| 160 tab_count = self.GetTabCount(0) | 160 tab_count = self.GetTabCount(0) |
| 161 for tab_index in xrange(tab_count - 1, 0, -1): | 161 for tab_index in xrange(tab_count - 1, 0, -1): |
| 162 self.GetBrowserWindow(0).GetTab(tab_index).Close(True) | 162 self.CloseTab(tab_index) |
| 163 | 163 |
| 164 def _CloseAllWindows(self): | 164 def _CloseAllWindows(self): |
| 165 """Close all windows except one.""" | 165 """Close all windows except one.""" |
| 166 win_count = self.GetBrowserWindowCount() | 166 win_count = self.GetBrowserWindowCount() |
| 167 for windex in xrange(win_count - 1, 0, -1): | 167 for windex in xrange(win_count - 1, 0, -1): |
| 168 self.RunCommand(pyauto.IDC_CLOSE_WINDOW, windex) | 168 self.RunCommand(pyauto.IDC_CLOSE_WINDOW, windex) |
| 169 | 169 |
| 170 def _ReloadAllTabs(self): | 170 def _ReloadAllTabs(self): |
| 171 """Reload all the tabs in first window.""" | 171 """Reload all the tabs in first window.""" |
| 172 for tab_index in range(self.GetTabCount()): | 172 for tab_index in range(self.GetTabCount()): |
| 173 self.GetBrowserWindow(0).GetTab(tab_index).Reload() | 173 self.ReloadTab(tab_index) |
| 174 | 174 |
| 175 def _LoadFlashInMultipleTabs(self): | 175 def _LoadFlashInMultipleTabs(self): |
| 176 """Load Flash in multiple tabs in first window.""" | 176 """Load Flash in multiple tabs in first window.""" |
| 177 self.NavigateToURL(self.empty_url) | 177 self.NavigateToURL(self.empty_url) |
| 178 # Open 18 tabs with flash | 178 # Open 18 tabs with flash |
| 179 for _ in range(9): | 179 for _ in range(9): |
| 180 self.AppendTab(pyauto.GURL(self.flash_url1)) | 180 self.AppendTab(pyauto.GURL(self.flash_url1)) |
| 181 self.AppendTab(pyauto.GURL(self.flash_url2)) | 181 self.AppendTab(pyauto.GURL(self.flash_url2)) |
| 182 | 182 |
| 183 def _OpenAndCloseMultipleTabsWithFlash(self): | 183 def _OpenAndCloseMultipleTabsWithFlash(self): |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 334 |
| 335 def _BrowserGoBack(self, window_index): | 335 def _BrowserGoBack(self, window_index): |
| 336 """Go back in the browser history. | 336 """Go back in the browser history. |
| 337 | 337 |
| 338 Chrome has limitation on going back and can only go back 49 pages. | 338 Chrome has limitation on going back and can only go back 49 pages. |
| 339 | 339 |
| 340 Args: | 340 Args: |
| 341 window_index: the index of the browser window to work on. | 341 window_index: the index of the browser window to work on. |
| 342 """ | 342 """ |
| 343 for nback in range(48): # Go back 48 times. | 343 for nback in range(48): # Go back 48 times. |
| 344 tab = self.GetBrowserWindow(window_index).GetTab(0) | |
| 345 if nback % 4 == 0: # Bookmark every 5th url when going back. | 344 if nback % 4 == 0: # Bookmark every 5th url when going back. |
| 346 self._BookMarkEvery5thURL(window_index) | 345 self._BookMarkEvery5thURL(window_index) |
| 347 tab.GoBack() | 346 self.TabGoBack(tab_index=0, windex=window_index) |
| 348 | 347 |
| 349 def _BrowserGoForward(self, window_index): | 348 def _BrowserGoForward(self, window_index): |
| 350 """Go Forward in the browser history. | 349 """Go Forward in the browser history. |
| 351 | 350 |
| 352 Chrome has limitation on going back and can only go back 49 pages. | 351 Chrome has limitation on going back and can only go back 49 pages. |
| 353 | 352 |
| 354 Args: | 353 Args: |
| 355 window_index: the index of the browser window to work on. | 354 window_index: the index of the browser window to work on. |
| 356 """ | 355 """ |
| 357 for nforward in range(48): # Go back 48 times. | 356 for nforward in range(48): # Go back 48 times. |
| 358 tab = self.GetBrowserWindow(window_index).GetTab(0) | |
| 359 if nforward % 4 == 0: # Bookmark every 5th url when going Forward | 357 if nforward % 4 == 0: # Bookmark every 5th url when going Forward |
| 360 self._BookMarkEvery5thURL(window_index) | 358 self._BookMarkEvery5thURL(window_index) |
| 361 tab.GoForward() | 359 self.TabGoForward(tab_index=0, windex=window_index) |
| 362 | 360 |
| 363 def _AddToListAndBookmark(self, newname, url): | 361 def _AddToListAndBookmark(self, newname, url): |
| 364 """Bookmark the url to bookmarkbar and to he list of bookmarks. | 362 """Bookmark the url to bookmarkbar and to he list of bookmarks. |
| 365 | 363 |
| 366 Args: | 364 Args: |
| 367 newname: the name of the bookmark. | 365 newname: the name of the bookmark. |
| 368 url: the url to bookmark. | 366 url: the url to bookmark. |
| 369 """ | 367 """ |
| 370 bookmarks = self.GetBookmarkModel() | 368 bookmarks = self.GetBookmarkModel() |
| 371 bar_id = bookmarks.BookmarkBar()['id'] | 369 bar_id = bookmarks.BookmarkBar()['id'] |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 | 797 |
| 800 if self.IsMac(): | 798 if self.IsMac(): |
| 801 zombie = 'ps -el | grep Chrom | grep -v grep | grep Z | wc -l' | 799 zombie = 'ps -el | grep Chrom | grep -v grep | grep Z | wc -l' |
| 802 zombie_count = int(commands.getoutput(zombie)) | 800 zombie_count = int(commands.getoutput(zombie)) |
| 803 if zombie_count > 0: | 801 if zombie_count > 0: |
| 804 logging.info('WE HAVE ZOMBIES = %d' % zombie_count) | 802 logging.info('WE HAVE ZOMBIES = %d' % zombie_count) |
| 805 | 803 |
| 806 | 804 |
| 807 if __name__ == '__main__': | 805 if __name__ == '__main__': |
| 808 pyauto_functional.Main() | 806 pyauto_functional.Main() |
| OLD | NEW |