| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <sstream> | 9 #include <sstream> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 // Returns a new heap-allocated test case for the given test, or NULL on | 23 // Returns a new heap-allocated test case for the given test, or NULL on |
| 24 // failure. | 24 // failure. |
| 25 TestingInstance::TestingInstance(PP_Instance instance) | 25 TestingInstance::TestingInstance(PP_Instance instance) |
| 26 #if (defined __native_client__) | 26 #if (defined __native_client__) |
| 27 : pp::Instance(instance), | 27 : pp::Instance(instance), |
| 28 #else | 28 #else |
| 29 : pp::InstancePrivate(instance), | 29 : pp::InstancePrivate(instance), |
| 30 #endif | 30 #endif |
| 31 current_case_(NULL), | 31 current_case_(NULL), |
| 32 progress_cookie_number_(0), | |
| 33 executed_tests_(false), | 32 executed_tests_(false), |
| 34 nacl_mode_(false) { | 33 nacl_mode_(false) { |
| 35 callback_factory_.Initialize(this); | 34 callback_factory_.Initialize(this); |
| 36 } | 35 } |
| 37 | 36 |
| 38 TestingInstance::~TestingInstance() { | 37 TestingInstance::~TestingInstance() { |
| 39 if (current_case_) | 38 if (current_case_) |
| 40 delete current_case_; | 39 delete current_case_; |
| 41 } | 40 } |
| 42 | 41 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } | 225 } |
| 227 | 226 |
| 228 void TestingInstance::LogHTML(const std::string& html) { | 227 void TestingInstance::LogHTML(const std::string& html) { |
| 229 std::string message("TESTING_MESSAGE:LogHTML:"); | 228 std::string message("TESTING_MESSAGE:LogHTML:"); |
| 230 message.append(html); | 229 message.append(html); |
| 231 PostMessage(pp::Var(message)); | 230 PostMessage(pp::Var(message)); |
| 232 } | 231 } |
| 233 | 232 |
| 234 void TestingInstance::ReportProgress(const std::string& progress_value) { | 233 void TestingInstance::ReportProgress(const std::string& progress_value) { |
| 235 // Use streams since nacl doesn't compile base yet (for StringPrintf). | 234 // Use streams since nacl doesn't compile base yet (for StringPrintf). |
| 236 std::ostringstream cookie_name; | 235 std::ostringstream script; |
| 237 cookie_name << "PPAPI_PROGRESS_" << progress_cookie_number_; | 236 script << "window.domAutomationController.setAutomationId(0);" << |
| 238 SetCookie(cookie_name.str(), progress_value); | 237 "window.domAutomationController.send(\"" << progress_value << "\")"; |
| 239 progress_cookie_number_++; | 238 EvalScript(script.str()); |
| 240 } | 239 } |
| 241 | 240 |
| 242 class Module : public pp::Module { | 241 class Module : public pp::Module { |
| 243 public: | 242 public: |
| 244 Module() : pp::Module() {} | 243 Module() : pp::Module() {} |
| 245 virtual ~Module() {} | 244 virtual ~Module() {} |
| 246 | 245 |
| 247 virtual pp::Instance* CreateInstance(PP_Instance instance) { | 246 virtual pp::Instance* CreateInstance(PP_Instance instance) { |
| 248 return new TestingInstance(instance); | 247 return new TestingInstance(instance); |
| 249 } | 248 } |
| 250 }; | 249 }; |
| 251 | 250 |
| 252 namespace pp { | 251 namespace pp { |
| 253 | 252 |
| 254 Module* CreateModule() { | 253 Module* CreateModule() { |
| 255 return new ::Module(); | 254 return new ::Module(); |
| 256 } | 255 } |
| 257 | 256 |
| 258 } // namespace pp | 257 } // namespace pp |
| OLD | NEW |