Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: chrome/test/ppapi/ppapi_test.cc

Issue 10827357: Add NaCl smoke test to browser_tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: VS2010 fix? Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/nacl/nacl_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/test/ppapi/ppapi_test.h" 5 #include "chrome/test/ppapi/ppapi_test.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 159
160 void PPAPITestBase::RunTestAndReload(const std::string& test_case) { 160 void PPAPITestBase::RunTestAndReload(const std::string& test_case) {
161 GURL url = GetTestFileUrl(test_case); 161 GURL url = GetTestFileUrl(test_case);
162 RunTestURL(url); 162 RunTestURL(url);
163 // If that passed, we simply run the test again, which navigates again. 163 // If that passed, we simply run the test again, which navigates again.
164 RunTestURL(url); 164 RunTestURL(url);
165 } 165 }
166 166
167 void PPAPITestBase::RunTestViaHTTP(const std::string& test_case) { 167 void PPAPITestBase::RunTestViaHTTP(const std::string& test_case) {
168 FilePath document_root; 168 FilePath document_root;
169 ASSERT_TRUE(GetHTTPDocumentRoot(&document_root)); 169 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&document_root));
170 RunHTTPTestServer(document_root, test_case, ""); 170 RunHTTPTestServer(document_root, test_case, "");
171 } 171 }
172 172
173 void PPAPITestBase::RunTestWithSSLServer(const std::string& test_case) { 173 void PPAPITestBase::RunTestWithSSLServer(const std::string& test_case) {
174 FilePath document_root; 174 FilePath document_root;
175 ASSERT_TRUE(GetHTTPDocumentRoot(&document_root)); 175 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&document_root));
176 net::TestServer test_server(net::BaseTestServer::HTTPSOptions(), 176 net::TestServer test_server(net::BaseTestServer::HTTPSOptions(),
177 document_root); 177 document_root);
178 ASSERT_TRUE(test_server.Start()); 178 ASSERT_TRUE(test_server.Start());
179 uint16_t port = test_server.host_port_pair().port(); 179 uint16_t port = test_server.host_port_pair().port();
180 RunHTTPTestServer(document_root, test_case, 180 RunHTTPTestServer(document_root, test_case,
181 StringPrintf("ssl_server_port=%d", port)); 181 StringPrintf("ssl_server_port=%d", port));
182 } 182 }
183 183
184 void PPAPITestBase::RunTestWithWebSocketServer(const std::string& test_case) { 184 void PPAPITestBase::RunTestWithWebSocketServer(const std::string& test_case) {
185 FilePath websocket_root_dir; 185 FilePath websocket_root_dir;
186 ASSERT_TRUE( 186 ASSERT_TRUE(
187 PathService::Get(content::DIR_LAYOUT_TESTS, &websocket_root_dir)); 187 PathService::Get(content::DIR_LAYOUT_TESTS, &websocket_root_dir));
188 content::TestWebSocketServer server; 188 content::TestWebSocketServer server;
189 int port = server.UseRandomPort(); 189 int port = server.UseRandomPort();
190 ASSERT_TRUE(server.Start(websocket_root_dir)); 190 ASSERT_TRUE(server.Start(websocket_root_dir));
191 FilePath http_document_root; 191 FilePath http_document_root;
192 ASSERT_TRUE(GetHTTPDocumentRoot(&http_document_root)); 192 ASSERT_TRUE(ui_test_utils::GetRelativeBuildDirectory(&http_document_root));
193 RunHTTPTestServer(http_document_root, test_case, 193 RunHTTPTestServer(http_document_root, test_case,
194 StringPrintf("websocket_port=%d", port)); 194 StringPrintf("websocket_port=%d", port));
195 } 195 }
196 196
197 void PPAPITestBase::RunTestIfAudioOutputAvailable( 197 void PPAPITestBase::RunTestIfAudioOutputAvailable(
198 const std::string& test_case) { 198 const std::string& test_case) {
199 if (IsAudioOutputAvailable()) { 199 if (IsAudioOutputAvailable()) {
200 RunTest(test_case); 200 RunTest(test_case);
201 } else { 201 } else {
202 LOG(WARNING) << "PPAPITest: " << test_case << 202 LOG(WARNING) << "PPAPITest: " << test_case <<
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 document_root); 249 document_root);
250 ASSERT_TRUE(test_server.Start()); 250 ASSERT_TRUE(test_server.Start());
251 std::string query = BuildQuery("files/test_case.html?", test_case); 251 std::string query = BuildQuery("files/test_case.html?", test_case);
252 if (!extra_params.empty()) 252 if (!extra_params.empty())
253 query = StringPrintf("%s&%s", query.c_str(), extra_params.c_str()); 253 query = StringPrintf("%s&%s", query.c_str(), extra_params.c_str());
254 254
255 GURL url = test_server.GetURL(query); 255 GURL url = test_server.GetURL(query);
256 RunTestURL(url); 256 RunTestURL(url);
257 } 257 }
258 258
259 bool PPAPITestBase::GetHTTPDocumentRoot(FilePath* document_root) {
260 // For HTTP tests, we use the output DIR to grab the generated files such
261 // as the NEXEs.
262 FilePath exe_dir = CommandLine::ForCurrentProcess()->GetProgram().DirName();
263 FilePath src_dir;
264 if (!PathService::Get(base::DIR_SOURCE_ROOT, &src_dir))
265 return false;
266
267 // TestServer expects a path relative to source. So we must first
268 // generate absolute paths to SRC and EXE and from there generate
269 // a relative path.
270 if (!exe_dir.IsAbsolute()) file_util::AbsolutePath(&exe_dir);
271 if (!src_dir.IsAbsolute()) file_util::AbsolutePath(&src_dir);
272 if (!exe_dir.IsAbsolute())
273 return false;
274 if (!src_dir.IsAbsolute())
275 return false;
276
277 size_t match, exe_size, src_size;
278 std::vector<FilePath::StringType> src_parts, exe_parts;
279
280 // Determine point at which src and exe diverge, and create a relative path.
281 exe_dir.GetComponents(&exe_parts);
282 src_dir.GetComponents(&src_parts);
283 exe_size = exe_parts.size();
284 src_size = src_parts.size();
285 for (match = 0; match < exe_size && match < src_size; ++match) {
286 if (exe_parts[match] != src_parts[match])
287 break;
288 }
289 for (size_t tmp_itr = match; tmp_itr < src_size; ++tmp_itr) {
290 *document_root = document_root->Append(FILE_PATH_LITERAL(".."));
291 }
292 for (; match < exe_size; ++match) {
293 *document_root = document_root->Append(exe_parts[match]);
294 }
295 return true;
296 }
297
298 PPAPITest::PPAPITest() { 259 PPAPITest::PPAPITest() {
299 } 260 }
300 261
301 void PPAPITest::SetUpCommandLine(CommandLine* command_line) { 262 void PPAPITest::SetUpCommandLine(CommandLine* command_line) {
302 PPAPITestBase::SetUpCommandLine(command_line); 263 PPAPITestBase::SetUpCommandLine(command_line);
303 264
304 // Append the switch to register the pepper plugin. 265 // Append the switch to register the pepper plugin.
305 // library name = <out dir>/<test_name>.<library_extension> 266 // library name = <out dir>/<test_name>.<library_extension>
306 // MIME type = application/x-ppapi-<test_name> 267 // MIME type = application/x-ppapi-<test_name>
307 FilePath plugin_dir; 268 FilePath plugin_dir;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 } 331 }
371 332
372 // Append the correct mode and testcase string 333 // Append the correct mode and testcase string
373 std::string PPAPINaClTestDisallowedSockets::BuildQuery( 334 std::string PPAPINaClTestDisallowedSockets::BuildQuery(
374 const std::string& base, 335 const std::string& base,
375 const std::string& test_case) { 336 const std::string& test_case) {
376 return StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(), 337 return StringPrintf("%smode=nacl_newlib&testcase=%s", base.c_str(),
377 test_case.c_str()); 338 test_case.c_str());
378 } 339 }
379 340
OLDNEW
« no previous file with comments | « chrome/test/nacl/nacl_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698