OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/search/instant_page.h" | 5 #include "chrome/browser/ui/search/instant_page.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "chrome/browser/ui/search/search_tab_helper.h" | 9 #include "chrome/browser/ui/search/search_tab_helper.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 ChromeViewMsg_DetermineIfPageSupportsInstant::ID); | 143 ChromeViewMsg_DetermineIfPageSupportsInstant::ID); |
144 ASSERT_TRUE(message != NULL); | 144 ASSERT_TRUE(message != NULL); |
145 EXPECT_EQ(web_contents()->GetRoutingID(), message->routing_id()); | 145 EXPECT_EQ(web_contents()->GetRoutingID(), message->routing_id()); |
146 | 146 |
147 EXPECT_CALL(delegate, InstantSupportDetermined(web_contents(), true)) | 147 EXPECT_CALL(delegate, InstantSupportDetermined(web_contents(), true)) |
148 .Times(1); | 148 .Times(1); |
149 | 149 |
150 // Assume the page supports instant. Invoke the message reply handler to make | 150 // Assume the page supports instant. Invoke the message reply handler to make |
151 // sure the InstantPage is notified about the instant support state. | 151 // sure the InstantPage is notified about the instant support state. |
152 const content::NavigationEntry* entry = | 152 const content::NavigationEntry* entry = |
153 web_contents()->GetController().GetActiveEntry(); | 153 web_contents()->GetController().GetLastCommittedEntry(); |
154 EXPECT_TRUE(entry); | 154 EXPECT_TRUE(entry); |
155 SearchTabHelper::FromWebContents(web_contents())->InstantSupportChanged(true); | 155 SearchTabHelper::FromWebContents(web_contents())->InstantSupportChanged(true); |
156 EXPECT_TRUE(page->supports_instant()); | 156 EXPECT_TRUE(page->supports_instant()); |
157 } | 157 } |
158 | 158 |
159 TEST_F(InstantPageTest, AppropriateMessagesSentToIncognitoPages) { | 159 TEST_F(InstantPageTest, AppropriateMessagesSentToIncognitoPages) { |
160 page.reset(new InstantPage(&delegate, "", NULL, true)); | 160 page.reset(new InstantPage(&delegate, "", NULL, true)); |
161 page->SetContents(web_contents()); | 161 page->SetContents(web_contents()); |
162 NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl)); | 162 NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl)); |
163 process()->sink().ClearMessages(); | 163 process()->sink().ClearMessages(); |
164 | 164 |
165 // Incognito pages should get these messages. | 165 // Incognito pages should get these messages. |
166 page->sender()->SetOmniboxBounds(gfx::Rect()); | 166 page->sender()->SetOmniboxBounds(gfx::Rect()); |
167 EXPECT_TRUE(MessageWasSent(ChromeViewMsg_SearchBoxMarginChange::ID)); | 167 EXPECT_TRUE(MessageWasSent(ChromeViewMsg_SearchBoxMarginChange::ID)); |
168 page->sender()->ToggleVoiceSearch(); | 168 page->sender()->ToggleVoiceSearch(); |
169 EXPECT_TRUE(MessageWasSent(ChromeViewMsg_SearchBoxToggleVoiceSearch::ID)); | 169 EXPECT_TRUE(MessageWasSent(ChromeViewMsg_SearchBoxToggleVoiceSearch::ID)); |
170 | 170 |
171 // Incognito pages should not get any others. | 171 // Incognito pages should not get any others. |
172 page->sender()->FocusChanged( | 172 page->sender()->FocusChanged( |
173 OMNIBOX_FOCUS_NONE, OMNIBOX_FOCUS_CHANGE_EXPLICIT); | 173 OMNIBOX_FOCUS_NONE, OMNIBOX_FOCUS_CHANGE_EXPLICIT); |
174 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxFocusChanged::ID)); | 174 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxFocusChanged::ID)); |
175 | 175 |
176 page->sender()->SetInputInProgress(false); | 176 page->sender()->SetInputInProgress(false); |
177 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxSetInputInProgress::ID)); | 177 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxSetInputInProgress::ID)); |
178 } | 178 } |
OLD | NEW |