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

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

Issue 11789003: Fixed a clipboard bug in views/omnibox. The content was always copied as pure text, never as hyperl… (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Style changes Created 7 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/omnibox/omnibox_view_views.cc » ('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) 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 20 matching lines...) Expand all
31 #include "chrome/browser/ui/tabs/tab_strip_model.h" 31 #include "chrome/browser/ui/tabs/tab_strip_model.h"
32 #include "chrome/common/chrome_notification_types.h" 32 #include "chrome/common/chrome_notification_types.h"
33 #include "chrome/common/chrome_paths.h" 33 #include "chrome/common/chrome_paths.h"
34 #include "chrome/common/url_constants.h" 34 #include "chrome/common/url_constants.h"
35 #include "chrome/test/base/interactive_test_utils.h" 35 #include "chrome/test/base/interactive_test_utils.h"
36 #include "chrome/test/base/in_process_browser_test.h" 36 #include "chrome/test/base/in_process_browser_test.h"
37 #include "chrome/test/base/ui_test_utils.h" 37 #include "chrome/test/base/ui_test_utils.h"
38 #include "content/public/browser/notification_service.h" 38 #include "content/public/browser/notification_service.h"
39 #include "content/public/browser/web_contents.h" 39 #include "content/public/browser/web_contents.h"
40 #include "net/base/mock_host_resolver.h" 40 #include "net/base/mock_host_resolver.h"
41 #include "ui/base/clipboard/clipboard.h"
41 #include "ui/base/events/event_constants.h" 42 #include "ui/base/events/event_constants.h"
42 #include "ui/base/keycodes/keyboard_codes.h" 43 #include "ui/base/keycodes/keyboard_codes.h"
43 #include "ui/gfx/point.h" 44 #include "ui/gfx/point.h"
44 45
45 #if defined(TOOLKIT_GTK) 46 #if defined(TOOLKIT_GTK)
46 #include <gdk/gdk.h> 47 #include <gdk/gdk.h>
47 #include <gtk/gtk.h> 48 #include <gtk/gtk.h>
48 #endif 49 #endif
49 50
50 #if defined(USE_AURA) 51 #if defined(USE_AURA)
(...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after
1677 1678
1678 // Middle-clicking shouldn't select all the text either. 1679 // Middle-clicking shouldn't select all the text either.
1679 ASSERT_NO_FATAL_FAILURE( 1680 ASSERT_NO_FATAL_FAILURE(
1680 ClickFocusViewOrigin(ui_controls::LEFT, kClickOffset, kClickOffset)); 1681 ClickFocusViewOrigin(ui_controls::LEFT, kClickOffset, kClickOffset));
1681 ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter()); 1682 ASSERT_NO_FATAL_FAILURE(ClickBrowserWindowCenter());
1682 ASSERT_NO_FATAL_FAILURE( 1683 ASSERT_NO_FATAL_FAILURE(
1683 ClickFocusViewOrigin(ui_controls::MIDDLE, kClickOffset, kClickOffset)); 1684 ClickFocusViewOrigin(ui_controls::MIDDLE, kClickOffset, kClickOffset));
1684 EXPECT_FALSE(omnibox_view->IsSelectAll()); 1685 EXPECT_FALSE(omnibox_view->IsSelectAll());
1685 } 1686 }
1686 #endif // defined(USE_AURA) 1687 #endif // defined(USE_AURA)
1688
1689 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, CopyURLToClipboard) {
1690 OmniboxView* omnibox_view = NULL;
1691 ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
1692 const char* target_url = "http://www.google.com/calendar";
1693 omnibox_view->SetUserText(ASCIIToUTF16(target_url));
1694
1695 // Set permanent text thus making sure that omnibox treats 'google.com'
1696 // as URL (not as ordinary user input).
1697 OmniboxEditModel* edit_model = omnibox_view->model();
1698 ASSERT_NE(edit_model, static_cast<OmniboxEditModel*>(NULL));
1699 edit_model->UpdatePermanentText(ASCIIToUTF16("http://www.google.com/"));
1700
1701 // Select full URL and copy it to clipboard. General text and html should
1702 // be available.
1703 omnibox_view->SelectAll(true);
1704 EXPECT_TRUE(omnibox_view->IsSelectAll());
1705 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
1706 clipboard->Clear(ui::Clipboard::BUFFER_STANDARD);
1707 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_C, kCtrlOrCmdMask));
1708 EXPECT_TRUE(clipboard->IsFormatAvailable(
1709 ui::Clipboard::GetPlainTextFormatType(), ui::Clipboard::BUFFER_STANDARD));
1710
1711 // MAC is the only platform which doesn't write html.
1712 #if !defined(OS_MACOSX)
1713 EXPECT_TRUE(clipboard->IsFormatAvailable(
1714 ui::Clipboard::GetHtmlFormatType(), ui::Clipboard::BUFFER_STANDARD));
1715 #endif
1716
1717 // These platforms should read bookmark format.
1718 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX)
1719 string16 title;
1720 std::string url;
1721 clipboard->ReadBookmark(&title, &url);
1722 EXPECT_EQ(target_url, url);
1723 EXPECT_EQ(ASCIIToUTF16(target_url), title);
1724 #endif
1725 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/omnibox/omnibox_view_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698