| 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 test |
| 9 from telemetry.core import util | 9 from telemetry.core import util |
| 10 from telemetry.page import page |
| 10 from telemetry.page import page_set | 11 from telemetry.page import page_set |
| 11 from telemetry.page import page_test | 12 from telemetry.page import page_test |
| 13 # pylint: disable=W0401,W0614 |
| 14 from telemetry.page.actions.all_page_actions import * |
| 12 | 15 |
| 13 data_path = os.path.join( | 16 data_path = os.path.join( |
| 14 util.GetChromiumSrcDir(), 'content', 'test', 'data', 'gpu') | 17 util.GetChromiumSrcDir(), 'content', 'test', 'data', 'gpu') |
| 15 | 18 |
| 16 class _ScreenshotSyncValidator(page_test.PageTest): | 19 class _ScreenshotSyncValidator(page_test.PageTest): |
| 17 def __init__(self): | 20 def __init__(self): |
| 18 super(_ScreenshotSyncValidator, self).__init__('ValidatePage') | 21 super(_ScreenshotSyncValidator, self).__init__('ValidatePage') |
| 19 | 22 |
| 20 def CustomizeBrowserOptions(self, options): | 23 def CustomizeBrowserOptions(self, options): |
| 21 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') | 24 options.AppendExtraBrowserArgs('--enable-gpu-benchmarking') |
| 22 | 25 |
| 23 def ValidatePage(self, page, tab, results): | 26 def ValidatePage(self, page, tab, results): |
| 24 test_success = tab.EvaluateJavaScript('window.__testSuccess') | 27 test_success = tab.EvaluateJavaScript('window.__testSuccess') |
| 25 if not test_success: | 28 if not test_success: |
| 26 message = tab.EvaluateJavaScript('window.__testMessage') | 29 message = tab.EvaluateJavaScript('window.__testMessage') |
| 27 raise page_test.Failure(message) | 30 raise page_test.Failure(message) |
| 28 | 31 |
| 32 |
| 33 class ScreenshotSyncPage(page.Page): |
| 34 def __init__(self, page_set, base_dir): |
| 35 super(ScreenshotSyncPage, self).__init__( |
| 36 url='file://screenshot_sync.html', |
| 37 page_set=page_set, |
| 38 base_dir=base_dir) |
| 39 self.name = 'ScreenshotSync' |
| 40 self.user_agent_type = 'desktop' |
| 41 |
| 42 def RunNavigateSteps(self, action_runner): |
| 43 action_runner.RunAction(NavigateAction()) |
| 44 action_runner.RunAction(WaitAction({ |
| 45 'javascript': 'window.__testComplete', |
| 46 'timeout': 120})) |
| 47 |
| 48 |
| 29 class ScreenshotSyncProcess(test.Test): | 49 class ScreenshotSyncProcess(test.Test): |
| 30 """Tests that screenhots are properly synchronized with the frame one which | 50 """Tests that screenhots are properly synchronized with the frame one which |
| 31 they were requested""" | 51 they were requested""" |
| 32 test = _ScreenshotSyncValidator | 52 test = _ScreenshotSyncValidator |
| 33 | 53 |
| 34 def CreateExpectations(self, page_set): | 54 def CreateExpectations(self, page_set): |
| 35 return expectations.ScreenshotSyncExpectations() | 55 return expectations.ScreenshotSyncExpectations() |
| 36 | 56 |
| 37 def CreatePageSet(self, options): | 57 def CreatePageSet(self, options): |
| 38 page_set_dict = { | 58 ps = page_set.PageSet( |
| 39 'description': 'Test cases for screenshot synchronization', | 59 file_path=data_path, |
| 40 'user_agent_type': 'desktop', | 60 description='Test cases for screenshot synchronization', |
| 41 'serving_dirs': [''], | 61 serving_dirs=['']) |
| 42 'pages': [ | 62 ps.AddPage(ScreenshotSyncPage(ps, ps.base_dir)) |
| 43 { | 63 return ps |
| 44 'name': 'ScreenshotSync', | |
| 45 'url': 'file://screenshot_sync.html', | |
| 46 'navigate_steps': [ | |
| 47 { 'action': 'navigate' }, | |
| 48 { 'action': 'wait', | |
| 49 'javascript': 'window.__testComplete', | |
| 50 'timeout': 120 } | |
| 51 ] | |
| 52 } | |
| 53 ] | |
| 54 } | |
| 55 return page_set.PageSet.FromDict(page_set_dict, data_path) | |
| OLD | NEW |