OLD | NEW |
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 "chrome/common/url_constants.h" | 5 #include "chrome/common/url_constants.h" |
6 #include "chrome/test/base/in_process_browser_test.h" | 6 #include "chrome/test/base/in_process_browser_test.h" |
7 #include "chrome/test/base/ui_test_utils.h" | 7 #include "chrome/test/base/ui_test_utils.h" |
8 #include "content/public/browser/navigation_details.h" | 8 #include "content/public/browser/navigation_details.h" |
9 #include "content/public/browser/notification_registrar.h" | 9 #include "content/public/browser/notification_registrar.h" |
10 #include "content/public/browser/notification_service.h" | 10 #include "content/public/browser/notification_service.h" |
11 #include "content/public/browser/notification_source.h" | 11 #include "content/public/browser/notification_source.h" |
12 #include "content/public/browser/notification_types.h" | 12 #include "content/public/browser/notification_types.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 class NavigationNotificationObserver : public content::NotificationObserver { | 16 class NavigationNotificationObserver : public content::NotificationObserver { |
17 public: | 17 public: |
18 NavigationNotificationObserver() | 18 NavigationNotificationObserver() |
19 : got_navigation_(false), | 19 : got_navigation_(false), |
20 http_status_code_(0) { | 20 http_status_code_(0) { |
21 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 21 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
22 content::NotificationService::AllSources()); | 22 content::NotificationService::AllSources()); |
23 } | 23 } |
24 | 24 |
25 virtual void Observe(int type, | 25 virtual void Observe(int type, |
26 const content::NotificationSource& source, | 26 const content::NotificationSource& source, |
27 const content::NotificationDetails& details) OVERRIDE { | 27 const content::NotificationDetails& details) override { |
28 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type); | 28 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type); |
29 got_navigation_ = true; | 29 got_navigation_ = true; |
30 http_status_code_ = | 30 http_status_code_ = |
31 content::Details<content::LoadCommittedDetails>(details)-> | 31 content::Details<content::LoadCommittedDetails>(details)-> |
32 http_status_code; | 32 http_status_code; |
33 } | 33 } |
34 | 34 |
35 int http_status_code() const { return http_status_code_; } | 35 int http_status_code() const { return http_status_code_; } |
36 bool got_navigation() const { return got_navigation_; } | 36 bool got_navigation() const { return got_navigation_; } |
37 | 37 |
(...skipping 10 matching lines...) Expand all Loading... |
48 typedef InProcessBrowserTest ChromeURLDataManagerTest; | 48 typedef InProcessBrowserTest ChromeURLDataManagerTest; |
49 | 49 |
50 // Makes sure navigating to the new tab page results in a http status code | 50 // Makes sure navigating to the new tab page results in a http status code |
51 // of 200. | 51 // of 200. |
52 IN_PROC_BROWSER_TEST_F(ChromeURLDataManagerTest, 200) { | 52 IN_PROC_BROWSER_TEST_F(ChromeURLDataManagerTest, 200) { |
53 NavigationNotificationObserver observer; | 53 NavigationNotificationObserver observer; |
54 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); | 54 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
55 EXPECT_TRUE(observer.got_navigation()); | 55 EXPECT_TRUE(observer.got_navigation()); |
56 EXPECT_EQ(200, observer.http_status_code()); | 56 EXPECT_EQ(200, observer.http_status_code()); |
57 } | 57 } |
OLD | NEW |