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

Side by Side Diff: chrome/browser/translate/translate_manager_render_view_host_unittest.cc

Issue 1110943003: Revert of Classify navigations without page id in parallel to the existing classifier. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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 #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
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();
845 content::RenderFrameHostTester::For(web_contents()->GetMainFrame()) 843 content::RenderFrameHostTester::For(web_contents()->GetMainFrame())
846 ->SendNavigateWithTransition(0, pending_id, false, url, 844 ->SendNavigateWithTransition(0, url, ui::PAGE_TRANSITION_TYPED);
847 ui::PAGE_TRANSITION_TYPED);
848 845
849 // Test that we are really getting a same page navigation, the test would be 846 // Test that we are really getting a same page navigation, the test would be
850 // useless if it was not the case. 847 // useless if it was not the case.
851 const content::LoadCommittedDetails& nav_details = 848 const content::LoadCommittedDetails& nav_details =
852 nav_observer.load_committed_details(); 849 nav_observer.load_committed_details();
853 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. 850 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation.
854 EXPECT_EQ(content::NAVIGATION_TYPE_SAME_PAGE, nav_details.type); 851 EXPECT_EQ(content::NAVIGATION_TYPE_SAME_PAGE, nav_details.type);
855 852
856 // The TranslateManager class processes the navigation entry committed 853 // The TranslateManager class processes the navigation entry committed
857 // notification in a posted task; process that task. 854 // notification in a posted task; process that task.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 887
891 EXPECT_TRUE(CloseTranslateInfoBar()); 888 EXPECT_TRUE(CloseTranslateInfoBar());
892 889
893 content::RenderFrameHostTester* subframe_tester = 890 content::RenderFrameHostTester* subframe_tester =
894 content::RenderFrameHostTester::For( 891 content::RenderFrameHostTester::For(
895 content::RenderFrameHostTester::For(main_rfh()) 892 content::RenderFrameHostTester::For(main_rfh())
896 ->AppendChild("subframe")); 893 ->AppendChild("subframe"));
897 894
898 // Simulate a sub-frame auto-navigating. 895 // Simulate a sub-frame auto-navigating.
899 subframe_tester->SendNavigateWithTransition( 896 subframe_tester->SendNavigateWithTransition(
900 0, 0, false, GURL("http://pub.com"), ui::PAGE_TRANSITION_AUTO_SUBFRAME); 897 0, GURL("http://pub.com"), ui::PAGE_TRANSITION_AUTO_SUBFRAME);
901 EXPECT_TRUE(GetTranslateInfoBar() == NULL); 898 EXPECT_TRUE(GetTranslateInfoBar() == NULL);
902 899
903 // Simulate the user navigating in a sub-frame. 900 // Simulate the user navigating in a sub-frame.
904 subframe_tester->SendNavigateWithTransition( 901 subframe_tester->SendNavigateWithTransition(
905 1, 0, true, GURL("http://pub.com"), ui::PAGE_TRANSITION_MANUAL_SUBFRAME); 902 1, GURL("http://pub.com"), ui::PAGE_TRANSITION_MANUAL_SUBFRAME);
906 EXPECT_TRUE(GetTranslateInfoBar() == NULL); 903 EXPECT_TRUE(GetTranslateInfoBar() == NULL);
907 904
908 // Navigate out of page, a new infobar should show. 905 // Navigate out of page, a new infobar should show.
909 SimulateNavigation(GURL("http://www.google.fr/foot"), "fr", true); 906 SimulateNavigation(GURL("http://www.google.fr/foot"), "fr", true);
910 EXPECT_TRUE(GetTranslateInfoBar() != NULL); 907 EXPECT_TRUE(GetTranslateInfoBar() != NULL);
911 } 908 }
912 909
913 // Tests that denying translation is sticky when navigating in page. 910 // Tests that denying translation is sticky when navigating in page.
914 TEST_F(TranslateManagerRenderViewHostTest, DenyTranslateInPageNavigation) { 911 TEST_F(TranslateManagerRenderViewHostTest, DenyTranslateInPageNavigation) {
915 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235 912 // TODO(port): Test corresponding bubble translate UX: http://crbug.com/383235
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE, 0); 1669 menu->ExecuteCommand(IDC_CONTENT_CONTEXT_TRANSLATE, 0);
1673 1670
1674 // Check the bubble exists instead of the infobar. 1671 // Check the bubble exists instead of the infobar.
1675 translate::TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); 1672 translate::TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
1676 ASSERT_TRUE(infobar == NULL); 1673 ASSERT_TRUE(infobar == NULL);
1677 TranslateBubbleModel* bubble = factory->model(); 1674 TranslateBubbleModel* bubble = factory->model();
1678 ASSERT_TRUE(bubble != NULL); 1675 ASSERT_TRUE(bubble != NULL);
1679 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, 1676 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING,
1680 bubble->GetViewState()); 1677 bubble->GetViewState());
1681 } 1678 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698