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

Side by Side Diff: content/test/content_browser_test.cc

Issue 138513002: Plumb network stack information about existence of cached copy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporated comments from Matt & Ricardo. Created 6 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "content/test/content_browser_test.h" 5 #include "content/test/content_browser_test.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 CHECK(PathService::Get(DIR_TEST_DATA, &content_test_data_dir)); 48 CHECK(PathService::Get(DIR_TEST_DATA, &content_test_data_dir));
49 embedded_test_server()->ServeFilesFromDirectory(content_test_data_dir); 49 embedded_test_server()->ServeFilesFromDirectory(content_test_data_dir);
50 } 50 }
51 51
52 ContentBrowserTest::~ContentBrowserTest() { 52 ContentBrowserTest::~ContentBrowserTest() {
53 CHECK(setup_called_) << "Overridden SetUp() did not call parent " 53 CHECK(setup_called_) << "Overridden SetUp() did not call parent "
54 "implementation, so test not run."; 54 "implementation, so test not run.";
55 } 55 }
56 56
57 void ContentBrowserTest::SetUp() { 57 void ContentBrowserTest::SetUp() {
58 setup_called_ = true;
59
60 shell_main_delegate_.reset(new ShellMainDelegate); 58 shell_main_delegate_.reset(new ShellMainDelegate);
61 shell_main_delegate_->PreSandboxStartup(); 59 shell_main_delegate_->PreSandboxStartup();
62 60
63 CommandLine* command_line = CommandLine::ForCurrentProcess(); 61 CommandLine* command_line = CommandLine::ForCurrentProcess();
64 command_line->AppendSwitch(switches::kContentBrowserTest); 62 command_line->AppendSwitch(switches::kContentBrowserTest);
65 63
66 SetUpCommandLine(command_line); 64 SetUpCommandLine(command_line);
67 65
68 // Single-process mode is not set in BrowserMain, so process it explicitly, 66 // Single-process mode is not set in BrowserMain, so if a subclass hasn't
69 // and set up renderer. 67 // modified it yet, process it explicitly, and set up renderer.
70 if (command_line->HasSwitch(switches::kSingleProcess)) { 68 if (!single_process_renderer_client_.get() &&
71 single_process_renderer_client_.reset(new ShellContentRendererClient); 69 command_line->HasSwitch(switches::kSingleProcess))
72 SetRendererClientForTesting(single_process_renderer_client_.get()); 70 SetContentRendererClient(
73 } 71 scoped_ptr<ContentRendererClient>(new ShellContentRendererClient));
74 72
75 #if defined(OS_MACOSX) 73 #if defined(OS_MACOSX)
76 // See InProcessBrowserTest::PrepareTestCommandLine(). 74 // See InProcessBrowserTest::PrepareTestCommandLine().
77 base::FilePath subprocess_path; 75 base::FilePath subprocess_path;
78 PathService::Get(base::FILE_EXE, &subprocess_path); 76 PathService::Get(base::FILE_EXE, &subprocess_path);
79 subprocess_path = subprocess_path.DirName().DirName(); 77 subprocess_path = subprocess_path.DirName().DirName();
80 DCHECK_EQ(subprocess_path.BaseName().value(), "Contents"); 78 DCHECK_EQ(subprocess_path.BaseName().value(), "Contents");
81 subprocess_path = subprocess_path.Append( 79 subprocess_path = subprocess_path.Append(
82 "Frameworks/Content Shell Helper.app/Contents/MacOS/Content Shell Helper") ; 80 "Frameworks/Content Shell Helper.app/Contents/MacOS/Content Shell Helper") ;
83 command_line->AppendSwitchPath(switches::kBrowserSubprocessPath, 81 command_line->AppendSwitchPath(switches::kBrowserSubprocessPath,
84 subprocess_path); 82 subprocess_path);
85 #endif 83 #endif
86 84
87 // LinuxInputMethodContextFactory has to be initialized. 85 // LinuxInputMethodContextFactory has to be initialized.
88 #if !defined(OS_CHROMEOS) && defined(USE_AURA) && defined(USE_X11) 86 #if !defined(OS_CHROMEOS) && defined(USE_AURA) && defined(USE_X11)
89 ui::InitializeInputMethodForTesting(); 87 ui::InitializeInputMethodForTesting();
90 #endif 88 #endif
91 89
90 setup_called_ = true;
91
92 BrowserTestBase::SetUp(); 92 BrowserTestBase::SetUp();
93 } 93 }
94 94
95 void ContentBrowserTest::TearDown() { 95 void ContentBrowserTest::TearDown() {
96 BrowserTestBase::TearDown(); 96 BrowserTestBase::TearDown();
97 97
98 // LinuxInputMethodContextFactory has to be shutdown. 98 // LinuxInputMethodContextFactory has to be shutdown.
99 #if !defined(OS_CHROMEOS) && defined(USE_AURA) && defined(USE_X11) 99 #if !defined(OS_CHROMEOS) && defined(USE_AURA) && defined(USE_X11)
100 ui::ShutdownInputMethodForTesting(); 100 ui::ShutdownInputMethodForTesting();
101 #endif 101 #endif
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 #endif 137 #endif
138 138
139 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); 139 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator());
140 !i.IsAtEnd(); i.Advance()) { 140 !i.IsAtEnd(); i.Advance()) {
141 i.GetCurrentValue()->FastShutdownIfPossible(); 141 i.GetCurrentValue()->FastShutdownIfPossible();
142 } 142 }
143 143
144 Shell::CloseAllWindows(); 144 Shell::CloseAllWindows();
145 } 145 }
146 146
147 void ContentBrowserTest::SetContentRendererClient(
148 scoped_ptr<ContentRendererClient> renderer_client) {
149 DCHECK(!setup_called_);
150 single_process_renderer_client_ = renderer_client.Pass();
151 SetRendererClientForTesting(single_process_renderer_client_.get());
152 }
153
147 Shell* ContentBrowserTest::CreateBrowser() { 154 Shell* ContentBrowserTest::CreateBrowser() {
148 return Shell::CreateNewWindow( 155 return Shell::CreateNewWindow(
149 ShellContentBrowserClient::Get()->browser_context(), 156 ShellContentBrowserClient::Get()->browser_context(),
150 GURL(kAboutBlankURL), 157 GURL(kAboutBlankURL),
151 NULL, 158 NULL,
152 MSG_ROUTING_NONE, 159 MSG_ROUTING_NONE,
153 gfx::Size()); 160 gfx::Size());
154 } 161 }
155 162
156 Shell* ContentBrowserTest::CreateOffTheRecordBrowser() { 163 Shell* ContentBrowserTest::CreateOffTheRecordBrowser() {
157 return Shell::CreateNewWindow( 164 return Shell::CreateNewWindow(
158 ShellContentBrowserClient::Get()->off_the_record_browser_context(), 165 ShellContentBrowserClient::Get()->off_the_record_browser_context(),
159 GURL(kAboutBlankURL), 166 GURL(kAboutBlankURL),
160 NULL, 167 NULL,
161 MSG_ROUTING_NONE, 168 MSG_ROUTING_NONE,
162 gfx::Size()); 169 gfx::Size());
163 } 170 }
164 171
165 } // namespace content 172 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698