OLD | NEW |
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 #include <algorithm> | 5 #include <algorithm> |
6 #include <set> | 6 #include <set> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 GURL url("http://www.google.fr"); | 833 GURL url("http://www.google.fr"); |
834 SimulateNavigation(url, "fr", true); | 834 SimulateNavigation(url, "fr", true); |
835 | 835 |
836 EXPECT_TRUE(CloseTranslateInfoBar()); | 836 EXPECT_TRUE(CloseTranslateInfoBar()); |
837 | 837 |
838 // Create a pending navigation and simulate a page load. That should be the | 838 // Create a pending navigation and simulate a page load. That should be the |
839 // equivalent of typing the URL again in the location bar. | 839 // equivalent of typing the URL again in the location bar. |
840 NavEntryCommittedObserver nav_observer(web_contents()); | 840 NavEntryCommittedObserver nav_observer(web_contents()); |
841 web_contents()->GetController().LoadURL( | 841 web_contents()->GetController().LoadURL( |
842 url, content::Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); | 842 url, content::Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); |
| 843 int pending_id = |
| 844 web_contents()->GetController().GetPendingEntry()->GetUniqueID(); |
843 content::RenderFrameHostTester::For(web_contents()->GetMainFrame()) | 845 content::RenderFrameHostTester::For(web_contents()->GetMainFrame()) |
844 ->SendNavigateWithTransition(0, url, ui::PAGE_TRANSITION_TYPED); | 846 ->SendNavigateWithTransition(0, pending_id, false, url, |
| 847 ui::PAGE_TRANSITION_TYPED); |
845 | 848 |
846 // Test that we are really getting a same page navigation, the test would be | 849 // Test that we are really getting a same page navigation, the test would be |
847 // useless if it was not the case. | 850 // useless if it was not the case. |
848 const content::LoadCommittedDetails& nav_details = | 851 const content::LoadCommittedDetails& nav_details = |
849 nav_observer.load_committed_details(); | 852 nav_observer.load_committed_details(); |
850 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. | 853 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. |
851 EXPECT_EQ(content::NAVIGATION_TYPE_SAME_PAGE, nav_details.type); | 854 EXPECT_EQ(content::NAVIGATION_TYPE_SAME_PAGE, nav_details.type); |
852 | 855 |
853 // The TranslateManager class processes the navigation entry committed | 856 // The TranslateManager class processes the navigation entry committed |
854 // notification in a posted task; process that task. | 857 // notification in a posted task; process that task. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 | 890 |
888 EXPECT_TRUE(CloseTranslateInfoBar()); | 891 EXPECT_TRUE(CloseTranslateInfoBar()); |
889 | 892 |
890 content::RenderFrameHostTester* subframe_tester = | 893 content::RenderFrameHostTester* subframe_tester = |
891 content::RenderFrameHostTester::For( | 894 content::RenderFrameHostTester::For( |
892 content::RenderFrameHostTester::For(main_rfh()) | 895 content::RenderFrameHostTester::For(main_rfh()) |
893 ->AppendChild("subframe")); | 896 ->AppendChild("subframe")); |
894 | 897 |
895 // Simulate a sub-frame auto-navigating. | 898 // Simulate a sub-frame auto-navigating. |
896 subframe_tester->SendNavigateWithTransition( | 899 subframe_tester->SendNavigateWithTransition( |
897 0, GURL("http://pub.com"), ui::PAGE_TRANSITION_AUTO_SUBFRAME); | 900 0, 0, false, GURL("http://pub.com"), ui::PAGE_TRANSITION_AUTO_SUBFRAME); |
898 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 901 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
899 | 902 |
900 // Simulate the user navigating in a sub-frame. | 903 // Simulate the user navigating in a sub-frame. |
901 subframe_tester->SendNavigateWithTransition( | 904 subframe_tester->SendNavigateWithTransition( |
902 1, GURL("http://pub.com"), ui::PAGE_TRANSITION_MANUAL_SUBFRAME); | 905 1, 0, true, GURL("http://pub.com"), ui::PAGE_TRANSITION_MANUAL_SUBFRAME); |
903 EXPECT_TRUE(GetTranslateInfoBar() == NULL); | 906 EXPECT_TRUE(GetTranslateInfoBar() == NULL); |
904 | 907 |
905 // Navigate out of page, a new infobar should show. | 908 // Navigate out of page, a new infobar should show. |
906 SimulateNavigation(GURL("http://www.google.fr/foot"), "fr", true); | 909 SimulateNavigation(GURL("http://www.google.fr/foot"), "fr", true); |
907 EXPECT_TRUE(GetTranslateInfoBar() != NULL); | 910 EXPECT_TRUE(GetTranslateInfoBar() != NULL); |
908 } | 911 } |
909 | 912 |
910 // Tests that denying translation is sticky when navigating in page. | 913 // Tests that denying translation is sticky when navigating in page. |
911 TEST_F(TranslateManagerRenderViewHostTest, DenyTranslateInPageNavigation) { | 914 TEST_F(TranslateManagerRenderViewHostTest, DenyTranslateInPageNavigation) { |
912 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235 | 915 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235 |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1669 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE, 0); | 1672 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE, 0); |
1670 | 1673 |
1671 // Check the bubble exists instead of the infobar. | 1674 // Check the bubble exists instead of the infobar. |
1672 translate::TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); | 1675 translate::TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); |
1673 ASSERT_TRUE(infobar == NULL); | 1676 ASSERT_TRUE(infobar == NULL); |
1674 TranslateBubbleModel* bubble = factory->model(); | 1677 TranslateBubbleModel* bubble = factory->model(); |
1675 ASSERT_TRUE(bubble != NULL); | 1678 ASSERT_TRUE(bubble != NULL); |
1676 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, | 1679 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, |
1677 bubble->GetViewState()); | 1680 bubble->GetViewState()); |
1678 } | 1681 } |
OLD | NEW |