Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Side by Side Diff: chrome/browser/ui/search/search_delegate_unittest.cc

Issue 10944016: Switch SearchTabHelper to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: const Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/search/search_delegate.cc ('k') | chrome/browser/ui/search/search_model.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/browser_tabstrip.h"
8 #include "chrome/browser/ui/search/search.h" 8 #include "chrome/browser/ui/search/search.h"
9 #include "chrome/browser/ui/search/search_model.h" 9 #include "chrome/browser/ui/search/search_model.h"
10 #include "chrome/browser/ui/search/search_tab_helper.h" 10 #include "chrome/browser/ui/search/search_tab_helper.h"
11 #include "chrome/browser/ui/tab_contents/tab_contents.h"
12 #include "chrome/common/chrome_switches.h" 11 #include "chrome/common/chrome_switches.h"
13 #include "chrome/test/base/browser_with_test_window_test.h" 12 #include "chrome/test/base/browser_with_test_window_test.h"
14 13
15 namespace chrome { 14 namespace chrome {
16 namespace search { 15 namespace search {
17 16
18 typedef BrowserWithTestWindowTest SearchDelegateTest; 17 typedef BrowserWithTestWindowTest SearchDelegateTest;
19 18
20 // 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
21 // the browser's search model. 20 // the browser's search model.
22 TEST_F(SearchDelegateTest, SearchModel) { 21 TEST_F(SearchDelegateTest, SearchModel) {
23 CommandLine* command_line = CommandLine::ForCurrentProcess(); 22 CommandLine* command_line = CommandLine::ForCurrentProcess();
24 command_line->AppendSwitch(switches::kEnableInstantExtendedAPI); 23 command_line->AppendSwitch(switches::kEnableInstantExtendedAPI);
25 24
26 // Avoid these tests on branded Chrome where channel is set to CHANNEL_STABLE. 25 // Avoid these tests on branded Chrome where channel is set to CHANNEL_STABLE.
27 if (!chrome::search::IsInstantExtendedAPIEnabled(profile())) 26 if (!chrome::search::IsInstantExtendedAPIEnabled(profile()))
28 return; 27 return;
29 28
30 // Initial state. 29 // Initial state.
31 EXPECT_TRUE(browser()->search_model()->mode().is_default()); 30 EXPECT_TRUE(browser()->search_model()->mode().is_default());
32 31
33 // Propagate change from tab's search model to browser's search model. 32 // Propagate change from tab's search model to browser's search model.
34 AddTab(browser(), GURL("http://foo/0")); 33 AddTab(browser(), GURL("http://foo/0"));
35 TabContents* contents = chrome::GetTabContentsAt(browser(), 0); 34 content::WebContents* web_contents = chrome::GetWebContentsAt(browser(), 0);
36 contents->search_tab_helper()->model()->SetMode(Mode(Mode::MODE_NTP, false)); 35 chrome::search::SearchTabHelper::FromWebContents(web_contents)->model()->
36 SetMode(Mode(Mode::MODE_NTP, false));
37 EXPECT_TRUE(browser()->search_model()->mode().is_ntp()); 37 EXPECT_TRUE(browser()->search_model()->mode().is_ntp());
38 38
39 // Add second tab, make it active, and make sure its mode changes 39 // Add second tab, make it active, and make sure its mode changes
40 // propagate to the browser's search model. 40 // propagate to the browser's search model.
41 AddTab(browser(), GURL("http://foo/1")); 41 AddTab(browser(), GURL("http://foo/1"));
42 chrome::ActivateTabAt(browser(), 1, true); 42 chrome::ActivateTabAt(browser(), 1, true);
43 contents = chrome::GetTabContentsAt(browser(), 1); 43 web_contents = chrome::GetWebContentsAt(browser(), 1);
44 contents->search_tab_helper()->model()->SetMode( 44 chrome::search::SearchTabHelper::FromWebContents(web_contents)->model()->
45 Mode(Mode::MODE_SEARCH_RESULTS, false)); 45 SetMode(Mode(Mode::MODE_SEARCH_RESULTS, false));
46 EXPECT_TRUE(browser()->search_model()->mode().is_search()); 46 EXPECT_TRUE(browser()->search_model()->mode().is_search());
47 47
48 // The first tab is not active so changes should not propagate. 48 // The first tab is not active so changes should not propagate.
49 contents = chrome::GetTabContentsAt(browser(), 0); 49 web_contents = chrome::GetWebContentsAt(browser(), 0);
50 contents->search_tab_helper()->model()->SetMode(Mode(Mode::MODE_NTP, false)); 50 chrome::search::SearchTabHelper::FromWebContents(web_contents)->model()->
51 SetMode(Mode(Mode::MODE_NTP, false));
51 EXPECT_TRUE(browser()->search_model()->mode().is_search()); 52 EXPECT_TRUE(browser()->search_model()->mode().is_search());
52 } 53 }
53 54
54 } // namespace search 55 } // namespace search
55 } // namespace chrome 56 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_delegate.cc ('k') | chrome/browser/ui/search/search_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698