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

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

Issue 304763002: Trust the renderer's same-document navigation flag if it is a same-origin nav. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: isNavigationInPage->isFragmentNavigation, with caveat on the name Created 6 years, 6 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 | Annotate | Revision Log
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/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/prefs/pref_change_registrar.h" 10 #include "base/prefs/pref_change_registrar.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 TranslateManagerRenderViewHostTest() 87 TranslateManagerRenderViewHostTest()
88 : pref_callback_( 88 : pref_callback_(
89 base::Bind(&TranslateManagerRenderViewHostTest::OnPreferenceChanged, 89 base::Bind(&TranslateManagerRenderViewHostTest::OnPreferenceChanged,
90 base::Unretained(this))) {} 90 base::Unretained(this))) {}
91 91
92 // Simulates navigating to a page and getting the page contents and language 92 // Simulates navigating to a page and getting the page contents and language
93 // for that navigation. 93 // for that navigation.
94 void SimulateNavigation(const GURL& url, 94 void SimulateNavigation(const GURL& url,
95 const std::string& lang, 95 const std::string& lang,
96 bool page_translatable) { 96 bool page_translatable) {
97 NavigateAndCommit(url); 97 if (rvh()->GetMainFrame()->GetLastCommittedURL() == url)
98 Reload();
99 else
100 NavigateAndCommit(url);
98 SimulateOnTranslateLanguageDetermined(lang, page_translatable); 101 SimulateOnTranslateLanguageDetermined(lang, page_translatable);
99 } 102 }
100 103
101 void SimulateOnTranslateLanguageDetermined(const std::string& lang, 104 void SimulateOnTranslateLanguageDetermined(const std::string& lang,
102 bool page_translatable) { 105 bool page_translatable) {
103 LanguageDetectionDetails details; 106 LanguageDetectionDetails details;
104 details.adopted_language = lang; 107 details.adopted_language = lang;
105 content::RenderViewHostTester::TestOnMessageReceived( 108 content::RenderViewHostTester::TestOnMessageReceived(
106 rvh(), 109 rvh(),
107 ChromeViewHostMsg_TranslateLanguageDetermined( 110 ChromeViewHostMsg_TranslateLanguageDetermined(
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 GURL url("http://www.google.fr"); 790 GURL url("http://www.google.fr");
788 SimulateNavigation(url, "fr", true); 791 SimulateNavigation(url, "fr", true);
789 792
790 EXPECT_TRUE(CloseTranslateInfoBar()); 793 EXPECT_TRUE(CloseTranslateInfoBar());
791 794
792 // Create a pending navigation and simulate a page load. That should be the 795 // Create a pending navigation and simulate a page load. That should be the
793 // equivalent of typing the URL again in the location bar. 796 // equivalent of typing the URL again in the location bar.
794 NavEntryCommittedObserver nav_observer(web_contents()); 797 NavEntryCommittedObserver nav_observer(web_contents());
795 web_contents()->GetController().LoadURL( 798 web_contents()->GetController().LoadURL(
796 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); 799 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string());
797 rvh_tester()->SendNavigate(0, url); 800 rvh_tester()->SendNavigateWithTransition(
801 0, url, content::PAGE_TRANSITION_TYPED);
798 802
799 // Test that we are really getting a same page navigation, the test would be 803 // Test that we are really getting a same page navigation, the test would be
800 // useless if it was not the case. 804 // useless if it was not the case.
801 const content::LoadCommittedDetails& nav_details = 805 const content::LoadCommittedDetails& nav_details =
802 nav_observer.load_committed_details(); 806 nav_observer.load_committed_details();
803 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation. 807 EXPECT_TRUE(nav_details.entry != NULL); // There was a navigation.
804 EXPECT_EQ(content::NAVIGATION_TYPE_SAME_PAGE, nav_details.type); 808 EXPECT_EQ(content::NAVIGATION_TYPE_SAME_PAGE, nav_details.type);
805 809
806 // The TranslateManager class processes the navigation entry committed 810 // The TranslateManager class processes the navigation entry committed
807 // notification in a posted task; process that task. 811 // notification in a posted task; process that task.
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 // Check the bubble exists instead of the infobar. 1548 // Check the bubble exists instead of the infobar.
1545 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar(); 1549 TranslateInfoBarDelegate* infobar = GetTranslateInfoBar();
1546 ASSERT_TRUE(infobar == NULL); 1550 ASSERT_TRUE(infobar == NULL);
1547 TranslateBubbleModel* bubble = factory->model(); 1551 TranslateBubbleModel* bubble = factory->model();
1548 ASSERT_TRUE(bubble != NULL); 1552 ASSERT_TRUE(bubble != NULL);
1549 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING, 1553 EXPECT_EQ(TranslateBubbleModel::VIEW_STATE_TRANSLATING,
1550 bubble->GetViewState()); 1554 bubble->GetViewState());
1551 } 1555 }
1552 1556
1553 #endif // defined(USE_AURA) 1557 #endif // defined(USE_AURA)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698