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