OLD | NEW |
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 "chrome/test/testing_browser_process_test.h" |
5 #include "chrome/test/testing_profile.h" | 6 #include "chrome/test/testing_profile.h" |
6 #include "content/browser/browser_url_handler.h" | 7 #include "content/browser/browser_url_handler.h" |
7 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
9 | 10 |
10 class BrowserURLHandlerTest : public testing::Test { | 11 class BrowserURLHandlerTest : public TestingBrowserProcessTest { |
11 }; | 12 }; |
12 | 13 |
13 // Test URL rewriter that rewrites all "foo://" URLs to "bar://bar". | 14 // Test URL rewriter that rewrites all "foo://" URLs to "bar://bar". |
14 static bool FooRewriter(GURL* url, content::BrowserContext* browser_context) { | 15 static bool FooRewriter(GURL* url, content::BrowserContext* browser_context) { |
15 if (url->scheme() == "foo") { | 16 if (url->scheme() == "foo") { |
16 *url = GURL("bar://bar"); | 17 *url = GURL("bar://bar"); |
17 return true; | 18 return true; |
18 } | 19 } |
19 return false; | 20 return false; |
20 } | 21 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 handler.AddHandlerPair(BrowserURLHandler::null_handler(), FooRewriter); | 66 handler.AddHandlerPair(BrowserURLHandler::null_handler(), FooRewriter); |
66 bool reversed = handler.ReverseURLRewrite(&url, original_url, &profile); | 67 bool reversed = handler.ReverseURLRewrite(&url, original_url, &profile); |
67 ASSERT_FALSE(reversed); | 68 ASSERT_FALSE(reversed); |
68 ASSERT_EQ(original_url, url); | 69 ASSERT_EQ(original_url, url); |
69 | 70 |
70 handler.AddHandlerPair(BrowserURLHandler::null_handler(), BarRewriter); | 71 handler.AddHandlerPair(BrowserURLHandler::null_handler(), BarRewriter); |
71 reversed = handler.ReverseURLRewrite(&url, original_url, &profile); | 72 reversed = handler.ReverseURLRewrite(&url, original_url, &profile); |
72 ASSERT_TRUE(reversed); | 73 ASSERT_TRUE(reversed); |
73 ASSERT_EQ("foo://foo", url.spec()); | 74 ASSERT_EQ("foo://foo", url.spec()); |
74 } | 75 } |
OLD | NEW |