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

Side by Side Diff: content/browser/renderer_host/render_view_host_unittest.cc

Issue 636673002: Remove navigation from TestRenderViewHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a TODO Created 6 years, 2 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
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 "base/path_service.h" 5 #include "base/path_service.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "content/browser/child_process_security_policy_impl.h" 7 #include "content/browser/child_process_security_policy_impl.h"
8 #include "content/browser/frame_host/render_frame_host_impl.h" 8 #include "content/browser/frame_host/render_frame_host_impl.h"
9 #include "content/browser/renderer_host/render_message_filter.h" 9 #include "content/browser/renderer_host/render_message_filter.h"
10 #include "content/browser/renderer_host/render_view_host_delegate_view.h" 10 #include "content/browser/renderer_host/render_view_host_delegate_view.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 private: 57 private:
58 RenderViewHostTestBrowserClient test_browser_client_; 58 RenderViewHostTestBrowserClient test_browser_client_;
59 ContentBrowserClient* old_browser_client_; 59 ContentBrowserClient* old_browser_client_;
60 60
61 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTest); 61 DISALLOW_COPY_AND_ASSIGN(RenderViewHostTest);
62 }; 62 };
63 63
64 // All about URLs reported by the renderer should get rewritten to about:blank. 64 // All about URLs reported by the renderer should get rewritten to about:blank.
65 // See RenderViewHost::OnNavigate for a discussion. 65 // See RenderViewHost::OnNavigate for a discussion.
66 TEST_F(RenderViewHostTest, FilterAbout) { 66 TEST_F(RenderViewHostTest, FilterAbout) {
67 test_rvh()->SendNavigate(1, GURL("about:cache")); 67 contents()->GetMainFrame()->SendNavigate(1, GURL("about:cache"));
68 ASSERT_TRUE(controller().GetVisibleEntry()); 68 ASSERT_TRUE(controller().GetVisibleEntry());
69 EXPECT_EQ(GURL(url::kAboutBlankURL), 69 EXPECT_EQ(GURL(url::kAboutBlankURL),
70 controller().GetVisibleEntry()->GetURL()); 70 controller().GetVisibleEntry()->GetURL());
71 } 71 }
72 72
73 // Create a full screen popup RenderWidgetHost and View. 73 // Create a full screen popup RenderWidgetHost and View.
74 TEST_F(RenderViewHostTest, CreateFullscreenWidget) { 74 TEST_F(RenderViewHostTest, CreateFullscreenWidget) {
75 int routing_id = process()->GetNextRoutingID(); 75 int routing_id = process()->GetNextRoutingID();
76 test_rvh()->CreateNewFullscreenWidget(routing_id); 76 test_rvh()->CreateNewFullscreenWidget(routing_id);
77 } 77 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 test_rvh()->TestOnUpdateStateWithFile(-1, file_path); 225 test_rvh()->TestOnUpdateStateWithFile(-1, file_path);
226 EXPECT_EQ(1, process()->bad_msg_count()); 226 EXPECT_EQ(1, process()->bad_msg_count());
227 } 227 }
228 228
229 TEST_F(RenderViewHostTest, NavigationWithBadHistoryItemFiles) { 229 TEST_F(RenderViewHostTest, NavigationWithBadHistoryItemFiles) {
230 GURL url("http://www.google.com"); 230 GURL url("http://www.google.com");
231 base::FilePath file_path; 231 base::FilePath file_path;
232 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path)); 232 EXPECT_TRUE(PathService::Get(base::DIR_TEMP, &file_path));
233 file_path = file_path.AppendASCII("bar"); 233 file_path = file_path.AppendASCII("bar");
234 EXPECT_EQ(0, process()->bad_msg_count()); 234 EXPECT_EQ(0, process()->bad_msg_count());
235 test_rvh()->SendNavigateWithFile(1, url, file_path); 235 contents()->GetMainFrame()->SendNavigateWithFile(1, url, file_path);
236 EXPECT_EQ(1, process()->bad_msg_count()); 236 EXPECT_EQ(1, process()->bad_msg_count());
237 237
238 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile( 238 ChildProcessSecurityPolicyImpl::GetInstance()->GrantReadFile(
239 process()->GetID(), file_path); 239 process()->GetID(), file_path);
240 test_rvh()->SendNavigateWithFile(process()->GetID(), url, file_path); 240 contents()->GetMainFrame()->SendNavigateWithFile(process()->GetID(), url,
241 file_path);
241 EXPECT_EQ(1, process()->bad_msg_count()); 242 EXPECT_EQ(1, process()->bad_msg_count());
242 } 243 }
243 244
244 TEST_F(RenderViewHostTest, RoutingIdSane) { 245 TEST_F(RenderViewHostTest, RoutingIdSane) {
245 RenderFrameHostImpl* root_rfh = 246 RenderFrameHostImpl* root_rfh =
246 contents()->GetFrameTree()->root()->current_frame_host(); 247 contents()->GetFrameTree()->root()->current_frame_host();
248 EXPECT_EQ(contents()->GetMainFrame(), root_rfh);
247 EXPECT_EQ(test_rvh()->GetProcess(), root_rfh->GetProcess()); 249 EXPECT_EQ(test_rvh()->GetProcess(), root_rfh->GetProcess());
248 EXPECT_NE(test_rvh()->GetRoutingID(), root_rfh->routing_id()); 250 EXPECT_NE(test_rvh()->GetRoutingID(), root_rfh->routing_id());
249 } 251 }
250 252
251 class TestSaveImageFromDataURL : public RenderMessageFilter { 253 class TestSaveImageFromDataURL : public RenderMessageFilter {
252 public: 254 public:
253 TestSaveImageFromDataURL( 255 TestSaveImageFromDataURL(
254 BrowserContext* context) 256 BrowserContext* context)
255 : RenderMessageFilter( 257 : RenderMessageFilter(
256 0, 258 0,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 const std::string data_url = "data:image/gif;base64," 311 const std::string data_url = "data:image/gif;base64,"
310 "R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="; 312 "R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=";
311 313
312 tester->Reset(); 314 tester->Reset();
313 tester->Test(data_url); 315 tester->Test(data_url);
314 EXPECT_EQ(tester->UrlString(), data_url); 316 EXPECT_EQ(tester->UrlString(), data_url);
315 EXPECT_TRUE(tester->IsDownloaded()); 317 EXPECT_TRUE(tester->IsDownloaded());
316 } 318 }
317 319
318 } // namespace content 320 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/render_frame_host_manager_unittest.cc ('k') | content/public/test/test_renderer_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698