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