blob: 54f45f241e2e5ac22a7ca5e6ac4be20e4a8354de [file] [log] [blame]
[email protected]fea79efe2012-05-02 01:14:011// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]9d1a9e22010-06-11 20:27:042// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "base/basictypes.h"
[email protected]3b63f8f42011-03-28 01:54:156#include "base/memory/scoped_ptr.h"
[email protected]3fc40c142011-12-01 13:09:047#include "base/message_loop.h"
[email protected]9d1a9e22010-06-11 20:27:048#include "chrome/browser/browser_about_handler.h"
9#include "chrome/common/url_constants.h"
[email protected]a4ff9eae2011-08-01 19:58:1610#include "chrome/test/base/testing_profile.h"
[email protected]e97882f2012-06-04 02:23:1711#include "content/public/test/test_browser_thread.h"
[email protected]9d1a9e22010-06-11 20:27:0412#include "googleurl/src/gurl.h"
13#include "testing/gtest/include/gtest/gtest.h"
14
[email protected]631bb742011-11-02 11:29:3915using content::BrowserThread;
16
[email protected]583844c2011-08-27 00:38:3517typedef testing::Test BrowserAboutHandlerTest;
[email protected]bcd98a52011-02-25 07:50:1918
19TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURL) {
[email protected]89f550b2011-06-08 18:34:0320 std::string chrome_prefix(chrome::kChromeUIScheme);
[email protected]fea79efe2012-05-02 01:14:0121 chrome_prefix.append(content::kStandardSchemeSeparator);
[email protected]9d1a9e22010-06-11 20:27:0422 struct AboutURLTestData {
23 GURL test_url;
24 GURL result_url;
[email protected]9d1a9e22010-06-11 20:27:0425 } test_data[] = {
26 {
27 GURL("http://google.com"),
[email protected]8bf1048012012-02-08 01:22:1828 GURL("http://google.com")
[email protected]9d1a9e22010-06-11 20:27:0429 },
30 {
31 GURL(chrome::kAboutBlankURL),
[email protected]8bf1048012012-02-08 01:22:1832 GURL(chrome::kAboutBlankURL)
[email protected]9d1a9e22010-06-11 20:27:0433 },
34 {
[email protected]89f550b2011-06-08 18:34:0335 GURL(chrome_prefix + chrome::kChromeUIMemoryHost),
[email protected]8bf1048012012-02-08 01:22:1836 GURL(chrome_prefix + chrome::kChromeUIMemoryHost)
[email protected]9d1a9e22010-06-11 20:27:0437 },
38 {
[email protected]89f550b2011-06-08 18:34:0339 GURL(chrome_prefix + chrome::kChromeUIDefaultHost),
[email protected]8bf1048012012-02-08 01:22:1840 GURL(chrome_prefix + chrome::kChromeUIVersionHost)
[email protected]9d1a9e22010-06-11 20:27:0441 },
[email protected]89f550b2011-06-08 18:34:0342 {
43 GURL(chrome_prefix + chrome::kChromeUIAboutHost),
[email protected]8bf1048012012-02-08 01:22:1844 GURL(chrome_prefix + chrome::kChromeUIChromeURLsHost)
[email protected]89f550b2011-06-08 18:34:0345 },
46 {
47 GURL(chrome_prefix + chrome::kChromeUICacheHost),
[email protected]46ed0862013-04-14 02:47:5648 GURL(chrome_prefix + content::kChromeUINetworkViewCacheHost)
[email protected]89f550b2011-06-08 18:34:0349 },
50 {
[email protected]df4223a2012-11-20 00:43:0251 GURL(chrome_prefix + chrome::kChromeUISignInInternalsHost),
52 GURL(chrome_prefix + chrome::kChromeUISignInInternalsHost)
53 },
54 {
[email protected]89f550b2011-06-08 18:34:0355 GURL(chrome_prefix + chrome::kChromeUISyncHost),
[email protected]8bf1048012012-02-08 01:22:1856 GURL(chrome_prefix + chrome::kChromeUISyncInternalsHost)
[email protected]89f550b2011-06-08 18:34:0357 },
58 {
59 GURL(chrome_prefix + "host/path?query#ref"),
60 GURL(chrome_prefix + "host/path?query#ref"),
[email protected]89f550b2011-06-08 18:34:0361 }
[email protected]9d1a9e22010-06-11 20:27:0462 };
[email protected]248ce192011-02-10 15:26:3463 MessageLoopForUI message_loop;
[email protected]c38831a12011-10-28 12:44:4964 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
[email protected]248ce192011-02-10 15:26:3465 TestingProfile profile;
[email protected]9d1a9e22010-06-11 20:27:0466
67 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) {
68 GURL url(test_data[i].test_url);
[email protected]8bf1048012012-02-08 01:22:1869 WillHandleBrowserAboutURL(&url, &profile);
[email protected]9d1a9e22010-06-11 20:27:0470 EXPECT_EQ(test_data[i].result_url, url);
71 }
[email protected]9d1a9e22010-06-11 20:27:0472}