Prepare for VS2015 toolchain
[chromium-blink-merge.git] / chrome / browser / browser_about_handler_unittest.cc
blobb90428780eef17f442266a9e1d31c6859dd31cbc
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 "content/public/test/test_browser_thread_bundle.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "url/gurl.h"
19 using content::BrowserThread;
20 using content::NavigationController;
21 using content::NavigationEntry;
22 using content::Referrer;
24 class BrowserAboutHandlerTest : public testing::Test {
25 content::TestBrowserThreadBundle thread_bundle_;
28 TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURL) {
29 std::string chrome_prefix(content::kChromeUIScheme);
30 chrome_prefix.append(url::kStandardSchemeSeparator);
31 struct AboutURLTestData {
32 GURL test_url;
33 GURL result_url;
34 } test_data[] = {
36 GURL("http://google.com"),
37 GURL("http://google.com")
40 GURL(url::kAboutBlankURL),
41 GURL(url::kAboutBlankURL)
44 GURL(chrome_prefix + chrome::kChromeUIMemoryHost),
45 GURL(chrome_prefix + chrome::kChromeUIMemoryHost)
48 GURL(chrome_prefix + chrome::kChromeUIDefaultHost),
49 GURL(chrome_prefix + chrome::kChromeUIVersionHost)
52 GURL(chrome_prefix + chrome::kChromeUIAboutHost),
53 GURL(chrome_prefix + chrome::kChromeUIChromeURLsHost)
56 GURL(chrome_prefix + chrome::kChromeUICacheHost),
57 GURL(chrome_prefix + content::kChromeUINetworkViewCacheHost)
60 GURL(chrome_prefix + chrome::kChromeUISignInInternalsHost),
61 GURL(chrome_prefix + chrome::kChromeUISignInInternalsHost)
64 GURL(chrome_prefix + chrome::kChromeUISyncHost),
65 GURL(chrome_prefix + chrome::kChromeUISyncInternalsHost)
68 GURL(chrome_prefix + chrome::kChromeUIInvalidationsHost),
69 GURL(chrome_prefix + chrome::kChromeUIInvalidationsHost)
72 GURL(chrome_prefix + "host/path?query#ref"),
73 GURL(chrome_prefix + "host/path?query#ref"),
76 TestingProfile profile;
78 for (size_t i = 0; i < arraysize(test_data); ++i) {
79 GURL url(test_data[i].test_url);
80 WillHandleBrowserAboutURL(&url, &profile);
81 EXPECT_EQ(test_data[i].result_url, url);
85 // Ensure that minor BrowserAboutHandler fixup to a URL does not cause us to
86 // keep a separate virtual URL, which would not be updated on redirects.
87 // See https://crbug.com/449829.
88 TEST_F(BrowserAboutHandlerTest, NoVirtualURLForFixup) {
89 GURL url("view-source:http://.foo");
91 // Fixup will remove the dot and add a slash.
92 GURL fixed_url("view-source:http://foo/");
94 // Rewriters will remove the view-source prefix and expect it to stay in the
95 // virtual URL.
96 GURL rewritten_url("http://foo/");
98 TestingProfile profile;
99 scoped_ptr<NavigationEntry> entry(NavigationController::CreateNavigationEntry(
100 url, Referrer(), ui::PAGE_TRANSITION_RELOAD, false, std::string(),
101 &profile));
102 EXPECT_EQ(fixed_url, entry->GetVirtualURL());
103 EXPECT_EQ(rewritten_url, entry->GetURL());