Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: chrome/browser/browser_about_handler_unittest.cc

Issue 7068007: Revise about: and chrome: url handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update special_tabs.py from Nirnimesh's codereview.chromium.org/6995057/. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "chrome/browser/browser_about_handler.h" 7 #include "chrome/browser/browser_about_handler.h"
8 #include "chrome/common/about_handler.h" 8 #include "chrome/common/about_handler.h"
9 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
10 #include "chrome/test/testing_browser_process_test.h" 10 #include "chrome/test/testing_browser_process_test.h"
11 #include "chrome/test/testing_profile.h" 11 #include "chrome/test/testing_profile.h"
12 #include "content/browser/browser_thread.h" 12 #include "content/browser/browser_thread.h"
13 #include "googleurl/src/gurl.h" 13 #include "googleurl/src/gurl.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 typedef TestingBrowserProcessTest BrowserAboutHandlerTest; 16 typedef TestingBrowserProcessTest BrowserAboutHandlerTest;
17 17
18 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURL) { 18 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURL) {
19 std::string chrome_prefix(chrome::kChromeUIScheme);
20 chrome_prefix.append(chrome::kStandardSchemeSeparator);
19 struct AboutURLTestData { 21 struct AboutURLTestData {
20 GURL test_url; 22 GURL test_url;
21 GURL result_url; 23 GURL result_url;
22 bool about_handled; 24 bool about_handled;
23 bool browser_handled; 25 bool browser_handled;
24 } test_data[] = { 26 } test_data[] = {
25 { 27 {
26 GURL("http://google.com"), 28 GURL("http://google.com"),
27 GURL("http://google.com"), 29 GURL("http://google.com"),
28 false, 30 false,
29 false 31 false
30 }, 32 },
31 { 33 {
32 GURL(chrome::kAboutBlankURL), 34 GURL(chrome::kAboutBlankURL),
33 GURL(chrome::kAboutBlankURL), 35 GURL(chrome::kAboutBlankURL),
34 false, 36 false,
35 false 37 false
36 }, 38 },
37 { 39 {
38 GURL(std::string(chrome::kAboutCacheURL) + "/mercury"), 40 GURL(chrome_prefix + chrome::kChromeUICrashHost),
39 GURL(std::string(chrome::kNetworkViewCacheURL) + "mercury"), 41 GURL(chrome_prefix + chrome::kChromeUICrashHost),
42 true,
43 false
44 },
45 {
46 GURL(chrome_prefix + chrome::kChromeUIKillHost),
47 GURL(chrome_prefix + chrome::kChromeUIKillHost),
48 true,
49 false
50 },
51 {
52 GURL(chrome_prefix + chrome::kChromeUIHangHost),
53 GURL(chrome_prefix + chrome::kChromeUIHangHost),
54 true,
55 false
56 },
57 {
58 GURL(chrome_prefix + chrome::kChromeUIShorthangHost),
59 GURL(chrome_prefix + chrome::kChromeUIShorthangHost),
60 true,
61 false
62 },
63 {
64 GURL(chrome_prefix + chrome::kChromeUIMemoryHost),
65 GURL(chrome_prefix + chrome::kChromeUIMemoryHost),
40 false, 66 false,
41 true 67 true
42 }, 68 },
43 { 69 {
44 GURL(std::string(chrome::kAboutNetInternalsURL) + "/venus"), 70 GURL(chrome_prefix + chrome::kChromeUIDefaultHost),
45 GURL(std::string(chrome::kNetworkViewInternalsURL) + "venus"), 71 GURL(chrome_prefix + chrome::kChromeUIVersionHost),
46 false, 72 false,
47 true 73 true
48 }, 74 },
49 { 75 {
50 GURL(std::string(chrome::kAboutGpuURL) + "/jupiter"), 76 GURL(chrome_prefix + chrome::kChromeUIAboutHost),
51 GURL(std::string(chrome::kGpuInternalsURL) + "jupiter"), 77 GURL(chrome_prefix + chrome::kChromeUIChromeURLsHost),
52 false, 78 false,
53 true 79 true
54 }, 80 },
55 { 81 {
56 GURL(std::string(chrome::kAboutAppCacheInternalsURL) + "/earth"), 82 GURL(chrome_prefix + chrome::kChromeUICacheHost),
57 GURL(std::string(chrome::kAppCacheViewInternalsURL) + "earth"), 83 GURL(chrome_prefix + chrome::kChromeUINetworkViewCacheHost),
58 false, 84 false,
59 true 85 true
60 }, 86 },
61 { 87 {
62 GURL(chrome::kAboutPluginsURL), 88 GURL(chrome_prefix + chrome::kChromeUIGpuHost),
63 GURL(chrome::kChromeUIPluginsURL), 89 GURL(chrome_prefix + chrome::kChromeUIGpuInternalsHost),
64 false, 90 false,
65 true 91 true
66 }, 92 },
67 { 93 {
68 GURL(chrome::kAboutCrashURL), 94 GURL(chrome_prefix + chrome::kChromeUISyncHost),
69 GURL(chrome::kAboutCrashURL), 95 GURL(chrome_prefix + chrome::kChromeUISyncInternalsHost),
70 true,
71 false
72 },
73 {
74 GURL(chrome::kAboutKillURL),
75 GURL(chrome::kAboutKillURL),
76 true,
77 false
78 },
79 {
80 GURL(chrome::kAboutHangURL),
81 GURL(chrome::kAboutHangURL),
82 true,
83 false
84 },
85 {
86 GURL(chrome::kAboutShorthangURL),
87 GURL(chrome::kAboutShorthangURL),
88 true,
89 false
90 },
91 {
92 GURL("about:memory"),
93 GURL("chrome://about/memory-redirect"),
94 false, 96 false,
95 true 97 true
96 }, 98 },
97 { 99 {
98 GURL("about:mars"), 100 GURL(chrome_prefix + "host/path?query#ref"),
99 GURL("chrome://about/mars"), 101 GURL(chrome_prefix + "host/path?query#ref"),
100 false, 102 false,
101 true 103 true
102 }, 104 }
103 }; 105 };
104 MessageLoopForUI message_loop; 106 MessageLoopForUI message_loop;
105 BrowserThread ui_thread(BrowserThread::UI, &message_loop); 107 BrowserThread ui_thread(BrowserThread::UI, &message_loop);
106 TestingProfile profile; 108 TestingProfile profile;
107 109
108 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) { 110 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) {
109 GURL url(test_data[i].test_url); 111 GURL url(test_data[i].test_url);
110 EXPECT_EQ(test_data[i].about_handled, 112 EXPECT_EQ(test_data[i].about_handled,
111 chrome_about_handler::WillHandle(url)); 113 chrome_about_handler::WillHandle(url));
112 EXPECT_EQ(test_data[i].browser_handled, 114 EXPECT_EQ(test_data[i].browser_handled,
113 WillHandleBrowserAboutURL(&url, &profile)); 115 WillHandleBrowserAboutURL(&url, &profile));
114 EXPECT_EQ(test_data[i].result_url, url); 116 EXPECT_EQ(test_data[i].result_url, url);
115 } 117 }
116 118
117 // Crash the browser process for about:inducebrowsercrashforrealz. 119 // Crash the browser process for about:inducebrowsercrashforrealz.
118 GURL url(chrome::kAboutBrowserCrash); 120 GURL url(chrome::kAboutBrowserCrash);
119 EXPECT_DEATH(WillHandleBrowserAboutURL(&url, NULL), ""); 121 EXPECT_DEATH(WillHandleBrowserAboutURL(&url, NULL), "");
120 } 122 }
OLDNEW
« no previous file with comments | « chrome/browser/browser_about_handler.cc ('k') | chrome/browser/chrome_content_browser_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698