Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / webui / chrome_url_data_manager_browsertest.cc
blob7cbe0f6e9f97731b812a30479aa9e7ecdd7a5ce6
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
3 // found in the LICENSE file.
5 #include "chrome/common/url_constants.h"
6 #include "chrome/test/base/in_process_browser_test.h"
7 #include "chrome/test/base/ui_test_utils.h"
8 #include "content/public/browser/navigation_details.h"
9 #include "content/public/browser/notification_registrar.h"
10 #include "content/public/browser/notification_service.h"
11 #include "content/public/browser/notification_source.h"
12 #include "content/public/browser/notification_types.h"
14 namespace {
16 class NavigationNotificationObserver : public content::NotificationObserver {
17 public:
18 NavigationNotificationObserver()
19 : got_navigation_(false),
20 http_status_code_(0) {
21 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
22 content::NotificationService::AllSources());
25 virtual void Observe(int type,
26 const content::NotificationSource& source,
27 const content::NotificationDetails& details) OVERRIDE {
28 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type);
29 got_navigation_ = true;
30 http_status_code_ =
31 content::Details<content::LoadCommittedDetails>(details)->
32 http_status_code;
35 int http_status_code() const { return http_status_code_; }
36 bool got_navigation() const { return got_navigation_; }
38 private:
39 content::NotificationRegistrar registrar_;
40 int got_navigation_;
41 int http_status_code_;
43 DISALLOW_COPY_AND_ASSIGN(NavigationNotificationObserver);
46 } // namespace
48 typedef InProcessBrowserTest ChromeURLDataManagerTest;
50 // Makes sure navigating to the new tab page results in a http status code
51 // of 200.
52 IN_PROC_BROWSER_TEST_F(ChromeURLDataManagerTest, 200) {
53 NavigationNotificationObserver observer;
54 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
55 EXPECT_TRUE(observer.got_navigation());
56 EXPECT_EQ(200, observer.http_status_code());