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