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

Unified Diff: ios/web/public/test/fakes/crw_test_web_state_observer.mm

Issue 2674503002: Unit tests for WebStateObserverBridge class. (Closed)
Patch Set: Created 3 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
Index: ios/web/public/test/fakes/crw_test_web_state_observer.mm
diff --git a/ios/web/public/test/fakes/crw_test_web_state_observer.mm b/ios/web/public/test/fakes/crw_test_web_state_observer.mm
new file mode 100644
index 0000000000000000000000000000000000000000..755753f1660e00ca3a68a520de3069f565affb6f
--- /dev/null
+++ b/ios/web/public/test/fakes/crw_test_web_state_observer.mm
@@ -0,0 +1,210 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/web/public/test/fakes/crw_test_web_state_observer.h"
+
+#include "base/memory/ptr_util.h"
+
+namespace web {
+TestFormActivityInfo::TestFormActivityInfo() {}
+TestFormActivityInfo::~TestFormActivityInfo() = default;
+TestUpdateFaviconUrlCandidatesInfo::TestUpdateFaviconUrlCandidatesInfo() {}
+TestUpdateFaviconUrlCandidatesInfo::~TestUpdateFaviconUrlCandidatesInfo() =
+ default;
+}
+
+@implementation CRWTestWebStateObserver {
+ // Arguments passed to |webState:didStartProvisionalNavigationForURL:|.
+ std::unique_ptr<web::TestStartProvisionalNavigationInfo>
+ _startProvisionalNavigationInfo;
+ // Arguments passed to |webState:didCommitNavigationWithDetails:|.
+ std::unique_ptr<web::TestCommitNavigationInfo> _commitNavigationInfo;
+ // Arguments passed to |webState:didLoadPageWithSuccess:|.
+ std::unique_ptr<web::TestLoadPageInfo> _loadPageInfo;
+ // Arguments passed to |webStateDidDismissInterstitial:|.
+ std::unique_ptr<web::TestDismissInterstitialInfo> _dismissInterstitialInfo;
+ // Arguments passed to |webStateDidChangeURLHash:|.
+ std::unique_ptr<web::TestChangeUrlHashInfo> _changeUrlHashInfo;
+ // Arguments passed to |webStateDidChangeHistoryState:|.
+ std::unique_ptr<web::TestChangeHistoryStateInfo> _changeHistoryStateInfo;
+ // Arguments passed to |webState:didChangeLoadingProgress:|.
+ std::unique_ptr<web::TestChangeLoadingProgressInfo>
+ _changeLoadingProgressInfo;
+ // Arguments passed to
+ // |webState:didSubmitDocumentWithFormNamed:userInitiated:|.
+ std::unique_ptr<web::TestSubmitDocumentInfo> _submitDocumentInfo;
+ // Arguments passed to
+ // |webState:didRegisterFormActivityWithFormNamed:fieldName:type:value:|.
+ std::unique_ptr<web::TestFormActivityInfo> _formActivityInfo;
+ // Arguments passed to |webState:didUpdateFaviconURLCandidates|.
+ std::unique_ptr<web::TestUpdateFaviconUrlCandidatesInfo>
+ _updateFaviconUrlCandidatesInfo;
+ // Arguments passed to |webState:renderProcessGoneForWebState:|.
+ std::unique_ptr<web::TestRenderProcessGoneInfo> _renderProcessGoneInfo;
+ // Arguments passed to |webStateDestroyed:|.
+ std::unique_ptr<web::TestWebStateDestroyedInfo> _webStateDestroyedInfo;
+ // Arguments passed to |webStateDidStopLoading:|.
+ std::unique_ptr<web::TestStopLoadingInfo> _stopLoadingInfo;
+ // Arguments passed to |webStateDidStartLoading:|.
+ std::unique_ptr<web::TestStartLoadingInfo> _startLoadingInfo;
+}
+
+- (web::TestStartProvisionalNavigationInfo*)startProvisionalNavigationInfo {
+ return _startProvisionalNavigationInfo.get();
+}
+
+- (web::TestCommitNavigationInfo*)commitNavigationInfo {
+ return _commitNavigationInfo.get();
+}
+
+- (web::TestLoadPageInfo*)loadPageInfo {
+ return _loadPageInfo.get();
+}
+
+- (web::TestDismissInterstitialInfo*)dismissInterstitialInfo {
+ return _dismissInterstitialInfo.get();
+}
+
+- (web::TestChangeUrlHashInfo*)changeUrlHashInfo {
+ return _changeUrlHashInfo.get();
+}
+
+- (web::TestChangeHistoryStateInfo*)changeHistoryStateInfo {
+ return _changeHistoryStateInfo.get();
+}
+
+- (web::TestChangeLoadingProgressInfo*)changeLoadingProgressInfo {
+ return _changeLoadingProgressInfo.get();
+}
+
+- (web::TestSubmitDocumentInfo*)submitDocumentInfo {
+ return _submitDocumentInfo.get();
+}
+
+- (web::TestFormActivityInfo*)formActivityInfo {
+ return _formActivityInfo.get();
+}
+
+- (web::TestUpdateFaviconUrlCandidatesInfo*)updateFaviconUrlCandidatesInfo {
+ return _updateFaviconUrlCandidatesInfo.get();
+}
+
+- (web::TestRenderProcessGoneInfo*)renderProcessGoneInfo {
+ return _renderProcessGoneInfo.get();
+}
+
+- (web::TestWebStateDestroyedInfo*)webStateDestroyedInfo {
+ return _webStateDestroyedInfo.get();
+}
+
+- (web::TestStopLoadingInfo*)stopLoadingInfo {
+ return _stopLoadingInfo.get();
+}
+
+- (web::TestStartLoadingInfo*)startLoadingInfo {
+ return _startLoadingInfo.get();
+}
+
+#pragma mark CRWWebStateObserver methods -
+
+- (void)webState:(web::WebState*)webState
+ didStartProvisionalNavigationForURL:(const GURL&)URL {
+ _startProvisionalNavigationInfo =
+ base::MakeUnique<web::TestStartProvisionalNavigationInfo>();
+ _startProvisionalNavigationInfo->web_state = webState;
+ _startProvisionalNavigationInfo->url = URL;
+}
+
+- (void)webState:(web::WebState*)webState
+ didCommitNavigationWithDetails:
+ (const web::LoadCommittedDetails&)load_details {
+ _commitNavigationInfo = base::MakeUnique<web::TestCommitNavigationInfo>();
+ _commitNavigationInfo->web_state = webState;
+ _commitNavigationInfo->load_details = load_details;
+}
+
+- (void)webState:(web::WebState*)webState didLoadPageWithSuccess:(BOOL)success {
+ _loadPageInfo = base::MakeUnique<web::TestLoadPageInfo>();
+ _loadPageInfo->web_state = webState;
+ _loadPageInfo->success = success;
+}
+
+- (void)webStateDidDismissInterstitial:(web::WebState*)webState {
+ _dismissInterstitialInfo =
+ base::MakeUnique<web::TestDismissInterstitialInfo>();
+ _dismissInterstitialInfo->web_state = webState;
+}
+
+- (void)webStateDidChangeURLHash:(web::WebState*)webState {
+ _changeUrlHashInfo = base::MakeUnique<web::TestChangeUrlHashInfo>();
+ _changeUrlHashInfo->web_state = webState;
+}
+
+- (void)webStateDidChangeHistoryState:(web::WebState*)webState {
+ _changeHistoryStateInfo = base::MakeUnique<web::TestChangeHistoryStateInfo>();
+ _changeHistoryStateInfo->web_state = webState;
+}
+
+- (void)webState:(web::WebState*)webState
+ didChangeLoadingProgress:(double)progress {
+ _changeLoadingProgressInfo =
+ base::MakeUnique<web::TestChangeLoadingProgressInfo>();
+ _changeLoadingProgressInfo->web_state = webState;
+ _changeLoadingProgressInfo->progress = progress;
+}
+
+- (void)webState:(web::WebState*)webState
+ didSubmitDocumentWithFormNamed:(const std::string&)formName
+ userInitiated:(BOOL)userInitiated {
+ _submitDocumentInfo = base::MakeUnique<web::TestSubmitDocumentInfo>();
+ _submitDocumentInfo->web_state = webState;
+ _submitDocumentInfo->form_name = formName;
+ _submitDocumentInfo->user_initiated = userInitiated;
+}
+
+- (void)webState:(web::WebState*)webState
+ didRegisterFormActivityWithFormNamed:(const std::string&)formName
+ fieldName:(const std::string&)fieldName
+ type:(const std::string&)type
+ value:(const std::string&)value
+ inputMissing:(BOOL)inputMissing {
+ _formActivityInfo = base::MakeUnique<web::TestFormActivityInfo>();
+ _formActivityInfo->web_state = webState;
+ _formActivityInfo->form_name = formName;
+ _formActivityInfo->field_name = fieldName;
+ _formActivityInfo->type = type;
+ _formActivityInfo->value = value;
+ _formActivityInfo->input_missing = inputMissing;
+}
+
+- (void)webState:(web::WebState*)webState
+ didUpdateFaviconURLCandidates:
+ (const std::vector<web::FaviconURL>&)candidates {
+ _updateFaviconUrlCandidatesInfo =
+ base::MakeUnique<web::TestUpdateFaviconUrlCandidatesInfo>();
+ _updateFaviconUrlCandidatesInfo->web_state = webState;
+ _updateFaviconUrlCandidatesInfo->candidates = candidates;
+}
+
+- (void)renderProcessGoneForWebState:(web::WebState*)webState {
+ _renderProcessGoneInfo = base::MakeUnique<web::TestRenderProcessGoneInfo>();
+ _renderProcessGoneInfo->web_state = webState;
+}
+
+- (void)webStateDestroyed:(web::WebState*)webState {
+ _webStateDestroyedInfo = base::MakeUnique<web::TestWebStateDestroyedInfo>();
+ _webStateDestroyedInfo->web_state = webState;
+}
+
+- (void)webStateDidStopLoading:(web::WebState*)webState {
+ _stopLoadingInfo = base::MakeUnique<web::TestStopLoadingInfo>();
+ _stopLoadingInfo->web_state = webState;
+}
+
+- (void)webStateDidStartLoading:(web::WebState*)webState {
+ _startLoadingInfo = base::MakeUnique<web::TestStartLoadingInfo>();
+ _startLoadingInfo->web_state = webState;
+}
+
+@end

Powered by Google App Engine
This is Rietveld 408576698