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

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

Issue 2086223002: Convert instant search messages to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge Created 3 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
Index: chrome/browser/ui/search/instant_tab_unittest.cc
diff --git a/chrome/browser/ui/search/instant_tab_unittest.cc b/chrome/browser/ui/search/instant_tab_unittest.cc
index b417daf21942a392e6f9dc1e8dfec4d0c7235809..8991f260de3f0b39483a2fd51553b6e5e254d3ea 100644
--- a/chrome/browser/ui/search/instant_tab_unittest.cc
+++ b/chrome/browser/ui/search/instant_tab_unittest.cc
@@ -9,9 +9,11 @@
#include <memory>
#include "base/command_line.h"
+#include "chrome/browser/ui/search/search_ipc_router.h"
#include "chrome/browser/ui/search/search_tab_helper.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/render_messages.h"
+#include "chrome/common/search/mock_searchbox.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "content/public/browser/navigation_controller.h"
@@ -23,6 +25,8 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
+using testing::Return;
+
class Profile;
namespace {
@@ -36,8 +40,13 @@ class FakePageDelegate : public InstantTab::Delegate {
void(const content::WebContents* contents,
bool supports_instant));
MOCK_METHOD2(InstantTabAboutToNavigateMainFrame,
- void(const content::WebContents* contents,
- const GURL& url));
+ void(const content::WebContents* contents, const GURL& url));
+};
+
+class MockSearchBoxClientFactory
+ : public SearchIPCRouter::SearchBoxClientFactory {
+ public:
+ MOCK_METHOD0(GetSearchBox, chrome::mojom::SearchBox*(void));
};
} // namespace
@@ -56,11 +65,17 @@ class InstantTabTest : public ChromeRenderViewHostTestHarness {
std::unique_ptr<InstantTab> page;
FakePageDelegate delegate;
+ MockSearchBox mock_search_box;
};
void InstantTabTest::SetUp() {
ChromeRenderViewHostTestHarness::SetUp();
SearchTabHelper::CreateForWebContents(web_contents());
+ auto factory = base::MakeUnique<MockSearchBoxClientFactory>();
+ ON_CALL(*factory, GetSearchBox()).WillByDefault(Return(&mock_search_box));
+ search_tab()
+ ->ipc_router_for_testing()
+ .set_search_box_client_factory_for_testing(std::move(factory));
}
TEST_F(InstantTabTest, DetermineIfPageSupportsInstant_Local) {
@@ -78,13 +93,8 @@ TEST_F(InstantTabTest, DetermineIfPageSupportsInstant_NonLocal) {
EXPECT_FALSE(SupportsInstant());
page->Init();
NavigateAndCommit(GURL("chrome-search://foo/bar"));
- process()->sink().ClearMessages();
+ EXPECT_CALL(mock_search_box, DetermineIfPageSupportsInstant());
search_tab()->DetermineIfPageSupportsInstant();
- const IPC::Message* message = process()->sink().GetFirstMessageMatching(
- ChromeViewMsg_DetermineIfPageSupportsInstant::ID);
- ASSERT_TRUE(message != NULL);
- EXPECT_EQ(web_contents()->GetRenderViewHost()->GetRoutingID(),
- message->routing_id());
}
TEST_F(InstantTabTest, PageURLDoesntBelongToInstantRenderer) {
@@ -97,13 +107,10 @@ TEST_F(InstantTabTest, PageURLDoesntBelongToInstantRenderer) {
// SearchTabHelper::DeterminerIfPageSupportsInstant() should return
// immediately without dispatching any message to the renderer.
NavigateAndCommit(GURL("http://www.example.com"));
- process()->sink().ClearMessages();
EXPECT_CALL(delegate, InstantSupportDetermined(web_contents(), false));
+ EXPECT_CALL(mock_search_box, DetermineIfPageSupportsInstant()).Times(0);
search_tab()->DetermineIfPageSupportsInstant();
- const IPC::Message* message = process()->sink().GetFirstMessageMatching(
- ChromeViewMsg_DetermineIfPageSupportsInstant::ID);
- ASSERT_TRUE(message == NULL);
EXPECT_FALSE(SupportsInstant());
}
@@ -114,13 +121,8 @@ TEST_F(InstantTabTest, PageSupportsInstant) {
EXPECT_FALSE(SupportsInstant());
page->Init();
NavigateAndCommit(GURL("chrome-search://foo/bar"));
- process()->sink().ClearMessages();
+ EXPECT_CALL(mock_search_box, DetermineIfPageSupportsInstant());
search_tab()->DetermineIfPageSupportsInstant();
- const IPC::Message* message = process()->sink().GetFirstMessageMatching(
- ChromeViewMsg_DetermineIfPageSupportsInstant::ID);
- ASSERT_TRUE(message != NULL);
- EXPECT_EQ(web_contents()->GetRenderViewHost()->GetRoutingID(),
- message->routing_id());
EXPECT_CALL(delegate, InstantSupportDetermined(web_contents(), true));
« no previous file with comments | « chrome/browser/ui/search/instant_search_prerenderer_unittest.cc ('k') | chrome/browser/ui/search/search_ipc_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698