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/test/trace_event_analyzer.h" | 9 #include "base/test/trace_event_analyzer.h" |
10 #include "base/version.h" | 10 #include "base/version.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 | 84 |
85 std::string result; | 85 std::string result; |
86 // Wait for message indicating the test has finished running. | 86 // Wait for message indicating the test has finished running. |
87 ASSERT_TRUE(message_queue.WaitForMessage(&result)); | 87 ASSERT_TRUE(message_queue.WaitForMessage(&result)); |
88 if (expected_reply) | 88 if (expected_reply) |
89 EXPECT_STREQ(expected_reply, result.c_str()); | 89 EXPECT_STREQ(expected_reply, result.c_str()); |
90 } | 90 } |
91 | 91 |
92 void RunTest(const FilePath& url, GpuResultFlags expectations) { | 92 void RunTest(const FilePath& url, GpuResultFlags expectations) { |
93 using namespace trace_analyzer; | 93 using trace_analyzer::Query; |
| 94 using trace_analyzer::TraceAnalyzer; |
94 | 95 |
95 ASSERT_TRUE(tracing::BeginTracing("test_gpu")); | 96 ASSERT_TRUE(tracing::BeginTracing("test_gpu")); |
96 | 97 |
97 // Have to use a new tab for the blacklist to work. | 98 // Have to use a new tab for the blacklist to work. |
98 RunTest(url, NULL, true); | 99 RunTest(url, NULL, true); |
99 | 100 |
100 std::string json_events; | 101 std::string json_events; |
101 ASSERT_TRUE(tracing::EndTracing(&json_events)); | 102 ASSERT_TRUE(tracing::EndTracing(&json_events)); |
102 | 103 |
103 scoped_ptr<TraceAnalyzer> analyzer(TraceAnalyzer::Create(json_events)); | 104 scoped_ptr<TraceAnalyzer> analyzer(TraceAnalyzer::Create(json_events)); |
104 analyzer->AssociateBeginEndEvents(); | 105 analyzer->AssociateBeginEndEvents(); |
105 TraceEventVector events; | 106 trace_analyzer::TraceEventVector events; |
106 | 107 |
107 // This measurement is flaky, because the GPU process is sometimes | 108 // This measurement is flaky, because the GPU process is sometimes |
108 // started before the test (always with force-compositing-mode on CrOS). | 109 // started before the test (always with force-compositing-mode on CrOS). |
109 if (expectations & EXPECT_NO_GPU_PROCESS) { | 110 if (expectations & EXPECT_NO_GPU_PROCESS) { |
110 EXPECT_EQ(0u, analyzer->FindEvents( | 111 EXPECT_EQ(0u, analyzer->FindEvents( |
111 Query::MatchBeginName("OnGraphicsInfoCollected"), &events)); | 112 Query::MatchBeginName("OnGraphicsInfoCollected"), &events)); |
112 } | 113 } |
113 | 114 |
114 // Check for swap buffers if expected: | 115 // Check for swap buffers if expected: |
115 if (expectations & EXPECT_GPU_SWAP_BUFFERS) { | 116 if (expectations & EXPECT_GPU_SWAP_BUFFERS) { |
116 EXPECT_GT(analyzer->FindEvents(Query(EVENT_NAME) == | 117 EXPECT_GT(analyzer->FindEvents(Query::EventName() == |
117 Query::String("SwapBuffers"), &events), | 118 Query::String("SwapBuffers"), &events), |
118 size_t(0)); | 119 size_t(0)); |
119 } | 120 } |
120 } | 121 } |
121 | 122 |
122 protected: | 123 protected: |
123 FilePath gpu_test_dir_; | 124 FilePath gpu_test_dir_; |
124 }; | 125 }; |
125 | 126 |
126 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingAllowed) { | 127 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingAllowed) { |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 RunTest(url, "\"SUCCESS\"", false); | 317 RunTest(url, "\"SUCCESS\"", false); |
317 } | 318 } |
318 | 319 |
319 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, CanOpenPopupAndRenderWith2DCanvas) { | 320 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, CanOpenPopupAndRenderWith2DCanvas) { |
320 const FilePath url(FILE_PATH_LITERAL("canvas_popup.html")); | 321 const FilePath url(FILE_PATH_LITERAL("canvas_popup.html")); |
321 RunTest(url, "\"SUCCESS\"", false); | 322 RunTest(url, "\"SUCCESS\"", false); |
322 } | 323 } |
323 | 324 |
324 } // namespace anonymous | 325 } // namespace anonymous |
325 | 326 |
OLD | NEW |