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 "mojo/shell/url_resolver.h" | 5 #include "mojo/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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 mappings = URLResolver::GetOriginMappings(args); | 108 mappings = URLResolver::GetOriginMappings(args); |
109 EXPECT_EQ(0U, mappings.size()); | 109 EXPECT_EQ(0U, mappings.size()); |
110 | 110 |
111 args.clear(); | 111 args.clear(); |
112 args.push_back(ARG_LITERAL("--map-origin=")); | 112 args.push_back(ARG_LITERAL("--map-origin=")); |
113 mappings = URLResolver::GetOriginMappings(args); | 113 mappings = URLResolver::GetOriginMappings(args); |
114 EXPECT_EQ(0U, mappings.size()); | 114 EXPECT_EQ(0U, mappings.size()); |
115 | 115 |
116 args.clear(); | 116 args.clear(); |
117 args.push_back(ARG_LITERAL("mojo_shell")); | 117 args.push_back(ARG_LITERAL("mojo_shell")); |
118 args.push_back(ARG_LITERAL("--args-for=https://a.org/foo --test")); | |
119 args.push_back(ARG_LITERAL("--map-origin=https://a.org=https://b.org/a")); | 118 args.push_back(ARG_LITERAL("--map-origin=https://a.org=https://b.org/a")); |
120 args.push_back(ARG_LITERAL("--map-origin=https://b.org=https://c.org/b")); | 119 args.push_back(ARG_LITERAL("--map-origin=https://b.org=https://c.org/b")); |
121 args.push_back(ARG_LITERAL("https://a.org/foo")); | 120 args.push_back(ARG_LITERAL("https://a.org/foo")); |
122 mappings = URLResolver::GetOriginMappings(args); | 121 mappings = URLResolver::GetOriginMappings(args); |
123 ASSERT_EQ(2U, mappings.size()); | 122 ASSERT_EQ(2U, mappings.size()); |
124 EXPECT_EQ("https://a.org", mappings[0].origin); | 123 EXPECT_EQ("https://a.org", mappings[0].origin); |
125 EXPECT_EQ("https://b.org/a", mappings[0].base_url); | 124 EXPECT_EQ("https://b.org/a", mappings[0].base_url); |
126 EXPECT_EQ("https://b.org", mappings[1].origin); | 125 EXPECT_EQ("https://b.org", mappings[1].origin); |
127 EXPECT_EQ("https://c.org/b", mappings[1].base_url); | 126 EXPECT_EQ("https://c.org/b", mappings[1].base_url); |
128 } | 127 } |
(...skipping 13 matching lines...) Expand all Loading... |
142 URLResolver resolver; | 141 URLResolver resolver; |
143 resolver.SetMojoBaseURL(GURL("file:///base")); | 142 resolver.SetMojoBaseURL(GURL("file:///base")); |
144 GURL mapped_url = resolver.ResolveMojoURL(GURL("mojo:foo?a=b")); | 143 GURL mapped_url = resolver.ResolveMojoURL(GURL("mojo:foo?a=b")); |
145 EXPECT_EQ("file:///base/foo.mojo?a=b", mapped_url.spec()); | 144 EXPECT_EQ("file:///base/foo.mojo?a=b", mapped_url.spec()); |
146 } | 145 } |
147 | 146 |
148 } // namespace | 147 } // namespace |
149 } // namespace test | 148 } // namespace test |
150 } // namespace shell | 149 } // namespace shell |
151 } // namespace mojo | 150 } // namespace mojo |
OLD | NEW |