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

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: make behaviour consistent across platforms 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
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. http://crbug.com/976.
Peter Kasting 2013/10/07 22:19:23 Nit: Don't refer to a bug number here; if any more
1618 #if !defined(OS_MACOSX) 1618 EXPECT_FALSE(clipboard->IsFormatAvailable(
1619 EXPECT_TRUE(clipboard->IsFormatAvailable(
1620 ui::Clipboard::GetHtmlFormatType(), ui::Clipboard::BUFFER_STANDARD)); 1619 ui::Clipboard::GetHtmlFormatType(), ui::Clipboard::BUFFER_STANDARD));
1621 #endif
1622 1620
1623 // These platforms should read bookmark format. 1621 // These platforms should read bookmark format.
1624 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) 1622 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX)
1625 string16 title; 1623 string16 title;
1626 std::string url; 1624 std::string url;
1627 clipboard->ReadBookmark(&title, &url); 1625 clipboard->ReadBookmark(&title, &url);
1628 EXPECT_EQ(target_url, url); 1626 EXPECT_EQ(target_url, url);
1629 EXPECT_EQ(ASCIIToUTF16(target_url), title); 1627 EXPECT_EQ(ASCIIToUTF16(target_url), title);
1630 #endif 1628 #endif
1631 } 1629 }
(...skipping 22 matching lines...) Expand all
1654 // in the clipboard. 1652 // in the clipboard.
1655 omnibox_view->SelectAll(true); 1653 omnibox_view->SelectAll(true);
1656 EXPECT_TRUE(omnibox_view->IsSelectAll()); 1654 EXPECT_TRUE(omnibox_view->IsSelectAll());
1657 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); 1655 ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
1658 clipboard->Clear(ui::Clipboard::BUFFER_STANDARD); 1656 clipboard->Clear(ui::Clipboard::BUFFER_STANDARD);
1659 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_CUT)); 1657 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_CUT));
1660 EXPECT_EQ(string16(), omnibox_view->GetText()); 1658 EXPECT_EQ(string16(), omnibox_view->GetText());
1661 EXPECT_TRUE(clipboard->IsFormatAvailable( 1659 EXPECT_TRUE(clipboard->IsFormatAvailable(
1662 ui::Clipboard::GetPlainTextFormatType(), ui::Clipboard::BUFFER_STANDARD)); 1660 ui::Clipboard::GetPlainTextFormatType(), ui::Clipboard::BUFFER_STANDARD));
1663 1661
1664 // The Mac is the only platform which doesn't write html. 1662 // Make sure HTML format isn't written. http://crbug.com/976.
1665 #if !defined(OS_MACOSX) 1663 EXPECT_FALSE(clipboard->IsFormatAvailable(
1666 EXPECT_TRUE(clipboard->IsFormatAvailable(
1667 ui::Clipboard::GetHtmlFormatType(), ui::Clipboard::BUFFER_STANDARD)); 1664 ui::Clipboard::GetHtmlFormatType(), ui::Clipboard::BUFFER_STANDARD));
1668 #endif
1669 1665
1670 // These platforms should read bookmark format. 1666 // These platforms should read bookmark format.
1671 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) 1667 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX)
1672 string16 title; 1668 string16 title;
1673 std::string url; 1669 std::string url;
1674 clipboard->ReadBookmark(&title, &url); 1670 clipboard->ReadBookmark(&title, &url);
1675 EXPECT_EQ(target_url, url); 1671 EXPECT_EQ(target_url, url);
1676 EXPECT_EQ(ASCIIToUTF16(target_url), title); 1672 EXPECT_EQ(ASCIIToUTF16(target_url), title);
1677 #endif 1673 #endif
1678 } 1674 }
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 omnibox_view->Update(); 1846 omnibox_view->Update();
1851 EXPECT_EQ(url_c, omnibox_view->GetText()); 1847 EXPECT_EQ(url_c, omnibox_view->GetText());
1852 } 1848 }
1853 1849
1854 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, InputResetsSearchTermReplacement) { 1850 IN_PROC_BROWSER_TEST_F(OmniboxViewTest, InputResetsSearchTermReplacement) {
1855 browser()->toolbar_model()->set_search_term_replacement_enabled(false); 1851 browser()->toolbar_model()->set_search_term_replacement_enabled(false);
1856 chrome::FocusLocationBar(browser()); 1852 chrome::FocusLocationBar(browser());
1857 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0)); 1853 ASSERT_NO_FATAL_FAILURE(SendKey(ui::VKEY_A, 0));
1858 EXPECT_TRUE(browser()->toolbar_model()->search_term_replacement_enabled()); 1854 EXPECT_TRUE(browser()->toolbar_model()->search_term_replacement_enabled());
1859 } 1855 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698