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

Unified Diff: chrome/browser/ui/search/search_delegate_unittest.cc

Issue 10644002: Add core plumbing for Instant Extended work (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed UI stuff from SearchModel Created 8 years, 6 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 side-by-side diff with in-line comments
Download patch
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) {
+ 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

Powered by Google App Engine
This is Rietveld 408576698