blob: 4d52104b6e2aa095d5a81f0c5870422b96202799 [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]8bf1048012012-02-08 01:22:1848 GURL(chrome_prefix + chrome::kChromeUINetworkViewCacheHost)
[email protected]89f550b2011-06-08 18:34:0349 },
50 {
51 GURL(chrome_prefix + chrome::kChromeUIGpuHost),
[email protected]8bf1048012012-02-08 01:22:1852 GURL(chrome_prefix + chrome::kChromeUIGpuInternalsHost)
[email protected]89f550b2011-06-08 18:34:0353 },
54 {
[email protected]df4223a2012-11-20 00:43:0255 GURL(chrome_prefix + chrome::kChromeUISignInInternalsHost),
56 GURL(chrome_prefix + chrome::kChromeUISignInInternalsHost)
57 },
58 {
[email protected]89f550b2011-06-08 18:34:0359 GURL(chrome_prefix + chrome::kChromeUISyncHost),
[email protected]8bf1048012012-02-08 01:22:1860 GURL(chrome_prefix + chrome::kChromeUISyncInternalsHost)
[email protected]89f550b2011-06-08 18:34:0361 },
62 {
63 GURL(chrome_prefix + "host/path?query#ref"),
64 GURL(chrome_prefix + "host/path?query#ref"),
[email protected]89f550b2011-06-08 18:34:0365 }
[email protected]9d1a9e22010-06-11 20:27:0466 };
[email protected]248ce192011-02-10 15:26:3467 MessageLoopForUI message_loop;
[email protected]c38831a12011-10-28 12:44:4968 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
[email protected]248ce192011-02-10 15:26:3469 TestingProfile profile;
[email protected]9d1a9e22010-06-11 20:27:0470
71 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) {
72 GURL url(test_data[i].test_url);
[email protected]8bf1048012012-02-08 01:22:1873 WillHandleBrowserAboutURL(&url, &profile);
[email protected]9d1a9e22010-06-11 20:27:0474 EXPECT_EQ(test_data[i].result_url, url);
75 }
[email protected]9d1a9e22010-06-11 20:27:0476}