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

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

Issue 2652413003: Convert CrossSiteRedirectorBrowserTest to use the new navigation callbacks. (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "base/macros.h" 5 #include "base/macros.h"
6 #include "content/public/browser/navigation_handle.h" 6 #include "content/public/browser/navigation_handle.h"
7 #include "content/public/browser/resource_request_details.h" 7 #include "content/public/browser/resource_request_details.h"
8 #include "content/public/test/browser_test_utils.h" 8 #include "content/public/test/browser_test_utils.h"
9 #include "content/public/test/content_browser_test.h" 9 #include "content/public/test/content_browser_test.h"
10 #include "content/public/test/content_browser_test_utils.h" 10 #include "content/public/test/content_browser_test_utils.h"
11 #include "content/shell/browser/shell.h" 11 #include "content/shell/browser/shell.h"
12 #include "net/dns/mock_host_resolver.h" 12 #include "net/dns/mock_host_resolver.h"
13 #include "net/test/embedded_test_server/embedded_test_server.h" 13 #include "net/test/embedded_test_server/embedded_test_server.h"
14 14
15 namespace content { 15 namespace content {
16 16
17 class NavigationObserver: public WebContentsObserver { 17 class NavigationObserver: public WebContentsObserver {
18 public: 18 public:
19 explicit NavigationObserver(WebContents* web_contents) 19 explicit NavigationObserver(WebContents* web_contents)
20 : WebContentsObserver(web_contents) {} 20 : WebContentsObserver(web_contents) {}
21 ~NavigationObserver() override {} 21 ~NavigationObserver() override {}
22 22
23 void DidCommitProvisionalLoadForFrame( 23 void DidFinishNavigation(NavigationHandle* navigation_handle) override {
24 RenderFrameHost* render_frame_host, 24 if (navigation_handle->HasCommitted())
nasko 2017/01/27 00:25:07 Should we use the same approach as the other CL to
jam 2017/01/27 00:37:08 since 1) it doesn't matter in this case since it's
25 const GURL& url, 25 navigation_url_ = navigation_handle->GetURL();
26 ui::PageTransition transition_type) override {
27 navigation_url_ = url;
28 } 26 }
29 27
30 void DidRedirectNavigation(NavigationHandle* handle) override { 28 void DidRedirectNavigation(NavigationHandle* handle) override {
31 redirect_url_ = handle->GetURL(); 29 redirect_url_ = handle->GetURL();
32 } 30 }
33 31
34 const GURL& navigation_url() const { 32 const GURL& navigation_url() const {
35 return navigation_url_; 33 return navigation_url_;
36 } 34 }
37 35
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 GURL::Replacements replace_host; 70 GURL::Replacements replace_host;
73 GURL expected_url(embedded_test_server()->GetURL("/title2.html")); 71 GURL expected_url(embedded_test_server()->GetURL("/title2.html"));
74 replace_host.SetHostStr("foo.com"); 72 replace_host.SetHostStr("foo.com");
75 expected_url = expected_url.ReplaceComponents(replace_host); 73 expected_url = expected_url.ReplaceComponents(replace_host);
76 74
77 EXPECT_EQ(expected_url, observer.navigation_url()); 75 EXPECT_EQ(expected_url, observer.navigation_url());
78 EXPECT_EQ(observer.redirect_url(), observer.navigation_url()); 76 EXPECT_EQ(observer.redirect_url(), observer.navigation_url());
79 } 77 }
80 78
81 } // namespace content 79 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698