| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 import os | 4 import os |
| 5 | 5 |
| 6 import screenshot_sync_expectations as expectations | 6 import screenshot_sync_expectations as expectations |
| 7 | 7 |
| 8 from telemetry import test | 8 from telemetry import benchmark |
| 9 from telemetry.core import util | 9 from telemetry.core import util |
| 10 from telemetry.page import page | 10 from telemetry.page import page |
| 11 from telemetry.page import page_set | 11 from telemetry.page import page_set |
| 12 from telemetry.page import page_test | 12 from telemetry.page import page_test |
| 13 # pylint: disable=W0401,W0614 | 13 # pylint: disable=W0401,W0614 |
| 14 from telemetry.page.actions.all_page_actions import * | 14 from telemetry.page.actions.all_page_actions import * |
| 15 | 15 |
| 16 data_path = os.path.join( | 16 data_path = os.path.join( |
| 17 util.GetChromiumSrcDir(), 'content', 'test', 'data', 'gpu') | 17 util.GetChromiumSrcDir(), 'content', 'test', 'data', 'gpu') |
| 18 | 18 |
| 19 @test.Disabled('mac') | 19 @benchmark.Disabled('mac') |
| 20 class _ScreenshotSyncValidator(page_test.PageTest): | 20 class _ScreenshotSyncValidator(page_test.PageTest): |
| 21 def CustomizeBrowserOptions(self, options): | 21 def CustomizeBrowserOptions(self, options): |
| 22 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') | 22 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') |
| 23 | 23 |
| 24 def ValidatePage(self, page, tab, results): | 24 def ValidatePage(self, page, tab, results): |
| 25 test_success = tab.EvaluateJavaScript('window.__testSuccess') | 25 test_success = tab.EvaluateJavaScript('window.__testSuccess') |
| 26 if not test_success: | 26 if not test_success: |
| 27 message = tab.EvaluateJavaScript('window.__testMessage') | 27 message = tab.EvaluateJavaScript('window.__testMessage') |
| 28 raise page_test.Failure(message) | 28 raise page_test.Failure(message) |
| 29 | 29 |
| 30 | 30 |
| 31 @test.Disabled('mac') | 31 @benchmark.Disabled('mac') |
| 32 class ScreenshotSyncPage(page.Page): | 32 class ScreenshotSyncPage(page.Page): |
| 33 def __init__(self, page_set, base_dir): | 33 def __init__(self, page_set, base_dir): |
| 34 super(ScreenshotSyncPage, self).__init__( | 34 super(ScreenshotSyncPage, self).__init__( |
| 35 url='file://screenshot_sync.html', | 35 url='file://screenshot_sync.html', |
| 36 page_set=page_set, | 36 page_set=page_set, |
| 37 base_dir=base_dir, | 37 base_dir=base_dir, |
| 38 name='ScreenshotSync') | 38 name='ScreenshotSync') |
| 39 self.user_agent_type = 'desktop' | 39 self.user_agent_type = 'desktop' |
| 40 | 40 |
| 41 def RunNavigateSteps(self, action_runner): | 41 def RunNavigateSteps(self, action_runner): |
| 42 action_runner.NavigateToPage(self) | 42 action_runner.NavigateToPage(self) |
| 43 action_runner.WaitForJavaScriptCondition( | 43 action_runner.WaitForJavaScriptCondition( |
| 44 'window.__testComplete', timeout_in_seconds=120) | 44 'window.__testComplete', timeout_in_seconds=120) |
| 45 | 45 |
| 46 | 46 |
| 47 @test.Disabled('mac') | 47 @benchmark.Disabled('mac') |
| 48 class ScreenshotSyncProcess(test.Test): | 48 class ScreenshotSyncProcess(benchmark.Benchmark): |
| 49 """Tests that screenhots are properly synchronized with the frame one which | 49 """Tests that screenhots are properly synchronized with the frame one which |
| 50 they were requested""" | 50 they were requested""" |
| 51 test = _ScreenshotSyncValidator | 51 test = _ScreenshotSyncValidator |
| 52 | 52 |
| 53 def CreateExpectations(self, page_set): | 53 def CreateExpectations(self, page_set): |
| 54 return expectations.ScreenshotSyncExpectations() | 54 return expectations.ScreenshotSyncExpectations() |
| 55 | 55 |
| 56 def CreatePageSet(self, options): | 56 def CreatePageSet(self, options): |
| 57 ps = page_set.PageSet(file_path=data_path, serving_dirs=['']) | 57 ps = page_set.PageSet(file_path=data_path, serving_dirs=['']) |
| 58 ps.AddPage(ScreenshotSyncPage(ps, ps.base_dir)) | 58 ps.AddPage(ScreenshotSyncPage(ps, ps.base_dir)) |
| 59 return ps | 59 return ps |
| OLD | NEW |