| OLD | NEW |
| 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 "content/public/browser/resource_request_details.h" | 5 #include "content/public/browser/resource_request_details.h" |
| 6 #include "content/public/test/browser_test_utils.h" | 6 #include "content/public/test/browser_test_utils.h" |
| 7 #include "content/public/test/content_browser_test.h" | 7 #include "content/public/test/content_browser_test.h" |
| 8 #include "content/public/test/content_browser_test_utils.h" | 8 #include "content/public/test/content_browser_test_utils.h" |
| 9 #include "content/shell/browser/shell.h" | 9 #include "content/shell/browser/shell.h" |
| 10 #include "net/dns/mock_host_resolver.h" | 10 #include "net/dns/mock_host_resolver.h" |
| 11 #include "net/test/embedded_test_server/embedded_test_server.h" | 11 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 12 | 12 |
| 13 namespace content { | 13 namespace content { |
| 14 | 14 |
| 15 class NavigationObserver: public WebContentsObserver { | 15 class NavigationObserver: public WebContentsObserver { |
| 16 public: | 16 public: |
| 17 explicit NavigationObserver(WebContents* web_contents) | 17 explicit NavigationObserver(WebContents* web_contents) |
| 18 : WebContentsObserver(web_contents) {} | 18 : WebContentsObserver(web_contents) {} |
| 19 virtual ~NavigationObserver() {} | 19 ~NavigationObserver() override {} |
| 20 | 20 |
| 21 virtual void DidCommitProvisionalLoadForFrame( | 21 void DidCommitProvisionalLoadForFrame( |
| 22 RenderFrameHost* render_frame_host, | 22 RenderFrameHost* render_frame_host, |
| 23 const GURL& url, | 23 const GURL& url, |
| 24 ui::PageTransition transition_type) override { | 24 ui::PageTransition transition_type) override { |
| 25 navigation_url_ = url; | 25 navigation_url_ = url; |
| 26 } | 26 } |
| 27 | 27 |
| 28 virtual void DidGetRedirectForResourceRequest( | 28 void DidGetRedirectForResourceRequest( |
| 29 RenderViewHost* render_view_host, | 29 RenderViewHost* render_view_host, |
| 30 const ResourceRedirectDetails& details) override { | 30 const ResourceRedirectDetails& details) override { |
| 31 redirect_url_ = details.new_url; | 31 redirect_url_ = details.new_url; |
| 32 } | 32 } |
| 33 | 33 |
| 34 const GURL& navigation_url() const { | 34 const GURL& navigation_url() const { |
| 35 return navigation_url_; | 35 return navigation_url_; |
| 36 } | 36 } |
| 37 | 37 |
| 38 const GURL& redirect_url() const { | 38 const GURL& redirect_url() const { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 std::string foo_com("foo.com"); | 74 std::string foo_com("foo.com"); |
| 75 GURL expected_url(embedded_test_server()->GetURL("/title2.html")); | 75 GURL expected_url(embedded_test_server()->GetURL("/title2.html")); |
| 76 replace_host.SetHostStr(foo_com); | 76 replace_host.SetHostStr(foo_com); |
| 77 expected_url = expected_url.ReplaceComponents(replace_host); | 77 expected_url = expected_url.ReplaceComponents(replace_host); |
| 78 | 78 |
| 79 EXPECT_EQ(expected_url, observer.navigation_url()); | 79 EXPECT_EQ(expected_url, observer.navigation_url()); |
| 80 EXPECT_EQ(observer.redirect_url(), observer.navigation_url()); | 80 EXPECT_EQ(observer.redirect_url(), observer.navigation_url()); |
| 81 } | 81 } |
| 82 | 82 |
| 83 } // namespace content | 83 } // namespace content |
| OLD | NEW |