OLD | NEW |
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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/files/scoped_file.h" | 14 #include "base/files/scoped_file.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
19 #include "base/values.h" | 19 #include "base/values.h" |
20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/io_thread.h" | 21 #include "chrome/browser/io_thread.h" |
22 #include "chrome/browser/prerender/prerender_manager.h" | 22 #include "chrome/browser/prerender/prerender_manager.h" |
23 #include "chrome/browser/prerender/prerender_manager_factory.h" | 23 #include "chrome/browser/prerender/prerender_manager_factory.h" |
24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
26 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 26 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
27 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" | 27 #include "chrome/browser/ui/webui/net_internals/net_internals_ui.h" |
28 #include "chrome/common/channel_info.h" | 28 #include "chrome/common/channel_info.h" |
29 #include "chrome/common/chrome_switches.h" | |
30 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
31 #include "chrome/test/base/ui_test_utils.h" | 30 #include "chrome/test/base/ui_test_utils.h" |
32 #include "components/net_log/chrome_net_log.h" | 31 #include "components/net_log/chrome_net_log.h" |
33 #include "components/prefs/pref_service.h" | 32 #include "components/prefs/pref_service.h" |
34 #include "content/public/browser/render_frame_host.h" | 33 #include "content/public/browser/render_frame_host.h" |
35 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
36 #include "content/public/browser/web_ui_message_handler.h" | 35 #include "content/public/browser/web_ui_message_handler.h" |
37 #include "net/base/address_list.h" | 36 #include "net/base/address_list.h" |
38 #include "net/base/net_errors.h" | 37 #include "net/base/net_errors.h" |
39 #include "net/dns/host_cache.h" | 38 #include "net/dns/host_cache.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 //////////////////////////////////////////////////////////////////////////////// | 322 //////////////////////////////////////////////////////////////////////////////// |
324 | 323 |
325 NetInternalsTest::NetInternalsTest() | 324 NetInternalsTest::NetInternalsTest() |
326 : test_server_started_(false) { | 325 : test_server_started_(false) { |
327 message_handler_.reset(new MessageHandler(this)); | 326 message_handler_.reset(new MessageHandler(this)); |
328 } | 327 } |
329 | 328 |
330 NetInternalsTest::~NetInternalsTest() { | 329 NetInternalsTest::~NetInternalsTest() { |
331 } | 330 } |
332 | 331 |
333 void NetInternalsTest::SetUpCommandLine(base::CommandLine* command_line) { | |
334 WebUIBrowserTest::SetUpCommandLine(command_line); | |
335 // Needed to test the prerender view. | |
336 command_line->AppendSwitchASCII(switches::kPrerenderMode, | |
337 switches::kPrerenderModeSwitchValueEnabled); | |
338 } | |
339 | |
340 void NetInternalsTest::SetUpOnMainThread() { | 332 void NetInternalsTest::SetUpOnMainThread() { |
341 WebUIBrowserTest::SetUpOnMainThread(); | 333 WebUIBrowserTest::SetUpOnMainThread(); |
342 // Increase the memory allowed in a prerendered page above normal settings, | 334 // Increase the memory allowed in a prerendered page above normal settings, |
343 // as debug builds use more memory and often go over the usual limit. | 335 // as debug builds use more memory and often go over the usual limit. |
344 Profile* profile = browser()->profile(); | 336 Profile* profile = browser()->profile(); |
345 prerender::PrerenderManager* prerender_manager = | 337 prerender::PrerenderManager* prerender_manager = |
346 prerender::PrerenderManagerFactory::GetForBrowserContext(profile); | 338 prerender::PrerenderManagerFactory::GetForBrowserContext(profile); |
347 prerender_manager->mutable_config().max_bytes = 1000 * 1024 * 1024; | 339 prerender_manager->mutable_config().max_bytes = 1000 * 1024 * 1024; |
348 } | 340 } |
349 | 341 |
(...skipping 18 matching lines...) Expand all Loading... |
368 if (test_server_started_) | 360 if (test_server_started_) |
369 return true; | 361 return true; |
370 test_server_started_ = embedded_test_server()->Start(); | 362 test_server_started_ = embedded_test_server()->Start(); |
371 | 363 |
372 // Sample domain for SDCH-view test. Dictionaries for localhost/127.0.0.1 | 364 // Sample domain for SDCH-view test. Dictionaries for localhost/127.0.0.1 |
373 // are forbidden. | 365 // are forbidden. |
374 host_resolver()->AddRule("testdomain.com", "127.0.0.1"); | 366 host_resolver()->AddRule("testdomain.com", "127.0.0.1"); |
375 host_resolver()->AddRule("sub.testdomain.com", "127.0.0.1"); | 367 host_resolver()->AddRule("sub.testdomain.com", "127.0.0.1"); |
376 return test_server_started_; | 368 return test_server_started_; |
377 } | 369 } |
OLD | NEW |