[email protected] | fea79efe | 2012-05-02 01:14:01 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 9d1a9e2 | 2010-06-11 20:27:04 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "base/basictypes.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 6 | #include "base/memory/scoped_ptr.h" |
[email protected] | 3fc40c14 | 2011-12-01 13:09:04 | [diff] [blame] | 7 | #include "base/message_loop.h" |
[email protected] | 9d1a9e2 | 2010-06-11 20:27:04 | [diff] [blame] | 8 | #include "chrome/browser/browser_about_handler.h" |
| 9 | #include "chrome/common/url_constants.h" |
[email protected] | a4ff9eae | 2011-08-01 19:58:16 | [diff] [blame] | 10 | #include "chrome/test/base/testing_profile.h" |
[email protected] | e97882f | 2012-06-04 02:23:17 | [diff] [blame] | 11 | #include "content/public/test/test_browser_thread.h" |
[email protected] | 9d1a9e2 | 2010-06-11 20:27:04 | [diff] [blame] | 12 | #include "googleurl/src/gurl.h" |
| 13 | #include "testing/gtest/include/gtest/gtest.h" |
| 14 | |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 15 | using content::BrowserThread; |
| 16 | |
[email protected] | 583844c | 2011-08-27 00:38:35 | [diff] [blame] | 17 | typedef testing::Test BrowserAboutHandlerTest; |
[email protected] | bcd98a5 | 2011-02-25 07:50:19 | [diff] [blame] | 18 | |
| 19 | TEST_F(BrowserAboutHandlerTest, WillHandleBrowserAboutURL) { |
[email protected] | 89f550b | 2011-06-08 18:34:03 | [diff] [blame] | 20 | std::string chrome_prefix(chrome::kChromeUIScheme); |
[email protected] | fea79efe | 2012-05-02 01:14:01 | [diff] [blame] | 21 | chrome_prefix.append(content::kStandardSchemeSeparator); |
[email protected] | 9d1a9e2 | 2010-06-11 20:27:04 | [diff] [blame] | 22 | struct AboutURLTestData { |
| 23 | GURL test_url; |
| 24 | GURL result_url; |
[email protected] | 9d1a9e2 | 2010-06-11 20:27:04 | [diff] [blame] | 25 | } test_data[] = { |
| 26 | { |
| 27 | GURL("http://google.com"), |
[email protected] | 8bf104801 | 2012-02-08 01:22:18 | [diff] [blame] | 28 | GURL("http://google.com") |
[email protected] | 9d1a9e2 | 2010-06-11 20:27:04 | [diff] [blame] | 29 | }, |
| 30 | { |
| 31 | GURL(chrome::kAboutBlankURL), |
[email protected] | 8bf104801 | 2012-02-08 01:22:18 | [diff] [blame] | 32 | GURL(chrome::kAboutBlankURL) |
[email protected] | 9d1a9e2 | 2010-06-11 20:27:04 | [diff] [blame] | 33 | }, |
| 34 | { |
[email protected] | 89f550b | 2011-06-08 18:34:03 | [diff] [blame] | 35 | GURL(chrome_prefix + chrome::kChromeUIMemoryHost), |
[email protected] | 8bf104801 | 2012-02-08 01:22:18 | [diff] [blame] | 36 | GURL(chrome_prefix + chrome::kChromeUIMemoryHost) |
[email protected] | 9d1a9e2 | 2010-06-11 20:27:04 | [diff] [blame] | 37 | }, |
| 38 | { |
[email protected] | 89f550b | 2011-06-08 18:34:03 | [diff] [blame] | 39 | GURL(chrome_prefix + chrome::kChromeUIDefaultHost), |
[email protected] | 8bf104801 | 2012-02-08 01:22:18 | [diff] [blame] | 40 | GURL(chrome_prefix + chrome::kChromeUIVersionHost) |
[email protected] | 9d1a9e2 | 2010-06-11 20:27:04 | [diff] [blame] | 41 | }, |
[email protected] | 89f550b | 2011-06-08 18:34:03 | [diff] [blame] | 42 | { |
| 43 | GURL(chrome_prefix + chrome::kChromeUIAboutHost), |
[email protected] | 8bf104801 | 2012-02-08 01:22:18 | [diff] [blame] | 44 | GURL(chrome_prefix + chrome::kChromeUIChromeURLsHost) |
[email protected] | 89f550b | 2011-06-08 18:34:03 | [diff] [blame] | 45 | }, |
| 46 | { |
| 47 | GURL(chrome_prefix + chrome::kChromeUICacheHost), |
[email protected] | 46ed086 | 2013-04-14 02:47:56 | [diff] [blame] | 48 | GURL(chrome_prefix + content::kChromeUINetworkViewCacheHost) |
[email protected] | 89f550b | 2011-06-08 18:34:03 | [diff] [blame] | 49 | }, |
| 50 | { |
[email protected] | df4223a | 2012-11-20 00:43:02 | [diff] [blame] | 51 | GURL(chrome_prefix + chrome::kChromeUISignInInternalsHost), |
| 52 | GURL(chrome_prefix + chrome::kChromeUISignInInternalsHost) |
| 53 | }, |
| 54 | { |
[email protected] | 89f550b | 2011-06-08 18:34:03 | [diff] [blame] | 55 | GURL(chrome_prefix + chrome::kChromeUISyncHost), |
[email protected] | 8bf104801 | 2012-02-08 01:22:18 | [diff] [blame] | 56 | GURL(chrome_prefix + chrome::kChromeUISyncInternalsHost) |
[email protected] | 89f550b | 2011-06-08 18:34:03 | [diff] [blame] | 57 | }, |
| 58 | { |
| 59 | GURL(chrome_prefix + "host/path?query#ref"), |
| 60 | GURL(chrome_prefix + "host/path?query#ref"), |
[email protected] | 89f550b | 2011-06-08 18:34:03 | [diff] [blame] | 61 | } |
[email protected] | 9d1a9e2 | 2010-06-11 20:27:04 | [diff] [blame] | 62 | }; |
[email protected] | 248ce19 | 2011-02-10 15:26:34 | [diff] [blame] | 63 | MessageLoopForUI message_loop; |
[email protected] | c38831a1 | 2011-10-28 12:44:49 | [diff] [blame] | 64 | content::TestBrowserThread ui_thread(BrowserThread::UI, &message_loop); |
[email protected] | 248ce19 | 2011-02-10 15:26:34 | [diff] [blame] | 65 | TestingProfile profile; |
[email protected] | 9d1a9e2 | 2010-06-11 20:27:04 | [diff] [blame] | 66 | |
| 67 | for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_data); ++i) { |
| 68 | GURL url(test_data[i].test_url); |
[email protected] | 8bf104801 | 2012-02-08 01:22:18 | [diff] [blame] | 69 | WillHandleBrowserAboutURL(&url, &profile); |
[email protected] | 9d1a9e2 | 2010-06-11 20:27:04 | [diff] [blame] | 70 | EXPECT_EQ(test_data[i].result_url, url); |
| 71 | } |
[email protected] | 9d1a9e2 | 2010-06-11 20:27:04 | [diff] [blame] | 72 | } |