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

Side by Side Diff: chrome/test/gpu/gpu_feature_browsertest.cc

Issue 12150004: Category group support/Renamings. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed review comments + lint errors. Created 7 years, 9 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "base/test/trace_event_analyzer.h" 10 #include "base/test/trace_event_analyzer.h"
(...skipping 29 matching lines...) Expand all
40 using trace_analyzer::TraceEventVector; 40 using trace_analyzer::TraceEventVector;
41 41
42 namespace { 42 namespace {
43 43
44 const char kSwapBuffersEvent[] = "SwapBuffers"; 44 const char kSwapBuffersEvent[] = "SwapBuffers";
45 const char kAcceleratedCanvasCreationEvent[] = "Canvas2DLayerBridgeCreation"; 45 const char kAcceleratedCanvasCreationEvent[] = "Canvas2DLayerBridgeCreation";
46 const char kWebGLCreationEvent[] = "DrawingBufferCreation"; 46 const char kWebGLCreationEvent[] = "DrawingBufferCreation";
47 47
48 class GpuFeatureTest : public InProcessBrowserTest { 48 class GpuFeatureTest : public InProcessBrowserTest {
49 public: 49 public:
50 GpuFeatureTest() : trace_categories_("test_gpu"), gpu_enabled_(false) {} 50 GpuFeatureTest() : category_patterns_("test_gpu"), gpu_enabled_(false) {}
51 51
52 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 52 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
53 base::FilePath test_dir; 53 base::FilePath test_dir;
54 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); 54 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir));
55 gpu_test_dir_ = test_dir.AppendASCII("gpu"); 55 gpu_test_dir_ = test_dir.AppendASCII("gpu");
56 } 56 }
57 57
58 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 58 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
59 // Do not use mesa if real GPU is required. 59 // Do not use mesa if real GPU is required.
60 if (!command_line->HasSwitch(switches::kUseGpuInTests)) { 60 if (!command_line->HasSwitch(switches::kUseGpuInTests)) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // Bypass tests on GPU Linux Debug bots. 117 // Bypass tests on GPU Linux Debug bots.
118 if (gpu_enabled_) 118 if (gpu_enabled_)
119 return; 119 return;
120 #endif 120 #endif
121 #if defined(OS_MACOSX) 121 #if defined(OS_MACOSX)
122 // Bypass tests on Mac OSX 10.5 bots (IOSurfaceSupport is now required). 122 // Bypass tests on Mac OSX 10.5 bots (IOSurfaceSupport is now required).
123 if (!IOSurfaceSupport::Initialize()) 123 if (!IOSurfaceSupport::Initialize())
124 return; 124 return;
125 #endif 125 #endif
126 126
127 ASSERT_TRUE(tracing::BeginTracing(trace_categories_)); 127 ASSERT_TRUE(tracing::BeginTracing(category_patterns_));
128 128
129 // Have to use a new tab for the blacklist to work. 129 // Have to use a new tab for the blacklist to work.
130 RunTest(url, NULL, true); 130 RunTest(url, NULL, true);
131 131
132 ASSERT_TRUE(tracing::EndTracing(&trace_events_json_)); 132 ASSERT_TRUE(tracing::EndTracing(&trace_events_json_));
133 133
134 analyzer_.reset(TraceAnalyzer::Create(trace_events_json_)); 134 analyzer_.reset(TraceAnalyzer::Create(trace_events_json_));
135 analyzer_->AssociateBeginEndEvents(); 135 analyzer_->AssociateBeginEndEvents();
136 TraceEventVector events; 136 TraceEventVector events;
137 137
138 if (!event_name) 138 if (!event_name)
139 return; 139 return;
140 140
141 size_t event_count = 141 size_t event_count =
142 analyzer_->FindEvents(Query::EventNameIs(event_name), &events); 142 analyzer_->FindEvents(Query::EventNameIs(event_name), &events);
143 143
144 if (event_expected) 144 if (event_expected)
145 EXPECT_GT(event_count, 0U); 145 EXPECT_GT(event_count, 0U);
146 else 146 else
147 EXPECT_EQ(event_count, 0U); 147 EXPECT_EQ(event_count, 0U);
148 } 148 }
149 149
150 // Trigger a resize of the chrome window, and use tracing to wait for the 150 // Trigger a resize of the chrome window, and use tracing to wait for the
151 // given |wait_event|. 151 // given |wait_event|.
152 bool ResizeAndWait(const gfx::Rect& new_bounds, 152 bool ResizeAndWait(const gfx::Rect& new_bounds,
153 const char* trace_categories, 153 const char* category_patterns,
154 const char* wait_category, 154 const char* wait_category,
155 const char* wait_event) { 155 const char* wait_event) {
156 if (!tracing::BeginTracingWithWatch(trace_categories, wait_category, 156 if (!tracing::BeginTracingWithWatch(category_patterns, wait_category,
157 wait_event, 1)) 157 wait_event, 1))
158 return false; 158 return false;
159 browser()->window()->SetBounds(new_bounds); 159 browser()->window()->SetBounds(new_bounds);
160 if (!tracing::WaitForWatchEvent(base::TimeDelta())) 160 if (!tracing::WaitForWatchEvent(base::TimeDelta()))
161 return false; 161 return false;
162 if (!tracing::EndTracing(&trace_events_json_)) 162 if (!tracing::EndTracing(&trace_events_json_))
163 return false; 163 return false;
164 analyzer_.reset(TraceAnalyzer::Create(trace_events_json_)); 164 analyzer_.reset(TraceAnalyzer::Create(trace_events_json_));
165 analyzer_->AssociateBeginEndEvents(); 165 analyzer_->AssociateBeginEndEvents();
166 return true; 166 return true;
167 } 167 }
168 168
169 protected: 169 protected:
170 base::FilePath gpu_test_dir_; 170 base::FilePath gpu_test_dir_;
171 scoped_ptr<TraceAnalyzer> analyzer_; 171 scoped_ptr<TraceAnalyzer> analyzer_;
172 std::string trace_categories_; 172 std::string category_patterns_;
173 std::string trace_events_json_; 173 std::string trace_events_json_;
174 bool gpu_enabled_; 174 bool gpu_enabled_;
175 }; 175 };
176 176
177 #if defined(OS_WIN) 177 #if defined(OS_WIN)
178 // This test is flaky on Windows. http://crbug.com/177113 178 // This test is flaky on Windows. http://crbug.com/177113
179 #define MAYBE_AcceleratedCompositingAllowed DISABLED_AcceleratedCompositingAllow ed 179 #define MAYBE_AcceleratedCompositingAllowed DISABLED_AcceleratedCompositingAllow ed
180 #else 180 #else
181 #define MAYBE_AcceleratedCompositingAllowed AcceleratedCompositingAllowed 181 #define MAYBE_AcceleratedCompositingAllowed AcceleratedCompositingAllowed
182 #endif 182 #endif
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 } 457 }
458 458
459 459
460 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) 460 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX)
461 // http://crbug.com/162343: flaky on Windows and Mac, failing on ChromiumOS. 461 // http://crbug.com/162343: flaky on Windows and Mac, failing on ChromiumOS.
462 #define MAYBE_RafNoDamage DISABLED_RafNoDamage 462 #define MAYBE_RafNoDamage DISABLED_RafNoDamage
463 #else 463 #else
464 #define MAYBE_RafNoDamage RafNoDamage 464 #define MAYBE_RafNoDamage RafNoDamage
465 #endif 465 #endif
466 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, MAYBE_RafNoDamage) { 466 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, MAYBE_RafNoDamage) {
467 trace_categories_ = "-test_*"; 467 category_patterns_ = "-test_*";
468 const base::FilePath url(FILE_PATH_LITERAL("feature_raf_no_damage.html")); 468 const base::FilePath url(FILE_PATH_LITERAL("feature_raf_no_damage.html"));
469 RunEventTest(url); 469 RunEventTest(url);
470 470
471 if (!analyzer_.get()) 471 if (!analyzer_.get())
472 return; 472 return;
473 473
474 // Search for matching name on begin event or async_begin event (any begin). 474 // Search for matching name on begin event or async_begin event (any begin).
475 Query query_raf = 475 Query query_raf =
476 (Query::EventPhaseIs(TRACE_EVENT_PHASE_BEGIN) || 476 (Query::EventPhaseIs(TRACE_EVENT_PHASE_BEGIN) ||
477 Query::EventPhaseIs(TRACE_EVENT_PHASE_ASYNC_BEGIN)) && 477 Query::EventPhaseIs(TRACE_EVENT_PHASE_ASYNC_BEGIN)) &&
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 base::StringPrintf( 566 base::StringPrintf(
567 "%d (resize offset %d): IOSurface width %d -> %d; Creates %d " 567 "%d (resize offset %d): IOSurface width %d -> %d; Creates %d "
568 "Expected %d", offset_i, offsets[offset_i], 568 "Expected %d", offset_i, offsets[offset_i],
569 old_width, new_width, num_creates, expected_creates); 569 old_width, new_width, num_creates, expected_creates);
570 } 570 }
571 } 571 }
572 } 572 }
573 #endif 573 #endif
574 574
575 } // namespace anonymous 575 } // namespace anonymous
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698