Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 tempfile | 8 import tempfile |
| 9 from urlparse import urlparse | 9 from urlparse import urlparse |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 real web sites. See webpagereplay.ReplayServer documentation to learn how | 26 real web sites. See webpagereplay.ReplayServer documentation to learn how |
| 27 to record new page archives. | 27 to record new page archives. |
| 28 """ | 28 """ |
| 29 | 29 |
| 30 # DevTools test pages live in src/data/devtools rather than | 30 # DevTools test pages live in src/data/devtools rather than |
| 31 # src/chrome/test/data | 31 # src/chrome/test/data |
| 32 DATA_PATH = os.path.abspath( | 32 DATA_PATH = os.path.abspath( |
| 33 os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, | 33 os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, |
| 34 'data', 'devtools_test_pages')) | 34 'data', 'devtools_test_pages')) |
| 35 | 35 |
| 36 WEBPAGEREPLAY_HOST = '127.0.0.1' | |
| 37 WEBPAGEREPLAY_HTTP_PORT = 8080 | |
| 38 WEBPAGEREPLAY_HTTPS_PORT = 8413 | |
| 39 | |
| 36 def ExtraChromeFlags(self): | 40 def ExtraChromeFlags(self): |
| 37 """Ensures Chrome is launched with custom flags. | 41 """Ensures Chrome is launched with custom flags. |
| 38 | 42 |
| 39 Returns: | 43 Returns: |
| 40 A list of extra flags to pass to Chrome when it is launched. | 44 A list of extra flags to pass to Chrome when it is launched. |
| 41 """ | 45 """ |
| 42 # Ensure Chrome enables remote debugging on port 9222. This is required to | 46 # Ensure Chrome enables remote debugging on port 9222. This is required to |
| 43 # interact with Chrome's remote inspector. | 47 # interact with Chrome's remote inspector. |
| 44 extra_flags = ['--remote-debugging-port=9222'] + webpagereplay.CHROME_FLAGS | 48 extra_flags = ['--remote-debugging-port=9222'] + \ |
| 49 webpagereplay.GetChromeFlags(self.WEBPAGEREPLAY_HOST, | |
|
tonyg
2013/01/03 19:00:12
Please indent this
hartmanng
2013/01/03 19:08:51
Done.
| |
| 50 self.WEBPAGEREPLAY_HTTP_PORT, | |
| 51 self.WEBPAGEREPLAY_HTTPS_PORT) | |
| 45 return (pyauto.PyUITest.ExtraChromeFlags(self) + extra_flags) | 52 return (pyauto.PyUITest.ExtraChromeFlags(self) + extra_flags) |
| 46 | 53 |
| 47 def setUp(self): | 54 def setUp(self): |
| 48 pyauto.PyUITest.setUp(self) | 55 pyauto.PyUITest.setUp(self) |
| 49 # Set up a remote inspector client associated with tab 0. | 56 # Set up a remote inspector client associated with tab 0. |
| 50 logging.info('Setting up connection to remote inspector...') | 57 logging.info('Setting up connection to remote inspector...') |
| 51 self._remote_inspector_client = ( | 58 self._remote_inspector_client = ( |
| 52 remote_inspector_client.RemoteInspectorClient()) | 59 remote_inspector_client.RemoteInspectorClient()) |
| 53 logging.info('Connection to remote inspector set up successfully.') | 60 logging.info('Connection to remote inspector set up successfully.') |
| 54 | 61 |
| 55 def tearDown(self): | 62 def tearDown(self): |
| 56 logging.info('Terminating connection to remote inspector...') | 63 logging.info('Terminating connection to remote inspector...') |
| 57 self._remote_inspector_client.Stop() | 64 self._remote_inspector_client.Stop() |
| 58 logging.info('Connection to remote inspector terminated.') | 65 logging.info('Connection to remote inspector terminated.') |
| 59 super(DevToolsTestBase, self).tearDown() | 66 super(DevToolsTestBase, self).tearDown() |
| 60 | 67 |
| 61 def RunTestWithUrl(self, url): | 68 def RunTestWithUrl(self, url): |
| 62 """Navigates browser to given URL and takes native memory snapshot.""" | 69 """Navigates browser to given URL and takes native memory snapshot.""" |
| 63 replay_options = None | 70 replay_options = None |
| 64 hostname = urlparse(url).hostname | 71 hostname = urlparse(url).hostname |
| 65 archive_path = os.path.join(self.DATA_PATH, hostname + '.wpr') | 72 archive_path = os.path.join(self.DATA_PATH, hostname + '.wpr') |
| 66 with webpagereplay.ReplayServer(archive_path, replay_options): | 73 with webpagereplay.ReplayServer(archive_path, |
| 74 self.WEBPAGEREPLAY_HOST, | |
| 75 self.WEBPAGEREPLAY_HTTP_PORT, | |
| 76 self.WEBPAGEREPLAY_HTTPS_PORT, | |
| 77 replay_options): | |
| 67 self.NavigateToURL(url) | 78 self.NavigateToURL(url) |
| 68 snapshot = self._remote_inspector_client.GetProcessMemoryDistribution() | 79 snapshot = self._remote_inspector_client.GetProcessMemoryDistribution() |
| 69 logging.info('Got snapshot for url: %s' % url) | 80 logging.info('Got snapshot for url: %s' % url) |
| 70 self.PrintTestResult(hostname, snapshot) | 81 self.PrintTestResult(hostname, snapshot) |
| 71 | 82 |
| 72 def PrintTestResult(self, hostname, snapshot): | 83 def PrintTestResult(self, hostname, snapshot): |
| 73 """This method is supposed to be overriden in subclasses.""" | 84 """This method is supposed to be overriden in subclasses.""" |
| 74 pass | 85 pass |
| 75 | 86 |
| OLD | NEW |