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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 virtual void GetNavigationErrorStrings( |
53 content::RenderView* render_view, | 53 content::RenderView* render_view, |
54 blink::WebFrame* frame, | 54 blink::WebFrame* frame, |
55 const blink::WebURLRequest& failed_request, | 55 const blink::WebURLRequest& failed_request, |
56 const blink::WebURLError& error, | 56 const blink::WebURLError& error, |
57 std::string* error_html, | 57 std::string* error_html, |
58 base::string16* error_description) OVERRIDE { | 58 base::string16* error_description) override { |
59 if (error_html) | 59 if (error_html) |
60 *error_html = "A suffusion of yellow."; | 60 *error_html = "A suffusion of yellow."; |
61 latest_error_valid_ = true; | 61 latest_error_valid_ = true; |
62 latest_error_reason_ = error.reason; | 62 latest_error_reason_ = error.reason; |
63 latest_error_stale_copy_in_cache_ = error.staleCopyInCache; | 63 latest_error_stale_copy_in_cache_ = error.staleCopyInCache; |
64 } | 64 } |
65 | 65 |
66 bool GetLatestError(int* error_code, bool* stale_cache_entry_present) { | 66 bool GetLatestError(int* error_code, bool* stale_cache_entry_present) { |
67 if (latest_error_valid_) { | 67 if (latest_error_valid_) { |
68 *error_code = latest_error_reason_; | 68 *error_code = latest_error_reason_; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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() {} | 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 SetUpOnMainThread() 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_ = new TestShellContentRendererClient(); |
151 // Explicitly leaks ownership; this object will remain alive | 151 // Explicitly leaks ownership; this object will remain alive |
152 // until process death. We don't deleted the returned value, | 152 // until process death. We don't deleted the returned value, |
153 // since some contexts set the pointer to a non-heap address. | 153 // since some contexts set the pointer to a non-heap address. |
154 SetRendererClientForTesting(renderer_client_); | 154 SetRendererClientForTesting(renderer_client_); |
155 } | 155 } |
156 | 156 |
157 // Navigates to the given URL and waits for |num_navigations| to occur, and | 157 // Navigates to the given URL and waits for |num_navigations| to occur, and |
158 // the title to change to |expected_title|. | 158 // the title to change to |expected_title|. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 236 |
237 error_code = net::OK; | 237 error_code = net::OK; |
238 stale_cache_entry_present = true; | 238 stale_cache_entry_present = true; |
239 ASSERT_TRUE(GetLatestErrorFromRendererClient( | 239 ASSERT_TRUE(GetLatestErrorFromRendererClient( |
240 &error_code, &stale_cache_entry_present)); | 240 &error_code, &stale_cache_entry_present)); |
241 EXPECT_EQ(net::ERR_FAILED, error_code); | 241 EXPECT_EQ(net::ERR_FAILED, error_code); |
242 EXPECT_FALSE(stale_cache_entry_present); | 242 EXPECT_FALSE(stale_cache_entry_present); |
243 } | 243 } |
244 | 244 |
245 } // namespace content | 245 } // namespace content |
OLD | NEW |