Print Preview: Changing displayed error message when PDF Viewer is missing.
[chromium-blink-merge.git] / chrome / browser / browser_about_handler_unittest.cc
blob064e807b44281c9a88a04e33df7d59bdec093e1f
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 {
22 GURL test_url;
23 GURL result_url;
24 bool about_handled;
25 bool browser_handled;
26 } test_data[] = {
28 GURL("http://google.com"),
29 GURL("http://google.com"),
30 false,
31 false
34 GURL(chrome::kAboutBlankURL),
35 GURL(chrome::kAboutBlankURL),
36 false,
37 false
40 GURL(chrome_prefix + chrome::kChromeUICrashHost),
41 GURL(chrome_prefix + chrome::kChromeUICrashHost),
42 true,
43 false
46 GURL(chrome_prefix + chrome::kChromeUIKillHost),
47 GURL(chrome_prefix + chrome::kChromeUIKillHost),
48 true,
49 false
52 GURL(chrome_prefix + chrome::kChromeUIHangHost),
53 GURL(chrome_prefix + chrome::kChromeUIHangHost),
54 true,
55 false
58 GURL(chrome_prefix + chrome::kChromeUIShorthangHost),
59 GURL(chrome_prefix + chrome::kChromeUIShorthangHost),
60 true,
61 false
64 GURL(chrome_prefix + chrome::kChromeUIMemoryHost),
65 GURL(chrome_prefix + chrome::kChromeUIMemoryHost),
66 false,
67 true
70 GURL(chrome_prefix + chrome::kChromeUIDefaultHost),
71 GURL(chrome_prefix + chrome::kChromeUIVersionHost),
72 false,
73 true
76 GURL(chrome_prefix + chrome::kChromeUIAboutHost),
77 GURL(chrome_prefix + chrome::kChromeUIChromeURLsHost),
78 false,
79 true
82 GURL(chrome_prefix + chrome::kChromeUICacheHost),
83 GURL(chrome_prefix + chrome::kChromeUINetworkViewCacheHost),
84 false,
85 true
88 GURL(chrome_prefix + chrome::kChromeUIGpuHost),
89 GURL(chrome_prefix + chrome::kChromeUIGpuInternalsHost),
90 false,
91 true
94 GURL(chrome_prefix + chrome::kChromeUISyncHost),
95 GURL(chrome_prefix + chrome::kChromeUISyncInternalsHost),
96 false,
97 true
100 GURL(chrome_prefix + "host/path?query#ref"),
101 GURL(chrome_prefix + "host/path?query#ref"),
102 false,
103 true
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), "");