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

Side by Side Diff: ios/web/web_state/web_state_impl_unittest.mm

Issue 2737943003: Moved window opening callback to WebStateDelegate. (Closed)
Patch Set: Self review Created 3 years, 9 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "ios/web/web_state/web_state_impl.h" 5 #import "ios/web/web_state/web_state_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 EXPECT_TRUE(observer->web_state_destroyed_info()); 413 EXPECT_TRUE(observer->web_state_destroyed_info());
414 414
415 EXPECT_EQ(nullptr, observer->web_state()); 415 EXPECT_EQ(nullptr, observer->web_state());
416 } 416 }
417 417
418 // Tests that WebStateDelegate methods appropriately called. 418 // Tests that WebStateDelegate methods appropriately called.
419 TEST_F(WebStateImplTest, DelegateTest) { 419 TEST_F(WebStateImplTest, DelegateTest) {
420 TestWebStateDelegate delegate; 420 TestWebStateDelegate delegate;
421 web_state_->SetDelegate(&delegate); 421 web_state_->SetDelegate(&delegate);
422 422
423 // Test that CreateNewWebState() is called.
424 GURL child_url("https://child.test/");
425 GURL opener_url("https://opener.test/");
426 EXPECT_FALSE(delegate.last_create_new_web_state_request());
427 web_state_->CreateNewWebState(child_url, opener_url, true);
428 TestCreateNewWebStateRequest* create_new_web_state_request =
429 delegate.last_create_new_web_state_request();
430 ASSERT_TRUE(create_new_web_state_request);
431 EXPECT_EQ(web_state_.get(), create_new_web_state_request->web_state);
432 EXPECT_EQ(child_url, create_new_web_state_request->url);
433 EXPECT_EQ(opener_url, create_new_web_state_request->opener_url);
434 EXPECT_TRUE(create_new_web_state_request->initiated_by_user);
435
436 // Test that OpenURLFromWebState() is called.
437 WebState::OpenURLParams params(GURL("https://chromium.test/"), Referrer(),
438 WindowOpenDisposition::CURRENT_TAB,
439 ui::PAGE_TRANSITION_LINK, true);
440 EXPECT_FALSE(delegate.last_open_url_request());
441 web_state_->OpenURL(params);
442 TestOpenURLRequest* open_url_request = delegate.last_open_url_request();
443 ASSERT_TRUE(open_url_request);
444 EXPECT_EQ(web_state_.get(), open_url_request->web_state);
445 WebState::OpenURLParams actual_params = open_url_request->params;
446 EXPECT_EQ(params.url, actual_params.url);
447 EXPECT_EQ(params.referrer.url, actual_params.referrer.url);
448 EXPECT_EQ(params.referrer.policy, actual_params.referrer.policy);
449 EXPECT_EQ(params.disposition, actual_params.disposition);
450 EXPECT_TRUE(
451 PageTransitionCoreTypeIs(params.transition, actual_params.transition));
452 EXPECT_EQ(params.is_renderer_initiated, actual_params.is_renderer_initiated);
453
423 // Test that HandleContextMenu() is called. 454 // Test that HandleContextMenu() is called.
424 EXPECT_FALSE(delegate.handle_context_menu_called()); 455 EXPECT_FALSE(delegate.handle_context_menu_called());
425 web::ContextMenuParams context_menu_params; 456 web::ContextMenuParams context_menu_params;
426 web_state_->HandleContextMenu(context_menu_params); 457 web_state_->HandleContextMenu(context_menu_params);
427 EXPECT_TRUE(delegate.handle_context_menu_called()); 458 EXPECT_TRUE(delegate.handle_context_menu_called());
428 459
429 // Test that ShowRepostFormWarningDialog() is called. 460 // Test that ShowRepostFormWarningDialog() is called.
430 EXPECT_FALSE(delegate.last_repost_form_request()); 461 EXPECT_FALSE(delegate.last_repost_form_request());
431 base::Callback<void(bool)> repost_callback; 462 base::Callback<void(bool)> repost_callback;
432 web_state_->ShowRepostFormWarningDialog(repost_callback); 463 web_state_->ShowRepostFormWarningDialog(repost_callback);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 // Check that a false return value is forwarded correctly. 652 // Check that a false return value is forwarded correctly.
622 EXPECT_FALSE( 653 EXPECT_FALSE(
623 web_state_->OnScriptCommandReceived(kCommand2, value_2, kUrl2, false)); 654 web_state_->OnScriptCommandReceived(kCommand2, value_2, kUrl2, false));
624 EXPECT_FALSE(is_called_1); 655 EXPECT_FALSE(is_called_1);
625 EXPECT_TRUE(is_called_2); 656 EXPECT_TRUE(is_called_2);
626 657
627 web_state_->RemoveScriptCommandCallback(kPrefix2); 658 web_state_->RemoveScriptCommandCallback(kPrefix2);
628 } 659 }
629 660
630 } // namespace web 661 } // namespace web
OLDNEW
« ios/web/public/test/fakes/test_web_state_delegate.h ('K') | « ios/web/web_state/web_state_impl.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698