| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "shell/url_resolver.h" | 5 #include "shell/url_resolver.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace mojo { | 10 namespace mojo { |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 args.push_back("--map-origin=https://b.org=https://c.org/b"); | 114 args.push_back("--map-origin=https://b.org=https://c.org/b"); |
| 115 args.push_back("https://a.org/foo"); | 115 args.push_back("https://a.org/foo"); |
| 116 mappings = URLResolver::GetOriginMappings(args); | 116 mappings = URLResolver::GetOriginMappings(args); |
| 117 ASSERT_EQ(2U, mappings.size()); | 117 ASSERT_EQ(2U, mappings.size()); |
| 118 EXPECT_EQ("https://a.org", mappings[0].origin); | 118 EXPECT_EQ("https://a.org", mappings[0].origin); |
| 119 EXPECT_EQ("https://b.org/a", mappings[0].base_url); | 119 EXPECT_EQ("https://b.org/a", mappings[0].base_url); |
| 120 EXPECT_EQ("https://b.org", mappings[1].origin); | 120 EXPECT_EQ("https://b.org", mappings[1].origin); |
| 121 EXPECT_EQ("https://c.org/b", mappings[1].base_url); | 121 EXPECT_EQ("https://c.org/b", mappings[1].base_url); |
| 122 } | 122 } |
| 123 | 123 |
| 124 TEST_F(URLResolverTest, TestQueryForURLMapping) { |
| 125 URLResolver resolver; |
| 126 resolver.SetMojoBaseURL(GURL("file:/base")); |
| 127 resolver.AddURLMapping(GURL("https://a.org/foo"), |
| 128 GURL("https://b.org/a/foo")); |
| 129 resolver.AddURLMapping(GURL("https://b.org/a/foo"), |
| 130 GURL("https://c.org/b/a/foo")); |
| 131 GURL mapped_url = resolver.ApplyMappings(GURL("https://a.org/foo?a=b")); |
| 132 EXPECT_EQ("https://c.org/b/a/foo?a=b", mapped_url.spec()); |
| 133 } |
| 134 |
| 135 TEST_F(URLResolverTest, TestQueryForBaseURL) { |
| 136 URLResolver resolver; |
| 137 resolver.SetMojoBaseURL(GURL("file:///base")); |
| 138 GURL mapped_url = resolver.ResolveMojoURL(GURL("mojo:foo?a=b")); |
| 139 EXPECT_EQ("file:///base/foo.mojo?a=b", mapped_url.spec()); |
| 140 } |
| 141 |
| 124 } // namespace | 142 } // namespace |
| 125 } // namespace test | 143 } // namespace test |
| 126 } // namespace shell | 144 } // namespace shell |
| 127 } // namespace mojo | 145 } // namespace mojo |
| OLD | NEW |