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

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

Issue 25894003: Don't write URLs to clipboard from views omnibox as hyperlinks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comments Created 7 years, 2 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 | « chrome/browser/bookmarks/bookmark_node_data.cc ('k') | no next file » | 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/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 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after
1607 // be available. 1607 // be available.
1608 omnibox_view->SelectAll(true); 1608 omnibox_view->SelectAll(true);
1609 EXPECT_TRUE(omnibox_view->IsSelectAll()); 1609 EXPECT_TRUE(omnibox_view->IsSelectAll());
1610 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); 1610 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
1611 clipboard->Clear(ui::Clipboard::BUFFER_STANDARD); 1611 clipboard->Clear(ui::Clipboard::BUFFER_STANDARD);
1612 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_COPY)); 1612 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_COPY));
1613 EXPECT_EQ(ASCIIToUTF16(target_url), omnibox_view->GetText()); 1613 EXPECT_EQ(ASCIIToUTF16(target_url), omnibox_view->GetText());
1614 EXPECT_TRUE(clipboard->IsFormatAvailable( 1614 EXPECT_TRUE(clipboard->IsFormatAvailable(
1615 ui::Clipboard::GetPlainTextFormatType(), ui::Clipboard::BUFFER_STANDARD)); 1615 ui::Clipboard::GetPlainTextFormatType(), ui::Clipboard::BUFFER_STANDARD));
1616 1616
1617 // The Mac is the only platform which doesn't write html. 1617 // Make sure HTML format isn't written. See
1618 #if !defined(OS_MACOSX) 1618 // BookmarkNodeData::WriteToClipboard() for details.
1619 EXPECT_TRUE(clipboard->IsFormatAvailable( 1619 EXPECT_FALSE(clipboard->IsFormatAvailable(
1620 ui::Clipboard::GetHtmlFormatType(), ui::Clipboard::BUFFER_STANDARD)); 1620 ui::Clipboard::GetHtmlFormatType(), ui::Clipboard::BUFFER_STANDARD));
1621 #endif
1622 1621
1623 // These platforms should read bookmark format. 1622 // These platforms should read bookmark format.
1624 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) 1623 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX)
1625 string16 title; 1624 string16 title;
1626 std::string url; 1625 std::string url;
1627 clipboard->ReadBookmark(&title, &url); 1626 clipboard->ReadBookmark(&title, &url);
1628 EXPECT_EQ(target_url, url); 1627 EXPECT_EQ(target_url, url);
1629 EXPECT_EQ(ASCIIToUTF16(target_url), title); 1628 EXPECT_EQ(ASCIIToUTF16(target_url), title);
1630 #endif 1629 #endif
1631 } 1630 }
(...skipping 22 matching lines...) Expand all
1654 // in the clipboard. 1653 // in the clipboard.
1655 omnibox_view->SelectAll(true); 1654 omnibox_view->SelectAll(true);
1656 EXPECT_TRUE(omnibox_view->IsSelectAll()); 1655 EXPECT_TRUE(omnibox_view->IsSelectAll());
1657 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); 1656 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
1658 clipboard->Clear(ui::Clipboard::BUFFER_STANDARD); 1657 clipboard->Clear(ui::Clipboard::BUFFER_STANDARD);
1659 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_CUT)); 1658 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_CUT));
1660 EXPECT_EQ(string16(), omnibox_view->GetText()); 1659 EXPECT_EQ(string16(), omnibox_view->GetText());
1661 EXPECT_TRUE(clipboard->IsFormatAvailable( 1660 EXPECT_TRUE(clipboard->IsFormatAvailable(
1662 ui::Clipboard::GetPlainTextFormatType(), ui::Clipboard::BUFFER_STANDARD)); 1661 ui::Clipboard::GetPlainTextFormatType(), ui::Clipboard::BUFFER_STANDARD));
1663 1662
1664 // The Mac is the only platform which doesn't write html. 1663 // Make sure HTML format isn't written. See
1665 #if !defined(OS_MACOSX) 1664 // BookmarkNodeData::WriteToClipboard() for details.
1666 EXPECT_TRUE(clipboard->IsFormatAvailable( 1665 EXPECT_FALSE(clipboard->IsFormatAvailable(
1667 ui::Clipboard::GetHtmlFormatType(), ui::Clipboard::BUFFER_STANDARD)); 1666 ui::Clipboard::GetHtmlFormatType(), ui::Clipboard::BUFFER_STANDARD));
1668 #endif
1669 1667
1670 // These platforms should read bookmark format. 1668 // These platforms should read bookmark format.
1671 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) 1669 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX)
1672 string16 title; 1670 string16 title;
1673 std::string url; 1671 std::string url;
1674 clipboard->ReadBookmark(&title, &url); 1672 clipboard->ReadBookmark(&title, &url);
1675 EXPECT_EQ(target_url, url); 1673 EXPECT_EQ(target_url, url);
1676 EXPECT_EQ(ASCIIToUTF16(target_url), title); 1674 EXPECT_EQ(ASCIIToUTF16(target_url), title);
1677 #endif 1675 #endif
1678 } 1676 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 omnibox_view->Update(); 1848 omnibox_view->Update();
1851 EXPECT_EQ(url_c, omnibox_view->GetText()); 1849 EXPECT_EQ(url_c, omnibox_view->GetText());
1852 } 1850 }
1853 1851
1854 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, InputResetsSearchTermReplacement) { 1852 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, InputResetsSearchTermReplacement) {
1855 browser()->toolbar_model()->set_search_term_replacement_enabled(false); 1853 browser()->toolbar_model()->set_search_term_replacement_enabled(false);
1856 chrome::FocusLocationBar(browser()); 1854 chrome::FocusLocationBar(browser());
1857 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0)); 1855 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0));
1858 EXPECT_TRUE(browser()->toolbar_model()->search_term_replacement_enabled()); 1856 EXPECT_TRUE(browser()->toolbar_model()->search_term_replacement_enabled());
1859 } 1857 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_node_data.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698