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

Unified Diff: ios/web/webui/crw_web_ui_manager_unittest.mm

Issue 2946383002: Support new-style Mojo JS core API on IOS. (Closed)
Patch Set: . Created 3 years, 6 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 | « ios/web/webui/crw_web_ui_manager.mm ('k') | ios/web/webui/mojo_facade.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/webui/crw_web_ui_manager_unittest.mm
diff --git a/ios/web/webui/crw_web_ui_manager_unittest.mm b/ios/web/webui/crw_web_ui_manager_unittest.mm
index 48b5f095cc9909d9630a332035259396f4bed030..3fd058827fffc1d9564923b0712c55e1cdd83b82 100644
--- a/ios/web/webui/crw_web_ui_manager_unittest.mm
+++ b/ios/web/webui/crw_web_ui_manager_unittest.mm
@@ -40,12 +40,8 @@ const char kFaviconPath[] = "ios/web/test/data/testfavicon.png";
const char kTestWebUIUrl[] = "testwebui://test/";
// URL for mock favicon.
const char kFaviconUrl[] = "testwebui://favicon/";
-// Name of test Mojo module.
-const char kMojoModuleName[] = "test-mojo-module";
// HTML for mock WebUI page.
NSString* kHtml = @"<html>Hello World</html>";
-// Mojo module for WebUI page.
-NSString* kMojoModule = @"service_provider.connect('Test');";
// Mock of WebStateImpl to check that LoadHtml and ExecuteJavaScript are called
// as expected.
@@ -83,10 +79,6 @@ class MockURLFetcherBlockAdapter : public URLFetcherBlockAdapter {
NSData* favicon = [NSData
dataWithContentsOfFile:base::SysUTF8ToNSString(favicon_path.value())];
completion_handler_(favicon, this);
- } else if (url_.path().find(kMojoModuleName) != std::string::npos) {
- completion_handler_([kMojoModule dataUsingEncoding:NSUTF8StringEncoding],
- this);
-
} else if (url_.scheme().find("test") != std::string::npos) {
completion_handler_([kHtml dataUsingEncoding:NSUTF8StringEncoding], this);
} else {
@@ -156,27 +148,4 @@ TEST_F(CRWWebUIManagerTest, LoadWebUI) {
web_state_impl_->OnNavigationStarted(context.get());
}
-// Tests that CRWWebUIManager responds to OnScriptCommandReceieved call and runs
-// JavaScript to fetch a mojo resource.
-TEST_F(CRWWebUIManagerTest, HandleLoadMojoRequest) {
- // Create mock JavaScript message to request a mojo resource.
- std::unique_ptr<base::ListValue> arguments(new base::ListValue());
- arguments->AppendString(kMojoModuleName);
- const char kTestLoadId[] = "test-load-id";
- arguments->AppendString(kTestLoadId);
- base::DictionaryValue message;
- message.SetString("message", "webui.loadMojo");
- message.Set("arguments", std::move(arguments));
-
- // Create expected JavaScript to call.
- std::string expected_javascript = base::StringPrintf(
- "%s__crWeb.webUIModuleLoadNotifier.moduleLoadCompleted(\"%s\", \"%s\");",
- base::SysNSStringToUTF8(kMojoModule).c_str(), kMojoModuleName,
- kTestLoadId);
-
- EXPECT_CALL(*web_state_impl_,
- ExecuteJavaScript(base::UTF8ToUTF16(expected_javascript)));
- web_state_impl_->OnScriptCommandReceived("webui.loadMojo", message,
- GURL(kTestWebUIUrl), false);
-}
} // namespace web
« no previous file with comments | « ios/web/webui/crw_web_ui_manager.mm ('k') | ios/web/webui/mojo_facade.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698