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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc

Issue 9264049: Allow SiteInstance for about:blank in new tab to be reused. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use helper function Created 8 years, 10 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
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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); 559 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
560 AutocompletePopupModel* popup_model = omnibox_view->model()->popup_model(); 560 AutocompletePopupModel* popup_model = omnibox_view->model()->popup_model();
561 ASSERT_TRUE(popup_model); 561 ASSERT_TRUE(popup_model);
562 562
563 // Test ctrl-Enter. 563 // Test ctrl-Enter.
564 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kDesiredTLDKeys)); 564 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kDesiredTLDKeys));
565 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); 565 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
566 ASSERT_TRUE(popup_model->IsOpen()); 566 ASSERT_TRUE(popup_model->IsOpen());
567 // ctrl-Enter triggers desired_tld feature, thus www.bar.com shall be 567 // ctrl-Enter triggers desired_tld feature, thus www.bar.com shall be
568 // opened. 568 // opened.
569 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, ui::EF_CONTROL_DOWN)); 569 ASSERT_TRUE(SendKeyAndWait(
570 browser(), ui::VKEY_RETURN, ui::EF_CONTROL_DOWN,
Peter Kasting 2012/02/06 19:25:17 Nit: You could also put these args at the end of t
Charlie Reis 2012/02/06 19:32:47 Fixed, thanks.
571 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
572 content::Source<content::NavigationController>(
573 &browser()->GetSelectedWebContents()->GetController())));
570 574
571 GURL url = browser()->GetSelectedWebContents()->GetURL(); 575 GURL url = browser()->GetSelectedWebContents()->GetURL();
572 EXPECT_STREQ(kDesiredTLDHostname, url.host().c_str()); 576 EXPECT_STREQ(kDesiredTLDHostname, url.host().c_str());
573 } 577 }
574 578
575 void AltEnterTest() { 579 void AltEnterTest() {
576 OmniboxView* omnibox_view = NULL; 580 OmniboxView* omnibox_view = NULL;
577 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); 581 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
578 582
579 omnibox_view->SetUserText(ASCIIToUTF16(chrome::kChromeUIHistoryURL)); 583 omnibox_view->SetUserText(ASCIIToUTF16(chrome::kChromeUIHistoryURL));
(...skipping 12 matching lines...) Expand all
592 // Test Enter to search. 596 // Test Enter to search.
593 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); 597 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys));
594 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); 598 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
595 ASSERT_TRUE(popup_model->IsOpen()); 599 ASSERT_TRUE(popup_model->IsOpen());
596 600
597 // Check if the default match result is Search Primary Provider. 601 // Check if the default match result is Search Primary Provider.
598 ASSERT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, 602 ASSERT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED,
599 popup_model->result().default_match()->type); 603 popup_model->result().default_match()->type);
600 604
601 // Open the default match. 605 // Open the default match.
602 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, 0)); 606 ASSERT_TRUE(SendKeyAndWait(
607 browser(), ui::VKEY_RETURN, 0,
608 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
609 content::Source<content::NavigationController>(
610 &browser()->GetSelectedWebContents()->GetController())));
603 GURL url = browser()->GetSelectedWebContents()->GetURL(); 611 GURL url = browser()->GetSelectedWebContents()->GetURL();
604 EXPECT_STREQ(kSearchTextURL, url.spec().c_str()); 612 EXPECT_STREQ(kSearchTextURL, url.spec().c_str());
605 613
606 // Test that entering a single character then Enter performs a search. 614 // Test that entering a single character then Enter performs a search.
607 browser()->FocusLocationBar(); 615 browser()->FocusLocationBar();
608 EXPECT_TRUE(omnibox_view->IsSelectAll()); 616 EXPECT_TRUE(omnibox_view->IsSelectAll());
609 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchSingleCharKeys)); 617 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchSingleCharKeys));
610 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); 618 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
611 ASSERT_TRUE(popup_model->IsOpen()); 619 ASSERT_TRUE(popup_model->IsOpen());
612 EXPECT_EQ(kSearchSingleChar, UTF16ToUTF8(omnibox_view->GetText())); 620 EXPECT_EQ(kSearchSingleChar, UTF16ToUTF8(omnibox_view->GetText()));
613 621
614 // Check if the default match result is Search Primary Provider. 622 // Check if the default match result is Search Primary Provider.
615 ASSERT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, 623 ASSERT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED,
616 popup_model->result().default_match()->type); 624 popup_model->result().default_match()->type);
617 625
618 // Open the default match. 626 // Open the default match.
619 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, 0)); 627 ASSERT_TRUE(SendKeyAndWait(
628 browser(), ui::VKEY_RETURN, 0,
629 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
630 content::Source<content::NavigationController>(
631 &browser()->GetSelectedWebContents()->GetController())));
620 url = browser()->GetSelectedWebContents()->GetURL(); 632 url = browser()->GetSelectedWebContents()->GetURL();
621 EXPECT_STREQ(kSearchSingleCharURL, url.spec().c_str()); 633 EXPECT_STREQ(kSearchSingleCharURL, url.spec().c_str());
622 } 634 }
623 635
624 void EscapeToDefaultMatchTest() { 636 void EscapeToDefaultMatchTest() {
625 OmniboxView* omnibox_view = NULL; 637 OmniboxView* omnibox_view = NULL;
626 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); 638 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
627 AutocompletePopupModel* popup_model = omnibox_view->model()->popup_model(); 639 AutocompletePopupModel* popup_model = omnibox_view->model()->popup_model();
628 ASSERT_TRUE(popup_model); 640 ASSERT_TRUE(popup_model);
629 641
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 } 1162 }
1151 1163
1152 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DesiredTLD) { 1164 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DesiredTLD) {
1153 DesiredTLDTest(); 1165 DesiredTLDTest();
1154 } 1166 }
1155 1167
1156 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, AltEnter) { 1168 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, AltEnter) {
1157 AltEnterTest(); 1169 AltEnterTest();
1158 } 1170 }
1159 1171
1160 // DISABLED http://crbug.com/80118
1161 #if defined(OS_LINUX)
1162 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_EnterToSearch) {
1163 #else
1164 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EnterToSearch) { 1172 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EnterToSearch) {
1165 #endif // OS_LINUX
1166 EnterToSearchTest(); 1173 EnterToSearchTest();
1167 } 1174 }
1168 1175
1169 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EscapeToDefaultMatch) { 1176 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, EscapeToDefaultMatch) {
1170 EscapeToDefaultMatchTest(); 1177 EscapeToDefaultMatchTest();
1171 } 1178 }
1172 1179
1173 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, BasicTextOperations) { 1180 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, BasicTextOperations) {
1174 BasicTextOperationsTest(); 1181 BasicTextOperationsTest();
1175 } 1182 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 1334
1328 // Paste text. 1335 // Paste text.
1329 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, ui::EF_CONTROL_DOWN)); 1336 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_V, ui::EF_CONTROL_DOWN));
1330 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); 1337 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
1331 ASSERT_TRUE(popup_model->IsOpen()); 1338 ASSERT_TRUE(popup_model->IsOpen());
1332 1339
1333 // Inline autocomplete shouldn't be triggered. 1340 // Inline autocomplete shouldn't be triggered.
1334 ASSERT_EQ(ASCIIToUTF16("abc"), omnibox_view->GetText()); 1341 ASSERT_EQ(ASCIIToUTF16("abc"), omnibox_view->GetText());
1335 } 1342 }
1336 #endif 1343 #endif
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc ('k') | content/browser/tab_contents/tab_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698