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

Side by Side Diff: chrome/test/base/in_process_browser_test_browsertest.cc

Issue 2349893002: Change LoadFailObserver to use WebContentsObserver::DidFinishNavigation notification. (Closed)
Patch Set: Created 4 years, 3 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <stddef.h> 5 #include <stddef.h>
6 #include <string.h> 6 #include <string.h>
7 7
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "chrome/browser/after_startup_task_utils.h" 11 #include "chrome/browser/after_startup_task_utils.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 13 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/test/base/in_process_browser_test.h" 14 #include "chrome/test/base/in_process_browser_test.h"
15 #include "chrome/test/base/ui_test_utils.h" 15 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/browser/navigation_handle.h"
16 #include "content/public/browser/render_view_host.h" 17 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/web_contents.h" 18 #include "content/public/browser/web_contents.h"
18 #include "content/public/browser/web_contents_observer.h" 19 #include "content/public/browser/web_contents_observer.h"
19 #include "net/base/filename_util.h" 20 #include "net/base/filename_util.h"
20 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 23
23 namespace { 24 namespace {
24 25
25 class InProcessBrowserTestP 26 class InProcessBrowserTestP
(...skipping 10 matching lines...) Expand all
36 ::testing::Values("foo")); 37 ::testing::Values("foo"));
37 38
38 // WebContents observer that can detect provisional load failures. 39 // WebContents observer that can detect provisional load failures.
39 class LoadFailObserver : public content::WebContentsObserver { 40 class LoadFailObserver : public content::WebContentsObserver {
40 public: 41 public:
41 explicit LoadFailObserver(content::WebContents* contents) 42 explicit LoadFailObserver(content::WebContents* contents)
42 : content::WebContentsObserver(contents), 43 : content::WebContentsObserver(contents),
43 failed_load_(false), 44 failed_load_(false),
44 error_code_(net::OK) { } 45 error_code_(net::OK) { }
45 46
46 void DidFailProvisionalLoad( 47 void DidFinishNavigation(
47 content::RenderFrameHost* render_frame_host, 48 content::NavigationHandle* navigation_handle) override {
48 const GURL& validated_url, 49 if (navigation_handle->GetNetErrorCode() == net::OK)
49 int error_code, 50 return;
50 const base::string16& error_description, 51
51 bool was_ignored_by_handler) override {
52 failed_load_ = true; 52 failed_load_ = true;
53 error_code_ = static_cast<net::Error>(error_code); 53 error_code_ = navigation_handle->GetNetErrorCode();
54 validated_url_ = validated_url; 54 validated_url_ = navigation_handle->GetURL();
55 } 55 }
56 56
57 bool failed_load() const { return failed_load_; } 57 bool failed_load() const { return failed_load_; }
58 net::Error error_code() const { return error_code_; } 58 net::Error error_code() const { return error_code_; }
59 const GURL& validated_url() const { return validated_url_; } 59 const GURL& validated_url() const { return validated_url_; }
60 60
61 private: 61 private:
62 bool failed_load_; 62 bool failed_load_;
63 net::Error error_code_; 63 net::Error error_code_;
64 GURL validated_url_; 64 GURL validated_url_;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 ASSERT_TRUE(NavigateToURL(kFailHTML)); 144 ASSERT_TRUE(NavigateToURL(kFailHTML));
145 145
146 std::string test_result; 146 std::string test_result;
147 EXPECT_FALSE(RunAccessibilityChecks(&test_result)); 147 EXPECT_FALSE(RunAccessibilityChecks(&test_result));
148 148
149 // Error should NOT be empty on failure. 149 // Error should NOT be empty on failure.
150 EXPECT_NE("", test_result); 150 EXPECT_NE("", test_result);
151 } 151 }
152 152
153 } // namespace 153 } // namespace
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