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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
diff --git a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
index ad931023f210c2342529f008ab8d084cba500a33..467e2d9c11b07fc6f11b8ae6674bbbb860c0dc21 100644
--- a/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
+++ b/chrome/browser/ui/omnibox/omnibox_view_browsertest.cc
@@ -38,6 +38,7 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/web_contents.h"
#include "net/base/mock_host_resolver.h"
+#include "ui/base/clipboard/clipboard.h"
#include "ui/base/events/event_constants.h"
#include "ui/base/keycodes/keyboard_codes.h"
#include "ui/gfx/point.h"
@@ -1684,3 +1685,41 @@ IN_PROC_BROWSER_TEST_F(OmniboxViewTest, DISABLED_SelectAllOnClick) {
EXPECT_FALSE(omnibox_view->IsSelectAll());
}
#endif // defined(USE_AURA)
+
+IN_PROC_BROWSER_TEST_F(OmniboxViewTest, CopyURLToClipboard) {
+ OmniboxView* omnibox_view = NULL;
+ ASSERT_NO_FATAL_FAILURE(GetOmniboxView(&omnibox_view));
+ const char* target_url = "http://www.google.com/calendar";
+ omnibox_view->SetUserText(ASCIIToUTF16(target_url));
+
+ // Set permanent text thus making sure that omnibox treats 'google.com'
+ // as URL (not as ordinary user input).
+ OmniboxEditModel* edit_model = omnibox_view->model();
+ ASSERT_NE(edit_model, static_cast<OmniboxEditModel*>(NULL));
+ edit_model->UpdatePermanentText(ASCIIToUTF16("http://www.google.com/"));
+
+ // Select full URL and copy it to clipboard. General text and html should
+ // be available.
+ omnibox_view->SelectAll(true);
+ EXPECT_TRUE(omnibox_view->IsSelectAll());
+ ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
+ clipboard->Clear(ui::Clipboard::BUFFER_STANDARD);
+ ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_C, kCtrlOrCmdMask));
+ EXPECT_TRUE(clipboard->IsFormatAvailable(
+ ui::Clipboard::GetPlainTextFormatType(), ui::Clipboard::BUFFER_STANDARD));
+
+ // MAC is the only platform which doesn't write html.
+#if !defined(OS_MACOSX)
+ EXPECT_TRUE(clipboard->IsFormatAvailable(
+ ui::Clipboard::GetHtmlFormatType(), ui::Clipboard::BUFFER_STANDARD));
+#endif
+
+ // These platforms should read bookmark format.
+#if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX)
+ string16 title;
+ std::string url;
+ clipboard->ReadBookmark(&title, &url);
+ EXPECT_EQ(target_url, url);
+ EXPECT_EQ(ASCIIToUTF16(target_url), title);
+#endif
+}
« 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