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

Side by Side Diff: gpu/command_buffer/service/gpu_tracer_unittest.cc

Issue 776603003: Changed the GPU Tracer so the category names can be customized. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Service side GPU trace not turned on when device is turned on Created 6 years 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <map> 5 #include <map>
6 #include <set> 6 #include <set>
7 7
8 #include "gpu/command_buffer/service/gpu_service_test.h" 8 #include "gpu/command_buffer/service/gpu_service_test.h"
9 #include "gpu/command_buffer/service/gpu_tracer.h" 9 #include "gpu/command_buffer/service/gpu_tracer.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/gl/gl_mock.h" 11 #include "ui/gl/gl_mock.h"
12 12
13 namespace gpu { 13 namespace gpu {
14 namespace gles2 { 14 namespace gles2 {
15 15
16 using ::testing::Return; 16 using ::testing::Return;
17 using ::testing::NotNull; 17 using ::testing::NotNull;
18 using ::testing::AtLeast; 18 using ::testing::AtLeast;
19 using ::testing::Invoke; 19 using ::testing::Invoke;
20 using ::testing::_; 20 using ::testing::_;
21 21
22 class MockOutputter : public Outputter { 22 class MockOutputter : public Outputter {
23 public: 23 public:
24 MockOutputter() {} 24 MockOutputter() {}
25 MOCK_METHOD3(Trace, 25 MOCK_METHOD4(Trace,
26 void(const std::string& name, int64 start_time, int64 end_time)); 26 void(const std::string& category, const std::string& name,
27 int64 start_time, int64 end_time));
27 28
28 protected: 29 protected:
29 ~MockOutputter() {} 30 ~MockOutputter() {}
30 }; 31 };
31 32
32 class GlFakeQueries { 33 class GlFakeQueries {
33 public: 34 public:
34 GlFakeQueries() {} 35 GlFakeQueries() {}
35 36
36 void Reset() { 37 void Reset() {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 107
107 /////////////////////////////////////////////////////////////////////////// 108 ///////////////////////////////////////////////////////////////////////////
108 109
109 void DoTraceTest() { 110 void DoTraceTest() {
110 MockOutputter* outputter = new MockOutputter(); 111 MockOutputter* outputter = new MockOutputter();
111 scoped_refptr<Outputter> outputter_ref = outputter; 112 scoped_refptr<Outputter> outputter_ref = outputter;
112 113
113 SetupTimerQueryMocks(); 114 SetupTimerQueryMocks();
114 115
115 // Expected results 116 // Expected results
117 const std::string category_name("trace_category");
116 const std::string trace_name("trace_test"); 118 const std::string trace_name("trace_test");
117 const int64 offset_time = 3231; 119 const int64 offset_time = 3231;
118 const GLint64 start_timestamp = 7 * base::Time::kNanosecondsPerMicrosecond; 120 const GLint64 start_timestamp = 7 * base::Time::kNanosecondsPerMicrosecond;
119 const GLint64 end_timestamp = 32 * base::Time::kNanosecondsPerMicrosecond; 121 const GLint64 end_timestamp = 32 * base::Time::kNanosecondsPerMicrosecond;
120 const int64 expect_start_time = 122 const int64 expect_start_time =
121 (start_timestamp / base::Time::kNanosecondsPerMicrosecond) + 123 (start_timestamp / base::Time::kNanosecondsPerMicrosecond) +
122 offset_time; 124 offset_time;
123 const int64 expect_end_time = 125 const int64 expect_end_time =
124 (end_timestamp / base::Time::kNanosecondsPerMicrosecond) + offset_time; 126 (end_timestamp / base::Time::kNanosecondsPerMicrosecond) + offset_time;
125 127
126 // Expected Outputter::Trace call 128 // Expected Outputter::Trace call
127 EXPECT_CALL(*outputter, 129 EXPECT_CALL(*outputter,
128 Trace(trace_name, expect_start_time, expect_end_time)); 130 Trace(category_name, trace_name,
131 expect_start_time, expect_end_time));
129 132
130 scoped_refptr<GPUTrace> trace = 133 scoped_refptr<GPUTrace> trace =
131 new GPUTrace(outputter_ref, trace_name, offset_time, 134 new GPUTrace(outputter_ref, category_name, trace_name,
132 GetTracerType()); 135 offset_time, GetTracerType());
133 136
134 gl_fake_queries_.SetCurrentGLTime(start_timestamp); 137 gl_fake_queries_.SetCurrentGLTime(start_timestamp);
135 trace->Start(); 138 trace->Start(true);
136 139
137 // Shouldn't be available before End() call 140 // Shouldn't be available before End() call
138 gl_fake_queries_.SetCurrentGLTime(end_timestamp); 141 gl_fake_queries_.SetCurrentGLTime(end_timestamp);
139 EXPECT_FALSE(trace->IsAvailable()); 142 EXPECT_FALSE(trace->IsAvailable());
140 143
141 trace->End(); 144 trace->End(true);
142 145
143 // Shouldn't be available until the queries complete 146 // Shouldn't be available until the queries complete
144 gl_fake_queries_.SetCurrentGLTime(end_timestamp - 147 gl_fake_queries_.SetCurrentGLTime(end_timestamp -
145 base::Time::kNanosecondsPerMicrosecond); 148 base::Time::kNanosecondsPerMicrosecond);
146 EXPECT_FALSE(trace->IsAvailable()); 149 EXPECT_FALSE(trace->IsAvailable());
147 150
148 // Now it should be available 151 // Now it should be available
149 gl_fake_queries_.SetCurrentGLTime(end_timestamp); 152 gl_fake_queries_.SetCurrentGLTime(end_timestamp);
150 EXPECT_TRUE(trace->IsAvailable()); 153 EXPECT_TRUE(trace->IsAvailable());
151 154
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 218
216 TEST_F(GpuDisjointTimerTracerTest, GPUTrace) { 219 TEST_F(GpuDisjointTimerTracerTest, GPUTrace) {
217 // Test basic timer query functionality 220 // Test basic timer query functionality
218 { 221 {
219 DoTraceTest(); 222 DoTraceTest();
220 } 223 }
221 } 224 }
222 225
223 } // namespace gles2 226 } // namespace gles2
224 } // namespace gpu 227 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gpu_tracer.cc ('k') | mojo/public/c/gles2/gles2_call_visitor_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698