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

Side by Side Diff: views/view_unittest.cc

Issue 174367: Change the ChromiumPasteboard to have a notion of an alternate clipboard... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | « views/controls/textfield/native_textfield_win.cc ('k') | webkit/api/public/WebClipboard.h » ('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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <map> 5 #include <map>
6 6
7 #include "app/gfx/canvas.h" 7 #include "app/gfx/canvas.h"
8 #include "app/gfx/path.h" 8 #include "app/gfx/path.h"
9 #include "base/clipboard.h" 9 #include "base/clipboard.h"
10 #include "base/keyboard_codes.h" 10 #include "base/keyboard_codes.h"
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 password->SetText(kPasswordText); 720 password->SetText(kPasswordText);
721 721
722 // 722 //
723 // Test cut. 723 // Test cut.
724 // 724 //
725 ASSERT_TRUE(normal->GetTestingHandle()); 725 ASSERT_TRUE(normal->GetTestingHandle());
726 normal->SelectAll(); 726 normal->SelectAll();
727 ::SendMessage(normal->GetTestingHandle(), WM_CUT, 0, 0); 727 ::SendMessage(normal->GetTestingHandle(), WM_CUT, 0, 0);
728 728
729 string16 result; 729 string16 result;
730 clipboard.ReadText(&result); 730 clipboard.ReadText(Clipboard::BUFFER_STANDARD, &result);
731 EXPECT_EQ(kNormalText, result); 731 EXPECT_EQ(kNormalText, result);
732 normal->SetText(kNormalText); // Let's revert to the original content. 732 normal->SetText(kNormalText); // Let's revert to the original content.
733 733
734 ASSERT_TRUE(read_only->GetTestingHandle()); 734 ASSERT_TRUE(read_only->GetTestingHandle());
735 read_only->SelectAll(); 735 read_only->SelectAll();
736 ::SendMessage(read_only->GetTestingHandle(), WM_CUT, 0, 0); 736 ::SendMessage(read_only->GetTestingHandle(), WM_CUT, 0, 0);
737 result.clear(); 737 result.clear();
738 clipboard.ReadText(&result); 738 clipboard.ReadText(Clipboard::BUFFER_STANDARD, &result);
739 // Cut should have failed, so the clipboard content should not have changed. 739 // Cut should have failed, so the clipboard content should not have changed.
740 EXPECT_EQ(kNormalText, result); 740 EXPECT_EQ(kNormalText, result);
741 741
742 ASSERT_TRUE(password->GetTestingHandle()); 742 ASSERT_TRUE(password->GetTestingHandle());
743 password->SelectAll(); 743 password->SelectAll();
744 ::SendMessage(password->GetTestingHandle(), WM_CUT, 0, 0); 744 ::SendMessage(password->GetTestingHandle(), WM_CUT, 0, 0);
745 result.clear(); 745 result.clear();
746 clipboard.ReadText(&result); 746 clipboard.ReadText(Clipboard::BUFFER_STANDARD, &result);
747 // Cut should have failed, so the clipboard content should not have changed. 747 // Cut should have failed, so the clipboard content should not have changed.
748 EXPECT_EQ(kNormalText, result); 748 EXPECT_EQ(kNormalText, result);
749 749
750 // 750 //
751 // Test copy. 751 // Test copy.
752 // 752 //
753 753
754 // Let's start with read_only as the clipboard already contains the content 754 // Let's start with read_only as the clipboard already contains the content
755 // of normal. 755 // of normal.
756 read_only->SelectAll(); 756 read_only->SelectAll();
757 ::SendMessage(read_only->GetTestingHandle(), WM_COPY, 0, 0); 757 ::SendMessage(read_only->GetTestingHandle(), WM_COPY, 0, 0);
758 result.clear(); 758 result.clear();
759 clipboard.ReadText(&result); 759 clipboard.ReadText(Clipboard::BUFFER_STANDARD, &result);
760 EXPECT_EQ(kReadOnlyText, result); 760 EXPECT_EQ(kReadOnlyText, result);
761 761
762 normal->SelectAll(); 762 normal->SelectAll();
763 ::SendMessage(normal->GetTestingHandle(), WM_COPY, 0, 0); 763 ::SendMessage(normal->GetTestingHandle(), WM_COPY, 0, 0);
764 result.clear(); 764 result.clear();
765 clipboard.ReadText(&result); 765 clipboard.ReadText(Clipboard::BUFFER_STANDARD, &result);
766 EXPECT_EQ(kNormalText, result); 766 EXPECT_EQ(kNormalText, result);
767 767
768 password->SelectAll(); 768 password->SelectAll();
769 ::SendMessage(password->GetTestingHandle(), WM_COPY, 0, 0); 769 ::SendMessage(password->GetTestingHandle(), WM_COPY, 0, 0);
770 result.clear(); 770 result.clear();
771 clipboard.ReadText(&result); 771 clipboard.ReadText(Clipboard::BUFFER_STANDARD, &result);
772 // We don't let you copy from a password field, clipboard should not have 772 // We don't let you copy from a password field, clipboard should not have
773 // changed. 773 // changed.
774 EXPECT_EQ(kNormalText, result); 774 EXPECT_EQ(kNormalText, result);
775 775
776 // 776 //
777 // Test Paste. 777 // Test Paste.
778 // 778 //
779 // Note that we use GetWindowText instead of Textfield::GetText below as the 779 // Note that we use GetWindowText instead of Textfield::GetText below as the
780 // text in the Textfield class is synced to the text of the HWND on 780 // text in the Textfield class is synced to the text of the HWND on
781 // WM_KEYDOWN messages that we are not simulating here. 781 // WM_KEYDOWN messages that we are not simulating here.
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1224 TestViewWithControls* view_with_controls = new TestViewWithControls(); 1224 TestViewWithControls* view_with_controls = new TestViewWithControls();
1225 views::Window* window = 1225 views::Window* window =
1226 views::Window::CreateChromeWindow( 1226 views::Window::CreateChromeWindow(
1227 NULL, gfx::Rect(200, 200, 500, 500), 1227 NULL, gfx::Rect(200, 200, 500, 500),
1228 new SimpleWindowDelegate(view_with_controls)); 1228 new SimpleWindowDelegate(view_with_controls));
1229 window->Show(); 1229 window->Show();
1230 AcceleratorHandler accelerator_handler; 1230 AcceleratorHandler accelerator_handler;
1231 MessageLoopForUI::current()->Run(&accelerator_handler); 1231 MessageLoopForUI::current()->Run(&accelerator_handler);
1232 } 1232 }
1233 #endif 1233 #endif
OLDNEW
« no previous file with comments | « views/controls/textfield/native_textfield_win.cc ('k') | webkit/api/public/WebClipboard.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698