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

Side by Side Diff: chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.cc

Issue 1378123003: Adding SSL ETS Tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ets
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 (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/browser/ui/webui/net_internals/net_internals_ui_browsertest.h" 5 #include "chrome/browser/ui/webui/net_internals/net_internals_ui_browsertest.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h" 11 #include "base/files/file_util.h"
12 #include "base/files/scoped_file.h" 12 #include "base/files/scoped_file.h"
13 #include "base/prefs/pref_service.h" 13 #include "base/prefs/pref_service.h"
14 #include "base/strings/string_split.h"
14 #include "base/strings/stringprintf.h" 15 #include "base/strings/stringprintf.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/io_thread.h" 19 #include "chrome/browser/io_thread.h"
19 #include "chrome/browser/prerender/prerender_manager.h" 20 #include "chrome/browser/prerender/prerender_manager.h"
20 #include "chrome/browser/prerender/prerender_manager_factory.h" 21 #include "chrome/browser/prerender/prerender_manager_factory.h"
21 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/ui/browser.h" 23 #include "chrome/browser/ui/browser.h"
23 #include "chrome/browser/ui/tabs/tab_strip_model.h" 24 #include "chrome/browser/ui/tabs/tab_strip_model.h"
24 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" 25 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h"
25 #include "chrome/common/channel_info.h" 26 #include "chrome/common/channel_info.h"
26 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
27 #include "chrome/test/base/ui_test_utils.h" 28 #include "chrome/test/base/ui_test_utils.h"
28 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_ names.h" 29 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_ names.h"
29 #include "components/net_log/chrome_net_log.h" 30 #include "components/net_log/chrome_net_log.h"
30 #include "content/public/browser/render_frame_host.h" 31 #include "content/public/browser/render_frame_host.h"
31 #include "content/public/browser/web_contents.h" 32 #include "content/public/browser/web_contents.h"
32 #include "content/public/browser/web_ui_message_handler.h" 33 #include "content/public/browser/web_ui_message_handler.h"
33 #include "net/base/address_list.h" 34 #include "net/base/address_list.h"
34 #include "net/base/net_errors.h" 35 #include "net/base/net_errors.h"
35 #include "net/dns/host_cache.h" 36 #include "net/dns/host_cache.h"
36 #include "net/dns/host_resolver.h" 37 #include "net/dns/host_resolver.h"
37 #include "net/dns/mock_host_resolver.h" 38 #include "net/dns/mock_host_resolver.h"
38 #include "net/http/http_network_session.h" 39 #include "net/http/http_network_session.h"
39 #include "net/http/http_transaction_factory.h" 40 #include "net/http/http_transaction_factory.h"
40 #include "net/log/net_log.h" 41 #include "net/log/net_log.h"
41 #include "net/log/write_to_file_net_log_observer.h" 42 #include "net/log/write_to_file_net_log_observer.h"
43 #include "net/test/embedded_test_server/request_handler_util.h"
42 #include "net/url_request/url_request_context.h" 44 #include "net/url_request/url_request_context.h"
43 #include "net/url_request/url_request_context_getter.h" 45 #include "net/url_request/url_request_context_getter.h"
44 #include "testing/gtest/include/gtest/gtest.h" 46 #include "testing/gtest/include/gtest/gtest.h"
45 #include "url/gurl.h" 47 #include "url/gurl.h"
46 48
47 using content::BrowserThread; 49 using content::BrowserThread;
48 using content::WebUIMessageHandler; 50 using content::WebUIMessageHandler;
49 51
50 namespace { 52 namespace {
51 53
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 void NetInternalsTest::MessageHandler::RunJavascriptCallback( 186 void NetInternalsTest::MessageHandler::RunJavascriptCallback(
185 base::Value* value) { 187 base::Value* value) {
186 web_ui()->CallJavascriptFunction("NetInternalsTest.callback", *value); 188 web_ui()->CallJavascriptFunction("NetInternalsTest.callback", *value);
187 } 189 }
188 190
189 void NetInternalsTest::MessageHandler::GetTestServerURL( 191 void NetInternalsTest::MessageHandler::GetTestServerURL(
190 const base::ListValue* list_value) { 192 const base::ListValue* list_value) {
191 ASSERT_TRUE(net_internals_test_->StartTestServer()); 193 ASSERT_TRUE(net_internals_test_->StartTestServer());
192 std::string path; 194 std::string path;
193 ASSERT_TRUE(list_value->GetString(0, &path)); 195 ASSERT_TRUE(list_value->GetString(0, &path));
194 GURL url = net_internals_test_->test_server()->GetURL(path); 196 GURL url = net_internals_test_->embedded_test_server()->GetURL(path);
195 scoped_ptr<base::Value> url_value(new base::StringValue(url.spec())); 197 scoped_ptr<base::Value> url_value(new base::StringValue(url.spec()));
196 RunJavascriptCallback(url_value.get()); 198 RunJavascriptCallback(url_value.get());
197 } 199 }
198 200
199 void NetInternalsTest::MessageHandler::AddCacheEntry( 201 void NetInternalsTest::MessageHandler::AddCacheEntry(
200 const base::ListValue* list_value) { 202 const base::ListValue* list_value) {
201 std::string hostname; 203 std::string hostname;
202 std::string ip_literal; 204 std::string ip_literal;
203 double net_error; 205 double net_error;
204 double expire_days_from_now; 206 double expire_days_from_now;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 prerender_manager->mutable_config().max_bytes = 1000 * 1024 * 1024; 347 prerender_manager->mutable_config().max_bytes = 1000 * 1024 * 1024;
346 } 348 }
347 349
348 content::WebUIMessageHandler* NetInternalsTest::GetMockMessageHandler() { 350 content::WebUIMessageHandler* NetInternalsTest::GetMockMessageHandler() {
349 return message_handler_.get(); 351 return message_handler_.get();
350 } 352 }
351 353
352 GURL NetInternalsTest::CreatePrerenderLoaderUrl( 354 GURL NetInternalsTest::CreatePrerenderLoaderUrl(
353 const GURL& prerender_url) { 355 const GURL& prerender_url) {
354 EXPECT_TRUE(StartTestServer()); 356 EXPECT_TRUE(StartTestServer());
355 std::vector<net::SpawnedTestServer::StringPair> replacement_text; 357 base::StringPairs replacement_text;
356 replacement_text.push_back( 358 replacement_text.push_back(
357 make_pair("REPLACE_WITH_PRERENDER_URL", prerender_url.spec())); 359 make_pair("REPLACE_WITH_PRERENDER_URL", prerender_url.spec()));
358 std::string replacement_path; 360 std::string replacement_path;
359 EXPECT_TRUE(net::SpawnedTestServer::GetFilePathWithReplacements( 361 net::test_server::GetFilePathWithReplacements(
360 "files/prerender/prerender_loader.html", 362 "/prerender/prerender_loader.html", replacement_text, &replacement_path);
361 replacement_text, 363 GURL url_loader = embedded_test_server()->GetURL(replacement_path);
362 &replacement_path));
363 GURL url_loader = test_server()->GetURL(replacement_path);
364 return url_loader; 364 return url_loader;
365 } 365 }
366 366
367 bool NetInternalsTest::StartTestServer() { 367 bool NetInternalsTest::StartTestServer() {
368 if (test_server_started_) 368 if (test_server_started_)
369 return true; 369 return true;
370 test_server_started_ = test_server()->Start(); 370 test_server_started_ = embedded_test_server()->Start();
371 371
372 // Sample domain for SDCH-view test. Dictionaries for localhost/127.0.0.1 372 // Sample domain for SDCH-view test. Dictionaries for localhost/127.0.0.1
373 // are forbidden. 373 // are forbidden.
374 host_resolver()->AddRule("testdomain.com", "127.0.0.1"); 374 host_resolver()->AddRule("testdomain.com", "127.0.0.1");
375 host_resolver()->AddRule("sub.testdomain.com", "127.0.0.1"); 375 host_resolver()->AddRule("sub.testdomain.com", "127.0.0.1");
376 return test_server_started_; 376 return test_server_started_;
377 } 377 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/inspect_ui_browsertest.cc ('k') | chrome/browser/ui/webui/webui_webview_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698