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

Unified Diff: chrome/browser/ui/search/search_ipc_router_unittest.cc

Issue 701973002: Separate checking the user identity and checking if the user is syncing his history in two differen… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Answered kmadhusu and dcheng Created 6 years, 1 month 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
Index: chrome/browser/ui/search/search_ipc_router_unittest.cc
diff --git a/chrome/browser/ui/search/search_ipc_router_unittest.cc b/chrome/browser/ui/search/search_ipc_router_unittest.cc
index d4836c640f4de180f4ecec803ff820dbf73b6e7c..818a2c5fe44604e8fd14b714fa9009fdc6a6205e 100644
--- a/chrome/browser/ui/search/search_ipc_router_unittest.cc
+++ b/chrome/browser/ui/search/search_ipc_router_unittest.cc
@@ -58,6 +58,7 @@ class MockSearchIPCRouterDelegate : public SearchIPCRouter::Delegate {
void(int position, const base::string16& provider));
MOCK_METHOD1(PasteIntoOmnibox, void(const base::string16&));
MOCK_METHOD1(OnChromeIdentityCheck, void(const base::string16& identity));
+ MOCK_METHOD0(OnHistorySyncCheck, void());
};
class MockSearchIPCRouterPolicy : public SearchIPCRouter::Policy {
@@ -73,6 +74,7 @@ class MockSearchIPCRouterPolicy : public SearchIPCRouter::Policy {
MOCK_METHOD0(ShouldProcessLogEvent, bool());
MOCK_METHOD1(ShouldProcessPasteIntoOmnibox, bool(bool));
MOCK_METHOD0(ShouldProcessChromeIdentityCheck, bool());
+ MOCK_METHOD0(ShouldProcessHistorySyncCheck, bool());
MOCK_METHOD0(ShouldSendSetPromoInformation, bool());
MOCK_METHOD0(ShouldSendSetDisplayInstantResults, bool());
MOCK_METHOD0(ShouldSendSetSuggestionToPrefetch, bool());
@@ -211,11 +213,9 @@ TEST_F(SearchIPCRouterTest, IgnoreMessagesFromNonInstantRenderers) {
MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
EXPECT_CALL(*policy, ShouldProcessNavigateToURL(is_active_tab)).Times(0);
- scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_SearchBoxNavigate(
- contents->GetRoutingID(),
- GetSearchIPCRouterSeqNo(),
- destination_url, CURRENT_TAB, true));
- OnMessageReceived(*message);
+ OnMessageReceived(ChromeViewHostMsg_SearchBoxNavigate(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), destination_url,
+ CURRENT_TAB, true));
}
TEST_F(SearchIPCRouterTest, ProcessVoiceSearchSupportMsg) {
@@ -227,10 +227,8 @@ TEST_F(SearchIPCRouterTest, ProcessVoiceSearchSupportMsg) {
.WillOnce(testing::Return(true));
content::WebContents* contents = web_contents();
- scoped_ptr<IPC::Message> message(
- new ChromeViewHostMsg_SetVoiceSearchSupported(
- contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), true));
- OnMessageReceived(*message);
+ OnMessageReceived(ChromeViewHostMsg_SetVoiceSearchSupported(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), true));
}
TEST_F(SearchIPCRouterTest, IgnoreVoiceSearchSupportMsg) {
@@ -242,10 +240,8 @@ TEST_F(SearchIPCRouterTest, IgnoreVoiceSearchSupportMsg) {
.WillOnce(testing::Return(false));
content::WebContents* contents = web_contents();
- scoped_ptr<IPC::Message> message(
- new ChromeViewHostMsg_SetVoiceSearchSupported(
- contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), true));
- OnMessageReceived(*message);
+ OnMessageReceived(ChromeViewHostMsg_SetVoiceSearchSupported(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), true));
}
TEST_F(SearchIPCRouterTest, ProcessFocusOmniboxMsg) {
@@ -260,11 +256,9 @@ TEST_F(SearchIPCRouterTest, ProcessFocusOmniboxMsg) {
EXPECT_CALL(*policy, ShouldProcessFocusOmnibox(is_active_tab)).Times(1)
.WillOnce(testing::Return(true));
- scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_FocusOmnibox(
- contents->GetRoutingID(),
- GetSearchIPCRouterSeqNo(),
+ OnMessageReceived(ChromeViewHostMsg_FocusOmnibox(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo(),
OMNIBOX_FOCUS_VISIBLE));
- OnMessageReceived(*message);
}
TEST_F(SearchIPCRouterTest, IgnoreFocusOmniboxMsg) {
@@ -279,11 +273,9 @@ TEST_F(SearchIPCRouterTest, IgnoreFocusOmniboxMsg) {
EXPECT_CALL(*policy, ShouldProcessFocusOmnibox(is_active_tab)).Times(1)
.WillOnce(testing::Return(false));
- scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_FocusOmnibox(
- contents->GetRoutingID(),
- GetSearchIPCRouterSeqNo(),
+ OnMessageReceived(ChromeViewHostMsg_FocusOmnibox(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo(),
OMNIBOX_FOCUS_VISIBLE));
- OnMessageReceived(*message);
}
TEST_F(SearchIPCRouterTest, HandleTabChangedEvents) {
@@ -320,11 +312,9 @@ TEST_F(SearchIPCRouterTest, ProcessNavigateToURLMsg) {
EXPECT_CALL(*policy, ShouldProcessNavigateToURL(is_active_tab)).Times(1)
.WillOnce(testing::Return(true));
- scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_SearchBoxNavigate(
- contents->GetRoutingID(),
- GetSearchIPCRouterSeqNo(),
- destination_url, CURRENT_TAB, true));
- OnMessageReceived(*message);
+ OnMessageReceived(ChromeViewHostMsg_SearchBoxNavigate(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), destination_url,
+ CURRENT_TAB, true));
}
TEST_F(SearchIPCRouterTest, IgnoreNavigateToURLMsg) {
@@ -341,11 +331,9 @@ TEST_F(SearchIPCRouterTest, IgnoreNavigateToURLMsg) {
EXPECT_CALL(*policy, ShouldProcessNavigateToURL(is_active_tab)).Times(1)
.WillOnce(testing::Return(false));
- scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_SearchBoxNavigate(
- contents->GetRoutingID(),
- GetSearchIPCRouterSeqNo(),
- destination_url, CURRENT_TAB, true));
- OnMessageReceived(*message);
+ OnMessageReceived(ChromeViewHostMsg_SearchBoxNavigate(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), destination_url,
+ CURRENT_TAB, true));
}
TEST_F(SearchIPCRouterTest, ProcessLogEventMsg) {
@@ -357,10 +345,8 @@ TEST_F(SearchIPCRouterTest, ProcessLogEventMsg) {
.WillOnce(testing::Return(true));
content::WebContents* contents = web_contents();
- scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_LogEvent(
- contents->GetRoutingID(), GetSearchIPCRouterSeqNo(),
- NTP_MOUSEOVER));
- OnMessageReceived(*message);
+ OnMessageReceived(ChromeViewHostMsg_LogEvent(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), NTP_MOUSEOVER));
}
TEST_F(SearchIPCRouterTest, IgnoreLogEventMsg) {
@@ -372,10 +358,8 @@ TEST_F(SearchIPCRouterTest, IgnoreLogEventMsg) {
.WillOnce(testing::Return(false));
content::WebContents* contents = web_contents();
- scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_LogEvent(
- contents->GetRoutingID(), GetSearchIPCRouterSeqNo(),
- NTP_MOUSEOVER));
- OnMessageReceived(*message);
+ OnMessageReceived(ChromeViewHostMsg_LogEvent(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), NTP_MOUSEOVER));
}
TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedImpressionMsg) {
@@ -388,13 +372,9 @@ TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedImpressionMsg) {
.WillOnce(testing::Return(true));
content::WebContents* contents = web_contents();
- scoped_ptr<IPC::Message> message(
- new ChromeViewHostMsg_LogMostVisitedImpression(
- contents->GetRoutingID(),
- GetSearchIPCRouterSeqNo(),
- 3,
+ OnMessageReceived(ChromeViewHostMsg_LogMostVisitedImpression(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), 3,
base::ASCIIToUTF16("Server")));
- OnMessageReceived(*message);
}
TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedNavigationMsg) {
@@ -407,13 +387,9 @@ TEST_F(SearchIPCRouterTest, ProcessLogMostVisitedNavigationMsg) {
.WillOnce(testing::Return(true));
content::WebContents* contents = web_contents();
- scoped_ptr<IPC::Message> message(
- new ChromeViewHostMsg_LogMostVisitedNavigation(
- contents->GetRoutingID(),
- GetSearchIPCRouterSeqNo(),
- 3,
+ OnMessageReceived(ChromeViewHostMsg_LogMostVisitedNavigation(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), 3,
base::ASCIIToUTF16("Server")));
- OnMessageReceived(*message);
}
TEST_F(SearchIPCRouterTest, ProcessChromeIdentityCheckMsg) {
@@ -426,9 +402,8 @@ TEST_F(SearchIPCRouterTest, ProcessChromeIdentityCheckMsg) {
.WillOnce(testing::Return(true));
content::WebContents* contents = web_contents();
- scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_ChromeIdentityCheck(
+ OnMessageReceived(ChromeViewHostMsg_ChromeIdentityCheck(
contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), test_identity));
- OnMessageReceived(*message);
}
TEST_F(SearchIPCRouterTest, IgnoreChromeIdentityCheckMsg) {
@@ -442,9 +417,35 @@ TEST_F(SearchIPCRouterTest, IgnoreChromeIdentityCheckMsg) {
.WillOnce(testing::Return(false));
content::WebContents* contents = web_contents();
- scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_ChromeIdentityCheck(
+ OnMessageReceived(ChromeViewHostMsg_ChromeIdentityCheck(
contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), test_identity));
- OnMessageReceived(*message);
+}
+
+TEST_F(SearchIPCRouterTest, ProcessHistorySyncCheckMsg) {
+ NavigateAndCommitActiveTab(GURL(chrome::kChromeSearchLocalNtpUrl));
+ SetupMockDelegateAndPolicy();
+ MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
+ EXPECT_CALL(*mock_delegate(), OnHistorySyncCheck()).Times(1);
+ EXPECT_CALL(*policy, ShouldProcessHistorySyncCheck()).Times(1)
+ .WillOnce(testing::Return(true));
+
+ content::WebContents* contents = web_contents();
+ OnMessageReceived(ChromeViewHostMsg_HistorySyncCheck(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo()));
+}
+
+TEST_F(SearchIPCRouterTest, IgnoreHistorySyncCheckMsg) {
+ NavigateAndCommitActiveTab(GURL("chrome-search://foo/bar"));
+ SetupMockDelegateAndPolicy();
+ MockSearchIPCRouterPolicy* policy = GetSearchIPCRouterPolicy();
+
+ EXPECT_CALL(*mock_delegate(), OnHistorySyncCheck()).Times(0);
+ EXPECT_CALL(*policy, ShouldProcessHistorySyncCheck()).Times(1)
+ .WillOnce(testing::Return(false));
+
+ content::WebContents* contents = web_contents();
+ OnMessageReceived(ChromeViewHostMsg_HistorySyncCheck(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo()));
}
TEST_F(SearchIPCRouterTest, ProcessDeleteMostVisitedItemMsg) {
@@ -457,10 +458,8 @@ TEST_F(SearchIPCRouterTest, ProcessDeleteMostVisitedItemMsg) {
.WillOnce(testing::Return(true));
content::WebContents* contents = web_contents();
- scoped_ptr<IPC::Message> message(
- new ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem(
- contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), item_url));
- OnMessageReceived(*message);
+ OnMessageReceived(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), item_url));
}
TEST_F(SearchIPCRouterTest, IgnoreDeleteMostVisitedItemMsg) {
@@ -473,10 +472,8 @@ TEST_F(SearchIPCRouterTest, IgnoreDeleteMostVisitedItemMsg) {
.WillOnce(testing::Return(false));
content::WebContents* contents = web_contents();
- scoped_ptr<IPC::Message> message(
- new ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem(
- contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), item_url));
- OnMessageReceived(*message);
+ OnMessageReceived(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), item_url));
}
TEST_F(SearchIPCRouterTest, ProcessUndoMostVisitedDeletionMsg) {
@@ -489,10 +486,8 @@ TEST_F(SearchIPCRouterTest, ProcessUndoMostVisitedDeletionMsg) {
.WillOnce(testing::Return(true));
content::WebContents* contents = web_contents();
- scoped_ptr<IPC::Message> message(
- new ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion(
- contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), item_url));
- OnMessageReceived(*message);
+ OnMessageReceived(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), item_url));
}
TEST_F(SearchIPCRouterTest, IgnoreUndoMostVisitedDeletionMsg) {
@@ -505,10 +500,8 @@ TEST_F(SearchIPCRouterTest, IgnoreUndoMostVisitedDeletionMsg) {
.WillOnce(testing::Return(false));
content::WebContents* contents = web_contents();
- scoped_ptr<IPC::Message> message(
- new ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion(
- contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), item_url));
- OnMessageReceived(*message);
+ OnMessageReceived(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), item_url));
}
TEST_F(SearchIPCRouterTest, ProcessUndoAllMostVisitedDeletionsMsg) {
@@ -520,10 +513,8 @@ TEST_F(SearchIPCRouterTest, ProcessUndoAllMostVisitedDeletionsMsg) {
.WillOnce(testing::Return(true));
content::WebContents* contents = web_contents();
- scoped_ptr<IPC::Message> message(
- new ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions(
- contents->GetRoutingID(), GetSearchIPCRouterSeqNo()));
- OnMessageReceived(*message);
+ OnMessageReceived(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo()));
}
TEST_F(SearchIPCRouterTest, IgnoreUndoAllMostVisitedDeletionsMsg) {
@@ -535,10 +526,8 @@ TEST_F(SearchIPCRouterTest, IgnoreUndoAllMostVisitedDeletionsMsg) {
.WillOnce(testing::Return(false));
content::WebContents* contents = web_contents();
- scoped_ptr<IPC::Message> message(
- new ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions(
- contents->GetRoutingID(), GetSearchIPCRouterSeqNo()));
- OnMessageReceived(*message);
+ OnMessageReceived(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions(
+ contents->GetRoutingID(), GetSearchIPCRouterSeqNo()));
}
TEST_F(SearchIPCRouterTest, IgnoreMessageIfThePageIsNotActive) {
@@ -557,50 +546,39 @@ TEST_F(SearchIPCRouterTest, IgnoreMessageIfThePageIsNotActive) {
// we'll decrement the sequence number on this side to simulate it.
--page_seq_no;
EXPECT_CALL(*policy, ShouldProcessNavigateToURL(is_active_tab)).Times(0);
-
- scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_SearchBoxNavigate(
- contents->GetRoutingID(), page_seq_no, item_url,
- CURRENT_TAB, true));
- OnMessageReceived(*message);
+ OnMessageReceived(ChromeViewHostMsg_SearchBoxNavigate(
+ contents->GetRoutingID(), page_seq_no, item_url, CURRENT_TAB, true));
EXPECT_CALL(*mock_delegate(), OnDeleteMostVisitedItem(item_url)).Times(0);
EXPECT_CALL(*policy, ShouldProcessDeleteMostVisitedItem()).Times(0);
- message.reset(new ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem(
+ OnMessageReceived(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem(
contents->GetRoutingID(), page_seq_no, item_url));
- OnMessageReceived(*message);
EXPECT_CALL(*mock_delegate(), OnUndoMostVisitedDeletion(item_url)).Times(0);
EXPECT_CALL(*policy, ShouldProcessUndoMostVisitedDeletion()).Times(0);
- message.reset(new ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion(
+ OnMessageReceived(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion(
contents->GetRoutingID(), page_seq_no, item_url));
- OnMessageReceived(*message);
EXPECT_CALL(*mock_delegate(), OnUndoAllMostVisitedDeletions()).Times(0);
EXPECT_CALL(*policy, ShouldProcessUndoAllMostVisitedDeletions()).Times(0);
- message.reset(new ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions(
+ OnMessageReceived(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions(
contents->GetRoutingID(), page_seq_no));
- OnMessageReceived(*message);
EXPECT_CALL(*mock_delegate(), FocusOmnibox(OMNIBOX_FOCUS_VISIBLE)).Times(0);
EXPECT_CALL(*policy, ShouldProcessFocusOmnibox(is_active_tab)).Times(0);
- message.reset(new ChromeViewHostMsg_FocusOmnibox(
- contents->GetRoutingID(), page_seq_no,
- OMNIBOX_FOCUS_VISIBLE));
- OnMessageReceived(*message);
+ OnMessageReceived(ChromeViewHostMsg_FocusOmnibox(
+ contents->GetRoutingID(), page_seq_no, OMNIBOX_FOCUS_VISIBLE));
EXPECT_CALL(*mock_delegate(), OnLogEvent(NTP_MOUSEOVER)).Times(0);
EXPECT_CALL(*policy, ShouldProcessLogEvent()).Times(0);
- message.reset(new ChromeViewHostMsg_LogEvent(contents->GetRoutingID(),
- page_seq_no,
- NTP_MOUSEOVER));
- OnMessageReceived(*message);
+ OnMessageReceived(ChromeViewHostMsg_LogEvent(
+ contents->GetRoutingID(), page_seq_no, NTP_MOUSEOVER));
base::string16 text;
EXPECT_CALL(*mock_delegate(), PasteIntoOmnibox(text)).Times(0);
EXPECT_CALL(*policy, ShouldProcessPasteIntoOmnibox(is_active_tab)).Times(0);
- message.reset(new ChromeViewHostMsg_PasteAndOpenDropdown(
+ OnMessageReceived(ChromeViewHostMsg_PasteAndOpenDropdown(
contents->GetRoutingID(), page_seq_no, text));
- OnMessageReceived(*message);
}
TEST_F(SearchIPCRouterTest, ProcessPasteAndOpenDropdownMsg) {
@@ -616,9 +594,8 @@ TEST_F(SearchIPCRouterTest, ProcessPasteAndOpenDropdownMsg) {
EXPECT_CALL(*mock_delegate(), PasteIntoOmnibox(text)).Times(1);
EXPECT_CALL(*policy, ShouldProcessPasteIntoOmnibox(is_active_tab)).Times(1)
.WillOnce(testing::Return(true));
- scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_PasteAndOpenDropdown(
+ OnMessageReceived(ChromeViewHostMsg_PasteAndOpenDropdown(
contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), text));
- OnMessageReceived(*message);
}
TEST_F(SearchIPCRouterTest, IgnorePasteAndOpenDropdownMsg) {
@@ -635,9 +612,8 @@ TEST_F(SearchIPCRouterTest, IgnorePasteAndOpenDropdownMsg) {
EXPECT_CALL(*policy, ShouldProcessPasteIntoOmnibox(is_active_tab)).Times(1)
.WillOnce(testing::Return(false));
- scoped_ptr<IPC::Message> message(new ChromeViewHostMsg_PasteAndOpenDropdown(
+ OnMessageReceived(ChromeViewHostMsg_PasteAndOpenDropdown(
contents->GetRoutingID(), GetSearchIPCRouterSeqNo(), text));
- OnMessageReceived(*message);
}
TEST_F(SearchIPCRouterTest, SendSetPromoInformationMsg) {

Powered by Google App Engine
This is Rietveld 408576698