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

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: More renamings and category filter cleanups. Created 7 years, 10 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 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingAllowed) { 177 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingAllowed) {
178 GpuFeatureType type = 178 GpuFeatureType type =
179 GpuDataManager::GetInstance()->GetBlacklistedFeatures(); 179 GpuDataManager::GetInstance()->GetBlacklistedFeatures();
180 EXPECT_EQ(type, 0); 180 EXPECT_EQ(type, 0);
181 181
182 const base::FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); 182 const base::FilePath url(FILE_PATH_LITERAL("feature_compositing.html"));
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 } 450 }
451 451
452 452
453 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) 453 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX)
454 // http://crbug.com/162343: flaky on Windows and Mac, failing on ChromiumOS. 454 // http://crbug.com/162343: flaky on Windows and Mac, failing on ChromiumOS.
455 #define MAYBE_RafNoDamage DISABLED_RafNoDamage 455 #define MAYBE_RafNoDamage DISABLED_RafNoDamage
456 #else 456 #else
457 #define MAYBE_RafNoDamage RafNoDamage 457 #define MAYBE_RafNoDamage RafNoDamage
458 #endif 458 #endif
459 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, MAYBE_RafNoDamage) { 459 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, MAYBE_RafNoDamage) {
460 trace_categories_ = "-test_*"; 460 category_patterns_ = "-test_*";
461 const base::FilePath url(FILE_PATH_LITERAL("feature_raf_no_damage.html")); 461 const base::FilePath url(FILE_PATH_LITERAL("feature_raf_no_damage.html"));
462 RunEventTest(url); 462 RunEventTest(url);
463 463
464 if (!analyzer_.get()) 464 if (!analyzer_.get())
465 return; 465 return;
466 466
467 // Search for matching name on begin event or async_begin event (any begin). 467 // Search for matching name on begin event or async_begin event (any begin).
468 Query query_raf = 468 Query query_raf =
469 (Query::EventPhaseIs(TRACE_EVENT_PHASE_BEGIN) || 469 (Query::EventPhaseIs(TRACE_EVENT_PHASE_BEGIN) ||
470 Query::EventPhaseIs(TRACE_EVENT_PHASE_ASYNC_BEGIN)) && 470 Query::EventPhaseIs(TRACE_EVENT_PHASE_ASYNC_BEGIN)) &&
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 base::StringPrintf( 559 base::StringPrintf(
560 "%d (resize offset %d): IOSurface width %d -> %d; Creates %d " 560 "%d (resize offset %d): IOSurface width %d -> %d; Creates %d "
561 "Expected %d", offset_i, offsets[offset_i], 561 "Expected %d", offset_i, offsets[offset_i],
562 old_width, new_width, num_creates, expected_creates); 562 old_width, new_width, num_creates, expected_creates);
563 } 563 }
564 } 564 }
565 } 565 }
566 #endif 566 #endif
567 567
568 } // namespace anonymous 568 } // namespace anonymous
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698