OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/ui/crw_web_controller.h" | 5 #import "ios/web/web_state/ui/crw_web_controller.h" |
6 | 6 |
7 #import <WebKit/WebKit.h> | 7 #import <WebKit/WebKit.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 CGFloat original_minimum_zoom_scale, | 643 CGFloat original_minimum_zoom_scale, |
644 CGFloat original_maximum_zoom_scale, | 644 CGFloat original_maximum_zoom_scale, |
645 CGFloat original_zoom_scale) const { | 645 CGFloat original_zoom_scale) const { |
646 return web::PageDisplayState( | 646 return web::PageDisplayState( |
647 scroll_offset.x, scroll_offset.y, original_minimum_zoom_scale, | 647 scroll_offset.x, scroll_offset.y, original_minimum_zoom_scale, |
648 original_maximum_zoom_scale, | 648 original_maximum_zoom_scale, |
649 relative_zoom_scale * original_minimum_zoom_scale); | 649 relative_zoom_scale * original_minimum_zoom_scale); |
650 } | 650 } |
651 }; | 651 }; |
652 | 652 |
653 // TODO(iOS): Flaky on the bots. crbug/493427 | 653 // TODO(crbug/493427): Flaky on the bots. |
654 TEST_F(CRWWebControllerPageScrollStateTest, | 654 TEST_F(CRWWebControllerPageScrollStateTest, |
655 FLAKY_SetPageDisplayStateWithUserScalableDisabled) { | 655 FLAKY_SetPageDisplayStateWithUserScalableDisabled) { |
656 #if !TARGET_IPHONE_SIMULATOR | 656 #if !TARGET_IPHONE_SIMULATOR |
657 // TODO(crbug.com/453530): fails flakily on device, so skip it there. | 657 // TODO(crbug.com/493427): fails flakily on device, so skip it there. |
658 return; | 658 return; |
659 #endif | 659 #endif |
660 web::PageZoomState zoom_state(1.0, 5.0, 1.0); | 660 web::PageZoomState zoom_state(1.0, 5.0, 1.0); |
661 LoadHtml(GetHTMLForZoomState(zoom_state, PAGE_SCALABILITY_DISABLED)); | 661 LoadHtml(GetHTMLForZoomState(zoom_state, PAGE_SCALABILITY_DISABLED)); |
662 WaitForZoomRendering(web_controller(), zoom_state); | 662 WaitForZoomRendering(web_controller(), zoom_state); |
663 web::PageZoomState original_zoom_state = | 663 web::PageZoomState original_zoom_state = |
664 web_controller().pageDisplayState.zoom_state(); | 664 web_controller().pageDisplayState.zoom_state(); |
665 | 665 |
666 web::NavigationManager* nagivation_manager = | 666 web::NavigationManager* nagivation_manager = |
667 web_state()->GetNavigationManager(); | 667 web_state()->GetNavigationManager(); |
668 nagivation_manager->GetLastCommittedItem()->SetPageDisplayState( | 668 nagivation_manager->GetLastCommittedItem()->SetPageDisplayState( |
669 CreateTestPageDisplayState(CGPointMake(1.0, 1.0), // scroll offset | 669 CreateTestPageDisplayState(CGPointMake(1.0, 1.0), // scroll offset |
670 3.0, // relative zoom scale | 670 3.0, // relative zoom scale |
671 1.0, // original minimum zoom scale | 671 1.0, // original minimum zoom scale |
672 5.0, // original maximum zoom scale | 672 5.0, // original maximum zoom scale |
673 1.0)); // original zoom scale | 673 1.0)); // original zoom scale |
674 [web_controller() restoreStateFromHistory]; | 674 [web_controller() restoreStateFromHistory]; |
675 | 675 |
676 // |-restoreStateFromHistory| is async; wait for its completion. | 676 // |-restoreStateFromHistory| is async; wait for its completion. |
677 base::test::ios::WaitUntilCondition(^bool() { | 677 base::test::ios::WaitUntilCondition(^bool() { |
678 return web_controller().pageDisplayState.scroll_state().offset_x() == 1.0; | 678 return web_controller().pageDisplayState.scroll_state().offset_x() == 1.0; |
679 }); | 679 }); |
680 | 680 |
681 ASSERT_EQ(original_zoom_state, | 681 ASSERT_EQ(original_zoom_state, |
682 web_controller().pageDisplayState.zoom_state()); | 682 web_controller().pageDisplayState.zoom_state()); |
683 }; | 683 }; |
684 | 684 |
685 // TODO(iOS): Flaky on the bots. crbug/493427 | 685 // TODO(crbug/493427): Flaky on the bots. |
686 TEST_F(CRWWebControllerPageScrollStateTest, | 686 TEST_F(CRWWebControllerPageScrollStateTest, |
687 FLAKY_SetPageDisplayStateWithUserScalableEnabled) { | 687 FLAKY_SetPageDisplayStateWithUserScalableEnabled) { |
| 688 #if !TARGET_IPHONE_SIMULATOR |
| 689 // TODO(crbug.com/493427): fails flakily on device, so skip it there. |
| 690 return; |
| 691 #endif |
688 web::PageZoomState zoom_state(1.0, 5.0, 1.0); | 692 web::PageZoomState zoom_state(1.0, 5.0, 1.0); |
689 | 693 |
690 LoadHtml(GetHTMLForZoomState(zoom_state, PAGE_SCALABILITY_ENABLED)); | 694 LoadHtml(GetHTMLForZoomState(zoom_state, PAGE_SCALABILITY_ENABLED)); |
691 WaitForZoomRendering(web_controller(), zoom_state); | 695 WaitForZoomRendering(web_controller(), zoom_state); |
692 | 696 |
693 web::NavigationManager* nagivation_manager = | 697 web::NavigationManager* nagivation_manager = |
694 web_state()->GetNavigationManager(); | 698 web_state()->GetNavigationManager(); |
695 nagivation_manager->GetLastCommittedItem()->SetPageDisplayState( | 699 nagivation_manager->GetLastCommittedItem()->SetPageDisplayState( |
696 CreateTestPageDisplayState(CGPointMake(1.0, 1.0), // scroll offset | 700 CreateTestPageDisplayState(CGPointMake(1.0, 1.0), // scroll offset |
697 3.0, // relative zoom scale | 701 3.0, // relative zoom scale |
698 1.0, // original minimum zoom scale | 702 1.0, // original minimum zoom scale |
699 5.0, // original maximum zoom scale | 703 5.0, // original maximum zoom scale |
700 1.0)); // original zoom scale | 704 1.0)); // original zoom scale |
701 [web_controller() restoreStateFromHistory]; | 705 [web_controller() restoreStateFromHistory]; |
702 | 706 |
703 // |-restoreStateFromHistory| is async; wait for its completion. | 707 // |-restoreStateFromHistory| is async; wait for its completion. |
704 base::test::ios::WaitUntilCondition(^bool() { | 708 base::test::ios::WaitUntilCondition(^bool() { |
705 return web_controller().pageDisplayState.scroll_state().offset_x() == 1.0; | 709 return web_controller().pageDisplayState.scroll_state().offset_x() == 1.0; |
706 }); | 710 }); |
707 | 711 |
708 web::PageZoomState final_zoom_state = | 712 web::PageZoomState final_zoom_state = |
709 web_controller().pageDisplayState.zoom_state(); | 713 web_controller().pageDisplayState.zoom_state(); |
710 EXPECT_FLOAT_EQ(3, final_zoom_state.zoom_scale() / | 714 EXPECT_FLOAT_EQ(3, final_zoom_state.zoom_scale() / |
711 final_zoom_state.minimum_zoom_scale()); | 715 final_zoom_state.minimum_zoom_scale()); |
712 }; | 716 }; |
713 | 717 |
714 // TODO(iOS): Flaky on the bots. crbug/493427 | 718 // TODO(crbug/493427): Flaky on the bots. |
715 TEST_F(CRWWebControllerPageScrollStateTest, FLAKY_AtTop) { | 719 TEST_F(CRWWebControllerPageScrollStateTest, FLAKY_AtTop) { |
716 // This test fails on iPhone 6/6+; skip until it's fixed. crbug.com/453105 | 720 // This test fails on iPhone 6/6+; skip until it's fixed. crbug.com/453105 |
717 if (IsIPhone6Or6Plus()) | 721 if (IsIPhone6Or6Plus()) |
718 return; | 722 return; |
719 | 723 |
720 web::PageZoomState zoom_state = web::PageZoomState(1.0, 5.0, 1.0); | 724 web::PageZoomState zoom_state = web::PageZoomState(1.0, 5.0, 1.0); |
721 LoadHtml(GetHTMLForZoomState(zoom_state, PAGE_SCALABILITY_ENABLED)); | 725 LoadHtml(GetHTMLForZoomState(zoom_state, PAGE_SCALABILITY_ENABLED)); |
722 WaitForZoomRendering(web_controller(), zoom_state); | 726 WaitForZoomRendering(web_controller(), zoom_state); |
723 ASSERT_TRUE(web_controller().atTop); | 727 ASSERT_TRUE(web_controller().atTop); |
724 | 728 |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1095 | 1099 |
1096 [web_controller() setDelegate:delegate]; | 1100 [web_controller() setDelegate:delegate]; |
1097 web::SimulateWKWebViewCrash(webView_); | 1101 web::SimulateWKWebViewCrash(webView_); |
1098 | 1102 |
1099 EXPECT_OCMOCK_VERIFY(delegate); | 1103 EXPECT_OCMOCK_VERIFY(delegate); |
1100 EXPECT_FALSE([web_controller() isViewAlive]); | 1104 EXPECT_FALSE([web_controller() isViewAlive]); |
1101 [web_controller() setDelegate:nil]; | 1105 [web_controller() setDelegate:nil]; |
1102 }; | 1106 }; |
1103 | 1107 |
1104 } // namespace | 1108 } // namespace |
OLD | NEW |