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

Side by Side Diff: ios/web/public/test/fakes/test_web_state_delegate.h

Issue 2642233004: Removed Form Resubmission callback from CRWWebDelegate. (Closed)
Patch Set: Added ShowRepostFormWarningWithNoDelegateMethod test Created 3 years, 10 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
OLDNEW
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 #ifndef IOS_WEB_PUBLIC_TEST_FAKES_TEST_WEB_STATE_DELEGATE_H_ 5 #ifndef IOS_WEB_PUBLIC_TEST_FAKES_TEST_WEB_STATE_DELEGATE_H_
6 #define IOS_WEB_PUBLIC_TEST_FAKES_TEST_WEB_STATE_DELEGATE_H_ 6 #define IOS_WEB_PUBLIC_TEST_FAKES_TEST_WEB_STATE_DELEGATE_H_
7 7
8 #import <Foundation/Foundation.h> 8 #import <Foundation/Foundation.h>
9 9
10 #include <memory> 10 #include <memory>
11 11
12 #include "base/mac/scoped_nsobject.h" 12 #include "base/mac/scoped_nsobject.h"
13 #import "ios/web/public/web_state/web_state_delegate.h" 13 #import "ios/web/public/web_state/web_state_delegate.h"
14 #import "ios/web/public/test/fakes/test_java_script_dialog_presenter.h" 14 #import "ios/web/public/test/fakes/test_java_script_dialog_presenter.h"
15 15
16 namespace web { 16 namespace web {
17 17
18 // Encapsulates parameters passed to ShowRepostFormWarningDialog.
19 struct TestRepostFormRequest {
20 TestRepostFormRequest();
21 TestRepostFormRequest(const TestRepostFormRequest&);
22 ~TestRepostFormRequest();
23 WebState* web_state = nullptr;
24 base::Callback<void(bool)> callback;
25 };
26
18 // Encapsulates parameters passed to OnAuthRequired. 27 // Encapsulates parameters passed to OnAuthRequired.
19 struct TestAuthenticationRequest { 28 struct TestAuthenticationRequest {
20 TestAuthenticationRequest(); 29 TestAuthenticationRequest();
21 TestAuthenticationRequest(const TestAuthenticationRequest&); 30 TestAuthenticationRequest(const TestAuthenticationRequest&);
22 ~TestAuthenticationRequest(); 31 ~TestAuthenticationRequest();
23 WebState* web_state = nullptr; 32 WebState* web_state = nullptr;
24 base::scoped_nsobject<NSURLProtectionSpace> protection_space; 33 base::scoped_nsobject<NSURLProtectionSpace> protection_space;
25 base::scoped_nsobject<NSURLCredential> credential; 34 base::scoped_nsobject<NSURLCredential> credential;
26 WebStateDelegate::AuthCallback auth_callback; 35 WebStateDelegate::AuthCallback auth_callback;
27 }; 36 };
28 37
29 // Fake WebStateDelegate used for testing purposes. 38 // Fake WebStateDelegate used for testing purposes.
30 class TestWebStateDelegate : public WebStateDelegate { 39 class TestWebStateDelegate : public WebStateDelegate {
31 public: 40 public:
32 TestWebStateDelegate(); 41 TestWebStateDelegate();
33 ~TestWebStateDelegate() override; 42 ~TestWebStateDelegate() override;
34 43
35 // WebStateDelegate overrides: 44 // WebStateDelegate overrides:
36 JavaScriptDialogPresenter* GetJavaScriptDialogPresenter(WebState*) override; 45 JavaScriptDialogPresenter* GetJavaScriptDialogPresenter(WebState*) override;
37 void LoadProgressChanged(WebState* source, double progress) override; 46 void LoadProgressChanged(WebState* source, double progress) override;
38 bool HandleContextMenu(WebState* source, 47 bool HandleContextMenu(WebState* source,
39 const ContextMenuParams& params) override; 48 const ContextMenuParams& params) override;
40 49 void ShowRepostFormWarningDialog(
50 WebState* source,
51 const base::Callback<void(bool)>& callback) override;
41 TestJavaScriptDialogPresenter* GetTestJavaScriptDialogPresenter(); 52 TestJavaScriptDialogPresenter* GetTestJavaScriptDialogPresenter();
42 void OnAuthRequired(WebState* source, 53 void OnAuthRequired(WebState* source,
43 NSURLProtectionSpace* protection_space, 54 NSURLProtectionSpace* protection_space,
44 NSURLCredential* proposed_credential, 55 NSURLCredential* proposed_credential,
45 const AuthCallback& callback) override; 56 const AuthCallback& callback) override;
46 57
47 // True if the WebStateDelegate LoadProgressChanged method has been called. 58 // True if the WebStateDelegate LoadProgressChanged method has been called.
48 bool load_progress_changed_called() const { 59 bool load_progress_changed_called() const {
49 return load_progress_changed_called_; 60 return load_progress_changed_called_;
50 } 61 }
51 62
52 // True if the WebStateDelegate HandleContextMenu method has been called. 63 // True if the WebStateDelegate HandleContextMenu method has been called.
53 bool handle_context_menu_called() const { 64 bool handle_context_menu_called() const {
54 return handle_context_menu_called_; 65 return handle_context_menu_called_;
55 } 66 }
56 67
68 // Returns the last Repost Form request passed to
69 // |ShowRepostFormWarningDialog|.
70 TestRepostFormRequest* last_repost_form_request() const {
71 return last_repost_form_request_.get();
72 }
73
57 // True if the WebStateDelegate GetJavaScriptDialogPresenter method has been 74 // True if the WebStateDelegate GetJavaScriptDialogPresenter method has been
58 // called. 75 // called.
59 bool get_java_script_dialog_presenter_called() const { 76 bool get_java_script_dialog_presenter_called() const {
60 return get_java_script_dialog_presenter_called_; 77 return get_java_script_dialog_presenter_called_;
61 } 78 }
62 79
63 // Returns the last HTTP Authentication request passed to |OnAuthRequired|. 80 // Returns the last HTTP Authentication request passed to |OnAuthRequired|.
64 TestAuthenticationRequest* last_authentication_request() const { 81 TestAuthenticationRequest* last_authentication_request() const {
65 return last_authentication_request_.get(); 82 return last_authentication_request_.get();
66 } 83 }
67 84
68 // Clears the last HTTP Authentication request passed to |OnAuthRequired|. 85 // Clears the last HTTP Authentication request passed to |OnAuthRequired|.
69 void ClearLastAuthenticationRequest() { 86 void ClearLastAuthenticationRequest() {
70 last_authentication_request_.reset(); 87 last_authentication_request_.reset();
71 } 88 }
72 89
73 private: 90 private:
74 bool load_progress_changed_called_ = false; 91 bool load_progress_changed_called_ = false;
75 bool handle_context_menu_called_ = false; 92 bool handle_context_menu_called_ = false;
93 std::unique_ptr<TestRepostFormRequest> last_repost_form_request_;
76 bool get_java_script_dialog_presenter_called_ = false; 94 bool get_java_script_dialog_presenter_called_ = false;
77 TestJavaScriptDialogPresenter java_script_dialog_presenter_; 95 TestJavaScriptDialogPresenter java_script_dialog_presenter_;
78 std::unique_ptr<TestAuthenticationRequest> last_authentication_request_; 96 std::unique_ptr<TestAuthenticationRequest> last_authentication_request_;
79 }; 97 };
80 98
81 } // namespace web 99 } // namespace web
82 100
83 #endif // IOS_WEB_PUBLIC_TEST_FAKES_TEST_WEB_STATE_DELEGATE_H_ 101 #endif // IOS_WEB_PUBLIC_TEST_FAKES_TEST_WEB_STATE_DELEGATE_H_
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/browser_view_controller.mm ('k') | ios/web/public/test/fakes/test_web_state_delegate.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698