| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/command_line.h" |
| 6 #include "chrome/browser/ui/browser.h" |
| 7 #include "chrome/browser/ui/search/search_model.h" |
| 8 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 9 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 10 #include "chrome/common/chrome_switches.h" |
| 11 #include "chrome/test/base/browser_with_test_window_test.h" |
| 12 |
| 13 namespace chrome { |
| 14 namespace search { |
| 15 |
| 16 typedef BrowserWithTestWindowTest SearchDelegateTest; |
| 17 |
| 18 // Test the propagation of search "mode" changes from the tab's search model to |
| 19 // the browser's search model. |
| 20 TEST_F(SearchDelegateTest, SearchModel) { |
| 21 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 22 command_line->AppendSwitch(switches::kEnableInstantExtendedAPI); |
| 23 |
| 24 // Initial state. |
| 25 EXPECT_TRUE(browser()->search_model()->mode().is_default()); |
| 26 |
| 27 // Propagate change from tab's search model to browser's search model. |
| 28 AddTab(browser(), GURL("http://foo/0")); |
| 29 TabContents* contents = browser()->GetTabContentsAt(0); |
| 30 contents->search_tab_helper()->model()->SetMode(Mode(Mode::MODE_NTP, false)); |
| 31 EXPECT_TRUE(browser()->search_model()->mode().is_ntp()); |
| 32 |
| 33 // Add second tab, make it active, and make sure its mode changes |
| 34 // propagate to the browser's search model. |
| 35 AddTab(browser(), GURL("http://foo/1")); |
| 36 browser()->ActivateTabAt(1, true); |
| 37 contents = browser()->GetTabContentsAt(1); |
| 38 contents->search_tab_helper()->model()->SetMode( |
| 39 Mode(Mode::MODE_SEARCH, false)); |
| 40 EXPECT_TRUE(browser()->search_model()->mode().is_search()); |
| 41 |
| 42 // The first tab is not active so changes should not propagate. |
| 43 contents = browser()->GetTabContentsAt(0); |
| 44 contents->search_tab_helper()->model()->SetMode(Mode(Mode::MODE_NTP, false)); |
| 45 EXPECT_TRUE(browser()->search_model()->mode().is_search()); |
| 46 } |
| 47 |
| 48 } // namespace search |
| 49 } // namespace chrome |
| OLD | NEW |