Add ability to gather metrics to BubbleManager.
[chromium-blink-merge.git] / chrome / browser / ui / webui / chrome_url_data_manager_browsertest.cc
blob543b7f85b6e8c0ce5ab42f67cae3db50531d21fe
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 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());
59 // Makes sure browser does not crash when the resource scale is very large.
60 IN_PROC_BROWSER_TEST_F(ChromeURLDataManagerTest, ResourceScaleTest) {
61 ui_test_utils::NavigateToURL(
62 browser(), GURL("chrome://theme/IDR_SETTINGS_FAVICON@2x"));
64 ui_test_utils::NavigateToURL(
65 browser(), GURL("chrome://theme/IDR_SETTINGS_FAVICON@99999x"));