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 "base/basictypes.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "chrome/browser/browser_about_handler.h"
8 #include "chrome/common/about_handler.h"
9 #include "chrome/common/url_constants.h"
10 #include "chrome/test/testing_browser_process_test.h"
11 #include "chrome/test/testing_profile.h"
12 #include "content/browser/browser_thread.h"
13 #include "googleurl/src/gurl.h"
14 #include "testing/gtest/include/gtest/gtest.h"
16 typedef TestingBrowserProcessTest BrowserAboutHandlerTest
;
18 TEST_F(BrowserAboutHandlerTest
, WillHandleBrowserAboutURL
) {
19 std::string
chrome_prefix(chrome::kChromeUIScheme
);
20 chrome_prefix
.append(chrome::kStandardSchemeSeparator
);
21 struct AboutURLTestData
{
28 GURL("http://google.com"),
29 GURL("http://google.com"),
34 GURL(chrome::kAboutBlankURL
),
35 GURL(chrome::kAboutBlankURL
),
40 GURL(chrome_prefix
+ chrome::kChromeUICrashHost
),
41 GURL(chrome_prefix
+ chrome::kChromeUICrashHost
),
46 GURL(chrome_prefix
+ chrome::kChromeUIKillHost
),
47 GURL(chrome_prefix
+ chrome::kChromeUIKillHost
),
52 GURL(chrome_prefix
+ chrome::kChromeUIHangHost
),
53 GURL(chrome_prefix
+ chrome::kChromeUIHangHost
),
58 GURL(chrome_prefix
+ chrome::kChromeUIShorthangHost
),
59 GURL(chrome_prefix
+ chrome::kChromeUIShorthangHost
),
64 GURL(chrome_prefix
+ chrome::kChromeUIMemoryHost
),
65 GURL(chrome_prefix
+ chrome::kChromeUIMemoryHost
),
70 GURL(chrome_prefix
+ chrome::kChromeUIDefaultHost
),
71 GURL(chrome_prefix
+ chrome::kChromeUIVersionHost
),
76 GURL(chrome_prefix
+ chrome::kChromeUIAboutHost
),
77 GURL(chrome_prefix
+ chrome::kChromeUIChromeURLsHost
),
82 GURL(chrome_prefix
+ chrome::kChromeUICacheHost
),
83 GURL(chrome_prefix
+ chrome::kChromeUINetworkViewCacheHost
),
88 GURL(chrome_prefix
+ chrome::kChromeUIGpuHost
),
89 GURL(chrome_prefix
+ chrome::kChromeUIGpuInternalsHost
),
94 GURL(chrome_prefix
+ chrome::kChromeUISyncHost
),
95 GURL(chrome_prefix
+ chrome::kChromeUISyncInternalsHost
),
100 GURL(chrome_prefix
+ "host/path?query#ref"),
101 GURL(chrome_prefix
+ "host/path?query#ref"),
106 MessageLoopForUI message_loop
;
107 BrowserThread
ui_thread(BrowserThread::UI
, &message_loop
);
108 TestingProfile profile
;
110 for (size_t i
= 0; i
< ARRAYSIZE_UNSAFE(test_data
); ++i
) {
111 GURL
url(test_data
[i
].test_url
);
112 EXPECT_EQ(test_data
[i
].about_handled
,
113 chrome_about_handler::WillHandle(url
));
114 EXPECT_EQ(test_data
[i
].browser_handled
,
115 WillHandleBrowserAboutURL(&url
, &profile
));
116 EXPECT_EQ(test_data
[i
].result_url
, url
);
119 // Crash the browser process for about:inducebrowsercrashforrealz.
120 GURL
url(chrome::kAboutBrowserCrash
);
121 EXPECT_DEATH(WillHandleBrowserAboutURL(&url
, NULL
), "");