Index: chrome/test/functional/devtools_native_memory_snapshot.py |
diff --git a/chrome/test/functional/devtools_native_memory_snapshot.py b/chrome/test/functional/devtools_native_memory_snapshot.py |
index d0d4ad75a6d2d5a11524a3dcaf9bb6fad78789e9..2489f6cb24cc13a7772c70fae19612d7de95c353 100755 |
--- a/chrome/test/functional/devtools_native_memory_snapshot.py |
+++ b/chrome/test/functional/devtools_native_memory_snapshot.py |
@@ -4,17 +4,14 @@ |
# found in the LICENSE file. |
import logging |
-import os |
-from urlparse import urlparse |
+import devtools_test_base |
import pyauto_functional # Must be imported before pyauto |
import pyauto |
import pyauto_utils |
-import remote_inspector_client |
-import webpagereplay |
-class DevToolsNativeMemorySnapshotTest(pyauto.PyUITest): |
+class DevToolsNativeMemorySnapshotTest(devtools_test_base.DevToolsTestBase): |
"""Test for tracking unknown share in the DevTools native memory snapshots. |
This test navigates the browser to a test page, then takes native memory |
@@ -28,60 +25,20 @@ class DevToolsNativeMemorySnapshotTest(pyauto.PyUITest): |
real web sites. See webpagereplay.ReplayServer documentation to learn how |
to record new page archives. |
""" |
- |
- # DevTools test pages live in src/data/devtools rather than |
- # src/chrome/test/data |
- DATA_PATH = os.path.abspath( |
- os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, |
- 'data', 'devtools_test_pages')) |
- |
- def ExtraChromeFlags(self): |
- """Ensures Chrome is launched with custom flags. |
- |
- Returns: |
- A list of extra flags to pass to Chrome when it is launched. |
- """ |
- # Ensure Chrome enables remote debugging on port 9222. This is required to |
- # interact with Chrome's remote inspector. |
- extra_flags = ['--remote-debugging-port=9222'] + webpagereplay.CHROME_FLAGS |
- return (pyauto.PyUITest.ExtraChromeFlags(self) + extra_flags) |
- |
- def setUp(self): |
- pyauto.PyUITest.setUp(self) |
- # Set up a remote inspector client associated with tab 0. |
- logging.info('Setting up connection to remote inspector...') |
- self._remote_inspector_client = ( |
- remote_inspector_client.RemoteInspectorClient()) |
- logging.info('Connection to remote inspector set up successfully.') |
- |
- def tearDown(self): |
- logging.info('Terminating connection to remote inspector...') |
- self._remote_inspector_client.Stop() |
- logging.info('Connection to remote inspector terminated.') |
- super(DevToolsNativeMemorySnapshotTest, self).tearDown() |
- |
def testNytimes(self): |
- self._RunTestWithUrl('http://www.nytimes.com/') |
+ self.RunTestWithUrl('http://www.nytimes.com/') |
def testCnn(self): |
- self._RunTestWithUrl('http://www.cnn.com/') |
+ self.RunTestWithUrl('http://www.cnn.com/') |
def testGoogle(self): |
- self._RunTestWithUrl('http://www.google.com/') |
+ self.RunTestWithUrl('http://www.google.com/') |
- def _RunTestWithUrl(self, url): |
- """Dumps native memory snapshot data for given page.""" |
- replay_options = None |
- hostname = urlparse(url).hostname |
- archive_path = os.path.join(self.DATA_PATH, hostname + '.wpr') |
- with webpagereplay.ReplayServer(archive_path, replay_options): |
- self.NavigateToURL(url) |
- snapshot = self._remote_inspector_client.GetProcessMemoryDistribution() |
+ def PrintTestResult(self, hostname, snapshot): |
total = snapshot.GetProcessPrivateMemorySize() |
unknown = snapshot.GetUnknownSize() |
- logging.info('Got data for url: %s, total size = %d, unknown size = %d '% |
- (url, total, unknown)) |
- |
+ logging.info('Got data for: %s, total size = %d, unknown size = %d' % |
+ (hostname, total, unknown)) |
graph_name = 'DevTools Native Snapshot - ' + hostname |
pyauto_utils.PrintPerfResult(graph_name, 'Total', total, 'bytes') |
pyauto_utils.PrintPerfResult(graph_name, 'Unknown', unknown, 'bytes') |