Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/instant/instant_loader.h" | 5 #include "chrome/browser/instant/instant_loader.h" |
| 6 #include "chrome/browser/instant/instant_test_utils.h" | 6 #include "chrome/browser/instant/instant_test_utils.h" |
| 7 #include "chrome/browser/ui/search/search.h" | 7 #include "chrome/browser/ui/search/search.h" |
| 8 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 8 #include "chrome/test/base/interactive_test_utils.h" | 9 #include "chrome/test/base/interactive_test_utils.h" |
| 9 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
| 10 | 11 |
| 11 class InstantExtendedTest : public InstantTestBase { | 12 class InstantExtendedTest : public InstantTestBase { |
| 12 protected: | 13 protected: |
| 13 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 14 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 14 chrome::search::EnableInstantExtendedAPIForTesting(); | 15 chrome::search::EnableInstantExtendedAPIForTesting(); |
| 15 ASSERT_TRUE(test_server()->Start()); | 16 ASSERT_TRUE(test_server()->Start()); |
| 16 instant_url_ = test_server()->GetURL("files/instant_extended.html"); | 17 instant_url_ = test_server()->GetURL("files/instant_extended.html"); |
| 17 } | 18 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 content::WebContents* preview_tab = instant()->GetPreviewContents(); | 74 content::WebContents* preview_tab = instant()->GetPreviewContents(); |
| 74 EXPECT_TRUE(preview_tab); | 75 EXPECT_TRUE(preview_tab); |
| 75 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); | 76 EXPECT_FALSE(instant()->IsPreviewingSearchResults()); |
| 76 EXPECT_TRUE(instant()->model()->mode().is_default()); | 77 EXPECT_TRUE(instant()->model()->mode().is_default()); |
| 77 | 78 |
| 78 // Typing in the omnibox should show the overlay. | 79 // Typing in the omnibox should show the overlay. |
| 79 SetOmniboxTextAndWaitForInstantToShow("query"); | 80 SetOmniboxTextAndWaitForInstantToShow("query"); |
| 80 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); | 81 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); |
| 81 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); | 82 EXPECT_EQ(preview_tab, instant()->GetPreviewContents()); |
| 82 } | 83 } |
| 84 | |
| 85 // Test that middle clicking on a suggestion opens the result in a new tab. | |
| 86 IN_PROC_BROWSER_TEST_F( | |
| 87 InstantExtendedTest, MiddleClickOnSuggestionOpensInNewTab) { | |
| 88 ASSERT_NO_FATAL_FAILURE(SetupInstant()); | |
| 89 FocusOmniboxAndWaitForInstantSupport(); | |
| 90 | |
| 91 ASSERT_TRUE(browser()->tab_strip_model()->count() == 1); | |
|
sreeram
2013/02/06 22:00:50
I'd just make this an EXPECT. Generally we use ASS
dougw
2013/02/20 21:46:56
Done.
| |
| 92 | |
| 93 // Typing in the omnibox should show the overlay. | |
| 94 SetOmniboxTextAndWaitForInstantToShow("test"); | |
| 95 EXPECT_TRUE(instant()->model()->mode().is_search_suggestions()); | |
| 96 | |
| 97 EXPECT_TRUE(ExecuteScript("function Click() {" | |
| 98 "var eventObject = document.createEvent('MouseEvents');" | |
| 99 "eventObject.initMouseEvent('click');" | |
| 100 "document.getElementsByTagName('body')[0].dispatchEvent(eventObject);" | |
| 101 "}" | |
| 102 "document.body.addEventListener(\"click\", function() {" | |
| 103 "var nativeSuggestions = chrome.searchBox.nativeSuggestions;" | |
| 104 "if (nativeSuggestions.length > 0) {" | |
| 105 "chrome.searchBox.navigateContentWindow(nativeSuggestions[0].rid, 2);" | |
|
sreeram
2013/02/06 22:00:50
I recommend that you navigate to a known URL, such
dougw
2013/02/20 21:46:56
Done.
| |
| 106 "}" | |
| 107 "});" | |
| 108 "Click();")); | |
|
sreeram
2013/02/06 22:00:50
Why not actually click on the page using ui_test_u
dougw
2013/02/20 21:46:56
Done.
| |
| 109 | |
| 110 // Check that there are now two tabs. | |
| 111 EXPECT_EQ(2, browser()->tab_strip_model()->count()); | |
| 112 } | |
| OLD | NEW |