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/test/test_browser_thread.h"
12 #include "testing/gtest/include/gtest/gtest.h"
15 using content::BrowserThread
;
17 typedef testing::Test BrowserAboutHandlerTest
;
19 TEST_F(BrowserAboutHandlerTest
, WillHandleBrowserAboutURL
) {
20 std::string
chrome_prefix(content::kChromeUIScheme
);
21 chrome_prefix
.append(url::kStandardSchemeSeparator
);
22 struct AboutURLTestData
{
27 GURL("http://google.com"),
28 GURL("http://google.com")
31 GURL(url::kAboutBlankURL
),
32 GURL(url::kAboutBlankURL
)
35 GURL(chrome_prefix
+ chrome::kChromeUIMemoryHost
),
36 GURL(chrome_prefix
+ chrome::kChromeUIMemoryHost
)
39 GURL(chrome_prefix
+ chrome::kChromeUIDefaultHost
),
40 GURL(chrome_prefix
+ chrome::kChromeUIVersionHost
)
43 GURL(chrome_prefix
+ chrome::kChromeUIAboutHost
),
44 GURL(chrome_prefix
+ chrome::kChromeUIChromeURLsHost
)
47 GURL(chrome_prefix
+ chrome::kChromeUICacheHost
),
48 GURL(chrome_prefix
+ content::kChromeUINetworkViewCacheHost
)
51 GURL(chrome_prefix
+ chrome::kChromeUISignInInternalsHost
),
52 GURL(chrome_prefix
+ chrome::kChromeUISignInInternalsHost
)
55 GURL(chrome_prefix
+ chrome::kChromeUISyncHost
),
56 GURL(chrome_prefix
+ chrome::kChromeUISyncInternalsHost
)
59 GURL(chrome_prefix
+ chrome::kChromeUIInvalidationsHost
),
60 GURL(chrome_prefix
+ chrome::kChromeUIInvalidationsHost
)
63 GURL(chrome_prefix
+ "host/path?query#ref"),
64 GURL(chrome_prefix
+ "host/path?query#ref"),
67 base::MessageLoopForUI message_loop
;
68 content::TestBrowserThread
ui_thread(BrowserThread::UI
, &message_loop
);
69 TestingProfile profile
;
71 for (size_t i
= 0; i
< arraysize(test_data
); ++i
) {
72 GURL
url(test_data
[i
].test_url
);
73 WillHandleBrowserAboutURL(&url
, &profile
);
74 EXPECT_EQ(test_data
[i
].result_url
, url
);