Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: content/test/gpu/gpu_tests/trace_integration_test.py

Issue 2604153005: Port trace_test to the new gpu_integration_test harness. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/test/gpu/generate_buildbot_json.py ('k') | content/test/gpu/gpu_tests/trace_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2016 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 from gpu_tests import gpu_test_base 4
5 import os
6
7 from gpu_tests import gpu_integration_test
8 from gpu_tests import path_util
9 from gpu_tests import pixel_test_pages
5 from gpu_tests import trace_test_expectations 10 from gpu_tests import trace_test_expectations
6 import page_sets
7 11
8 from telemetry.page import legacy_page_test
9 from telemetry.timeline import model as model_module 12 from telemetry.timeline import model as model_module
10 from telemetry.timeline import tracing_config 13 from telemetry.timeline import tracing_config
11 14
12 TOPLEVEL_GL_CATEGORY = 'gpu_toplevel' 15 TOPLEVEL_GL_CATEGORY = 'gpu_toplevel'
13 TOPLEVEL_SERVICE_CATEGORY = 'disabled-by-default-gpu.service' 16 TOPLEVEL_SERVICE_CATEGORY = 'disabled-by-default-gpu.service'
14 TOPLEVEL_DEVICE_CATEGORY = 'disabled-by-default-gpu.device' 17 TOPLEVEL_DEVICE_CATEGORY = 'disabled-by-default-gpu.device'
15 TOPLEVEL_CATEGORIES = [TOPLEVEL_SERVICE_CATEGORY, TOPLEVEL_DEVICE_CATEGORY] 18 TOPLEVEL_CATEGORIES = [TOPLEVEL_SERVICE_CATEGORY, TOPLEVEL_DEVICE_CATEGORY]
16 19
20 data_path = os.path.join(
21 path_util.GetChromiumSrcDir(), 'content', 'test', 'data', 'gpu')
22
17 test_harness_script = r""" 23 test_harness_script = r"""
18 var domAutomationController = {}; 24 var domAutomationController = {};
19 25
20 domAutomationController._finished = false; 26 domAutomationController._finished = false;
21 27
22 domAutomationController.setAutomationId = function(id) {} 28 domAutomationController.setAutomationId = function(id) {}
23 29
24 domAutomationController.send = function(msg) { 30 domAutomationController.send = function(msg) {
25 // Issue a read pixel to synchronize the gpu process to ensure 31 // Issue a read pixel to synchronize the gpu process to ensure
26 // the asynchronous category enabling is finished. 32 // the asynchronous category enabling is finished.
27 var temp_canvas = document.createElement("canvas") 33 var temp_canvas = document.createElement("canvas")
28 temp_canvas.width = 1; 34 temp_canvas.width = 1;
29 temp_canvas.height = 1; 35 temp_canvas.height = 1;
30 var temp_gl = temp_canvas.getContext("experimental-webgl") || 36 var temp_gl = temp_canvas.getContext("experimental-webgl") ||
31 temp_canvas.getContext("webgl"); 37 temp_canvas.getContext("webgl");
32 if (temp_gl) { 38 if (temp_gl) {
33 temp_gl.clear(temp_gl.COLOR_BUFFER_BIT); 39 temp_gl.clear(temp_gl.COLOR_BUFFER_BIT);
34 var id = new Uint8Array(4); 40 var id = new Uint8Array(4);
35 temp_gl.readPixels(0, 0, 1, 1, temp_gl.RGBA, temp_gl.UNSIGNED_BYTE, id); 41 temp_gl.readPixels(0, 0, 1, 1, temp_gl.RGBA, temp_gl.UNSIGNED_BYTE, id);
36 } else { 42 } else {
37 console.log('Failed to get WebGL context.'); 43 console.log('Failed to get WebGL context.');
38 } 44 }
39 45
40 domAutomationController._finished = true; 46 domAutomationController._finished = true;
41 } 47 }
42 48
43 window.domAutomationController = domAutomationController; 49 window.domAutomationController = domAutomationController;
44 """ 50 """
45 51
52 class TraceIntegrationTest(gpu_integration_test.GpuIntegrationTest):
53 """Tests GPU traces are plumbed through properly.
46 54
47 class TraceValidatorBase(gpu_test_base.ValidatorBase): 55 Also tests that GPU Device traces show up on devices that support them."""
48 def GetCategoryName(self):
49 raise NotImplementedError("GetCategoryName() Not implemented!")
50 56
51 def ValidateAndMeasurePage(self, page, tab, results): 57 @classmethod
58 def Name(cls):
59 return 'trace_test'
60
61 @classmethod
62 def CustomizeOptions(cls):
63 options = cls._finder_options.browser_options
64 options.AppendExtraBrowserArgs('--enable-logging')
65 options.AppendExtraBrowserArgs('--enable-experimental-canvas-features')
66
67 @classmethod
68 def GenerateGpuTests(cls, options):
69 # Include the device level trace tests, even though they're
70 # currently skipped on all platforms, to give a hint that they
71 # should perhaps be enabled in the future.
72 for p in pixel_test_pages.DefaultPages('TraceTest'):
73 yield (p.name, p.url, (TOPLEVEL_SERVICE_CATEGORY))
74 for p in pixel_test_pages.DefaultPages('DeviceTraceTest'):
75 yield (p.name, p.url, (TOPLEVEL_DEVICE_CATEGORY))
76
77 def RunActualGpuTest(self, test_path, *args):
78 # The version of this test in the old GPU test harness restarted
79 # the browser after each test, so continue to do that to match its
80 # behavior.
81 self._RestartBrowser('Restarting browser to ensure clean traces')
82
83 # Set up tracing.
84 config = tracing_config.TracingConfig()
85 config.chrome_trace_config.category_filter.AddExcludedCategory('*')
86 for cat in TOPLEVEL_CATEGORIES:
87 config.chrome_trace_config.category_filter.AddDisabledByDefault(cat)
88 config.enable_chrome_trace = True
89 tab = self.tab
90 tab.browser.platform.tracing_controller.StartTracing(config, 60)
91
92 # Perform page navigation.
93 url = self.UrlOfStaticFilePath(test_path)
94 tab.Navigate(url, script_to_evaluate_on_commit=test_harness_script)
95 tab.action_runner.WaitForJavaScriptCondition(
96 'domAutomationController._finished', timeout_in_seconds=30)
97
98 # Stop tracing.
52 timeline_data = tab.browser.platform.tracing_controller.StopTracing() 99 timeline_data = tab.browser.platform.tracing_controller.StopTracing()
100
101 # Evaluate success.
53 timeline_model = model_module.TimelineModel(timeline_data) 102 timeline_model = model_module.TimelineModel(timeline_data)
54 103 category_name = args[0]
55 category_name = self.GetCategoryName()
56 event_iter = timeline_model.IterAllEvents( 104 event_iter = timeline_model.IterAllEvents(
57 event_type_predicate=model_module.IsSliceOrAsyncSlice) 105 event_type_predicate=model_module.IsSliceOrAsyncSlice)
58 for event in event_iter: 106 for event in event_iter:
59 if (event.args.get('gl_category', None) == TOPLEVEL_GL_CATEGORY and 107 if (event.args.get('gl_category', None) == TOPLEVEL_GL_CATEGORY and
60 event.category == category_name): 108 event.category == category_name):
109 print 'Found event with category name ' + category_name
61 break 110 break
62 else: 111 else:
63 raise legacy_page_test.Failure(self._FormatException(category_name)) 112 self.fail(self._FormatException(category_name))
64
65 def CustomizeBrowserOptions(self, options):
66 options.AppendExtraBrowserArgs('--enable-logging')
67 options.AppendExtraBrowserArgs('--enable-experimental-canvas-features')
68
69 def WillNavigateToPage(self, page, tab):
70 config = tracing_config.TracingConfig()
71 config.chrome_trace_config.category_filter.AddExcludedCategory('*')
72 for cat in TOPLEVEL_CATEGORIES:
73 config.chrome_trace_config.category_filter.AddDisabledByDefault(
74 cat)
75 config.enable_chrome_trace = True
76 tab.browser.platform.tracing_controller.StartTracing(config, 60)
77 113
78 def _FormatException(self, category): 114 def _FormatException(self, category):
79 return 'Trace markers for GPU category was not found: %s' % category 115 return 'Trace markers for GPU category were not found: %s' % category
80
81
82 class _TraceValidator(TraceValidatorBase):
83 def GetCategoryName(self):
84 return TOPLEVEL_SERVICE_CATEGORY
85
86
87 class _DeviceTraceValidator(TraceValidatorBase):
88 def GetCategoryName(self):
89 return TOPLEVEL_DEVICE_CATEGORY
90
91
92 class TraceTestBase(gpu_test_base.TestBase):
93 """Base class for the trace tests."""
94 def CreateStorySet(self, options):
95 # Utilize pixel tests page set as a set of simple pages to load.
96 story_set = page_sets.PixelTestsStorySet(self.GetExpectations(),
97 base_name=self.Name())
98 for story in story_set:
99 story.script_to_evaluate_on_commit = test_harness_script
100 return story_set
101
102
103 class TraceTest(TraceTestBase):
104 """Tests GPU traces are plumbed through properly."""
105 test = _TraceValidator
106 name = 'TraceTest'
107 116
108 @classmethod 117 @classmethod
109 def Name(cls): 118 def _CreateExpectations(cls):
110 return 'trace_test'
111
112 def _CreateExpectations(self):
113 return trace_test_expectations.TraceTestExpectations() 119 return trace_test_expectations.TraceTestExpectations()
114 120
115
116 class DeviceTraceTest(TraceTestBase):
117 """Tests GPU Device traces show up on devices that support it."""
118 test = _DeviceTraceValidator
119 name = 'DeviceTraceTest'
120
121 @classmethod 121 @classmethod
122 def Name(cls): 122 def setUpClass(cls):
123 return 'device_trace_test' 123 super(cls, TraceIntegrationTest).setUpClass()
124 124 path_util.SetupTelemetryPaths()
125 def _CreateExpectations(self): 125 cls.CustomizeOptions()
126 return trace_test_expectations.DeviceTraceTestExpectations() 126 cls.SetBrowserOptions(cls._finder_options)
127 cls.StartBrowser()
128 cls.SetStaticServerDirs([data_path])
OLDNEW
« no previous file with comments | « content/test/gpu/generate_buildbot_json.py ('k') | content/test/gpu/gpu_tests/trace_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698