Remove no longer needed toolbar layer method.
[chromium-blink-merge.git] / chrome / browser / browser_about_handler_unittest.cc
blob2448653ab24c3e07bfe12580c0d6957945ee5a92
1 // Copyright (c) 2012 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 "base/message_loop/message_loop.h"
8 #include "chrome/browser/browser_about_handler.h"
9 #include "chrome/common/url_constants.h"
10 #include "chrome/test/base/testing_profile.h"
11 #include "content/public/browser/navigation_controller.h"
12 #include "content/public/browser/navigation_entry.h"
13 #include "content/public/common/referrer.h"
14 #include "content/public/test/test_browser_thread.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "url/gurl.h"
18 using content::BrowserThread;
19 using content::NavigationController;
20 using content::NavigationEntry;
21 using content::Referrer;
23 typedef testing::Test BrowserAboutHandlerTest;
25 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURL) {
26 std::string chrome_prefix(content::kChromeUIScheme);
27 chrome_prefix.append(url::kStandardSchemeSeparator);
28 struct AboutURLTestData {
29 GURL test_url;
30 GURL result_url;
31 } test_data[] = {
33 GURL("http://google.com"),
34 GURL("http://google.com")
37 GURL(url::kAboutBlankURL),
38 GURL(url::kAboutBlankURL)
41 GURL(chrome_prefix + chrome::kChromeUIMemoryHost),
42 GURL(chrome_prefix + chrome::kChromeUIMemoryHost)
45 GURL(chrome_prefix + chrome::kChromeUIDefaultHost),
46 GURL(chrome_prefix + chrome::kChromeUIVersionHost)
49 GURL(chrome_prefix + chrome::kChromeUIAboutHost),
50 GURL(chrome_prefix + chrome::kChromeUIChromeURLsHost)
53 GURL(chrome_prefix + chrome::kChromeUICacheHost),
54 GURL(chrome_prefix + content::kChromeUINetworkViewCacheHost)
57 GURL(chrome_prefix + chrome::kChromeUISignInInternalsHost),
58 GURL(chrome_prefix + chrome::kChromeUISignInInternalsHost)
61 GURL(chrome_prefix + chrome::kChromeUISyncHost),
62 GURL(chrome_prefix + chrome::kChromeUISyncInternalsHost)
65 GURL(chrome_prefix + chrome::kChromeUIInvalidationsHost),
66 GURL(chrome_prefix + chrome::kChromeUIInvalidationsHost)
69 GURL(chrome_prefix + "host/path?query#ref"),
70 GURL(chrome_prefix + "host/path?query#ref"),
73 base::MessageLoopForUI message_loop;
74 content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop);
75 TestingProfile profile;
77 for (size_t i = 0; i < arraysize(test_data); ++i) {
78 GURL url(test_data[i].test_url);
79 WillHandleBrowserAboutURL(&url, &profile);
80 EXPECT_EQ(test_data[i].result_url, url);
84 // Ensure that minor BrowserAboutHandler fixup to a URL does not cause us to
85 // keep a separate virtual URL, which would not be updated on redirects.
86 // See https://crbug.com/449829.
87 TEST_F(BrowserAboutHandlerTest, NoVirtualURLForFixup) {
88 GURL url("view-source:http://.foo");
90 // Fixup will remove the dot and add a slash.
91 GURL fixed_url("view-source:http://foo/");
93 // Rewriters will remove the view-source prefix and expect it to stay in the
94 // virtual URL.
95 GURL rewritten_url("http://foo/");
97 TestingProfile profile;
98 scoped_ptr<NavigationEntry> entry(NavigationController::CreateNavigationEntry(
99 url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, std::string(),
100 &profile));
101 EXPECT_EQ(fixed_url, entry->GetVirtualURL());
102 EXPECT_EQ(rewritten_url, entry->GetURL());