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

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

Issue 9015022: Replace most of Browser::GetSelectedTabContents calls into Browser::GetSelectedWebContents. I've ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 13 matching lines...) Expand all
24 #include "chrome/browser/search_engines/template_url_service_factory.h" 24 #include "chrome/browser/search_engines/template_url_service_factory.h"
25 #include "chrome/browser/ui/browser.h" 25 #include "chrome/browser/ui/browser.h"
26 #include "chrome/browser/ui/browser_window.h" 26 #include "chrome/browser/ui/browser_window.h"
27 #include "chrome/browser/ui/omnibox/location_bar.h" 27 #include "chrome/browser/ui/omnibox/location_bar.h"
28 #include "chrome/browser/ui/omnibox/omnibox_view.h" 28 #include "chrome/browser/ui/omnibox/omnibox_view.h"
29 #include "chrome/common/chrome_notification_types.h" 29 #include "chrome/common/chrome_notification_types.h"
30 #include "chrome/common/chrome_paths.h" 30 #include "chrome/common/chrome_paths.h"
31 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
32 #include "chrome/test/base/in_process_browser_test.h" 32 #include "chrome/test/base/in_process_browser_test.h"
33 #include "chrome/test/base/ui_test_utils.h" 33 #include "chrome/test/base/ui_test_utils.h"
34 #include "content/browser/tab_contents/tab_contents.h"
35 #include "content/public/browser/notification_service.h" 34 #include "content/public/browser/notification_service.h"
35 #include "content/public/browser/web_contents.h"
36 #include "net/base/mock_host_resolver.h" 36 #include "net/base/mock_host_resolver.h"
37 #include "ui/base/events.h" 37 #include "ui/base/events.h"
38 #include "ui/base/keycodes/keyboard_codes.h" 38 #include "ui/base/keycodes/keyboard_codes.h"
39 39
40 #if defined(TOOLKIT_USES_GTK) 40 #if defined(TOOLKIT_USES_GTK)
41 #include <gdk/gdk.h> 41 #include <gdk/gdk.h>
42 #include <gtk/gtk.h> 42 #include <gtk/gtk.h>
43 #endif 43 #endif
44 44
45 #if defined(TOOLKIT_VIEWS) 45 #if defined(TOOLKIT_VIEWS)
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, ui::EF_CONTROL_DOWN));
570 570
571 GURL url = browser()->GetSelectedTabContents()->GetURL(); 571 GURL url = browser()->GetSelectedWebContents()->GetURL();
572 EXPECT_STREQ(kDesiredTLDHostname, url.host().c_str()); 572 EXPECT_STREQ(kDesiredTLDHostname, url.host().c_str());
573 } 573 }
574 574
575 void AltEnterTest() { 575 void AltEnterTest() {
576 OmniboxView* omnibox_view = NULL; 576 OmniboxView* omnibox_view = NULL;
577 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); 577 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
578 578
579 omnibox_view->SetUserText(ASCIIToUTF16(chrome::kChromeUIHistoryURL)); 579 omnibox_view->SetUserText(ASCIIToUTF16(chrome::kChromeUIHistoryURL));
580 int tab_count = browser()->tab_count(); 580 int tab_count = browser()->tab_count();
581 // alt-Enter opens a new tab. 581 // alt-Enter opens a new tab.
(...skipping 11 matching lines...) Expand all
593 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys)); 593 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchTextKeys));
594 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); 594 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
595 ASSERT_TRUE(popup_model->IsOpen()); 595 ASSERT_TRUE(popup_model->IsOpen());
596 596
597 // Check if the default match result is Search Primary Provider. 597 // Check if the default match result is Search Primary Provider.
598 ASSERT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, 598 ASSERT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED,
599 popup_model->result().default_match()->type); 599 popup_model->result().default_match()->type);
600 600
601 // Open the default match. 601 // Open the default match.
602 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, 0)); 602 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, 0));
603 GURL url = browser()->GetSelectedTabContents()->GetURL(); 603 GURL url = browser()->GetSelectedWebContents()->GetURL();
604 EXPECT_STREQ(kSearchTextURL, url.spec().c_str()); 604 EXPECT_STREQ(kSearchTextURL, url.spec().c_str());
605 605
606 // Test that entering a single character then Enter performs a search. 606 // Test that entering a single character then Enter performs a search.
607 browser()->FocusLocationBar(); 607 browser()->FocusLocationBar();
608 EXPECT_TRUE(omnibox_view->IsSelectAll()); 608 EXPECT_TRUE(omnibox_view->IsSelectAll());
609 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchSingleCharKeys)); 609 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchSingleCharKeys));
610 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); 610 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
611 ASSERT_TRUE(popup_model->IsOpen()); 611 ASSERT_TRUE(popup_model->IsOpen());
612 EXPECT_EQ(kSearchSingleChar, UTF16ToUTF8(omnibox_view->GetText())); 612 EXPECT_EQ(kSearchSingleChar, UTF16ToUTF8(omnibox_view->GetText()));
613 613
614 // Check if the default match result is Search Primary Provider. 614 // Check if the default match result is Search Primary Provider.
615 ASSERT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, 615 ASSERT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED,
616 popup_model->result().default_match()->type); 616 popup_model->result().default_match()->type);
617 617
618 // Open the default match. 618 // Open the default match.
619 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, 0)); 619 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_RETURN, 0));
620 url = browser()->GetSelectedTabContents()->GetURL(); 620 url = browser()->GetSelectedWebContents()->GetURL();
621 EXPECT_STREQ(kSearchSingleCharURL, url.spec().c_str()); 621 EXPECT_STREQ(kSearchSingleCharURL, url.spec().c_str());
622 } 622 }
623 623
624 void EscapeToDefaultMatchTest() { 624 void EscapeToDefaultMatchTest() {
625 OmniboxView* omnibox_view = NULL; 625 OmniboxView* omnibox_view = NULL;
626 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); 626 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
627 AutocompletePopupModel* popup_model = omnibox_view->model()->popup_model(); 627 AutocompletePopupModel* popup_model = omnibox_view->model()->popup_model();
628 ASSERT_TRUE(popup_model); 628 ASSERT_TRUE(popup_model);
629 629
630 // Input something to trigger inline autocomplete. 630 // Input something to trigger inline autocomplete.
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1403 PersistKeywordModeOnTabSwitch) { 1403 PersistKeywordModeOnTabSwitch) {
1404 PersistKeywordModeOnTabSwitch(); 1404 PersistKeywordModeOnTabSwitch();
1405 } 1405 }
1406 1406
1407 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest, 1407 IN_PROC_BROWSER_TEST_F(OmniboxViewViewsTest,
1408 CtrlKeyPressedWithInlineAutocompleteTest) { 1408 CtrlKeyPressedWithInlineAutocompleteTest) {
1409 CtrlKeyPressedWithInlineAutocompleteTest(); 1409 CtrlKeyPressedWithInlineAutocompleteTest();
1410 } 1410 }
1411 1411
1412 #endif 1412 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/intents/web_intent_picker_controller_browsertest.cc ('k') | chrome/browser/ui/panels/panel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698