Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: mojo/shell/mojo_url_resolver_unittest.cc

Issue 668483002: Change mojo URLs from mojo://mojo_foo to mojo://foo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/mojo_url_resolver.h" 5 #include "mojo/shell/mojo_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 {
11 namespace shell { 11 namespace shell {
12 namespace test { 12 namespace test {
13 namespace { 13 namespace {
14 14
15 typedef testing::Test MojoURLResolverTest; 15 typedef testing::Test MojoURLResolverTest;
16 16
17 TEST_F(MojoURLResolverTest, MojoURLsFallThrough) { 17 TEST_F(MojoURLResolverTest, MojoURLsFallThrough) {
18 MojoURLResolver resolver; 18 MojoURLResolver resolver;
19 resolver.AddCustomMapping(GURL("mojo:test"), GURL("mojo:foo")); 19 resolver.AddCustomMapping(GURL("mojo:test"), GURL("mojo:foo"));
20 const GURL base_url("file:/base"); 20 const GURL base_url("file:/base");
21 resolver.SetBaseURL(base_url); 21 resolver.SetBaseURL(base_url);
22 const std::string resolved(resolver.Resolve(GURL("mojo:test")).spec()); 22 std::string resolved(resolver.Resolve(GURL("mojo:test")).spec());
23 // Resolved must start with |base_url|. 23 // Resolved must start with |base_url|.
24 EXPECT_EQ(base_url.spec(), resolved.substr(0, base_url.spec().size())); 24 EXPECT_EQ(base_url.spec(), resolved.substr(0, base_url.spec().size()));
25 // And must contain foo (which is what test mapped to. 25 // And must contain mojo_foo (we got mapped to foo, and all libraries are
26 EXPECT_NE(std::string::npos, resolved.find("foo")); 26 // prefixed with mojo_).
27 EXPECT_NE(std::string::npos, resolved.find("mojo_foo"));
28
29 // Make sure we don't double-mojo.
30 resolved = resolver.Resolve(GURL("mojo:mojo_test")).spec();
31 EXPECT_EQ(std::string::npos, resolved.find("mojo:mojo_mojo_foo"));
27 } 32 }
28 33
29 } // namespace 34 } // namespace
30 } // namespace test 35 } // namespace test
31 } // namespace shell 36 } // namespace shell
32 } // namespace mojo 37 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698