OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/toolbar/toolbar_model.h" | 5 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/search_engines/template_url.h" | 9 #include "chrome/browser/search_engines/template_url.h" |
10 #include "chrome/browser/search_engines/template_url_service.h" | 10 #include "chrome/browser/search_engines/template_url_service.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 CommitPendingLoad(&contents->GetController()); | 169 CommitPendingLoad(&contents->GetController()); |
170 EXPECT_EQ(should_display, toolbar_model->ShouldDisplayURL()); | 170 EXPECT_EQ(should_display, toolbar_model->ShouldDisplayURL()); |
171 EXPECT_EQ(expected_text, toolbar_model->GetText(can_replace)); | 171 EXPECT_EQ(expected_text, toolbar_model->GetText(can_replace)); |
172 EXPECT_EQ(would_replace, | 172 EXPECT_EQ(would_replace, |
173 toolbar_model->WouldReplaceSearchURLWithSearchTerms()); | 173 toolbar_model->WouldReplaceSearchURLWithSearchTerms()); |
174 } | 174 } |
175 }; | 175 }; |
176 | 176 |
177 // Test that we don't replace any URLs when the InstantExtended API is disabled. | 177 // Test that we don't replace any URLs when the InstantExtended API is disabled. |
178 TEST_F(ToolbarModelTest, ShouldDisplayURLInstantExtendedAPIDisabled) { | 178 TEST_F(ToolbarModelTest, ShouldDisplayURLInstantExtendedAPIDisabled) { |
179 ASSERT_FALSE(CommandLine::ForCurrentProcess()->HasSwitch( | 179 ASSERT_FALSE(chrome::search::IsInstantExtendedAPIEnabled(profile())) |
180 switches::kEnableInstantExtendedAPI)) | |
181 << "This test expects Extended Instant to be disabled."; | 180 << "This test expects Extended Instant to be disabled."; |
182 | 181 |
183 ResetDefaultTemplateURL(); | 182 ResetDefaultTemplateURL(); |
184 AddTab(browser(), GURL(chrome::kAboutBlankURL)); | 183 AddTab(browser(), GURL(chrome::kAboutBlankURL)); |
185 for (size_t i = 0; i < arraysize(test_items); ++i) { | 184 for (size_t i = 0; i < arraysize(test_items); ++i) { |
186 const TestItem& test_item = test_items[i]; | 185 const TestItem& test_item = test_items[i]; |
187 NavigateAndCheckText(test_item.url, | 186 NavigateAndCheckText(test_item.url, |
188 test_item.expected_text, | 187 test_item.expected_text, |
189 test_item.expected_replace_text_inactive, | 188 test_item.expected_replace_text_inactive, |
190 false, | 189 false, |
191 test_item.should_display); | 190 test_item.should_display); |
192 } | 191 } |
193 } | 192 } |
194 | 193 |
195 // Test that we replace URLs when the InstantExtended API is enabled. | 194 // Test that we replace URLs when the InstantExtended API is enabled. |
196 TEST_F(ToolbarModelTest, ShouldDisplayURLInstantExtendedAPIEnabled) { | 195 TEST_F(ToolbarModelTest, ShouldDisplayURLInstantExtendedAPIEnabled) { |
197 CommandLine::ForCurrentProcess()->AppendSwitch( | 196 chrome::search::EnableInstantExtendedAPIForTesting(); |
198 switches::kEnableInstantExtendedAPI); | |
199 | |
200 // Avoid tests on branded Chrome where channel is set to CHANNEL_STABLE. | |
201 if (!chrome::search::IsInstantExtendedAPIEnabled(profile())) | |
202 return; | |
203 | 197 |
204 ResetDefaultTemplateURL(); | 198 ResetDefaultTemplateURL(); |
205 AddTab(browser(), GURL(chrome::kAboutBlankURL)); | 199 AddTab(browser(), GURL(chrome::kAboutBlankURL)); |
206 for (size_t i = 0; i < arraysize(test_items); ++i) { | 200 for (size_t i = 0; i < arraysize(test_items); ++i) { |
207 const TestItem& test_item = test_items[i]; | 201 const TestItem& test_item = test_items[i]; |
208 NavigateAndCheckText(test_item.url, | 202 NavigateAndCheckText(test_item.url, |
209 test_item.expected_text, | 203 test_item.expected_text, |
210 test_item.expected_replace_text_active, | 204 test_item.expected_replace_text_active, |
211 test_item.would_replace, | 205 test_item.would_replace, |
212 test_item.should_display); | 206 test_item.should_display); |
213 } | 207 } |
214 } | 208 } |
OLD | NEW |