blob: 543b7f85b6e8c0ce5ab42f67cae3db50531d21fe [file] [log] [blame]
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/common/url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/notification_types.h"
namespace {
class NavigationNotificationObserver : public content::NotificationObserver {
public:
NavigationNotificationObserver()
: got_navigation_(false),
http_status_code_(0) {
registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
content::NotificationService::AllSources());
}
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override {
DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type);
got_navigation_ = true;
http_status_code_ =
content::Details<content::LoadCommittedDetails>(details)->
http_status_code;
}
int http_status_code() const { return http_status_code_; }
bool got_navigation() const { return got_navigation_; }
private:
content::NotificationRegistrar registrar_;
int got_navigation_;
int http_status_code_;
DISALLOW_COPY_AND_ASSIGN(NavigationNotificationObserver);
};
} // namespace
typedef InProcessBrowserTest ChromeURLDataManagerTest;
// Makes sure navigating to the new tab page results in a http status code
// of 200.
IN_PROC_BROWSER_TEST_F(ChromeURLDataManagerTest, 200) {
NavigationNotificationObserver observer;
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
EXPECT_TRUE(observer.got_navigation());
EXPECT_EQ(200, observer.http_status_code());
}
// Makes sure browser does not crash when the resource scale is very large.
IN_PROC_BROWSER_TEST_F(ChromeURLDataManagerTest, ResourceScaleTest) {
ui_test_utils::NavigateToURL(
browser(), GURL("chrome://theme/IDR_SETTINGS_FAVICON@2x"));
ui_test_utils::NavigateToURL(
browser(), GURL("chrome://theme/IDR_SETTINGS_FAVICON@99999x"));
}