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

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

Issue 2615093004: [ios] Made TestWebStateDelegate and TestJavaScriptDialogPresenter reusable. (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 unified diff | Download patch
« no previous file with comments | « ios/web/BUILD.gn ('k') | ios/web/public/test/fakes/test_java_script_dialog_presenter.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef IOS_WEB_PUBLIC_TEST_FAKES_TEST_JAVA_SCRIPT_DIALOG_PRESENTER_H_
6 #define IOS_WEB_PUBLIC_TEST_FAKES_TEST_JAVA_SCRIPT_DIALOG_PRESENTER_H_
7
8 #include <vector>
9
10 #import "ios/web/public/java_script_dialog_presenter.h"
11 #import "base/mac/scoped_nsobject.h"
12
13 namespace web {
14
15 struct TestJavaScriptDialog {
16 TestJavaScriptDialog();
17 TestJavaScriptDialog(const TestJavaScriptDialog&);
18 ~TestJavaScriptDialog();
19 WebState* web_state = nullptr;
20 GURL origin_url;
21 JavaScriptDialogType java_script_dialog_type;
22 base::scoped_nsobject<NSString> message_text;
23 base::scoped_nsobject<NSString> default_prompt_text;
24 };
25
26 // Test presenter to check that the JavaScriptDialogPresenter methods are called
27 // as expected. |RunJavaScriptDialog| always calls |callback| with
28 // |callback_success_argument| and |callback_user_input_argument| values.
29 class TestJavaScriptDialogPresenter : public JavaScriptDialogPresenter {
30 public:
31 TestJavaScriptDialogPresenter();
32 ~TestJavaScriptDialogPresenter();
33
34 // JavaScriptDialogPresenter overrides:
35 void RunJavaScriptDialog(WebState* web_state,
36 const GURL& origin_url,
37 JavaScriptDialogType java_script_dialog_type,
38 NSString* message_text,
39 NSString* default_prompt_text,
40 const DialogClosedCallback& callback) override;
41 void CancelDialogs(WebState* web_state) override;
42
43 // True if the JavaScriptDialogPresenter CancelDialogs method has been called.
44 bool cancel_dialogs_called() const { return cancel_dialogs_called_; }
45
46 // Returns a vector of requested dialogs.
47 const std::vector<TestJavaScriptDialog>& requested_dialogs() const {
48 return requested_dialogs_;
49 }
50
51 // Sets |success| argument to be used for RunJavaScriptDialog callback.
52 void set_callback_success_argument(bool success) {
53 callback_success_argument_ = success;
54 }
55
56 // Sets |user_input| argument to be used for RunJavaScriptDialog callback.
57 void set_callback_user_input_argument(NSString* user_input) {
58 callback_user_input_argument_.reset(user_input);
59 }
60
61 private:
62 bool cancel_dialogs_called_ = false;
63 std::vector<TestJavaScriptDialog> requested_dialogs_;
64 bool callback_success_argument_ = false;
65 base::scoped_nsobject<NSString> callback_user_input_argument_;
66 };
67
68 } // namespace web
69
70 #endif // IOS_WEB_PUBLIC_TEST_FAKES_TEST_JAVA_SCRIPT_DIALOG_PRESENTER_H_
OLDNEW
« no previous file with comments | « ios/web/BUILD.gn ('k') | ios/web/public/test/fakes/test_java_script_dialog_presenter.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698