Index: chrome/test/functional/devtools_test_base.py |
diff --git a/chrome/test/functional/devtools_native_memory_snapshot.py b/chrome/test/functional/devtools_test_base.py |
similarity index 63% |
copy from chrome/test/functional/devtools_native_memory_snapshot.py |
copy to chrome/test/functional/devtools_test_base.py |
index d0d4ad75a6d2d5a11524a3dcaf9bb6fad78789e9..bf938d808148509f6fdb17d9df461ff932bb9d60 100755 |
--- a/chrome/test/functional/devtools_native_memory_snapshot.py |
+++ b/chrome/test/functional/devtools_test_base.py |
@@ -5,6 +5,7 @@ |
import logging |
import os |
+import tempfile |
from urlparse import urlparse |
import pyauto_functional # Must be imported before pyauto |
@@ -14,14 +15,11 @@ import remote_inspector_client |
import webpagereplay |
-class DevToolsNativeMemorySnapshotTest(pyauto.PyUITest): |
- """Test for tracking unknown share in the DevTools native memory snapshots. |
+class DevToolsTestBase(pyauto.PyUITest): |
+ """Base class for DevTools tests that use replay server. |
- This test navigates the browser to a test page, then takes native memory |
- snapshot over remote debugging protocol and prints render process private |
- memory size and unknown size extracted from the snapshot. It is used to |
- track size of the memory that is not counted by DevTools memory |
- instrumentation. |
+ This class allows to navigate the browser to a test page and take native |
+ memory snapshot over remote debugging protocol. |
The test uses Web Page Replay server as a proxy that allows to replay |
the same state of the test pages and avoid heavy network traffic on the |
@@ -58,34 +56,20 @@ class DevToolsNativeMemorySnapshotTest(pyauto.PyUITest): |
logging.info('Terminating connection to remote inspector...') |
self._remote_inspector_client.Stop() |
logging.info('Connection to remote inspector terminated.') |
- super(DevToolsNativeMemorySnapshotTest, self).tearDown() |
+ super(DevToolsTestBase, self).tearDown() |
- def testNytimes(self): |
- self._RunTestWithUrl('http://www.nytimes.com/') |
- |
- def testCnn(self): |
- self._RunTestWithUrl('http://www.cnn.com/') |
- |
- def testGoogle(self): |
- self._RunTestWithUrl('http://www.google.com/') |
- |
- def _RunTestWithUrl(self, url): |
- """Dumps native memory snapshot data for given page.""" |
+ def RunTestWithUrl(self, url): |
+ """Navigates browser to given URL and takes native memory snapshot.""" |
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() |
- total = snapshot.GetProcessPrivateMemorySize() |
- unknown = snapshot.GetUnknownSize() |
- logging.info('Got data for url: %s, total size = %d, unknown size = %d '% |
- (url, total, unknown)) |
- |
- graph_name = 'DevTools Native Snapshot - ' + hostname |
- pyauto_utils.PrintPerfResult(graph_name, 'Total', total, 'bytes') |
- pyauto_utils.PrintPerfResult(graph_name, 'Unknown', unknown, 'bytes') |
+ logging.info('Got snapshot for url: %s' % url) |
+ self.PrintTestResult(hostname, snapshot) |
+ def PrintTestResult(self, hostname, snapshot): |
+ """This method is supposed to be overriden in subclasses.""" |
+ pass |
-if __name__ == '__main__': |
- pyauto_functional.Main() |