| 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 // 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 namespace { | 43 namespace { |
| 44 | 44 |
| 45 class TestShellContentRendererClient : public ShellContentRendererClient { | 45 class TestShellContentRendererClient : public ShellContentRendererClient { |
| 46 public: | 46 public: |
| 47 TestShellContentRendererClient() | 47 TestShellContentRendererClient() |
| 48 : latest_error_valid_(false), | 48 : latest_error_valid_(false), |
| 49 latest_error_reason_(0), | 49 latest_error_reason_(0), |
| 50 latest_error_stale_copy_in_cache_(false) {} | 50 latest_error_stale_copy_in_cache_(false) {} |
| 51 | 51 |
| 52 virtual void GetNavigationErrorStrings( | 52 void GetNavigationErrorStrings(content::RenderView* render_view, |
| 53 content::RenderView* render_view, | 53 blink::WebFrame* frame, |
| 54 blink::WebFrame* frame, | 54 const blink::WebURLRequest& failed_request, |
| 55 const blink::WebURLRequest& failed_request, | 55 const blink::WebURLError& error, |
| 56 const blink::WebURLError& error, | 56 std::string* error_html, |
| 57 std::string* error_html, | 57 base::string16* error_description) override { |
| 58 base::string16* error_description) override { | |
| 59 if (error_html) | 58 if (error_html) |
| 60 *error_html = "A suffusion of yellow."; | 59 *error_html = "A suffusion of yellow."; |
| 61 latest_error_valid_ = true; | 60 latest_error_valid_ = true; |
| 62 latest_error_reason_ = error.reason; | 61 latest_error_reason_ = error.reason; |
| 63 latest_error_stale_copy_in_cache_ = error.staleCopyInCache; | 62 latest_error_stale_copy_in_cache_ = error.staleCopyInCache; |
| 64 } | 63 } |
| 65 | 64 |
| 66 bool GetLatestError(int* error_code, bool* stale_cache_entry_present) { | 65 bool GetLatestError(int* error_code, bool* stale_cache_entry_present) { |
| 67 if (latest_error_valid_) { | 66 if (latest_error_valid_) { |
| 68 *error_code = latest_error_reason_; | 67 *error_code = latest_error_reason_; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 backend_callback.Run(net::OK); | 130 backend_callback.Run(net::OK); |
| 132 } | 131 } |
| 133 } | 132 } |
| 134 | 133 |
| 135 } // namespace | 134 } // namespace |
| 136 | 135 |
| 137 class RenderViewBrowserTest : public ContentBrowserTest { | 136 class RenderViewBrowserTest : public ContentBrowserTest { |
| 138 public: | 137 public: |
| 139 RenderViewBrowserTest() {} | 138 RenderViewBrowserTest() {} |
| 140 | 139 |
| 141 virtual void SetUpCommandLine(CommandLine* command_line) override { | 140 void SetUpCommandLine(CommandLine* command_line) override { |
| 142 // This method is needed to allow interaction with in-process renderer | 141 // This method is needed to allow interaction with in-process renderer |
| 143 // and use of a test ContentRendererClient. | 142 // and use of a test ContentRendererClient. |
| 144 command_line->AppendSwitch(switches::kSingleProcess); | 143 command_line->AppendSwitch(switches::kSingleProcess); |
| 145 } | 144 } |
| 146 | 145 |
| 147 virtual void SetUpOnMainThread() override { | 146 void SetUpOnMainThread() override { |
| 148 // Override setting of renderer client. | 147 // Override setting of renderer client. |
| 149 renderer_client_ = new TestShellContentRendererClient(); | 148 renderer_client_ = new TestShellContentRendererClient(); |
| 150 // Explicitly leaks ownership; this object will remain alive | 149 // Explicitly leaks ownership; this object will remain alive |
| 151 // until process death. We don't deleted the returned value, | 150 // until process death. We don't deleted the returned value, |
| 152 // since some contexts set the pointer to a non-heap address. | 151 // since some contexts set the pointer to a non-heap address. |
| 153 SetRendererClientForTesting(renderer_client_); | 152 SetRendererClientForTesting(renderer_client_); |
| 154 } | 153 } |
| 155 | 154 |
| 156 // Navigates to the given URL and waits for |num_navigations| to occur, and | 155 // Navigates to the given URL and waits for |num_navigations| to occur, and |
| 157 // the title to change to |expected_title|. | 156 // the title to change to |expected_title|. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 234 |
| 236 error_code = net::OK; | 235 error_code = net::OK; |
| 237 stale_cache_entry_present = true; | 236 stale_cache_entry_present = true; |
| 238 ASSERT_TRUE(GetLatestErrorFromRendererClient( | 237 ASSERT_TRUE(GetLatestErrorFromRendererClient( |
| 239 &error_code, &stale_cache_entry_present)); | 238 &error_code, &stale_cache_entry_present)); |
| 240 EXPECT_EQ(net::ERR_FAILED, error_code); | 239 EXPECT_EQ(net::ERR_FAILED, error_code); |
| 241 EXPECT_FALSE(stale_cache_entry_present); | 240 EXPECT_FALSE(stale_cache_entry_present); |
| 242 } | 241 } |
| 243 | 242 |
| 244 } // namespace content | 243 } // namespace content |
| OLD | NEW |