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

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

Issue 1060613004: Fix a variety of omnibox bugs around zerosuggest, the escape key, or both. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Safer escape handling method Created 5 years, 8 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
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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/scoped_observer.h" 8 #include "base/scoped_observer.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 #endif 550 #endif
551 // Backspace at the beginning of the search text shall turn off 551 // Backspace at the beginning of the search text shall turn off
552 // the keyword mode. 552 // the keyword mode.
553 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); 553 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0));
554 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint()); 554 ASSERT_FALSE(omnibox_view->model()->is_keyword_hint());
555 ASSERT_EQ(base::string16(), omnibox_view->model()->keyword()); 555 ASSERT_EQ(base::string16(), omnibox_view->model()->keyword());
556 ASSERT_EQ(std::string(kSearchKeyword) + kSearchText, 556 ASSERT_EQ(std::string(kSearchKeyword) + kSearchText,
557 UTF16ToUTF8(omnibox_view->GetText())); 557 UTF16ToUTF8(omnibox_view->GetText()));
558 } 558 }
559 559
560 // http://crbug.com/158913 560 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, Escape) {
561 #if defined(USE_AURA)
562 #define MAYBE_Escape DISABLED_Escape
563 #else
564 #define MAYBE_Escape Escape
565 #endif
566
567 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, MAYBE_Escape) {
568 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIHistoryURL)); 561 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIHistoryURL));
569 chrome::FocusLocationBar(browser()); 562 chrome::FocusLocationBar(browser());
570 563
571 OmniboxView* omnibox_view = NULL; 564 OmniboxView* omnibox_view = NULL;
572 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); 565 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
573 566
574 base::string16 old_text = omnibox_view->GetText(); 567 base::string16 old_text = omnibox_view->GetText();
575 EXPECT_FALSE(old_text.empty()); 568 EXPECT_FALSE(old_text.empty());
576 EXPECT_TRUE(omnibox_view->IsSelectAll()); 569 EXPECT_TRUE(omnibox_view->IsSelectAll());
577 570
578 // Delete all text in omnibox. 571 // Delete all text in omnibox.
579 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0)); 572 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_BACK, 0));
580 EXPECT_TRUE(omnibox_view->GetText().empty()); 573 EXPECT_TRUE(omnibox_view->GetText().empty());
581 574
582 // Escape shall revert the text in omnibox. 575 // Escape shall revert the text in omnibox.
583 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0)); 576 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_ESCAPE, 0));
584 EXPECT_EQ(old_text, omnibox_view->GetText()); 577 EXPECT_EQ(old_text, omnibox_view->GetText());
585 EXPECT_TRUE(omnibox_view->IsSelectAll()); 578 EXPECT_TRUE(omnibox_view->IsSelectAll());
586 } 579 }
587 #undef MAYBE_ESCAPE
588 580
589 #if defined(OS_LINUX) 581 #if defined(OS_LINUX)
590 #define MAYBE_DesiredTLD DISABLED_DesiredTLD 582 #define MAYBE_DesiredTLD DISABLED_DesiredTLD
591 #else 583 #else
592 #define MAYBE_DesiredTLD DesiredTLD 584 #define MAYBE_DesiredTLD DesiredTLD
593 #endif 585 #endif
594 586
595 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, MAYBE_DesiredTLD) { 587 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, MAYBE_DesiredTLD) {
596 OmniboxView* omnibox_view = NULL; 588 OmniboxView* omnibox_view = NULL;
597 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); 589 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 browser()->toolbar_model()->set_url_replacement_enabled(false); 1859 browser()->toolbar_model()->set_url_replacement_enabled(false);
1868 test_toolbar_model->set_text(url_b); 1860 test_toolbar_model->set_text(url_b);
1869 omnibox_view->Update(); 1861 omnibox_view->Update();
1870 EXPECT_EQ(url_a, omnibox_view->GetText()); 1862 EXPECT_EQ(url_a, omnibox_view->GetText());
1871 omnibox_view->RevertAll(); 1863 omnibox_view->RevertAll();
1872 EXPECT_EQ(url_b, omnibox_view->GetText()); 1864 EXPECT_EQ(url_b, omnibox_view->GetText());
1873 test_toolbar_model->set_text(url_c); 1865 test_toolbar_model->set_text(url_c);
1874 omnibox_view->Update(); 1866 omnibox_view->Update();
1875 EXPECT_EQ(url_c, omnibox_view->GetText()); 1867 EXPECT_EQ(url_c, omnibox_view->GetText());
1876 } 1868 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698