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

Side by Side Diff: chrome/test/nacl/nacl_browsertest_util.cc

Issue 16296005: Split pnacl and nacl mime types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: After (hopefully) last rebase. Created 7 years, 6 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
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/nacl/nacl_browsertest_util.h" 5 #include "chrome/test/nacl/nacl_browsertest_util.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 // glibc/ 170 // glibc/
171 static bool GetNaClVariantRoot(const base::FilePath::StringType& variant, 171 static bool GetNaClVariantRoot(const base::FilePath::StringType& variant,
172 base::FilePath* document_root) { 172 base::FilePath* document_root) {
173 if (!ui_test_utils::GetRelativeBuildDirectory(document_root)) 173 if (!ui_test_utils::GetRelativeBuildDirectory(document_root))
174 return false; 174 return false;
175 *document_root = document_root->Append(FILE_PATH_LITERAL("nacl_test_data")); 175 *document_root = document_root->Append(FILE_PATH_LITERAL("nacl_test_data"));
176 *document_root = document_root->Append(variant); 176 *document_root = document_root->Append(variant);
177 return true; 177 return true;
178 } 178 }
179 179
180 static void AddPnaclParm(const base::FilePath::StringType& url,
181 base::FilePath::StringType* url_with_parm) {
182 if (url.find(FILE_PATH_LITERAL("?")) == base::FilePath::StringType::npos) {
183 *url_with_parm = url + FILE_PATH_LITERAL("?pnacl=1");
184 } else {
185 *url_with_parm = url + FILE_PATH_LITERAL("&pnacl=1");
186 }
187 }
188
180 NaClBrowserTestBase::NaClBrowserTestBase() { 189 NaClBrowserTestBase::NaClBrowserTestBase() {
181 } 190 }
182 191
183 NaClBrowserTestBase::~NaClBrowserTestBase() { 192 NaClBrowserTestBase::~NaClBrowserTestBase() {
184 } 193 }
185 194
186 void NaClBrowserTestBase::SetUpCommandLine(CommandLine* command_line) { 195 void NaClBrowserTestBase::SetUpCommandLine(CommandLine* command_line) {
187 command_line->AppendSwitch(switches::kNoFirstRun); 196 command_line->AppendSwitch(switches::kNoFirstRun);
188 command_line->AppendSwitch(switches::kEnableNaCl); 197 command_line->AppendSwitch(switches::kEnableNaCl);
189 } 198 }
(...skipping 27 matching lines...) Expand all
217 JavascriptTestObserver observer( 226 JavascriptTestObserver observer(
218 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(), 227 browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost(),
219 handler); 228 handler);
220 ui_test_utils::NavigateToURL(browser(), url); 229 ui_test_utils::NavigateToURL(browser(), url);
221 return observer.Run(); 230 return observer.Run();
222 } 231 }
223 232
224 void NaClBrowserTestBase::RunLoadTest( 233 void NaClBrowserTestBase::RunLoadTest(
225 const base::FilePath::StringType& test_file) { 234 const base::FilePath::StringType& test_file) {
226 LoadTestMessageHandler handler; 235 LoadTestMessageHandler handler;
227 bool ok = RunJavascriptTest(TestURL(test_file), &handler); 236 base::FilePath::StringType test_file_with_parm = test_file;
237 if (IsPnacl()) {
238 AddPnaclParm(test_file, &test_file_with_parm);
239 }
240 bool ok = RunJavascriptTest(TestURL(test_file_with_parm), &handler);
228 ASSERT_TRUE(ok) << handler.error_message(); 241 ASSERT_TRUE(ok) << handler.error_message();
229 ASSERT_TRUE(handler.test_passed()) << "Test failed."; 242 ASSERT_TRUE(handler.test_passed()) << "Test failed.";
230 } 243 }
231 244
232 void NaClBrowserTestBase::RunNaClIntegrationTest( 245 void NaClBrowserTestBase::RunNaClIntegrationTest(
233 const base::FilePath::StringType& url_fragment) { 246 const base::FilePath::StringType& url_fragment) {
234 NaClIntegrationMessageHandler handler; 247 NaClIntegrationMessageHandler handler;
235 bool ok = RunJavascriptTest(TestURL(url_fragment), &handler); 248 base::FilePath::StringType url_fragment_with_parm = url_fragment;
249 if (IsPnacl()) {
250 AddPnaclParm(url_fragment, &url_fragment_with_parm);
251 }
252 bool ok = RunJavascriptTest(TestURL(url_fragment_with_parm), &handler);
236 ASSERT_TRUE(ok) << handler.error_message(); 253 ASSERT_TRUE(ok) << handler.error_message();
237 ASSERT_TRUE(handler.test_passed()) << "Test failed."; 254 ASSERT_TRUE(handler.test_passed()) << "Test failed.";
238 } 255 }
239 256
240 bool NaClBrowserTestBase::StartTestServer() { 257 bool NaClBrowserTestBase::StartTestServer() {
241 // Launch the web server. 258 // Launch the web server.
242 base::FilePath document_root; 259 base::FilePath document_root;
243 if (!GetDocumentRoot(&document_root)) 260 if (!GetDocumentRoot(&document_root))
244 return false; 261 return false;
245 test_server_.reset(new net::SpawnedTestServer( 262 test_server_.reset(new net::SpawnedTestServer(
(...skipping 25 matching lines...) Expand all
271 } 288 }
272 289
273 base::FilePath::StringType NaClBrowserTestStatic::Variant() { 290 base::FilePath::StringType NaClBrowserTestStatic::Variant() {
274 return FILE_PATH_LITERAL("static"); 291 return FILE_PATH_LITERAL("static");
275 } 292 }
276 293
277 bool NaClBrowserTestStatic::GetDocumentRoot(base::FilePath* document_root) { 294 bool NaClBrowserTestStatic::GetDocumentRoot(base::FilePath* document_root) {
278 *document_root = base::FilePath(FILE_PATH_LITERAL("chrome/test/data/nacl")); 295 *document_root = base::FilePath(FILE_PATH_LITERAL("chrome/test/data/nacl"));
279 return true; 296 return true;
280 } 297 }
OLDNEW
« no previous file with comments | « chrome/test/nacl/nacl_browsertest.cc ('k') | ppapi/native_client/src/trusted/plugin/json_manifest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698