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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 bool MessageWasSent(uint32 id) { | 55 bool MessageWasSent(uint32 id) { |
56 return process()->sink().GetFirstMessageMatching(id) != NULL; | 56 return process()->sink().GetFirstMessageMatching(id) != NULL; |
57 } | 57 } |
58 | 58 |
59 scoped_ptr<InstantPage> page; | 59 scoped_ptr<InstantPage> page; |
60 FakePageDelegate delegate; | 60 FakePageDelegate delegate; |
61 }; | 61 }; |
62 | 62 |
63 void InstantPageTest::SetUp() { | 63 void InstantPageTest::SetUp() { |
64 CommandLine::ForCurrentProcess()->AppendSwitch( | |
65 switches::kEnableInstantExtendedAPI); | |
66 ChromeRenderViewHostTestHarness::SetUp(); | 64 ChromeRenderViewHostTestHarness::SetUp(); |
67 SearchTabHelper::CreateForWebContents(web_contents()); | 65 SearchTabHelper::CreateForWebContents(web_contents()); |
68 } | 66 } |
69 | 67 |
70 TEST_F(InstantPageTest, IsLocal) { | 68 TEST_F(InstantPageTest, IsLocal) { |
71 page.reset(new InstantPage(&delegate, "", NULL, false)); | 69 page.reset(new InstantPage(&delegate, "", NULL, false)); |
72 EXPECT_FALSE(page->supports_instant()); | 70 EXPECT_FALSE(page->supports_instant()); |
73 EXPECT_FALSE(page->IsLocal()); | 71 EXPECT_FALSE(page->IsLocal()); |
74 page->SetContents(web_contents()); | 72 page->SetContents(web_contents()); |
75 NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl)); | 73 NavigateAndCommit(GURL(chrome::kChromeSearchLocalNtpUrl)); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 EXPECT_TRUE(MessageWasSent(ChromeViewMsg_SearchBoxToggleVoiceSearch::ID)); | 167 EXPECT_TRUE(MessageWasSent(ChromeViewMsg_SearchBoxToggleVoiceSearch::ID)); |
170 | 168 |
171 // Incognito pages should not get any others. | 169 // Incognito pages should not get any others. |
172 page->sender()->FocusChanged( | 170 page->sender()->FocusChanged( |
173 OMNIBOX_FOCUS_NONE, OMNIBOX_FOCUS_CHANGE_EXPLICIT); | 171 OMNIBOX_FOCUS_NONE, OMNIBOX_FOCUS_CHANGE_EXPLICIT); |
174 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxFocusChanged::ID)); | 172 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxFocusChanged::ID)); |
175 | 173 |
176 page->sender()->SetInputInProgress(false); | 174 page->sender()->SetInputInProgress(false); |
177 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxSetInputInProgress::ID)); | 175 EXPECT_FALSE(MessageWasSent(ChromeViewMsg_SearchBoxSetInputInProgress::ID)); |
178 } | 176 } |
OLD | NEW |