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

Side by Side Diff: chrome/browser/extensions/background_xhr_browsertest.cc

Issue 1409163006: Migrating tests to use EmbeddedTestServer (/chrome/browser misc) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 1 month 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "chrome/browser/extensions/extension_browsertest.h" 8 #include "chrome/browser/extensions/extension_browsertest.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_io_data.h" 10 #include "chrome/browser/profiles/profile_io_data.h"
11 #include "chrome/browser/ui/browser.h" 11 #include "chrome/browser/ui/browser.h"
12 #include "chrome/test/base/ui_test_utils.h" 12 #include "chrome/test/base/ui_test_utils.h"
13 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
14 #include "extensions/common/extension.h" 14 #include "extensions/common/extension.h"
15 #include "extensions/test/result_catcher.h" 15 #include "extensions/test/result_catcher.h"
16 #include "net/base/escape.h" 16 #include "net/base/escape.h"
17 #include "net/base/url_util.h" 17 #include "net/base/url_util.h"
18 #include "net/ssl/client_cert_store.h" 18 #include "net/ssl/client_cert_store.h"
19 #include "net/test/spawned_test_server/spawned_test_server.h" 19 #include "net/ssl/ssl_server_config.h"
20 #include "net/test/embedded_test_server/embedded_test_server.h"
20 #include "url/gurl.h" 21 #include "url/gurl.h"
21 22
22 namespace { 23 namespace {
23 24
24 scoped_ptr<net::ClientCertStore> CreateNullCertStore() { 25 scoped_ptr<net::ClientCertStore> CreateNullCertStore() {
25 return nullptr; 26 return nullptr;
26 } 27 }
27 28
28 void InstallNullCertStoreFactoryOnIOThread( 29 void InstallNullCertStoreFactoryOnIOThread(
29 content::ResourceContext* resource_context) { 30 content::ResourceContext* resource_context) {
(...skipping 26 matching lines...) Expand all
56 // to the system certificate store returning no certificates. 57 // to the system certificate store returning no certificates.
57 base::RunLoop loop; 58 base::RunLoop loop;
58 content::BrowserThread::PostTaskAndReply( 59 content::BrowserThread::PostTaskAndReply(
59 content::BrowserThread::IO, FROM_HERE, 60 content::BrowserThread::IO, FROM_HERE,
60 base::Bind(&InstallNullCertStoreFactoryOnIOThread, 61 base::Bind(&InstallNullCertStoreFactoryOnIOThread,
61 browser()->profile()->GetResourceContext()), 62 browser()->profile()->GetResourceContext()),
62 loop.QuitClosure()); 63 loop.QuitClosure());
63 loop.Run(); 64 loop.Run();
64 65
65 // Launch HTTPS server. 66 // Launch HTTPS server.
66 net::SpawnedTestServer::SSLOptions ssl_options; 67 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
67 ssl_options.request_client_certificate = true; 68 net::SSLServerConfig ssl_config;
68 net::SpawnedTestServer https_server( 69 ssl_config.require_client_cert = true;
69 net::SpawnedTestServer::TYPE_HTTPS, ssl_options, 70 https_server.SetSSLConfig(net::EmbeddedTestServer::CERT_OK, ssl_config);
70 base::FilePath(FILE_PATH_LITERAL("content/test/data"))); 71 https_server.ServeFilesFromSourceDirectory("content/test/data");
71 ASSERT_TRUE(https_server.Start()); 72 ASSERT_TRUE(https_server.Start());
72 73
73 ASSERT_NO_FATAL_FAILURE( 74 ASSERT_NO_FATAL_FAILURE(
74 RunTest("test_tls_client_auth.html", https_server.GetURL(""))); 75 RunTest("test_tls_client_auth.html", https_server.GetURL("/")));
75 } 76 }
76 77
77 // Test that fetching a URL using HTTP auth doesn't crash, hang, or prompt. 78 // Test that fetching a URL using HTTP auth doesn't crash, hang, or prompt.
78 IN_PROC_BROWSER_TEST_F(BackgroundXhrTest, HttpAuth) { 79 IN_PROC_BROWSER_TEST_F(BackgroundXhrTest, HttpAuth) {
79 ASSERT_TRUE(test_server()->Start()); 80 ASSERT_TRUE(embedded_test_server()->Start());
80 ASSERT_NO_FATAL_FAILURE( 81 ASSERT_NO_FATAL_FAILURE(RunTest(
81 RunTest("test_http_auth.html", test_server()->GetURL("auth-basic"))); 82 "test_http_auth.html", embedded_test_server()->GetURL("/auth-basic")));
82 } 83 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_process_apitest.cc ('k') | chrome/browser/extensions/chrome_app_api_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698