| 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 "base/command_line.h" | |
| 6 #include "chrome/browser/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
| 7 #include "chrome/browser/ui/search/search.h" | 6 #include "chrome/browser/ui/search/search.h" |
| 8 #include "chrome/browser/ui/search/search_model.h" | 7 #include "chrome/browser/ui/search/search_model.h" |
| 9 #include "chrome/browser/ui/search/search_tab_helper.h" | 8 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 11 #include "chrome/common/chrome_switches.h" | |
| 12 #include "chrome/test/base/browser_with_test_window_test.h" | 10 #include "chrome/test/base/browser_with_test_window_test.h" |
| 13 | 11 |
| 14 namespace chrome { | 12 namespace chrome { |
| 15 namespace search { | 13 namespace search { |
| 16 | 14 |
| 17 typedef BrowserWithTestWindowTest SearchDelegateTest; | 15 typedef BrowserWithTestWindowTest SearchDelegateTest; |
| 18 | 16 |
| 19 // Test the propagation of search "mode" changes from the tab's search model to | 17 // Test the propagation of search "mode" changes from the tab's search model to |
| 20 // the browser's search model. | 18 // the browser's search model. |
| 21 TEST_F(SearchDelegateTest, SearchModel) { | 19 TEST_F(SearchDelegateTest, SearchModel) { |
| 22 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 20 chrome::search::EnableInstantExtendedAPIForTesting(); |
| 23 command_line->AppendSwitch(switches::kEnableInstantExtendedAPI); | |
| 24 | |
| 25 // Avoid these tests on branded Chrome where channel is set to CHANNEL_STABLE. | |
| 26 if (!chrome::search::IsInstantExtendedAPIEnabled(profile())) | |
| 27 return; | |
| 28 | 21 |
| 29 // Initial state. | 22 // Initial state. |
| 30 EXPECT_TRUE(browser()->search_model()->mode().is_default()); | 23 EXPECT_TRUE(browser()->search_model()->mode().is_default()); |
| 31 | 24 |
| 32 // Propagate change from tab's search model to browser's search model. | 25 // Propagate change from tab's search model to browser's search model. |
| 33 AddTab(browser(), GURL("http://foo/0")); | 26 AddTab(browser(), GURL("http://foo/0")); |
| 34 content::WebContents* web_contents = | 27 content::WebContents* web_contents = |
| 35 browser()->tab_strip_model()->GetWebContentsAt(0); | 28 browser()->tab_strip_model()->GetWebContentsAt(0); |
| 36 chrome::search::SearchTabHelper::FromWebContents(web_contents)->model()-> | 29 chrome::search::SearchTabHelper::FromWebContents(web_contents)->model()-> |
| 37 SetMode(Mode(Mode::MODE_NTP, Mode::ORIGIN_NTP, false)); | 30 SetMode(Mode(Mode::MODE_NTP, Mode::ORIGIN_NTP, false)); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 48 | 41 |
| 49 // The first tab is not active so changes should not propagate. | 42 // The first tab is not active so changes should not propagate. |
| 50 web_contents = browser()->tab_strip_model()->GetWebContentsAt(0); | 43 web_contents = browser()->tab_strip_model()->GetWebContentsAt(0); |
| 51 chrome::search::SearchTabHelper::FromWebContents(web_contents)->model()-> | 44 chrome::search::SearchTabHelper::FromWebContents(web_contents)->model()-> |
| 52 SetMode(Mode(Mode::MODE_NTP, Mode::ORIGIN_NTP, false)); | 45 SetMode(Mode(Mode::MODE_NTP, Mode::ORIGIN_NTP, false)); |
| 53 EXPECT_TRUE(browser()->search_model()->mode().is_search()); | 46 EXPECT_TRUE(browser()->search_model()->mode().is_search()); |
| 54 } | 47 } |
| 55 | 48 |
| 56 } // namespace search | 49 } // namespace search |
| 57 } // namespace chrome | 50 } // namespace chrome |
| OLD | NEW |