| OLD | NEW |
| 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 Loading... |
| 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() : tag_patterns_("test_gpu"), gpu_enabled_(false) {} |
| 51 | 51 |
| 52 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 52 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 53 FilePath test_dir; | 53 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) { | 58 virtual void SetUpCommandLine(CommandLine* command_line) { |
| 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 Loading... |
| 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(tag_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* tag_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(tag_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 FilePath gpu_test_dir_; | 170 FilePath gpu_test_dir_; |
| 171 scoped_ptr<TraceAnalyzer> analyzer_; | 171 scoped_ptr<TraceAnalyzer> analyzer_; |
| 172 std::string trace_categories_; | 172 std::string tag_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 FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); | 182 const FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 } | 453 } |
| 454 | 454 |
| 455 | 455 |
| 456 #if defined(OS_WIN) | 456 #if defined(OS_WIN) |
| 457 // http://crbug.com/162343: flaky on Windows | 457 // http://crbug.com/162343: flaky on Windows |
| 458 #define MAYBE_RafNoDamage DISABLED_RafNoDamage | 458 #define MAYBE_RafNoDamage DISABLED_RafNoDamage |
| 459 #else | 459 #else |
| 460 #define MAYBE_RafNoDamage RafNoDamage | 460 #define MAYBE_RafNoDamage RafNoDamage |
| 461 #endif | 461 #endif |
| 462 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, MAYBE_RafNoDamage) { | 462 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, MAYBE_RafNoDamage) { |
| 463 trace_categories_ = "-test_*"; | 463 tag_patterns_ = "-test_*"; |
| 464 const FilePath url(FILE_PATH_LITERAL("feature_raf_no_damage.html")); | 464 const FilePath url(FILE_PATH_LITERAL("feature_raf_no_damage.html")); |
| 465 RunEventTest(url); | 465 RunEventTest(url); |
| 466 | 466 |
| 467 if (!analyzer_.get()) | 467 if (!analyzer_.get()) |
| 468 return; | 468 return; |
| 469 | 469 |
| 470 // Search for matching name on begin event or async_begin event (any begin). | 470 // Search for matching name on begin event or async_begin event (any begin). |
| 471 Query query_raf = | 471 Query query_raf = |
| 472 (Query::EventPhaseIs(TRACE_EVENT_PHASE_BEGIN) || | 472 (Query::EventPhaseIs(TRACE_EVENT_PHASE_BEGIN) || |
| 473 Query::EventPhaseIs(TRACE_EVENT_PHASE_ASYNC_BEGIN)) && | 473 Query::EventPhaseIs(TRACE_EVENT_PHASE_ASYNC_BEGIN)) && |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 base::StringPrintf( | 561 base::StringPrintf( |
| 562 "%d (resize offset %d): IOSurface width %d -> %d; Creates %d " | 562 "%d (resize offset %d): IOSurface width %d -> %d; Creates %d " |
| 563 "Expected %d", offset_i, offsets[offset_i], | 563 "Expected %d", offset_i, offsets[offset_i], |
| 564 old_width, new_width, num_creates, expected_creates); | 564 old_width, new_width, num_creates, expected_creates); |
| 565 } | 565 } |
| 566 } | 566 } |
| 567 } | 567 } |
| 568 #endif | 568 #endif |
| 569 | 569 |
| 570 } // namespace anonymous | 570 } // namespace anonymous |
| OLD | NEW |