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

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

Issue 2755823002: Moved |openedByDOM| to WebState's CreateParams and public interface. (Closed)
Patch Set: . Created 3 years, 9 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_impl_unittest.mm ('k') | ios/web/webui/web_ui_mojo_inttest.mm » ('j') | 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 29 matching lines...) Expand all
40 const char kMojoModuleName[] = "test-mojo-module"; 40 const char kMojoModuleName[] = "test-mojo-module";
41 // HTML for mock WebUI page. 41 // HTML for mock WebUI page.
42 NSString* kHtml = @"<html>Hello World</html>"; 42 NSString* kHtml = @"<html>Hello World</html>";
43 // Mojo module for WebUI page. 43 // Mojo module for WebUI page.
44 NSString* kMojoModule = @"service_provider.connect('Test');"; 44 NSString* kMojoModule = @"service_provider.connect('Test');";
45 45
46 // Mock of WebStateImpl to check that LoadHtml and ExecuteJavaScript are called 46 // Mock of WebStateImpl to check that LoadHtml and ExecuteJavaScript are called
47 // as expected. 47 // as expected.
48 class MockWebStateImpl : public WebStateImpl { 48 class MockWebStateImpl : public WebStateImpl {
49 public: 49 public:
50 MockWebStateImpl(BrowserState* browser_state) 50 MockWebStateImpl(const WebState::CreateParams& params)
51 : WebStateImpl(browser_state), last_committed_url_(kTestWebUIUrl) {} 51 : WebStateImpl(params), last_committed_url_(kTestWebUIUrl) {}
52 MOCK_METHOD2(LoadWebUIHtml, 52 MOCK_METHOD2(LoadWebUIHtml,
53 void(const base::string16& html, const GURL& url)); 53 void(const base::string16& html, const GURL& url));
54 MOCK_METHOD1(ExecuteJavaScript, void(const base::string16& javascript)); 54 MOCK_METHOD1(ExecuteJavaScript, void(const base::string16& javascript));
55 const GURL& GetLastCommittedURL() const override { 55 const GURL& GetLastCommittedURL() const override {
56 return last_committed_url_; 56 return last_committed_url_;
57 } 57 }
58 58
59 private: 59 private:
60 GURL last_committed_url_; 60 GURL last_committed_url_;
61 }; 61 };
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 @end 118 @end
119 119
120 namespace web { 120 namespace web {
121 121
122 // Test fixture for testing CRWWebUIManager 122 // Test fixture for testing CRWWebUIManager
123 class CRWWebUIManagerTest : public web::WebTest { 123 class CRWWebUIManagerTest : public web::WebTest {
124 protected: 124 protected:
125 void SetUp() override { 125 void SetUp() override {
126 PlatformTest::SetUp(); 126 PlatformTest::SetUp();
127 test_browser_state_.reset(new TestBrowserState()); 127 test_browser_state_.reset(new TestBrowserState());
128 web_state_impl_.reset(new MockWebStateImpl(test_browser_state_.get())); 128 WebState::CreateParams params(test_browser_state_.get());
129 web_state_impl_.reset(new MockWebStateImpl(params));
129 web_ui_manager_.reset( 130 web_ui_manager_.reset(
130 [[CRWTestWebUIManager alloc] initWithWebState:web_state_impl_.get()]); 131 [[CRWTestWebUIManager alloc] initWithWebState:web_state_impl_.get()]);
131 } 132 }
132 133
133 // TestBrowserState for creation of WebStateImpl. 134 // TestBrowserState for creation of WebStateImpl.
134 std::unique_ptr<TestBrowserState> test_browser_state_; 135 std::unique_ptr<TestBrowserState> test_browser_state_;
135 // MockWebStateImpl for detection of LoadHtml and EvaluateJavaScriptAync 136 // MockWebStateImpl for detection of LoadHtml and EvaluateJavaScriptAync
136 // calls. 137 // calls.
137 std::unique_ptr<MockWebStateImpl> web_state_impl_; 138 std::unique_ptr<MockWebStateImpl> web_state_impl_;
138 // WebUIManager for testing. 139 // WebUIManager for testing.
(...skipping 26 matching lines...) Expand all
165 "%s__crWeb.webUIModuleLoadNotifier.moduleLoadCompleted(\"%s\", \"%s\");", 166 "%s__crWeb.webUIModuleLoadNotifier.moduleLoadCompleted(\"%s\", \"%s\");",
166 base::SysNSStringToUTF8(kMojoModule).c_str(), kMojoModuleName, 167 base::SysNSStringToUTF8(kMojoModule).c_str(), kMojoModuleName,
167 kTestLoadId); 168 kTestLoadId);
168 169
169 EXPECT_CALL(*web_state_impl_, 170 EXPECT_CALL(*web_state_impl_,
170 ExecuteJavaScript(base::UTF8ToUTF16(expected_javascript))); 171 ExecuteJavaScript(base::UTF8ToUTF16(expected_javascript)));
171 web_state_impl_->OnScriptCommandReceived("webui.loadMojo", message, 172 web_state_impl_->OnScriptCommandReceived("webui.loadMojo", message,
172 GURL(kTestWebUIUrl), false); 173 GURL(kTestWebUIUrl), false);
173 } 174 }
174 } // namespace web 175 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/web_state/web_state_impl_unittest.mm ('k') | ios/web/webui/web_ui_mojo_inttest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698