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

Side by Side Diff: ios/web/webui/crw_web_ui_manager_unittest.mm

Issue 2896623003: Added web::NavigationContext::GetPageTransition. (Closed)
Patch Set: Rebased Created 3 years, 7 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
« no previous file with comments | « ios/web/web_state/web_state_observer_bridge_unittest.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #import "ios/web/webui/crw_web_ui_manager.h" 5 #import "ios/web/webui/crw_web_ui_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 base::scoped_nsobject<CRWTestWebUIManager> web_ui_manager_; 141 base::scoped_nsobject<CRWTestWebUIManager> web_ui_manager_;
142 }; 142 };
143 143
144 // Tests that CRWWebUIManager observes provisional navigation and invokes an 144 // Tests that CRWWebUIManager observes provisional navigation and invokes an
145 // HTML load in web state. 145 // HTML load in web state.
146 TEST_F(CRWWebUIManagerTest, LoadWebUI) { 146 TEST_F(CRWWebUIManagerTest, LoadWebUI) {
147 base::string16 html(base::SysNSStringToUTF16(kHtml)); 147 base::string16 html(base::SysNSStringToUTF16(kHtml));
148 GURL url(kTestWebUIUrl); 148 GURL url(kTestWebUIUrl);
149 EXPECT_CALL(*web_state_impl_, LoadWebUIHtml(html, url)); 149 EXPECT_CALL(*web_state_impl_, LoadWebUIHtml(html, url));
150 std::unique_ptr<web::NavigationContext> context = 150 std::unique_ptr<web::NavigationContext> context =
151 NavigationContextImpl::CreateNavigationContext(web_state_impl_.get(), 151 NavigationContextImpl::CreateNavigationContext(
152 url); 152 web_state_impl_.get(), url,
153 ui::PageTransition::PAGE_TRANSITION_AUTO_BOOKMARK);
153 web_state_impl_->OnNavigationStarted(context.get()); 154 web_state_impl_->OnNavigationStarted(context.get());
154 } 155 }
155 156
156 // Tests that CRWWebUIManager responds to OnScriptCommandReceieved call and runs 157 // Tests that CRWWebUIManager responds to OnScriptCommandReceieved call and runs
157 // JavaScript to fetch a mojo resource. 158 // JavaScript to fetch a mojo resource.
158 TEST_F(CRWWebUIManagerTest, HandleLoadMojoRequest) { 159 TEST_F(CRWWebUIManagerTest, HandleLoadMojoRequest) {
159 // Create mock JavaScript message to request a mojo resource. 160 // Create mock JavaScript message to request a mojo resource.
160 std::unique_ptr<base::ListValue> arguments(new base::ListValue()); 161 std::unique_ptr<base::ListValue> arguments(new base::ListValue());
161 arguments->AppendString(kMojoModuleName); 162 arguments->AppendString(kMojoModuleName);
162 const char kTestLoadId[] = "test-load-id"; 163 const char kTestLoadId[] = "test-load-id";
163 arguments->AppendString(kTestLoadId); 164 arguments->AppendString(kTestLoadId);
164 base::DictionaryValue message; 165 base::DictionaryValue message;
165 message.SetString("message", "webui.loadMojo"); 166 message.SetString("message", "webui.loadMojo");
166 message.Set("arguments", std::move(arguments)); 167 message.Set("arguments", std::move(arguments));
167 168
168 // Create expected JavaScript to call. 169 // Create expected JavaScript to call.
169 std::string expected_javascript = base::StringPrintf( 170 std::string expected_javascript = base::StringPrintf(
170 "%s__crWeb.webUIModuleLoadNotifier.moduleLoadCompleted(\"%s\", \"%s\");", 171 "%s__crWeb.webUIModuleLoadNotifier.moduleLoadCompleted(\"%s\", \"%s\");",
171 base::SysNSStringToUTF8(kMojoModule).c_str(), kMojoModuleName, 172 base::SysNSStringToUTF8(kMojoModule).c_str(), kMojoModuleName,
172 kTestLoadId); 173 kTestLoadId);
173 174
174 EXPECT_CALL(*web_state_impl_, 175 EXPECT_CALL(*web_state_impl_,
175 ExecuteJavaScript(base::UTF8ToUTF16(expected_javascript))); 176 ExecuteJavaScript(base::UTF8ToUTF16(expected_javascript)));
176 web_state_impl_->OnScriptCommandReceived("webui.loadMojo", message, 177 web_state_impl_->OnScriptCommandReceived("webui.loadMojo", message,
177 GURL(kTestWebUIUrl), false); 178 GURL(kTestWebUIUrl), false);
178 } 179 }
179 } // namespace web 180 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/web_state/web_state_observer_bridge_unittest.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698