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

Side by Side Diff: content/renderer/browser_render_view_browsertest.cc

Issue 190663012: Run ContentMain in a browser_test's browser process. This removes duplication of code in the browse… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: try to fix android by restoring old path just for it Created 6 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // Browser tests targeted at the RenderView that run in browser context. 5 // Browser tests targeted at the RenderView that run in browser context.
6 // Note that these tests rely on single-process mode, and hence may be 6 // Note that these tests rely on single-process mode, and hence may be
7 // disabled in some configurations (check gyp files). 7 // disabled in some configurations (check gyp files).
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 if (net::OK == cache->GetBackend(backend_ptr, backend_callback)) { 130 if (net::OK == cache->GetBackend(backend_ptr, backend_callback)) {
131 // The call completed synchronously, so GetBackend didn't run the callback. 131 // The call completed synchronously, so GetBackend didn't run the callback.
132 backend_callback.Run(net::OK); 132 backend_callback.Run(net::OK);
133 } 133 }
134 } 134 }
135 135
136 } // namespace 136 } // namespace
137 137
138 class RenderViewBrowserTest : public ContentBrowserTest { 138 class RenderViewBrowserTest : public ContentBrowserTest {
139 public: 139 public:
140 RenderViewBrowserTest() : renderer_client_(NULL) {} 140 RenderViewBrowserTest() {}
141 141
142 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 142 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
143 // This method is needed to allow interaction with in-process renderer 143 // This method is needed to allow interaction with in-process renderer
144 // and use of a test ContentRendererClient. 144 // and use of a test ContentRendererClient.
145 command_line->AppendSwitch(switches::kSingleProcess); 145 command_line->AppendSwitch(switches::kSingleProcess);
146 } 146 }
147 147
148 virtual void SetUp() OVERRIDE { 148 virtual void SetUpOnMainThread() OVERRIDE {
149 // Override setting of renderer client. 149 // Override setting of renderer client.
150 renderer_client_ = new TestShellContentRendererClient(); 150 renderer_client_.reset(new TestShellContentRendererClient());
151 SetContentRendererClient( 151 SetRendererClientForTesting(renderer_client_.get());
152 scoped_ptr<ContentRendererClient>(renderer_client_).Pass());
153
154 ContentBrowserTest::SetUp();
155 } 152 }
156 153
157 // Navigates to the given URL and waits for |num_navigations| to occur, and 154 // Navigates to the given URL and waits for |num_navigations| to occur, and
158 // the title to change to |expected_title|. 155 // the title to change to |expected_title|.
159 void NavigateToURLAndWaitForTitle(const GURL& url, 156 void NavigateToURLAndWaitForTitle(const GURL& url,
160 const std::string& expected_title, 157 const std::string& expected_title,
161 int num_navigations) { 158 int num_navigations) {
162 content::TitleWatcher title_watcher( 159 content::TitleWatcher title_watcher(
163 shell()->web_contents(), base::ASCIIToUTF16(expected_title)); 160 shell()->web_contents(), base::ASCIIToUTF16(expected_title));
164 161
165 content::NavigateToURLBlockUntilNavigationsComplete( 162 content::NavigateToURLBlockUntilNavigationsComplete(
166 shell(), url, num_navigations); 163 shell(), url, num_navigations);
167 164
168 EXPECT_EQ(base::ASCIIToUTF16(expected_title), 165 EXPECT_EQ(base::ASCIIToUTF16(expected_title),
169 title_watcher.WaitAndGetTitle()); 166 title_watcher.WaitAndGetTitle());
170 } 167 }
171 168
172 // Returns true if there is a valid error stored; in this case 169 // Returns true if there is a valid error stored; in this case
173 // |*error_code| and |*stale_cache_entry_present| will be updated 170 // |*error_code| and |*stale_cache_entry_present| will be updated
174 // appropriately. 171 // appropriately.
175 // Must be called after the renderer thread is created. 172 // Must be called after the renderer thread is created.
176 bool GetLatestErrorFromRendererClient( 173 bool GetLatestErrorFromRendererClient(
177 int* error_code, bool* stale_cache_entry_present) { 174 int* error_code, bool* stale_cache_entry_present) {
178 bool result = false; 175 bool result = false;
179 176
180 PostTaskToInProcessRendererAndWait( 177 PostTaskToInProcessRendererAndWait(
181 base::Bind(&RenderViewBrowserTest::GetLatestErrorFromRendererClient0, 178 base::Bind(&RenderViewBrowserTest::GetLatestErrorFromRendererClient0,
182 renderer_client_, &result, error_code, 179 renderer_client_.get(), &result, error_code,
183 stale_cache_entry_present)); 180 stale_cache_entry_present));
184 return result; 181 return result;
185 } 182 }
186 183
187 private: 184 private:
188 // Must be run on renderer thread. 185 // Must be run on renderer thread.
189 static void GetLatestErrorFromRendererClient0( 186 static void GetLatestErrorFromRendererClient0(
190 TestShellContentRendererClient* renderer_client, 187 TestShellContentRendererClient* renderer_client,
191 bool* result, int* error_code, bool* stale_cache_entry_present) { 188 bool* result, int* error_code, bool* stale_cache_entry_present) {
192 *result = renderer_client->GetLatestError( 189 *result = renderer_client->GetLatestError(
193 error_code, stale_cache_entry_present); 190 error_code, stale_cache_entry_present);
194 } 191 }
195 192
196 // Actually owned by the superclass, so safe to keep a bare pointer. 193 scoped_ptr<TestShellContentRendererClient> renderer_client_;
197 TestShellContentRendererClient* renderer_client_;
198 }; 194 };
199 195
200 #if defined(OS_ANDROID) 196 #if defined(OS_ANDROID)
201 // Flaky https://crbug.com/341745 197 // Flaky https://crbug.com/341745
202 #define MAYBE_ConfirmCacheInformationPlumbed DISABLED_ConfirmCacheInformationPlu mbed 198 #define MAYBE_ConfirmCacheInformationPlumbed DISABLED_ConfirmCacheInformationPlu mbed
203 #else 199 #else
204 #define MAYBE_ConfirmCacheInformationPlumbed ConfirmCacheInformationPlumbed 200 #define MAYBE_ConfirmCacheInformationPlumbed ConfirmCacheInformationPlumbed
205 #endif 201 #endif
206 202
207 IN_PROC_BROWSER_TEST_F(RenderViewBrowserTest, 203 IN_PROC_BROWSER_TEST_F(RenderViewBrowserTest,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 241
246 error_code = net::OK; 242 error_code = net::OK;
247 stale_cache_entry_present = true; 243 stale_cache_entry_present = true;
248 ASSERT_TRUE(GetLatestErrorFromRendererClient( 244 ASSERT_TRUE(GetLatestErrorFromRendererClient(
249 &error_code, &stale_cache_entry_present)); 245 &error_code, &stale_cache_entry_present));
250 EXPECT_EQ(net::ERR_FAILED, error_code); 246 EXPECT_EQ(net::ERR_FAILED, error_code);
251 EXPECT_FALSE(stale_cache_entry_present); 247 EXPECT_FALSE(stale_cache_entry_present);
252 } 248 }
253 249
254 } // namespace content 250 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin_browsertest.cc ('k') | content/renderer/render_thread_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698