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 "ppapi/tests/testing_instance.h" | 5 #include "ppapi/tests/testing_instance.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cstring> | 8 #include <cstring> |
9 #include <iomanip> | 9 #include <iomanip> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 117 } |
118 | 118 |
119 void TestingInstance::SetCookie(const std::string& name, | 119 void TestingInstance::SetCookie(const std::string& name, |
120 const std::string& value) { | 120 const std::string& value) { |
121 SendTestCommand("SetCookie", name + "=" + value); | 121 SendTestCommand("SetCookie", name + "=" + value); |
122 } | 122 } |
123 | 123 |
124 void TestingInstance::LogTest(const std::string& test_name, | 124 void TestingInstance::LogTest(const std::string& test_name, |
125 const std::string& error_message, | 125 const std::string& error_message, |
126 PP_TimeTicks start_time) { | 126 PP_TimeTicks start_time) { |
| 127 current_test_name_ = test_name; |
| 128 |
127 // Compute the time to run the test and save it in a string for logging: | 129 // Compute the time to run the test and save it in a string for logging: |
128 PP_TimeTicks end_time(pp::Module::Get()->core()->GetTimeTicks()); | 130 PP_TimeTicks end_time(pp::Module::Get()->core()->GetTimeTicks()); |
129 std::ostringstream number_stream; | 131 std::ostringstream number_stream; |
130 PP_TimeTicks elapsed_time(end_time - start_time); | 132 PP_TimeTicks elapsed_time(end_time - start_time); |
131 number_stream << std::fixed << std::setprecision(3) << elapsed_time; | 133 number_stream << std::fixed << std::setprecision(3) << elapsed_time; |
132 std::string time_string(number_stream.str()); | 134 std::string time_string(number_stream.str()); |
133 | 135 |
134 // Tell the browser we're still working. | 136 // Tell the browser we're still working. |
135 ReportProgress(kProgressSignal); | 137 ReportProgress(kProgressSignal); |
136 | 138 |
(...skipping 20 matching lines...) Expand all Loading... |
157 | 159 |
158 html.append("</div>"); | 160 html.append("</div>"); |
159 LogHTML(html); | 161 LogHTML(html); |
160 | 162 |
161 std::string test_time; | 163 std::string test_time; |
162 test_time.append(test_name); | 164 test_time.append(test_name); |
163 test_time.append(" finished in "); | 165 test_time.append(" finished in "); |
164 test_time.append(time_string); | 166 test_time.append(time_string); |
165 test_time.append(" seconds."); | 167 test_time.append(" seconds."); |
166 LogTestTime(test_time); | 168 LogTestTime(test_time); |
| 169 |
| 170 current_test_name_.clear(); |
167 } | 171 } |
168 | 172 |
169 void TestingInstance::AppendError(const std::string& message) { | 173 void TestingInstance::AppendError(const std::string& message) { |
170 if (!errors_.empty()) | 174 if (!errors_.empty()) |
171 errors_.append(", "); | 175 errors_.append(", "); |
172 errors_.append(message); | 176 errors_.append(message); |
173 } | 177 } |
174 | 178 |
175 void TestingInstance::ExecuteTests(int32_t unused) { | 179 void TestingInstance::ExecuteTests(int32_t unused) { |
176 ReportProgress(kProgressSignal); | 180 ReportProgress(kProgressSignal); |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 } | 322 } |
319 }; | 323 }; |
320 | 324 |
321 namespace pp { | 325 namespace pp { |
322 | 326 |
323 Module* CreateModule() { | 327 Module* CreateModule() { |
324 return new ::Module(); | 328 return new ::Module(); |
325 } | 329 } |
326 | 330 |
327 } // namespace pp | 331 } // namespace pp |
OLD | NEW |