Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / test / functional / perf.py
index a65a792..0bc8f44 100755 (executable)
@@ -51,7 +51,6 @@ import simplejson  # Must be imported after pyauto; located in third_party.
 from netflix import NetflixTestHelper
 import pyauto_utils
 import test_utils
-import webpagereplay
 from youtube import YoutubeTestHelper
 
 
@@ -1720,210 +1719,6 @@ class FileUploadDownloadTest(BasePerfTest):
                               'upload_file')
 
 
-class ScrollResults(object):
-  """Container for ScrollTest results."""
-
-  def __init__(self, first_paint_seconds, results_list):
-    assert len(results_list) == 2, 'Expecting initial and repeat results.'
-    self._first_paint_time = 1000.0 * first_paint_seconds
-    self._results_list = results_list
-
-  def GetFirstPaintTime(self):
-    return self._first_paint_time
-
-  def GetFrameCount(self, index):
-    results = self._results_list[index]
-    return results.get('numFramesSentToScreen', results['numAnimationFrames'])
-
-  def GetFps(self, index):
-    return (self.GetFrameCount(index) /
-            self._results_list[index]['totalTimeInSeconds'])
-
-  def GetMeanFrameTime(self, index):
-    return (self._results_list[index]['totalTimeInSeconds'] /
-            self.GetFrameCount(index))
-
-  def GetPercentBelow60Fps(self, index):
-    return (float(self._results_list[index]['droppedFrameCount']) /
-            self.GetFrameCount(index))
-
-
-class BaseScrollTest(BasePerfTest):
-  """Base class for tests measuring scrolling performance."""
-
-  def setUp(self):
-    """Performs necessary setup work before running each test."""
-    super(BaseScrollTest, self).setUp()
-    scroll_file = os.path.join(self.DataDir(), 'scroll', 'scroll.js')
-    with open(scroll_file) as f:
-      self._scroll_text = f.read()
-
-  def ExtraChromeFlags(self):
-    """Ensures Chrome is launched with custom flags.
-
-    Returns:
-      A list of extra flags to pass to Chrome when it is launched.
-    """
-    # Extra flag used by scroll performance tests.
-    return (super(BaseScrollTest, self).ExtraChromeFlags() +
-            ['--enable-gpu-benchmarking'])
-
-  def RunSingleInvocation(self, url, is_gmail_test=False):
-    """Runs a single invocation of the scroll test.
-
-    Args:
-      url: The string url for the webpage on which to run the scroll test.
-      is_gmail_test: True iff the test is a GMail test.
-
-    Returns:
-      Instance of ScrollResults.
-    """
-
-    self.assertTrue(self.AppendTab(pyauto.GURL(url)),
-                    msg='Failed to append tab for webpage.')
-
-    timeout = pyauto.PyUITest.ActionTimeoutChanger(self, 300 * 1000)  # ms
-    test_js = """%s;
-        new __ScrollTest(function(results) {
-          var stringify = JSON.stringify || JSON.encode;
-          window.domAutomationController.send(stringify(results));
-        }, %s);
-    """ % (self._scroll_text, 'true' if is_gmail_test else 'false')
-    results = simplejson.loads(self.ExecuteJavascript(test_js, tab_index=1))
-
-    first_paint_js = ('window.domAutomationController.send('
-                      '(chrome.loadTimes().firstPaintTime - '
-                      'chrome.loadTimes().requestTime).toString());')
-    first_paint_time = float(self.ExecuteJavascript(first_paint_js,
-                                                    tab_index=1))
-
-    self.CloseTab(tab_index=1)
-
-    return ScrollResults(first_paint_time, results)
-
-  def RunScrollTest(self, url, description, graph_name, is_gmail_test=False):
-    """Runs a scroll performance test on the specified webpage.
-
-    Args:
-      url: The string url for the webpage on which to run the scroll test.
-      description: A string description for the particular test being run.
-      graph_name: A string name for the performance graph associated with this
-          test.  Only used on Chrome desktop.
-      is_gmail_test: True iff the test is a GMail test.
-    """
-    results = []
-    for iteration in range(self._num_iterations + 1):
-      result = self.RunSingleInvocation(url, is_gmail_test)
-      # Ignore the first iteration.
-      if iteration:
-        fps = result.GetFps(1)
-        assert fps, '%s did not scroll' % url
-        logging.info('Iteration %d of %d: %f fps', iteration,
-                     self._num_iterations, fps)
-        results.append(result)
-    self._PrintSummaryResults(
-        description, [r.GetFps(1) for r in results],
-        'FPS', graph_name)
-
-
-class PopularSitesScrollTest(BaseScrollTest):
-  """Measures scrolling performance on recorded versions of popular sites."""
-
-  def ExtraChromeFlags(self):
-    """Ensures Chrome is launched with custom flags.
-
-    Returns:
-      A list of extra flags to pass to Chrome when it is launched.
-    """
-    return super(PopularSitesScrollTest,
-                 self).ExtraChromeFlags() + PageCyclerReplay.CHROME_FLAGS
-
-  def _GetUrlList(self, test_name):
-    """Returns list of recorded sites."""
-    sites_path = PageCyclerReplay.Path('page_sets', test_name=test_name)
-    with open(sites_path) as f:
-      sites_text = f.read()
-    js = """
-      %s
-      window.domAutomationController.send(JSON.stringify(pageSets));
-    """ % sites_text
-    page_sets = eval(self.ExecuteJavascript(js))
-    return list(itertools.chain(*page_sets))[1:]  # Skip first.
-
-  def _PrintScrollResults(self, results):
-    self._PrintSummaryResults(
-        'initial', [r.GetMeanFrameTime(0) for r in results],
-        'ms', 'FrameTimes')
-    self._PrintSummaryResults(
-        'repeat', [r.GetMeanFrameTime(1) for r in results],
-        'ms', 'FrameTimes')
-    self._PrintSummaryResults(
-        'initial',
-        [r.GetPercentBelow60Fps(0) for r in results],
-        'percent', 'PercentBelow60FPS')
-    self._PrintSummaryResults(
-        'repeat',
-        [r.GetPercentBelow60Fps(1) for r in results],
-        'percent', 'PercentBelow60FPS')
-    self._PrintSummaryResults(
-        'first_paint_time', [r.GetFirstPaintTime() for r in results],
-        'ms', 'FirstPaintTime')
-
-  def test2012Q3(self):
-    test_name = '2012Q3'
-    urls = self._GetUrlList(test_name)
-    results = []
-    with PageCyclerReplay.ReplayServer(test_name) as replay_server:
-      if replay_server.is_record_mode:
-        self._num_iterations = 1
-      for iteration in range(self._num_iterations):
-        for url in urls:
-          result = self.RunSingleInvocation(url)
-          fps = result.GetFps(0)
-          assert fps, '%s did not scroll' % url
-          logging.info('Iteration %d of %d: %f fps', iteration + 1,
-                       self._num_iterations, fps)
-          results.append(result)
-    self._PrintScrollResults(results)
-
-
-class ScrollTest(BaseScrollTest):
-  """Tests to measure scrolling performance."""
-
-  def ExtraChromeFlags(self):
-    """Ensures Chrome is launched with custom flags.
-
-    Returns:
-      A list of extra flags to pass to Chrome when it is launched.
-    """
-    # Extra flag needed by scroll performance tests.
-    return super(ScrollTest, self).ExtraChromeFlags() + ['--disable-gpu-vsync']
-
-  def testBlankPageScroll(self):
-    """Runs the scroll test on a blank page."""
-    self.RunScrollTest(
-        self.GetFileURLForDataPath('scroll', 'blank.html'), 'ScrollBlankPage',
-        'scroll_fps')
-
-  def testTextScroll(self):
-    """Runs the scroll test on a text-filled page."""
-    self.RunScrollTest(
-        self.GetFileURLForDataPath('scroll', 'text.html'), 'ScrollTextPage',
-        'scroll_fps')
-
-  def testGooglePlusScroll(self):
-    """Runs the scroll test on a Google Plus anonymized page."""
-    self.RunScrollTest(
-        self.GetFileURLForDataPath('scroll', 'plus.html'),
-        'ScrollGooglePlusPage', 'scroll_fps')
-
-  def testGmailScroll(self):
-    """Runs the scroll test using the live Gmail site."""
-    self._LoginToGoogleAccount(account_key='test_google_account_gmail')
-    self.RunScrollTest('http://www.gmail.com', 'ScrollGmail',
-                       'scroll_fps', True)
-
-
 class FlashTest(BasePerfTest):
   """Tests to measure flash performance."""
 
@@ -2289,97 +2084,6 @@ class PageCyclerTest(BasePageCyclerTest):
     self.RunPageCyclerTest('moz2', 'Moz2File')
 
 
-class PageCyclerReplay(object):
-  """Run page cycler tests with network simulation via Web Page Replay.
-
-  Web Page Replay is a proxy that can record and "replay" web pages with
-  simulated network characteristics -- without having to edit the pages
-  by hand. With WPR, tests can use "real" web content, and catch
-  performance issues that may result from introducing network delays and
-  bandwidth throttling.
-  """
-  _PATHS = {
-      'archive':    'src/data/page_cycler/webpagereplay/{test_name}.wpr',
-      'page_sets':  'src/tools/page_cycler/webpagereplay/tests/{test_name}.js',
-      'start_page': 'src/tools/page_cycler/webpagereplay/start.html',
-      'extension':  'src/tools/page_cycler/webpagereplay/extension',
-      }
-
-  WEBPAGEREPLAY_HOST = '127.0.0.1'
-  WEBPAGEREPLAY_HTTP_PORT = 8080
-  WEBPAGEREPLAY_HTTPS_PORT = 8413
-
-  CHROME_FLAGS = webpagereplay.GetChromeFlags(
-      WEBPAGEREPLAY_HOST,
-      WEBPAGEREPLAY_HTTP_PORT,
-      WEBPAGEREPLAY_HTTPS_PORT) + [
-          '--log-level=0',
-          '--disable-background-networking',
-          '--enable-experimental-extension-apis',
-          '--enable-logging',
-          '--enable-benchmarking',
-          '--enable-net-benchmarking',
-          '--metrics-recording-only',
-          '--activate-on-launch',
-          '--no-first-run',
-          '--no-proxy-server',
-          ]
-
-  @classmethod
-  def Path(cls, key, **kwargs):
-    return FormatChromePath(cls._PATHS[key], **kwargs)
-
-  @classmethod
-  def ReplayServer(cls, test_name, replay_options=None):
-    archive_path = cls.Path('archive', test_name=test_name)
-    return webpagereplay.ReplayServer(archive_path,
-                                      cls.WEBPAGEREPLAY_HOST,
-                                      cls.WEBPAGEREPLAY_HTTP_PORT,
-                                      cls.WEBPAGEREPLAY_HTTPS_PORT,
-                                      replay_options)
-
-
-class PageCyclerNetSimTest(BasePageCyclerTest):
-  """Tests to run Web Page Replay backed page cycler tests."""
-  MAX_ITERATION_SECONDS = 180
-
-  def ExtraChromeFlags(self):
-    """Ensures Chrome is launched with custom flags.
-
-    Returns:
-      A list of extra flags to pass to Chrome when it is launched.
-    """
-    flags = super(PageCyclerNetSimTest, self).ExtraChromeFlags()
-    flags.append('--load-extension=%s' % PageCyclerReplay.Path('extension'))
-    flags.extend(PageCyclerReplay.CHROME_FLAGS)
-    return flags
-
-  def StartUrl(self, test_name, iterations):
-    start_path = PageCyclerReplay.Path('start_page')
-    start_url = 'file://%s?test=%s&iterations=%d' % (
-        start_path, test_name, iterations)
-    if self.use_auto:
-      start_url += '&auto=1'
-    return start_url
-
-  def RunPageCyclerTest(self, test_name, description):
-    """Runs the specified PageCycler test.
-
-    Args:
-      test_name: name for archive (.wpr) and config (.js) files.
-      description: a string description for the test
-    """
-    replay_options = None
-    with PageCyclerReplay.ReplayServer(test_name, replay_options) as server:
-      if server.is_record_mode:
-        self._num_iterations = 1
-      super_self = super(PageCyclerNetSimTest, self)
-      super_self.RunPageCyclerTest(test_name, description)
-
-  def test2012Q2(self):
-    self.RunPageCyclerTest('2012Q2', '2012Q2')
-
-
 class MemoryTest(BasePerfTest):
   """Tests to measure memory consumption under different usage scenarios."""