Chromium Code Reviews| Index: ppapi/tests/testing_instance.cc |
| =================================================================== |
| --- ppapi/tests/testing_instance.cc (revision 97356) |
| +++ ppapi/tests/testing_instance.cc (working copy) |
| @@ -6,6 +6,7 @@ |
| #include <algorithm> |
| #include <cstring> |
| +#include <sstream> |
| #include <vector> |
| #include "ppapi/cpp/module.h" |
| @@ -14,6 +15,10 @@ |
| TestCaseFactory* TestCaseFactory::head_ = NULL; |
| +// Cookie value we use to signal "we're still working." See the comment above |
| +// the class declaration for how this works. |
| +static const char kProgressCookie[] = "..."; |
|
polina
2011/08/22 23:53:58
s/kProgressCookie/kProgressSignal/
Otherwise, it g
|
| + |
| // Returns a new heap-allocated test case for the given test, or NULL on |
| // failure. |
| TestingInstance::TestingInstance(PP_Instance instance) |
| @@ -23,6 +28,7 @@ |
| : pp::InstancePrivate(instance), |
| #endif |
| current_case_(NULL), |
| + progress_number_(0), |
| executed_tests_(false), |
| nacl_mode_(false) { |
| callback_factory_.Initialize(this); |
| @@ -87,6 +93,9 @@ |
| void TestingInstance::LogTest(const std::string& test_name, |
| const std::string& error_message) { |
| + // Tell the browser we're still working. |
| + ReportProgress(kProgressCookie); |
| + |
| std::string html; |
| html.append("<div class=\"test_line\"><span class=\"test_name\">"); |
| html.append(test_name); |
| @@ -113,7 +122,7 @@ |
| } |
| void TestingInstance::ExecuteTests(int32_t unused) { |
| - SetCookie("STARTUP_COOKIE", "STARTED"); |
| + ReportProgress(kProgressCookie); |
| // Clear the console. |
| PostMessage(pp::Var("TESTING_MESSAGE:ClearConsole")); |
| @@ -134,7 +143,7 @@ |
| } |
| // Declare we're done by setting a cookie to either "PASS" or the errors. |
| - SetCookie("COMPLETION_COOKIE", errors_.empty() ? "PASS" : errors_); |
| + ReportProgress(errors_.empty() ? "PASS" : errors_); |
| PostMessage(pp::Var("TESTING_MESSAGE:DidExecuteTests")); |
| } |
| @@ -189,6 +198,14 @@ |
| PostMessage(pp::Var(message)); |
| } |
| +void TestingInstance::ReportProgress(const std::string& progress_value) { |
| + // Use streams since nacl doesn't compile base yet (for stringprintf). |
|
polina
2011/08/22 23:53:58
StringPrintf?
|
| + std::ostringstream cookie_name; |
| + cookie_name << "PPAPI_PROGRESS_" << progress_number_; |
| + SetCookie(cookie_name.str(), progress_value); |
| + progress_number_++; |
| +} |
| + |
| void TestingInstance::SetCookie(const std::string& name, |
| const std::string& value) { |
| std::string message("TESTING_MESSAGE:SetCookie:"); |