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

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

Issue 2166023004: Cleanup in InstantTab and InstantController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bring back Init() Created 4 years, 5 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/ui/search/instant_tab.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 97d92e0858116c1ffd4f7418999f95113ea05992..06c0b3bda2bf3de7bc371d508fe3d919e3f017fb 100644
--- a/chrome/browser/ui/search/instant_tab_unittest.cc
+++ b/chrome/browser/ui/search/instant_tab_unittest.cc
@@ -35,17 +35,9 @@ class FakePageDelegate : public InstantTab::Delegate {
MOCK_METHOD2(InstantSupportDetermined,
void(const content::WebContents* contents,
bool supports_instant));
- MOCK_METHOD1(InstantTabRenderProcessGone,
- void(const content::WebContents* contents));
MOCK_METHOD2(InstantTabAboutToNavigateMainFrame,
void(const content::WebContents* contents,
const GURL& url));
- MOCK_METHOD5(NavigateToURL,
- void(const content::WebContents* contents,
- const GURL& url,
- ui::PageTransition transition,
- WindowOpenDisposition disposition,
- bool is_search_type));
};
} // namespace
@@ -54,8 +46,8 @@ class InstantTabTest : public ChromeRenderViewHostTestHarness {
public:
void SetUp() override;
- bool MessageWasSent(uint32_t id) {
- return process()->sink().GetFirstMessageMatching(id) != NULL;
+ SearchTabHelper* search_tab() {
+ return SearchTabHelper::FromWebContents(web_contents());
}
std::unique_ptr<InstantTab> page;
@@ -67,36 +59,22 @@ void InstantTabTest::SetUp() {
SearchTabHelper::CreateForWebContents(web_contents());
}
-TEST_F(InstantTabTest, IsLocal) {
- page.reset(new InstantTab(&delegate));
- EXPECT_FALSE(page->supports_instant());
- EXPECT_FALSE(page->IsLocal());
- page->Init(web_contents());
- NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl));
- EXPECT_TRUE(page->IsLocal());
- NavigateAndCommit(GURL("http://example.com"));
- EXPECT_FALSE(page->IsLocal());
-}
-
TEST_F(InstantTabTest, DetermineIfPageSupportsInstant_Local) {
- page.reset(new InstantTab(&delegate));
- EXPECT_FALSE(page->supports_instant());
- page->Init(web_contents());
+ page.reset(new InstantTab(&delegate, web_contents()));
+ EXPECT_FALSE(search_tab()->SupportsInstant());
+ page->Init();
NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl));
- EXPECT_TRUE(page->IsLocal());
- EXPECT_CALL(delegate, InstantSupportDetermined(web_contents(), true))
- .Times(1);
+ EXPECT_CALL(delegate, InstantSupportDetermined(web_contents(), true));
SearchTabHelper::FromWebContents(web_contents())->
DetermineIfPageSupportsInstant();
- EXPECT_TRUE(page->supports_instant());
+ EXPECT_TRUE(search_tab()->SupportsInstant());
}
TEST_F(InstantTabTest, DetermineIfPageSupportsInstant_NonLocal) {
Marc Treib 2016/07/25 12:27:56 Random other thing: This test is BS, or at least i
- page.reset(new InstantTab(&delegate));
- EXPECT_FALSE(page->supports_instant());
- page->Init(web_contents());
+ page.reset(new InstantTab(&delegate, web_contents()));
+ EXPECT_FALSE(search_tab()->SupportsInstant());
+ page->Init();
NavigateAndCommit(GURL("chrome-search://foo/bar"));
- EXPECT_FALSE(page->IsLocal());
process()->sink().ClearMessages();
SearchTabHelper::FromWebContents(web_contents())->
DetermineIfPageSupportsInstant();
@@ -107,34 +85,32 @@ TEST_F(InstantTabTest, DetermineIfPageSupportsInstant_NonLocal) {
}
TEST_F(InstantTabTest, PageURLDoesntBelongToInstantRenderer) {
- page.reset(new InstantTab(&delegate));
- EXPECT_FALSE(page->supports_instant());
+ page.reset(new InstantTab(&delegate, web_contents()));
+ EXPECT_FALSE(search_tab()->SupportsInstant());
NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl));
- page->Init(web_contents());
+ page->Init();
// Navigate to a page URL that doesn't belong to Instant renderer.
// SearchTabHelper::DeterminerIfPageSupportsInstant() should return
// immediately without dispatching any message to the renderer.
NavigateAndCommit(GURL("http://www.example.com"));
- EXPECT_FALSE(page->IsLocal());
process()->sink().ClearMessages();
- EXPECT_CALL(delegate, InstantSupportDetermined(web_contents(), false))
- .Times(1);
+ EXPECT_CALL(delegate, InstantSupportDetermined(web_contents(), false));
SearchTabHelper::FromWebContents(web_contents())->
DetermineIfPageSupportsInstant();
const IPC::Message* message = process()->sink().GetFirstMessageMatching(
ChromeViewMsg_DetermineIfPageSupportsInstant::ID);
ASSERT_TRUE(message == NULL);
- EXPECT_FALSE(page->supports_instant());
+ EXPECT_FALSE(search_tab()->SupportsInstant());
}
// Test to verify that ChromeViewMsg_DetermineIfPageSupportsInstant message
// reply handler updates the instant support state in InstantTab.
TEST_F(InstantTabTest, PageSupportsInstant) {
- page.reset(new InstantTab(&delegate));
- EXPECT_FALSE(page->supports_instant());
- page->Init(web_contents());
+ page.reset(new InstantTab(&delegate, web_contents()));
+ EXPECT_FALSE(search_tab()->SupportsInstant());
+ page->Init();
NavigateAndCommit(GURL("chrome-search://foo/bar"));
process()->sink().ClearMessages();
SearchTabHelper::FromWebContents(web_contents())->
@@ -144,8 +120,7 @@ TEST_F(InstantTabTest, PageSupportsInstant) {
ASSERT_TRUE(message != NULL);
EXPECT_EQ(web_contents()->GetRoutingID(), message->routing_id());
- EXPECT_CALL(delegate, InstantSupportDetermined(web_contents(), true))
- .Times(1);
+ EXPECT_CALL(delegate, InstantSupportDetermined(web_contents(), true));
// Assume the page supports instant. Invoke the message reply handler to make
// sure the InstantTab is notified about the instant support state.
@@ -153,5 +128,5 @@ TEST_F(InstantTabTest, PageSupportsInstant) {
web_contents()->GetController().GetLastCommittedEntry();
EXPECT_TRUE(entry);
SearchTabHelper::FromWebContents(web_contents())->InstantSupportChanged(true);
- EXPECT_TRUE(page->supports_instant());
+ EXPECT_TRUE(search_tab()->SupportsInstant());
}
« no previous file with comments | « chrome/browser/ui/search/instant_tab.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698