OLD | NEW |
---|---|
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/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 #include "chrome/browser/search_engines/template_url.h" | 23 #include "chrome/browser/search_engines/template_url.h" |
24 #include "chrome/browser/search_engines/template_url_service.h" | 24 #include "chrome/browser/search_engines/template_url_service.h" |
25 #include "chrome/browser/search_engines/template_url_service_factory.h" | 25 #include "chrome/browser/search_engines/template_url_service_factory.h" |
26 #include "chrome/browser/ui/browser.h" | 26 #include "chrome/browser/ui/browser.h" |
27 #include "chrome/browser/ui/browser_commands.h" | 27 #include "chrome/browser/ui/browser_commands.h" |
28 #include "chrome/browser/ui/browser_window.h" | 28 #include "chrome/browser/ui/browser_window.h" |
29 #include "chrome/browser/ui/omnibox/location_bar.h" | 29 #include "chrome/browser/ui/omnibox/location_bar.h" |
30 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 30 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
31 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 31 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
32 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 32 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
33 #include "chrome/browser/ui/toolbar/test_toolbar_model.h" | |
33 #include "chrome/common/chrome_paths.h" | 34 #include "chrome/common/chrome_paths.h" |
34 #include "chrome/common/url_constants.h" | 35 #include "chrome/common/url_constants.h" |
35 #include "chrome/test/base/in_process_browser_test.h" | 36 #include "chrome/test/base/in_process_browser_test.h" |
36 #include "chrome/test/base/interactive_test_utils.h" | 37 #include "chrome/test/base/interactive_test_utils.h" |
37 #include "chrome/test/base/ui_test_utils.h" | 38 #include "chrome/test/base/ui_test_utils.h" |
38 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
39 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
40 #include "net/dns/mock_host_resolver.h" | 41 #include "net/dns/mock_host_resolver.h" |
41 #include "ui/base/clipboard/clipboard.h" | 42 #include "ui/base/clipboard/clipboard.h" |
42 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 43 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1665 | 1666 |
1666 // Middle-clicking should not be handled by the omnibox. | 1667 // Middle-clicking should not be handled by the omnibox. |
1667 ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter()); | 1668 ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter()); |
1668 ASSERT_NO_FATAL_FAILURE(ClickOmnibox(ui_controls::MIDDLE, click, click)); | 1669 ASSERT_NO_FATAL_FAILURE(ClickOmnibox(ui_controls::MIDDLE, click, click)); |
1669 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); | 1670 EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); |
1670 EXPECT_FALSE(omnibox_view->IsSelectAll()); | 1671 EXPECT_FALSE(omnibox_view->IsSelectAll()); |
1671 } | 1672 } |
1672 #endif // defined(TOOLKIT_VIEWS) | 1673 #endif // defined(TOOLKIT_VIEWS) |
1673 | 1674 |
1674 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, CopyURLToClipboard) { | 1675 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, CopyURLToClipboard) { |
1676 // Set permanent text thus making sure that omnibox treats 'google.com' | |
1677 // as URL (not as ordinary user input). | |
1678 TestToolbarModel* toolbar_model = new TestToolbarModel; | |
msw
2013/08/30 16:12:16
Remove |toolbar_model|, rename |toolbar_model_dele
Peter Kasting
2013/08/30 18:26:48
I need a TestToolbarModel type to call set_text(),
msw
2013/08/30 18:32:26
Ah, I didn't realize it was using test-specific AP
| |
1679 scoped_ptr<ToolbarModel> toolbar_model_deleter(toolbar_model); | |
1680 toolbar_model->set_text(ASCIIToUTF16("http://www.google.com/")); | |
1681 browser()->swap_toolbar_models(&toolbar_model_deleter); | |
1682 OmniboxEditModel* edit_model = omnibox_view->model(); | |
1683 ASSERT_NE(static_cast<OmniboxEditModel*>(NULL), edit_model); | |
1684 edit_model->UpdatePermanentText(); | |
1685 | |
1675 OmniboxView* omnibox_view = NULL; | 1686 OmniboxView* omnibox_view = NULL; |
1676 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 1687 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
1677 const char* target_url = "http://www.google.com/calendar"; | 1688 const char* target_url = "http://www.google.com/calendar"; |
1678 omnibox_view->SetUserText(ASCIIToUTF16(target_url)); | 1689 omnibox_view->SetUserText(ASCIIToUTF16(target_url)); |
1679 | 1690 |
1680 // Set permanent text thus making sure that omnibox treats 'google.com' | |
1681 // as URL (not as ordinary user input). | |
1682 OmniboxEditModel* edit_model = omnibox_view->model(); | |
1683 ASSERT_NE(static_cast<OmniboxEditModel*>(NULL), edit_model); | |
1684 edit_model->UpdatePermanentText(ASCIIToUTF16("http://www.google.com/")); | |
1685 | |
1686 // Location bar must have focus. | 1691 // Location bar must have focus. |
1687 chrome::FocusLocationBar(browser()); | 1692 chrome::FocusLocationBar(browser()); |
1688 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); | 1693 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); |
1689 | 1694 |
1690 // Select full URL and copy it to clipboard. General text and html should | 1695 // Select full URL and copy it to clipboard. General text and html should |
1691 // be available. | 1696 // be available. |
1692 omnibox_view->SelectAll(true); | 1697 omnibox_view->SelectAll(true); |
1693 EXPECT_TRUE(omnibox_view->IsSelectAll()); | 1698 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
1694 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); | 1699 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); |
1695 clipboard->Clear(ui::Clipboard::BUFFER_STANDARD); | 1700 clipboard->Clear(ui::Clipboard::BUFFER_STANDARD); |
(...skipping 12 matching lines...) Expand all Loading... | |
1708 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) | 1713 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) |
1709 string16 title; | 1714 string16 title; |
1710 std::string url; | 1715 std::string url; |
1711 clipboard->ReadBookmark(&title, &url); | 1716 clipboard->ReadBookmark(&title, &url); |
1712 EXPECT_EQ(target_url, url); | 1717 EXPECT_EQ(target_url, url); |
1713 EXPECT_EQ(ASCIIToUTF16(target_url), title); | 1718 EXPECT_EQ(ASCIIToUTF16(target_url), title); |
1714 #endif | 1719 #endif |
1715 } | 1720 } |
1716 | 1721 |
1717 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, CutURLToClipboard) { | 1722 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, CutURLToClipboard) { |
1723 // Set permanent text thus making sure that omnibox treats 'google.com' | |
1724 // as URL (not as ordinary user input). | |
1725 TestToolbarModel* toolbar_model = new TestToolbarModel; | |
msw
2013/08/30 16:12:16
ditto
| |
1726 scoped_ptr<ToolbarModel> toolbar_model_deleter(toolbar_model); | |
1727 toolbar_model->set_text(ASCIIToUTF16("http://www.google.com/")); | |
1728 browser()->swap_toolbar_models(&toolbar_model_deleter); | |
1729 OmniboxEditModel* edit_model = omnibox_view->model(); | |
1730 ASSERT_NE(static_cast<OmniboxEditModel*>(NULL), edit_model); | |
1731 edit_model->UpdatePermanentText(); | |
1732 | |
1718 OmniboxView* omnibox_view = NULL; | 1733 OmniboxView* omnibox_view = NULL; |
1719 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); | 1734 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view)); |
1720 const char* target_url = "http://www.google.com/calendar"; | 1735 const char* target_url = "http://www.google.com/calendar"; |
1721 omnibox_view->SetUserText(ASCIIToUTF16(target_url)); | 1736 omnibox_view->SetUserText(ASCIIToUTF16(target_url)); |
1722 | 1737 |
1723 // Set permanent text thus making sure that omnibox treats 'google.com' | |
1724 // as URL (not as ordinary user input). | |
1725 OmniboxEditModel* edit_model = omnibox_view->model(); | |
1726 ASSERT_NE(static_cast<OmniboxEditModel*>(NULL), edit_model); | |
1727 edit_model->UpdatePermanentText(ASCIIToUTF16("http://www.google.com/")); | |
1728 | |
1729 // Location bar must have focus. | 1738 // Location bar must have focus. |
1730 chrome::FocusLocationBar(browser()); | 1739 chrome::FocusLocationBar(browser()); |
1731 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); | 1740 ASSERT_TRUE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_OMNIBOX)); |
1732 | 1741 |
1733 // Select full URL and cut it. General text and html should be available | 1742 // Select full URL and cut it. General text and html should be available |
1734 // in the clipboard. | 1743 // in the clipboard. |
1735 omnibox_view->SelectAll(true); | 1744 omnibox_view->SelectAll(true); |
1736 EXPECT_TRUE(omnibox_view->IsSelectAll()); | 1745 EXPECT_TRUE(omnibox_view->IsSelectAll()); |
1737 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); | 1746 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); |
1738 clipboard->Clear(ui::Clipboard::BUFFER_STANDARD); | 1747 clipboard->Clear(ui::Clipboard::BUFFER_STANDARD); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1862 #if defined(OS_MACOSX) | 1871 #if defined(OS_MACOSX) |
1863 // Mac uses alt-left/right to select a word. | 1872 // Mac uses alt-left/right to select a word. |
1864 const int modifiers = ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN; | 1873 const int modifiers = ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN; |
1865 #else | 1874 #else |
1866 const int modifiers = ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN; | 1875 const int modifiers = ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN; |
1867 #endif | 1876 #endif |
1868 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, modifiers)); | 1877 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, modifiers)); |
1869 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, modifiers)); | 1878 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_LEFT, modifiers)); |
1870 ASSERT_EQ(ASCIIToUTF16("www.bar.com/2"), omnibox_view->GetText()); | 1879 ASSERT_EQ(ASCIIToUTF16("www.bar.com/2"), omnibox_view->GetText()); |
1871 } | 1880 } |
OLD | NEW |