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

Unified Diff: shell/application_manager/application_manager_unittest.cc

Issue 859863002: Fix shell URL resolver. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « shell/application_manager/application_manager.cc ('k') | shell/context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: shell/application_manager/application_manager_unittest.cc
diff --git a/shell/application_manager/application_manager_unittest.cc b/shell/application_manager/application_manager_unittest.cc
index f1a09cd06efcf64bd604e44978850c455aa34c38..9352a7d759cbe288e9d6f9803e9d128f840c5bd8 100644
--- a/shell/application_manager/application_manager_unittest.cc
+++ b/shell/application_manager/application_manager_unittest.cc
@@ -389,13 +389,25 @@ class TestDelegate : public ApplicationManager::Delegate {
}
// ApplicationManager::Delegate
- virtual GURL ResolveURL(const GURL& url) override {
+ virtual GURL ResolveMappings(const GURL& url) override {
auto it = mappings_.find(url);
if (it != mappings_.end())
return it->second;
return url;
}
+ // ApplicationManager::Delegate
+ virtual GURL ResolveURL(const GURL& url) override {
+ GURL mapped_url = ResolveMappings(url);
+ // The shell automatically map mojo URLs.
+ if (mapped_url.scheme() == "mojo") {
+ url::Replacements<char> replacements;
+ replacements.SetScheme("file", url::Component(0, 4));
+ mapped_url = mapped_url.ReplaceComponents(replacements);
+ }
+ return mapped_url;
+ }
+
virtual void OnApplicationError(const GURL& url) override {
}
@@ -670,4 +682,18 @@ TEST_F(ApplicationManagerTest, MappedURLsShouldNotCauseDuplicateLoad) {
EXPECT_EQ(3, test_loader_->num_loads());
}
+TEST_F(ApplicationManagerTest, MappedURLsShouldWorkWithLoaders) {
+ TestApplicationLoader* custom_loader = new TestApplicationLoader;
+ TestContext context;
+ custom_loader->set_context(&context);
+ application_manager_->SetLoaderForURL(make_scoped_ptr(custom_loader),
+ GURL("mojo:foo"));
+ test_delegate_.AddMapping(GURL("mojo:foo2"), GURL("mojo:foo"));
+
+ TestServicePtr test_service;
+ application_manager_->ConnectToService(GURL("mojo:foo2"), &test_service);
+ EXPECT_EQ(1, custom_loader->num_loads());
+ custom_loader->set_context(nullptr);
+}
+
} // namespace mojo
« no previous file with comments | « shell/application_manager/application_manager.cc ('k') | shell/context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698