| Index: ppapi/tests/testing_instance.cc
|
| diff --git a/ppapi/tests/testing_instance.cc b/ppapi/tests/testing_instance.cc
|
| index 58e08907fc217d7e8d4c3a0aa83d67becad7865e..042e703dcf77c2d337791f4031da0cc06c0481f2 100644
|
| --- a/ppapi/tests/testing_instance.cc
|
| +++ b/ppapi/tests/testing_instance.cc
|
| @@ -102,18 +102,16 @@ bool TestingInstance::HandleInputEvent(const pp::InputEvent& event) {
|
| }
|
|
|
| void TestingInstance::EvalScript(const std::string& script) {
|
| - std::string message("TESTING_MESSAGE:EvalScript:");
|
| - message.append(script);
|
| - PostMessage(pp::Var(message));
|
| + SendTestCommand("EvalScript", script);
|
| }
|
|
|
| void TestingInstance::SetCookie(const std::string& name,
|
| const std::string& value) {
|
| - std::string message("TESTING_MESSAGE:SetCookie:");
|
| - message.append(name);
|
| - message.append("=");
|
| - message.append(value);
|
| - PostMessage(pp::Var(message));
|
| + SendTestCommand("SetCookie", name + "=" + value);
|
| +}
|
| +
|
| +void TestingInstance::AddPostCondition(const std::string& script) {
|
| + SendTestCommand("AddPostCondition", script);
|
| }
|
|
|
| void TestingInstance::LogTest(const std::string& test_name,
|
| @@ -150,7 +148,7 @@ void TestingInstance::ExecuteTests(int32_t unused) {
|
| ReportProgress(kProgressSignal);
|
|
|
| // Clear the console.
|
| - PostMessage(pp::Var("TESTING_MESSAGE:ClearConsole"));
|
| + SendTestCommand("ClearConsole");
|
|
|
| if (!errors_.empty()) {
|
| // Catch initialization errors and output the current error string to
|
| @@ -169,7 +167,9 @@ void TestingInstance::ExecuteTests(int32_t unused) {
|
|
|
| // Declare we're done by setting a cookie to either "PASS" or the errors.
|
| ReportProgress(errors_.empty() ? "PASS" : errors_);
|
| - PostMessage(pp::Var("TESTING_MESSAGE:DidExecuteTests"));
|
| + SendTestCommand("DidExecuteTests");
|
| + // Note, DidExecuteTests unloads the plugin. We can't really do anthing after
|
| + // this point.
|
| }
|
|
|
| TestCase* TestingInstance::CaseForTestName(const std::string& name) {
|
| @@ -190,6 +190,18 @@ std::string TestingInstance::FilterForTestName(const std::string& name) {
|
| return "";
|
| }
|
|
|
| +void TestingInstance::SendTestCommand(const std::string& command) {
|
| + std::string msg("TESTING_MESSAGE:");
|
| + msg += command;
|
| + PostMessage(pp::Var(msg));
|
| +}
|
| +
|
| +void TestingInstance::SendTestCommand(const std::string& command,
|
| + const std::string& params) {
|
| + SendTestCommand(command + ":" + params);
|
| +}
|
| +
|
| +
|
| void TestingInstance::LogAvailableTests() {
|
| // Print out a listing of all tests.
|
| std::vector<std::string> test_cases;
|
| @@ -226,9 +238,7 @@ void TestingInstance::LogError(const std::string& text) {
|
| }
|
|
|
| void TestingInstance::LogHTML(const std::string& html) {
|
| - std::string message("TESTING_MESSAGE:LogHTML:");
|
| - message.append(html);
|
| - PostMessage(pp::Var(message));
|
| + SendTestCommand("LogHTML", html);
|
| }
|
|
|
| void TestingInstance::ReportProgress(const std::string& progress_value) {
|
|
|