summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_commands_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/browser_commands_unittest.cc')
-rw-r--r--chrome/browser/browser_commands_unittest.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/chrome/browser/browser_commands_unittest.cc b/chrome/browser/browser_commands_unittest.cc
index 60284b9..daaf106 100644
--- a/chrome/browser/browser_commands_unittest.cc
+++ b/chrome/browser/browser_commands_unittest.cc
@@ -166,3 +166,30 @@ TEST_F(BrowserCommandsTest, BackForwardInNewTab) {
ASSERT_EQ(4, browser()->active_index());
ASSERT_EQ(url2, browser()->GetSelectedTabContents()->GetURL());
}
+
+// Tests IDC_SEARCH (the Search key on Chrome OS devices).
+#if defined(OS_CHROMEOS)
+TEST_F(BrowserCommandsTest, Search) {
+ // Load a non-NTP URL.
+ GURL non_ntp_url("http://foo/");
+ AddTab(browser(), non_ntp_url);
+ ASSERT_EQ(1, browser()->tab_count());
+ EXPECT_EQ(non_ntp_url, browser()->GetSelectedTabContents()->GetURL());
+
+ // Pressing the Search key should open a new tab containing the NTP.
+ browser()->Search();
+ ASSERT_EQ(2, browser()->tab_count());
+ ASSERT_EQ(1, browser()->active_index());
+ GURL current_url = browser()->GetSelectedTabContents()->GetURL();
+ EXPECT_TRUE(current_url.SchemeIs(chrome::kChromeUIScheme));
+ EXPECT_EQ(chrome::kChromeUINewTabHost, current_url.host());
+
+ // Pressing it a second time while the NTP is open shouldn't change anything.
+ browser()->Search();
+ ASSERT_EQ(2, browser()->tab_count());
+ ASSERT_EQ(1, browser()->active_index());
+ current_url = browser()->GetSelectedTabContents()->GetURL();
+ EXPECT_TRUE(current_url.SchemeIs(chrome::kChromeUIScheme));
+ EXPECT_EQ(chrome::kChromeUINewTabHost, current_url.host());
+}
+#endif