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

Unified Diff: chrome/browser/sessions/session_types_unittest.cc

Issue 11876045: [Search] Store and recall search terms using NavigationEntry to improve search term extraction (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: reupload Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sessions/session_types.cc ('k') | chrome/browser/ui/search/search.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/session_types_unittest.cc
diff --git a/chrome/browser/sessions/session_types_unittest.cc b/chrome/browser/sessions/session_types_unittest.cc
index 801d4ae8808430d90cc22696dc37c13418bc2c41..d6165642db2d7118e511f02863ae3f16315660bc 100644
--- a/chrome/browser/sessions/session_types_unittest.cc
+++ b/chrome/browser/sessions/session_types_unittest.cc
@@ -14,6 +14,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/sessions/session_types.h"
#include "chrome/browser/sessions/session_types_test_helper.h"
+#include "chrome/browser/ui/search/search.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/common/page_transition_types.h"
#include "content/public/common/referrer.h"
@@ -43,6 +44,7 @@ const int64 kPostID = 100;
const GURL kOriginalRequestURL("http://www.original-request.com");
const bool kIsOverridingUserAgent = true;
const base::Time kTimestamp = syncer::ProtoTimeToTime(100);
+const string16 kSearchTerms = ASCIIToUTF16("my search terms");
const int kPageID = 10;
@@ -60,6 +62,8 @@ scoped_ptr<content::NavigationEntry> MakeNavigationEntryForTest() {
navigation_entry->SetOriginalRequestURL(kOriginalRequestURL);
navigation_entry->SetIsOverridingUserAgent(kIsOverridingUserAgent);
navigation_entry->SetTimestamp(kTimestamp);
+ navigation_entry->SetExtraData(
+ chrome::search::kInstantExtendedSearchTermsKey, kSearchTerms);
return navigation_entry.Pass();
}
@@ -76,6 +80,7 @@ sync_pb::TabNavigation MakeSyncDataForTest() {
sync_data.set_timestamp(syncer::TimeToProtoTime(kTimestamp));
sync_data.set_redirect_type(sync_pb::SyncEnums::CLIENT_REDIRECT);
sync_data.set_navigation_home_page(true);
+ sync_data.set_search_terms(UTF16ToUTF8(kSearchTerms));
return sync_data;
}
@@ -98,6 +103,7 @@ TEST(TabNavigationTest, DefaultInitializer) {
EXPECT_EQ(GURL(), SessionTypesTestHelper::GetOriginalRequestURL(navigation));
EXPECT_FALSE(SessionTypesTestHelper::GetIsOverridingUserAgent(navigation));
EXPECT_TRUE(SessionTypesTestHelper::GetTimestamp(navigation).is_null());
+ EXPECT_TRUE(navigation.search_terms().empty());
}
// Create a TabNavigation from a NavigationEntry. All its fields
@@ -155,6 +161,7 @@ TEST(TabNavigationTest, FromSyncData) {
EXPECT_EQ(GURL(), SessionTypesTestHelper::GetOriginalRequestURL(navigation));
EXPECT_FALSE(SessionTypesTestHelper::GetIsOverridingUserAgent(navigation));
EXPECT_TRUE(SessionTypesTestHelper::GetTimestamp(navigation).is_null());
+ EXPECT_EQ(kSearchTerms, navigation.search_terms());
}
// Create a TabNavigation, pickle it, then create another one by
@@ -191,6 +198,7 @@ TEST(TabNavigationTest, Pickle) {
EXPECT_EQ(kIsOverridingUserAgent,
SessionTypesTestHelper::GetIsOverridingUserAgent(new_navigation));
EXPECT_EQ(kTimestamp, SessionTypesTestHelper::GetTimestamp(new_navigation));
+ EXPECT_EQ(kSearchTerms, new_navigation.search_terms());
}
// Create a NavigationEntry, then create another one by converting to
@@ -221,6 +229,9 @@ TEST(TabNavigationTest, ToNavigationEntry) {
new_navigation_entry->GetOriginalRequestURL());
EXPECT_EQ(kIsOverridingUserAgent,
new_navigation_entry->GetIsOverridingUserAgent());
+ EXPECT_EQ(kSearchTerms,
+ chrome::search::GetSearchTermsFromNavigationEntry(
+ new_navigation_entry.get()));
}
// Create a NavigationEntry, convert it to a TabNavigation, then
« no previous file with comments | « chrome/browser/sessions/session_types.cc ('k') | chrome/browser/ui/search/search.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698