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

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

Issue 2737943003: Moved window opening callback to WebStateDelegate. (Closed)
Patch Set: Rebased 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
« no previous file with comments | « ios/web/web_state/web_state_impl.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 EXPECT_TRUE(observer->web_state_destroyed_info()); 415 EXPECT_TRUE(observer->web_state_destroyed_info());
416 416
417 EXPECT_EQ(nullptr, observer->web_state()); 417 EXPECT_EQ(nullptr, observer->web_state());
418 } 418 }
419 419
420 // Tests that WebStateDelegate methods appropriately called. 420 // Tests that WebStateDelegate methods appropriately called.
421 TEST_F(WebStateImplTest, DelegateTest) { 421 TEST_F(WebStateImplTest, DelegateTest) {
422 TestWebStateDelegate delegate; 422 TestWebStateDelegate delegate;
423 web_state_->SetDelegate(&delegate); 423 web_state_->SetDelegate(&delegate);
424 424
425 // Test that CreateNewWebState() is called.
426 GURL child_url("https://child.test/");
427 GURL opener_url("https://opener.test/");
428 EXPECT_FALSE(delegate.last_create_new_web_state_request());
429 web_state_->CreateNewWebState(child_url, opener_url, true);
430 TestCreateNewWebStateRequest* create_new_web_state_request =
431 delegate.last_create_new_web_state_request();
432 ASSERT_TRUE(create_new_web_state_request);
433 EXPECT_EQ(web_state_.get(), create_new_web_state_request->web_state);
434 EXPECT_EQ(child_url, create_new_web_state_request->url);
435 EXPECT_EQ(opener_url, create_new_web_state_request->opener_url);
436 EXPECT_TRUE(create_new_web_state_request->initiated_by_user);
437
438 // Test that OpenURLFromWebState() is called.
439 WebState::OpenURLParams params(GURL("https://chromium.test/"), Referrer(),
440 WindowOpenDisposition::CURRENT_TAB,
441 ui::PAGE_TRANSITION_LINK, true);
442 EXPECT_FALSE(delegate.last_open_url_request());
443 web_state_->OpenURL(params);
444 TestOpenURLRequest* open_url_request = delegate.last_open_url_request();
445 ASSERT_TRUE(open_url_request);
446 EXPECT_EQ(web_state_.get(), open_url_request->web_state);
447 WebState::OpenURLParams actual_params = open_url_request->params;
448 EXPECT_EQ(params.url, actual_params.url);
449 EXPECT_EQ(params.referrer.url, actual_params.referrer.url);
450 EXPECT_EQ(params.referrer.policy, actual_params.referrer.policy);
451 EXPECT_EQ(params.disposition, actual_params.disposition);
452 EXPECT_TRUE(
453 PageTransitionCoreTypeIs(params.transition, actual_params.transition));
454 EXPECT_EQ(params.is_renderer_initiated, actual_params.is_renderer_initiated);
455
425 // Test that HandleContextMenu() is called. 456 // Test that HandleContextMenu() is called.
426 EXPECT_FALSE(delegate.handle_context_menu_called()); 457 EXPECT_FALSE(delegate.handle_context_menu_called());
427 web::ContextMenuParams context_menu_params; 458 web::ContextMenuParams context_menu_params;
428 web_state_->HandleContextMenu(context_menu_params); 459 web_state_->HandleContextMenu(context_menu_params);
429 EXPECT_TRUE(delegate.handle_context_menu_called()); 460 EXPECT_TRUE(delegate.handle_context_menu_called());
430 461
431 // Test that ShowRepostFormWarningDialog() is called. 462 // Test that ShowRepostFormWarningDialog() is called.
432 EXPECT_FALSE(delegate.last_repost_form_request()); 463 EXPECT_FALSE(delegate.last_repost_form_request());
433 base::Callback<void(bool)> repost_callback; 464 base::Callback<void(bool)> repost_callback;
434 web_state_->ShowRepostFormWarningDialog(repost_callback); 465 web_state_->ShowRepostFormWarningDialog(repost_callback);
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 // Check that a false return value is forwarded correctly. 654 // Check that a false return value is forwarded correctly.
624 EXPECT_FALSE( 655 EXPECT_FALSE(
625 web_state_->OnScriptCommandReceived(kCommand2, value_2, kUrl2, false)); 656 web_state_->OnScriptCommandReceived(kCommand2, value_2, kUrl2, false));
626 EXPECT_FALSE(is_called_1); 657 EXPECT_FALSE(is_called_1);
627 EXPECT_TRUE(is_called_2); 658 EXPECT_TRUE(is_called_2);
628 659
629 web_state_->RemoveScriptCommandCallback(kPrefix2); 660 web_state_->RemoveScriptCommandCallback(kPrefix2);
630 } 661 }
631 662
632 } // namespace web 663 } // namespace web
OLDNEW
« no previous file with comments | « 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