| 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 #ifndef IOS_WEB_PUBLIC_TEST_FAKES_TEST_JAVA_SCRIPT_DIALOG_PRESENTER_H_ | 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_ | 6 #define IOS_WEB_PUBLIC_TEST_FAKES_TEST_JAVA_SCRIPT_DIALOG_PRESENTER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #import "ios/web/public/java_script_dialog_presenter.h" | 10 #import "ios/web/public/java_script_dialog_presenter.h" |
| 11 #import "base/mac/scoped_nsobject.h" | |
| 12 | 11 |
| 13 namespace web { | 12 namespace web { |
| 14 | 13 |
| 15 struct TestJavaScriptDialog { | 14 struct TestJavaScriptDialog { |
| 16 TestJavaScriptDialog(); | 15 TestJavaScriptDialog(); |
| 17 TestJavaScriptDialog(const TestJavaScriptDialog&); | 16 TestJavaScriptDialog(const TestJavaScriptDialog&); |
| 18 ~TestJavaScriptDialog(); | 17 ~TestJavaScriptDialog(); |
| 19 WebState* web_state = nullptr; | 18 WebState* web_state = nullptr; |
| 20 GURL origin_url; | 19 GURL origin_url; |
| 21 JavaScriptDialogType java_script_dialog_type; | 20 JavaScriptDialogType java_script_dialog_type; |
| 22 base::scoped_nsobject<NSString> message_text; | 21 NSString* message_text; |
| 23 base::scoped_nsobject<NSString> default_prompt_text; | 22 NSString* default_prompt_text; |
| 24 }; | 23 }; |
| 25 | 24 |
| 26 // Test presenter to check that the JavaScriptDialogPresenter methods are called | 25 // Test presenter to check that the JavaScriptDialogPresenter methods are called |
| 27 // as expected. |RunJavaScriptDialog| always calls |callback| with | 26 // as expected. |RunJavaScriptDialog| always calls |callback| with |
| 28 // |callback_success_argument| and |callback_user_input_argument| values. | 27 // |callback_success_argument| and |callback_user_input_argument| values. |
| 29 class TestJavaScriptDialogPresenter : public JavaScriptDialogPresenter { | 28 class TestJavaScriptDialogPresenter : public JavaScriptDialogPresenter { |
| 30 public: | 29 public: |
| 31 TestJavaScriptDialogPresenter(); | 30 TestJavaScriptDialogPresenter(); |
| 32 ~TestJavaScriptDialogPresenter(); | 31 ~TestJavaScriptDialogPresenter(); |
| 33 | 32 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 48 return requested_dialogs_; | 47 return requested_dialogs_; |
| 49 } | 48 } |
| 50 | 49 |
| 51 // Sets |success| argument to be used for RunJavaScriptDialog callback. | 50 // Sets |success| argument to be used for RunJavaScriptDialog callback. |
| 52 void set_callback_success_argument(bool success) { | 51 void set_callback_success_argument(bool success) { |
| 53 callback_success_argument_ = success; | 52 callback_success_argument_ = success; |
| 54 } | 53 } |
| 55 | 54 |
| 56 // Sets |user_input| argument to be used for RunJavaScriptDialog callback. | 55 // Sets |user_input| argument to be used for RunJavaScriptDialog callback. |
| 57 void set_callback_user_input_argument(NSString* user_input) { | 56 void set_callback_user_input_argument(NSString* user_input) { |
| 58 callback_user_input_argument_.reset(user_input); | 57 callback_user_input_argument_ = user_input; |
| 59 } | 58 } |
| 60 | 59 |
| 61 private: | 60 private: |
| 62 bool cancel_dialogs_called_ = false; | 61 bool cancel_dialogs_called_ = false; |
| 63 std::vector<TestJavaScriptDialog> requested_dialogs_; | 62 std::vector<TestJavaScriptDialog> requested_dialogs_; |
| 64 bool callback_success_argument_ = false; | 63 bool callback_success_argument_ = false; |
| 65 base::scoped_nsobject<NSString> callback_user_input_argument_; | 64 NSString* callback_user_input_argument_; |
| 66 }; | 65 }; |
| 67 | 66 |
| 68 } // namespace web | 67 } // namespace web |
| 69 | 68 |
| 70 #endif // IOS_WEB_PUBLIC_TEST_FAKES_TEST_JAVA_SCRIPT_DIALOG_PRESENTER_H_ | 69 #endif // IOS_WEB_PUBLIC_TEST_FAKES_TEST_JAVA_SCRIPT_DIALOG_PRESENTER_H_ |
| OLD | NEW |