OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include "ppapi/cpp/module.h" | 10 #include "ppapi/cpp/module.h" |
11 #include "ppapi/cpp/var.h" | 11 #include "ppapi/cpp/var.h" |
12 #include "ppapi/tests/test_case.h" | 12 #include "ppapi/tests/test_case.h" |
13 | 13 |
14 TestCaseFactory* TestCaseFactory::head_ = NULL; | 14 TestCaseFactory* TestCaseFactory::head_ = NULL; |
15 | 15 |
16 // Returns a new heap-allocated test case for the given test, or NULL on | 16 // Returns a new heap-allocated test case for the given test, or NULL on |
17 // failure. | 17 // failure. |
18 TestingInstance::TestingInstance(PP_Instance instance) | 18 TestingInstance::TestingInstance(PP_Instance instance) |
19 : pp::Instance(instance), | 19 : pp::Instance(instance), |
20 current_case_(NULL), | 20 current_case_(NULL), |
21 executed_tests_(false) { | 21 executed_tests_(false), |
| 22 nacl_mode_(false) { |
22 callback_factory_.Initialize(this); | 23 callback_factory_.Initialize(this); |
23 } | 24 } |
24 | 25 |
25 bool TestingInstance::Init(uint32_t argc, const char* argn[], const char* argv[]
) { | 26 bool TestingInstance::Init(uint32_t argc, |
| 27 const char* argn[], |
| 28 const char* argv[]) { |
| 29 for (uint32_t i = 0; i < argc; i++) { |
| 30 if (strcmp(argn[i], "mode") == 0) { |
| 31 if (strcmp(argv[i], "nacl") == 0) |
| 32 nacl_mode_ = true; |
| 33 break; |
| 34 } |
| 35 } |
26 // Create the proper test case from the argument. | 36 // Create the proper test case from the argument. |
27 for (uint32_t i = 0; i < argc; i++) { | 37 for (uint32_t i = 0; i < argc; i++) { |
28 if (strcmp(argn[i], "testcase") == 0) { | 38 if (strcmp(argn[i], "testcase") == 0) { |
29 if (argv[i][0] == '\0') | 39 if (argv[i][0] == '\0') |
30 break; | 40 break; |
31 current_case_ = CaseForTestName(argv[i]); | 41 current_case_ = CaseForTestName(argv[i]); |
32 if (!current_case_) | 42 if (!current_case_) |
33 errors_.append(std::string("Unknown test case ") + argv[i]); | 43 errors_.append(std::string("Unknown test case ") + argv[i]); |
34 else if (!current_case_->Init()) | 44 else if (!current_case_->Init()) |
35 errors_.append(" Test case could not initialize."); | 45 errors_.append(" Test case could not initialize."); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 TestCaseFactory* iter = TestCaseFactory::head_; | 131 TestCaseFactory* iter = TestCaseFactory::head_; |
122 while (iter != NULL) { | 132 while (iter != NULL) { |
123 test_cases.push_back(iter->name_); | 133 test_cases.push_back(iter->name_); |
124 iter = iter->next_; | 134 iter = iter->next_; |
125 } | 135 } |
126 std::sort(test_cases.begin(), test_cases.end()); | 136 std::sort(test_cases.begin(), test_cases.end()); |
127 | 137 |
128 std::string html; | 138 std::string html; |
129 html.append("Available test cases: <dl>"); | 139 html.append("Available test cases: <dl>"); |
130 for (size_t i = 0; i < test_cases.size(); ++i) { | 140 for (size_t i = 0; i < test_cases.size(); ++i) { |
131 html.append("<dd><a href='?"); | 141 html.append("<dd><a href='?testcase="); |
132 html.append(test_cases[i]); | 142 html.append(test_cases[i]); |
| 143 if (nacl_mode_) |
| 144 html.append("&mode=nacl"); |
133 html.append("'>"); | 145 html.append("'>"); |
134 html.append(test_cases[i]); | 146 html.append(test_cases[i]); |
135 html.append("</a></dd>"); | 147 html.append("</a></dd>"); |
136 } | 148 } |
137 html.append("</dl>"); | 149 html.append("</dl>"); |
138 html.append("<button onclick='RunAll()'>Run All Tests</button>"); | 150 html.append("<button onclick='RunAll()'>Run All Tests</button>"); |
139 LogHTML(html); | 151 LogHTML(html); |
140 } | 152 } |
141 | 153 |
142 void TestingInstance::LogError(const std::string& text) { | 154 void TestingInstance::LogError(const std::string& text) { |
(...skipping 30 matching lines...) Expand all Loading... |
173 } | 185 } |
174 }; | 186 }; |
175 | 187 |
176 namespace pp { | 188 namespace pp { |
177 | 189 |
178 Module* CreateModule() { | 190 Module* CreateModule() { |
179 return new ::Module(); | 191 return new ::Module(); |
180 } | 192 } |
181 | 193 |
182 } // namespace pp | 194 } // namespace pp |
OLD | NEW |