| Index: ios/web/public/test/fakes/test_java_script_dialog_presenter.h
|
| diff --git a/ios/web/public/test/fakes/test_java_script_dialog_presenter.h b/ios/web/public/test/fakes/test_java_script_dialog_presenter.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..8abb8535ad40220e5ca8da5d38bd0b75cad1c379
|
| --- /dev/null
|
| +++ b/ios/web/public/test/fakes/test_java_script_dialog_presenter.h
|
| @@ -0,0 +1,70 @@
|
| +// 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.
|
| +
|
| +#ifndef IOS_WEB_PUBLIC_TEST_FAKES_TEST_JAVA_SCRIPT_DIALOG_PRESENTER_H_
|
| +#define IOS_WEB_PUBLIC_TEST_FAKES_TEST_JAVA_SCRIPT_DIALOG_PRESENTER_H_
|
| +
|
| +#include <vector>
|
| +
|
| +#import "ios/web/public/java_script_dialog_presenter.h"
|
| +#import "base/mac/scoped_nsobject.h"
|
| +
|
| +namespace web {
|
| +
|
| +struct TestJavaScriptDialog {
|
| + TestJavaScriptDialog();
|
| + TestJavaScriptDialog(const TestJavaScriptDialog&);
|
| + ~TestJavaScriptDialog();
|
| + WebState* web_state = nullptr;
|
| + GURL origin_url;
|
| + JavaScriptDialogType java_script_dialog_type;
|
| + base::scoped_nsobject<NSString> message_text;
|
| + base::scoped_nsobject<NSString> default_prompt_text;
|
| +};
|
| +
|
| +// Test presenter to check that the JavaScriptDialogPresenter methods are called
|
| +// as expected. |RunJavaScriptDialog| always calls |callback| with
|
| +// |callback_success_argument| and |callback_user_input_argument| values.
|
| +class TestJavaScriptDialogPresenter : public JavaScriptDialogPresenter {
|
| + public:
|
| + TestJavaScriptDialogPresenter();
|
| + ~TestJavaScriptDialogPresenter();
|
| +
|
| + // JavaScriptDialogPresenter overrides:
|
| + void RunJavaScriptDialog(WebState* web_state,
|
| + const GURL& origin_url,
|
| + JavaScriptDialogType java_script_dialog_type,
|
| + NSString* message_text,
|
| + NSString* default_prompt_text,
|
| + const DialogClosedCallback& callback) override;
|
| + void CancelDialogs(WebState* web_state) override;
|
| +
|
| + // True if the JavaScriptDialogPresenter CancelDialogs method has been called.
|
| + bool cancel_dialogs_called() const { return cancel_dialogs_called_; }
|
| +
|
| + // Returns a vector of requested dialogs.
|
| + const std::vector<TestJavaScriptDialog>& requested_dialogs() const {
|
| + return requested_dialogs_;
|
| + }
|
| +
|
| + // Sets |success| argument to be used for RunJavaScriptDialog callback.
|
| + void set_callback_success_argument(bool success) {
|
| + callback_success_argument_ = success;
|
| + }
|
| +
|
| + // Sets |user_input| argument to be used for RunJavaScriptDialog callback.
|
| + void set_callback_user_input_argument(NSString* user_input) {
|
| + callback_user_input_argument_.reset(user_input);
|
| + }
|
| +
|
| + private:
|
| + bool cancel_dialogs_called_ = false;
|
| + std::vector<TestJavaScriptDialog> requested_dialogs_;
|
| + bool callback_success_argument_ = false;
|
| + base::scoped_nsobject<NSString> callback_user_input_argument_;
|
| +};
|
| +
|
| +} // namespace web
|
| +
|
| +#endif // IOS_WEB_PUBLIC_TEST_FAKES_TEST_JAVA_SCRIPT_DIALOG_PRESENTER_H_
|
|
|