OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/public/test/fakes/crw_test_web_state_observer.h" | 5 #import "ios/web/public/test/fakes/crw_test_web_state_observer.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "ios/web/public/web_state/navigation_context.h" |
| 9 #include "ios/web/web_state/navigation_context_impl.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
8 | 11 |
9 namespace web { | 12 namespace web { |
10 TestFormActivityInfo::TestFormActivityInfo() {} | 13 TestFormActivityInfo::TestFormActivityInfo() {} |
11 TestFormActivityInfo::~TestFormActivityInfo() = default; | 14 TestFormActivityInfo::~TestFormActivityInfo() = default; |
12 TestUpdateFaviconUrlCandidatesInfo::TestUpdateFaviconUrlCandidatesInfo() {} | 15 TestUpdateFaviconUrlCandidatesInfo::TestUpdateFaviconUrlCandidatesInfo() {} |
13 TestUpdateFaviconUrlCandidatesInfo::~TestUpdateFaviconUrlCandidatesInfo() = | 16 TestUpdateFaviconUrlCandidatesInfo::~TestUpdateFaviconUrlCandidatesInfo() = |
14 default; | 17 default; |
15 } | 18 } |
16 | 19 |
17 @implementation CRWTestWebStateObserver { | 20 @implementation CRWTestWebStateObserver { |
18 // Arguments passed to |webState:didStartProvisionalNavigationForURL:|. | 21 // Arguments passed to |webState:didStartProvisionalNavigationForURL:|. |
19 std::unique_ptr<web::TestStartProvisionalNavigationInfo> | 22 std::unique_ptr<web::TestStartProvisionalNavigationInfo> |
20 _startProvisionalNavigationInfo; | 23 _startProvisionalNavigationInfo; |
21 // Arguments passed to |webState:didFinishNavigationForURL:|. | 24 // Arguments passed to |webState:didFinishNavigationForURL:|. |
22 std::unique_ptr<web::TestDidFinishNavigationInfo> _didFinishNavigationInfo; | 25 std::unique_ptr<web::TestDidFinishNavigationInfo> _didFinishNavigationInfo; |
23 // Arguments passed to |webState:didCommitNavigationWithDetails:|. | 26 // Arguments passed to |webState:didCommitNavigationWithDetails:|. |
24 std::unique_ptr<web::TestCommitNavigationInfo> _commitNavigationInfo; | 27 std::unique_ptr<web::TestCommitNavigationInfo> _commitNavigationInfo; |
25 // Arguments passed to |webState:didLoadPageWithSuccess:|. | 28 // Arguments passed to |webState:didLoadPageWithSuccess:|. |
26 std::unique_ptr<web::TestLoadPageInfo> _loadPageInfo; | 29 std::unique_ptr<web::TestLoadPageInfo> _loadPageInfo; |
27 // Arguments passed to |webStateDidDismissInterstitial:|. | 30 // Arguments passed to |webStateDidDismissInterstitial:|. |
28 std::unique_ptr<web::TestDismissInterstitialInfo> _dismissInterstitialInfo; | 31 std::unique_ptr<web::TestDismissInterstitialInfo> _dismissInterstitialInfo; |
29 // Arguments passed to |webStateDidChangeHistoryState:|. | |
30 std::unique_ptr<web::TestChangeHistoryStateInfo> _changeHistoryStateInfo; | |
31 // Arguments passed to |webState:didChangeLoadingProgress:|. | 32 // Arguments passed to |webState:didChangeLoadingProgress:|. |
32 std::unique_ptr<web::TestChangeLoadingProgressInfo> | 33 std::unique_ptr<web::TestChangeLoadingProgressInfo> |
33 _changeLoadingProgressInfo; | 34 _changeLoadingProgressInfo; |
34 // Arguments passed to |webStateDidChangeTitle:|. | 35 // Arguments passed to |webStateDidChangeTitle:|. |
35 std::unique_ptr<web::TestTitleWasSetInfo> _titleWasSetInfo; | 36 std::unique_ptr<web::TestTitleWasSetInfo> _titleWasSetInfo; |
36 // Arguments passed to | 37 // Arguments passed to |
37 // |webState:didSubmitDocumentWithFormNamed:userInitiated:|. | 38 // |webState:didSubmitDocumentWithFormNamed:userInitiated:|. |
38 std::unique_ptr<web::TestSubmitDocumentInfo> _submitDocumentInfo; | 39 std::unique_ptr<web::TestSubmitDocumentInfo> _submitDocumentInfo; |
39 // Arguments passed to | 40 // Arguments passed to |
40 // |webState:didRegisterFormActivityWithFormNamed:fieldName:type:value:|. | 41 // |webState:didRegisterFormActivityWithFormNamed:fieldName:type:value:|. |
(...skipping 24 matching lines...) Expand all Loading... |
65 } | 66 } |
66 | 67 |
67 - (web::TestLoadPageInfo*)loadPageInfo { | 68 - (web::TestLoadPageInfo*)loadPageInfo { |
68 return _loadPageInfo.get(); | 69 return _loadPageInfo.get(); |
69 } | 70 } |
70 | 71 |
71 - (web::TestDismissInterstitialInfo*)dismissInterstitialInfo { | 72 - (web::TestDismissInterstitialInfo*)dismissInterstitialInfo { |
72 return _dismissInterstitialInfo.get(); | 73 return _dismissInterstitialInfo.get(); |
73 } | 74 } |
74 | 75 |
75 - (web::TestChangeHistoryStateInfo*)changeHistoryStateInfo { | |
76 return _changeHistoryStateInfo.get(); | |
77 } | |
78 | |
79 - (web::TestChangeLoadingProgressInfo*)changeLoadingProgressInfo { | 76 - (web::TestChangeLoadingProgressInfo*)changeLoadingProgressInfo { |
80 return _changeLoadingProgressInfo.get(); | 77 return _changeLoadingProgressInfo.get(); |
81 } | 78 } |
82 | 79 |
83 - (web::TestTitleWasSetInfo*)titleWasSetInfo { | 80 - (web::TestTitleWasSetInfo*)titleWasSetInfo { |
84 return _titleWasSetInfo.get(); | 81 return _titleWasSetInfo.get(); |
85 } | 82 } |
86 | 83 |
87 - (web::TestSubmitDocumentInfo*)submitDocumentInfo { | 84 - (web::TestSubmitDocumentInfo*)submitDocumentInfo { |
88 return _submitDocumentInfo.get(); | 85 return _submitDocumentInfo.get(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 _commitNavigationInfo = base::MakeUnique<web::TestCommitNavigationInfo>(); | 125 _commitNavigationInfo = base::MakeUnique<web::TestCommitNavigationInfo>(); |
129 _commitNavigationInfo->web_state = webState; | 126 _commitNavigationInfo->web_state = webState; |
130 _commitNavigationInfo->load_details = load_details; | 127 _commitNavigationInfo->load_details = load_details; |
131 } | 128 } |
132 | 129 |
133 - (void)webState:(web::WebState*)webState | 130 - (void)webState:(web::WebState*)webState |
134 didFinishNavigation:(web::NavigationContext*)navigation { | 131 didFinishNavigation:(web::NavigationContext*)navigation { |
135 _didFinishNavigationInfo = | 132 _didFinishNavigationInfo = |
136 base::MakeUnique<web::TestDidFinishNavigationInfo>(); | 133 base::MakeUnique<web::TestDidFinishNavigationInfo>(); |
137 _didFinishNavigationInfo->web_state = webState; | 134 _didFinishNavigationInfo->web_state = webState; |
138 _didFinishNavigationInfo->context = navigation; | 135 if (navigation->IsSamePage()) { |
| 136 ASSERT_FALSE(navigation->IsErrorPage()); |
| 137 _didFinishNavigationInfo->context = |
| 138 web::NavigationContextImpl::CreateSamePageNavigationContext( |
| 139 navigation->GetWebState(), navigation->GetUrl()); |
| 140 } else if (navigation->IsErrorPage()) { |
| 141 ASSERT_FALSE(navigation->IsSamePage()); |
| 142 _didFinishNavigationInfo->context = |
| 143 web::NavigationContextImpl::CreateErrorPageNavigationContext( |
| 144 navigation->GetWebState(), navigation->GetUrl()); |
| 145 } else { |
| 146 _didFinishNavigationInfo->context = |
| 147 web::NavigationContextImpl::CreateNavigationContext( |
| 148 navigation->GetWebState(), navigation->GetUrl()); |
| 149 } |
139 } | 150 } |
140 | 151 |
141 - (void)webState:(web::WebState*)webState didLoadPageWithSuccess:(BOOL)success { | 152 - (void)webState:(web::WebState*)webState didLoadPageWithSuccess:(BOOL)success { |
142 _loadPageInfo = base::MakeUnique<web::TestLoadPageInfo>(); | 153 _loadPageInfo = base::MakeUnique<web::TestLoadPageInfo>(); |
143 _loadPageInfo->web_state = webState; | 154 _loadPageInfo->web_state = webState; |
144 _loadPageInfo->success = success; | 155 _loadPageInfo->success = success; |
145 } | 156 } |
146 | 157 |
147 - (void)webStateDidDismissInterstitial:(web::WebState*)webState { | 158 - (void)webStateDidDismissInterstitial:(web::WebState*)webState { |
148 _dismissInterstitialInfo = | 159 _dismissInterstitialInfo = |
149 base::MakeUnique<web::TestDismissInterstitialInfo>(); | 160 base::MakeUnique<web::TestDismissInterstitialInfo>(); |
150 _dismissInterstitialInfo->web_state = webState; | 161 _dismissInterstitialInfo->web_state = webState; |
151 } | 162 } |
152 | 163 |
153 - (void)webStateDidChangeHistoryState:(web::WebState*)webState { | |
154 _changeHistoryStateInfo = base::MakeUnique<web::TestChangeHistoryStateInfo>(); | |
155 _changeHistoryStateInfo->web_state = webState; | |
156 } | |
157 | |
158 - (void)webState:(web::WebState*)webState | 164 - (void)webState:(web::WebState*)webState |
159 didChangeLoadingProgress:(double)progress { | 165 didChangeLoadingProgress:(double)progress { |
160 _changeLoadingProgressInfo = | 166 _changeLoadingProgressInfo = |
161 base::MakeUnique<web::TestChangeLoadingProgressInfo>(); | 167 base::MakeUnique<web::TestChangeLoadingProgressInfo>(); |
162 _changeLoadingProgressInfo->web_state = webState; | 168 _changeLoadingProgressInfo->web_state = webState; |
163 _changeLoadingProgressInfo->progress = progress; | 169 _changeLoadingProgressInfo->progress = progress; |
164 } | 170 } |
165 | 171 |
166 - (void)webStateDidChangeTitle:(web::WebState*)webState { | 172 - (void)webStateDidChangeTitle:(web::WebState*)webState { |
167 _titleWasSetInfo = base::MakeUnique<web::TestTitleWasSetInfo>(); | 173 _titleWasSetInfo = base::MakeUnique<web::TestTitleWasSetInfo>(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 _stopLoadingInfo = base::MakeUnique<web::TestStopLoadingInfo>(); | 221 _stopLoadingInfo = base::MakeUnique<web::TestStopLoadingInfo>(); |
216 _stopLoadingInfo->web_state = webState; | 222 _stopLoadingInfo->web_state = webState; |
217 } | 223 } |
218 | 224 |
219 - (void)webStateDidStartLoading:(web::WebState*)webState { | 225 - (void)webStateDidStartLoading:(web::WebState*)webState { |
220 _startLoadingInfo = base::MakeUnique<web::TestStartLoadingInfo>(); | 226 _startLoadingInfo = base::MakeUnique<web::TestStartLoadingInfo>(); |
221 _startLoadingInfo->web_state = webState; | 227 _startLoadingInfo->web_state = webState; |
222 } | 228 } |
223 | 229 |
224 @end | 230 @end |
OLD | NEW |