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

Unified Diff: ios/web/web_state/web_state_delegate_bridge_unittest.mm

Issue 2642233004: Removed Form Resubmission callback from CRWWebDelegate. (Closed)
Patch Set: Added ShowRepostFormWarningWithNoDelegateMethod test 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/web_state/web_state_delegate_bridge.mm ('k') | ios/web/web_state/web_state_delegate_stub.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/web_state_delegate_bridge_unittest.mm
diff --git a/ios/web/web_state/web_state_delegate_bridge_unittest.mm b/ios/web/web_state/web_state_delegate_bridge_unittest.mm
index 422b0ecb4907405f5a40d74ef7370cc8a7e10502..1429a63bee58a60c7709e6026aa92a2b9e2f4fa7 100644
--- a/ios/web/web_state/web_state_delegate_bridge_unittest.mm
+++ b/ios/web/web_state/web_state_delegate_bridge_unittest.mm
@@ -8,6 +8,7 @@
#include <memory>
+#include "base/mac/bind_objc_block.h"
#import "base/mac/scoped_nsobject.h"
#include "base/strings/utf_string_conversions.h"
#import "ios/web/public/test/fakes/test_web_state.h"
@@ -17,6 +18,13 @@
#import "third_party/ocmock/gtest_support.h"
#include "ui/base/page_transition_types.h"
+// Class which conforms to CRWWebStateDelegate protocol, but does not implement
+// any optional methods.
+@interface TestEmptyWebStateDelegate : NSObject<CRWWebStateDelegate>
+@end
+@implementation TestEmptyWebStateDelegate
+@end
+
namespace web {
// Test fixture to test WebStateDelegateBridge class.
@@ -29,8 +37,11 @@ class WebStateDelegateBridgeTest : public PlatformTest {
[OCMockObject niceMockForProtocol:@protocol(CRWWebStateDelegate)];
delegate_.reset([[CRWWebStateDelegateStub alloc]
initWithRepresentedObject:originalMockDelegate]);
+ empty_delegate_.reset([[TestEmptyWebStateDelegate alloc] init]);
bridge_.reset(new WebStateDelegateBridge(delegate_.get()));
+ empty_delegate_bridge_.reset(
+ new WebStateDelegateBridge(empty_delegate_.get()));
}
void TearDown() override {
@@ -39,7 +50,9 @@ class WebStateDelegateBridgeTest : public PlatformTest {
}
base::scoped_nsprotocol<id> delegate_;
+ base::scoped_nsprotocol<id> empty_delegate_;
std::unique_ptr<WebStateDelegateBridge> bridge_;
+ std::unique_ptr<WebStateDelegateBridge> empty_delegate_bridge_;
web::TestWebState test_web_state_;
};
@@ -97,6 +110,28 @@ TEST_F(WebStateDelegateBridgeTest, HandleContextMenu) {
EXPECT_EQ(context_menu_params.location.y, result_params->location.y);
}
+// Tests |ShowRepostFormWarningDialog| forwarding.
+TEST_F(WebStateDelegateBridgeTest, ShowRepostFormWarningDialog) {
+ EXPECT_FALSE([delegate_ repostFormWarningRequested]);
+ EXPECT_FALSE([delegate_ webState]);
+ base::Callback<void(bool)> callback;
+ bridge_->ShowRepostFormWarningDialog(&test_web_state_, callback);
+ EXPECT_TRUE([delegate_ repostFormWarningRequested]);
+ EXPECT_EQ(&test_web_state_, [delegate_ webState]);
+}
+
+// Tests |ShowRepostFormWarningDialog| forwarding to delegate which does not
+// implement |webState:runRepostFormDialogWithCompletionHandler:| method.
+TEST_F(WebStateDelegateBridgeTest, ShowRepostFormWarningWithNoDelegateMethod) {
+ __block bool callback_called = false;
+ empty_delegate_bridge_->ShowRepostFormWarningDialog(
+ nullptr, base::BindBlock(^(bool should_repost) {
+ EXPECT_TRUE(should_repost);
+ callback_called = true;
+ }));
+ EXPECT_TRUE(callback_called);
+}
+
// Tests |GetJavaScriptDialogPresenter| forwarding.
TEST_F(WebStateDelegateBridgeTest, GetJavaScriptDialogPresenter) {
EXPECT_FALSE([delegate_ javaScriptDialogPresenterRequested]);
« no previous file with comments | « ios/web/web_state/web_state_delegate_bridge.mm ('k') | ios/web/web_state/web_state_delegate_stub.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698