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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc

Issue 200131: Fix issue 21587, a regression of CL 196020.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/autocomplete/autocomplete_edit_view_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/file_path.h" 7 #include "base/file_path.h"
8 #include "base/keyboard_codes.h" 8 #include "base/keyboard_codes.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 const wchar_t kSearchKeywordKeys[] = { 43 const wchar_t kSearchKeywordKeys[] = {
44 base::VKEY_F, base::VKEY_O, base::VKEY_O, 0 44 base::VKEY_F, base::VKEY_O, base::VKEY_O, 0
45 }; 45 };
46 const wchar_t kSearchURL[] = L"http://www.foo.com/search?q={searchTerms}"; 46 const wchar_t kSearchURL[] = L"http://www.foo.com/search?q={searchTerms}";
47 const wchar_t kSearchShortName[] = L"foo"; 47 const wchar_t kSearchShortName[] = L"foo";
48 const wchar_t kSearchText[] = L"abc"; 48 const wchar_t kSearchText[] = L"abc";
49 const wchar_t kSearchTextKeys[] = { 49 const wchar_t kSearchTextKeys[] = {
50 base::VKEY_A, base::VKEY_B, base::VKEY_C, 0 50 base::VKEY_A, base::VKEY_B, base::VKEY_C, 0
51 }; 51 };
52 const char kSearchTextURL[] = "http://www.foo.com/search?q=abc"; 52 const char kSearchTextURL[] = "http://www.foo.com/search?q=abc";
53 const wchar_t kSearchSingleChar[] = L"z";
54 const wchar_t kSearchSingleCharKeys[] = { base::VKEY_Z, 0 };
55 const char kSearchSingleCharURL[] = "http://www.foo.com/search?q=z";
56
53 const char kHistoryPageURL[] = "chrome://history/#q=abc"; 57 const char kHistoryPageURL[] = "chrome://history/#q=abc";
54 58
55 const char kDesiredTLDHostname[] = "www.bar.com"; 59 const char kDesiredTLDHostname[] = "www.bar.com";
56 const wchar_t kDesiredTLDKeys[] = { 60 const wchar_t kDesiredTLDKeys[] = {
57 base::VKEY_B, base::VKEY_A, base::VKEY_R, 0 61 base::VKEY_B, base::VKEY_A, base::VKEY_R, 0
58 }; 62 };
59 63
60 // Hostnames that shall be blocked by host resolver. 64 // Hostnames that shall be blocked by host resolver.
61 const char *kBlockedHostnames[] = { 65 const char *kBlockedHostnames[] = {
62 "foo", 66 "foo",
63 "*.foo.com", 67 "*.foo.com",
64 "bar", 68 "bar",
65 "*.bar.com", 69 "*.bar.com",
66 "abc", 70 "abc",
67 "*.abc.com" 71 "*.abc.com",
72 "history",
73 "z"
68 }; 74 };
69 75
70 const struct TestHistoryEntry { 76 const struct TestHistoryEntry {
71 const char* url; 77 const char* url;
72 const wchar_t* title; 78 const wchar_t* title;
73 const wchar_t* body; 79 const wchar_t* body;
74 int visit_count; 80 int visit_count;
75 int typed_count; 81 int typed_count;
76 bool starred; 82 bool starred;
77 } kHistoryEntries[] = { 83 } kHistoryEntries[] = {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone()); 379 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
374 ASSERT_TRUE(popup_model->IsOpen()); 380 ASSERT_TRUE(popup_model->IsOpen());
375 // ctrl-Enter triggers desired_tld feature, thus www.bar.com shall be opened. 381 // ctrl-Enter triggers desired_tld feature, thus www.bar.com shall be opened.
376 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_RETURN, true, false, false)); 382 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_RETURN, true, false, false));
377 383
378 GURL url = browser()->GetSelectedTabContents()->GetURL(); 384 GURL url = browser()->GetSelectedTabContents()->GetURL();
379 EXPECT_STREQ(kDesiredTLDHostname, url.host().c_str()); 385 EXPECT_STREQ(kDesiredTLDHostname, url.host().c_str());
380 } 386 }
381 387
382 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, AltEnter) { 388 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, AltEnter) {
389 ASSERT_NO_FATAL_FAILURE(SetupHostResolver());
383 browser()->FocusLocationBar(); 390 browser()->FocusLocationBar();
384 391
385 AutocompleteEditView* edit_view = NULL; 392 AutocompleteEditView* edit_view = NULL;
386 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view)); 393 ASSERT_NO_FATAL_FAILURE(GetAutocompleteEditView(&edit_view));
387 394
388 edit_view->SetUserText(L"chrome://history/"); 395 edit_view->SetUserText(L"chrome://history/");
389 int tab_count = browser()->tab_count(); 396 int tab_count = browser()->tab_count();
390 // alt-Enter opens a new tab. 397 // alt-Enter opens a new tab.
391 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_RETURN, false, false, true)); 398 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_RETURN, false, false, true));
392 ASSERT_NO_FATAL_FAILURE(WaitForTabOpenOrClose(tab_count + 1)); 399 ASSERT_NO_FATAL_FAILURE(WaitForTabOpenOrClose(tab_count + 1));
(...skipping 15 matching lines...) Expand all
408 ASSERT_TRUE(popup_model->IsOpen()); 415 ASSERT_TRUE(popup_model->IsOpen());
409 416
410 // Check if the default match result is Search Primary Provider. 417 // Check if the default match result is Search Primary Provider.
411 ASSERT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, 418 ASSERT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED,
412 popup_model->result().default_match()->type); 419 popup_model->result().default_match()->type);
413 420
414 // Open the default match. 421 // Open the default match.
415 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_RETURN, false, false, false)); 422 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_RETURN, false, false, false));
416 GURL url = browser()->GetSelectedTabContents()->GetURL(); 423 GURL url = browser()->GetSelectedTabContents()->GetURL();
417 EXPECT_STREQ(kSearchTextURL, url.spec().c_str()); 424 EXPECT_STREQ(kSearchTextURL, url.spec().c_str());
425
426 // Test Enter to search a single character.
Evan Martin 2009/09/15 16:22:03 This comment is a bit confusing, it makes it sound
James Su 2009/09/16 01:22:46 Done.
427 browser()->FocusLocationBar();
428 EXPECT_TRUE(edit_view->IsSelectAll());
429 ASSERT_NO_FATAL_FAILURE(SendKeySequence(kSearchSingleCharKeys));
430 ASSERT_NO_FATAL_FAILURE(WaitForAutocompleteControllerDone());
431 ASSERT_TRUE(popup_model->IsOpen());
432 EXPECT_EQ(std::wstring(kSearchSingleChar), edit_view->GetText());
433
434 // Check if the default match result is Search Primary Provider.
435 ASSERT_EQ(AutocompleteMatch::SEARCH_WHAT_YOU_TYPED,
436 popup_model->result().default_match()->type);
437
438 // Open the default match.
439 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_RETURN, false, false, false));
440 url = browser()->GetSelectedTabContents()->GetURL();
441 EXPECT_STREQ(kSearchSingleCharURL, url.spec().c_str());
418 } 442 }
419 443
420 // See http://crbug.com/20934: Omnibox keyboard behavior wrong for 444 // See http://crbug.com/20934: Omnibox keyboard behavior wrong for
421 // "See recent pages in history" 445 // "See recent pages in history"
422 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, EnterToOpenHistoryPage) { 446 IN_PROC_BROWSER_TEST_F(AutocompleteEditViewTest, EnterToOpenHistoryPage) {
423 ASSERT_NO_FATAL_FAILURE(SetupHostResolver()); 447 ASSERT_NO_FATAL_FAILURE(SetupHostResolver());
424 ASSERT_NO_FATAL_FAILURE(SetupSearchEngine()); 448 ASSERT_NO_FATAL_FAILURE(SetupSearchEngine());
425 ASSERT_NO_FATAL_FAILURE(SetupHistory()); 449 ASSERT_NO_FATAL_FAILURE(SetupHistory());
426 450
427 browser()->FocusLocationBar(); 451 browser()->FocusLocationBar();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 break; 516 break;
493 } 517 }
494 518
495 EXPECT_NE(old_text, edit_view->GetText()); 519 EXPECT_NE(old_text, edit_view->GetText());
496 520
497 // Escape shall revert back to the default match item. 521 // Escape shall revert back to the default match item.
498 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_ESCAPE, false, false, false)); 522 ASSERT_NO_FATAL_FAILURE(SendKey(base::VKEY_ESCAPE, false, false, false));
499 EXPECT_EQ(old_text, edit_view->GetText()); 523 EXPECT_EQ(old_text, edit_view->GetText());
500 EXPECT_EQ(old_selected_line, popup_model->selected_line()); 524 EXPECT_EQ(old_selected_line, popup_model->selected_line());
501 } 525 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autocomplete/autocomplete_edit_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698