Chromium Code Reviews| Index: chrome/browser/ui/search/search_delegate_unittest.cc |
| diff --git a/chrome/browser/ui/search/search_delegate_unittest.cc b/chrome/browser/ui/search/search_delegate_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..382aac50842b6726e3aba72741be0bce49da62e3 |
| --- /dev/null |
| +++ b/chrome/browser/ui/search/search_delegate_unittest.cc |
| @@ -0,0 +1,49 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/command_line.h" |
| +#include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/search/search_model.h" |
| +#include "chrome/browser/ui/search/search_tab_helper.h" |
| +#include "chrome/browser/ui/tab_contents/tab_contents.h" |
| +#include "chrome/common/chrome_switches.h" |
| +#include "chrome/test/base/browser_with_test_window_test.h" |
| + |
| +namespace chrome { |
| +namespace search { |
| + |
| +typedef BrowserWithTestWindowTest SearchDelegateTest; |
| + |
| +// Test the propagation of search "mode" changes from the tab's search model to |
| +// the browser's search model. |
| +TEST_F(SearchDelegateTest, SearchModel) { |
|
sky
2012/06/21 18:26:49
Can this be a unit test? Specifically a BrowserWit
dhollowa
2012/06/21 22:16:43
It is, see typedef above.
On 2012/06/21 18:26:49,
|
| + CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| + command_line->AppendSwitch(switches::kEnableInstantExtendedAPI); |
| + |
| + // Initial state. |
| + EXPECT_TRUE(browser()->search_model()->mode().is_default()); |
| + |
| + // Propagate change from tab's search model to browser's search model. |
| + AddTab(browser(), GURL("http://foo/0")); |
| + TabContents* contents = browser()->GetTabContentsAt(0); |
| + contents->search_tab_helper()->model()->SetMode(Mode(Mode::MODE_NTP, false)); |
| + EXPECT_TRUE(browser()->search_model()->mode().is_ntp()); |
| + |
| + // Add second tab, make it active, and make sure its mode changes |
| + // propagate to the browser's search model. |
| + AddTab(browser(), GURL("http://foo/1")); |
| + browser()->ActivateTabAt(1, true); |
| + contents = browser()->GetTabContentsAt(1); |
| + contents->search_tab_helper()->model()->SetMode( |
| + Mode(Mode::MODE_SEARCH, false)); |
| + EXPECT_TRUE(browser()->search_model()->mode().is_search()); |
| + |
| + // The first tab is not active so changes should not propagate. |
| + contents = browser()->GetTabContentsAt(0); |
| + contents->search_tab_helper()->model()->SetMode(Mode(Mode::MODE_NTP, false)); |
| + EXPECT_TRUE(browser()->search_model()->mode().is_search()); |
| +} |
| + |
| +} // namespace search |
| +} // namespace chrome |