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 <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 errors_.append(" Test case could not initialize."); | 46 errors_.append(" Test case could not initialize."); |
47 return true; | 47 return true; |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 // In DidChangeView, we'll dump out a list of all available tests. | 51 // In DidChangeView, we'll dump out a list of all available tests. |
52 return true; | 52 return true; |
53 } | 53 } |
54 | 54 |
55 pp::Var TestingInstance::GetInstanceObject() { | 55 pp::Var TestingInstance::GetInstanceObject() { |
56 return current_case_->GetTestObject(); | 56 if (current_case_) |
| 57 return current_case_->GetTestObject(); |
| 58 |
| 59 return pp::Var(this, NULL); |
57 } | 60 } |
58 | 61 |
59 void TestingInstance::HandleMessage(const pp::Var& message_data) { | 62 void TestingInstance::HandleMessage(const pp::Var& message_data) { |
60 current_case_->HandleMessage(message_data); | 63 current_case_->HandleMessage(message_data); |
61 } | 64 } |
62 | 65 |
63 void TestingInstance::DidChangeView(const pp::Rect& position, | 66 void TestingInstance::DidChangeView(const pp::Rect& position, |
64 const pp::Rect& clip) { | 67 const pp::Rect& clip) { |
65 if (!executed_tests_) { | 68 if (!executed_tests_) { |
66 executed_tests_ = true; | 69 executed_tests_ = true; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 111 |
109 if (!errors_.empty()) { | 112 if (!errors_.empty()) { |
110 // Catch initialization errors and output the current error string to | 113 // Catch initialization errors and output the current error string to |
111 // the console. | 114 // the console. |
112 LogError("Plugin initialization failed: " + errors_); | 115 LogError("Plugin initialization failed: " + errors_); |
113 } else if (!current_case_) { | 116 } else if (!current_case_) { |
114 LogAvailableTests(); | 117 LogAvailableTests(); |
115 errors_.append("FAIL: Only listed tests"); | 118 errors_.append("FAIL: Only listed tests"); |
116 } else { | 119 } else { |
117 current_case_->RunTest(); | 120 current_case_->RunTest(); |
| 121 // Automated PyAuto tests rely on finding the exact strings below. |
| 122 LogHTML(errors_.empty() ? |
| 123 "<span class=\"pass\">[SHUTDOWN]</span> All tests passed." : |
| 124 "<span class=\"fail\">[SHUTDOWN]</span> Some tests failed."); |
118 } | 125 } |
119 | 126 |
120 // Declare we're done by setting a cookie to either "PASS" or the errors. | 127 // Declare we're done by setting a cookie to either "PASS" or the errors. |
121 SetCookie("COMPLETION_COOKIE", errors_.empty() ? "PASS" : errors_); | 128 SetCookie("COMPLETION_COOKIE", errors_.empty() ? "PASS" : errors_); |
122 | 129 |
123 window.Call("DidExecuteTests"); | 130 window.Call("DidExecuteTests"); |
124 } | 131 } |
125 | 132 |
126 TestCase* TestingInstance::CaseForTestName(const char* name) { | 133 TestCase* TestingInstance::CaseForTestName(const char* name) { |
127 TestCaseFactory* iter = TestCaseFactory::head_; | 134 TestCaseFactory* iter = TestCaseFactory::head_; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 } | 200 } |
194 }; | 201 }; |
195 | 202 |
196 namespace pp { | 203 namespace pp { |
197 | 204 |
198 Module* CreateModule() { | 205 Module* CreateModule() { |
199 return new ::Module(); | 206 return new ::Module(); |
200 } | 207 } |
201 | 208 |
202 } // namespace pp | 209 } // namespace pp |
OLD | NEW |