OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
843 textfield->ClearSelection(); | 843 textfield->ClearSelection(); |
844 EXPECT_EQ(kEmptyString, textfield->GetSelectedText()); | 844 EXPECT_EQ(kEmptyString, textfield->GetSelectedText()); |
845 | 845 |
846 widget->CloseNow(); | 846 widget->CloseNow(); |
847 } | 847 } |
848 | 848 |
849 #if defined(OS_WIN) && !defined(USE_AURA) | 849 #if defined(OS_WIN) && !defined(USE_AURA) |
850 | 850 |
851 // Tests that the Textfield view respond appropiately to cut/copy/paste. | 851 // Tests that the Textfield view respond appropiately to cut/copy/paste. |
852 TEST_F(ViewTest, TextfieldCutCopyPaste) { | 852 TEST_F(ViewTest, TextfieldCutCopyPaste) { |
853 const std::wstring kNormalText = L"Normal"; | 853 const string16 kNormalText = ASCIIToUTF16("Normal"); |
854 const std::wstring kReadOnlyText = L"Read only"; | 854 const string16 kReadOnlyText = ASCIIToUTF16("Read only"); |
855 const std::wstring kPasswordText = L"Password! ** Secret stuff **"; | 855 const string16 kPasswordText = ASCIIToUTF16("Password! ** Secret stuff **"); |
856 | 856 |
857 ui::Clipboard clipboard; | 857 ui::Clipboard clipboard; |
858 | 858 |
859 Widget* widget = new Widget; | 859 Widget* widget = new Widget; |
860 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); | 860 Widget::InitParams params(Widget::InitParams::TYPE_POPUP); |
861 params.bounds = gfx::Rect(0, 0, 100, 100); | 861 params.bounds = gfx::Rect(0, 0, 100, 100); |
862 widget->Init(params); | 862 widget->Init(params); |
863 View* root_view = widget->GetRootView(); | 863 View* root_view = widget->GetRootView(); |
864 | 864 |
865 Textfield* normal = new Textfield(); | 865 Textfield* normal = new Textfield(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
934 // | 934 // |
935 // Note that we use GetWindowText instead of Textfield::GetText below as the | 935 // Note that we use GetWindowText instead of Textfield::GetText below as the |
936 // text in the Textfield class is synced to the text of the HWND on | 936 // text in the Textfield class is synced to the text of the HWND on |
937 // WM_KEYDOWN messages that we are not simulating here. | 937 // WM_KEYDOWN messages that we are not simulating here. |
938 | 938 |
939 // Attempting to copy kNormalText in a read-only text-field should fail. | 939 // Attempting to copy kNormalText in a read-only text-field should fail. |
940 read_only->SelectAll(); | 940 read_only->SelectAll(); |
941 ::SendMessage(read_only->GetTestingHandle(), WM_KEYDOWN, 0, 0); | 941 ::SendMessage(read_only->GetTestingHandle(), WM_KEYDOWN, 0, 0); |
942 wchar_t buffer[1024] = { 0 }; | 942 wchar_t buffer[1024] = { 0 }; |
943 ::GetWindowText(read_only->GetTestingHandle(), buffer, 1024); | 943 ::GetWindowText(read_only->GetTestingHandle(), buffer, 1024); |
944 EXPECT_EQ(kReadOnlyText, std::wstring(buffer)); | 944 EXPECT_EQ(kReadOnlyText, string16(buffer)); |
sky
2011/10/24 14:56:08
I believe these should rename wstring since buffer
tfarina
2011/10/24 15:19:42
On Windows string16 is typedefed to std::wstring.
| |
945 | 945 |
946 password->SelectAll(); | 946 password->SelectAll(); |
947 ::SendMessage(password->GetTestingHandle(), WM_PASTE, 0, 0); | 947 ::SendMessage(password->GetTestingHandle(), WM_PASTE, 0, 0); |
948 ::GetWindowText(password->GetTestingHandle(), buffer, 1024); | 948 ::GetWindowText(password->GetTestingHandle(), buffer, 1024); |
949 EXPECT_EQ(kNormalText, std::wstring(buffer)); | 949 EXPECT_EQ(kNormalText, string16(buffer)); |
950 | 950 |
951 // Copy from read_only so the string we are pasting is not the same as the | 951 // Copy from read_only so the string we are pasting is not the same as the |
952 // current one. | 952 // current one. |
953 read_only->SelectAll(); | 953 read_only->SelectAll(); |
954 ::SendMessage(read_only->GetTestingHandle(), WM_COPY, 0, 0); | 954 ::SendMessage(read_only->GetTestingHandle(), WM_COPY, 0, 0); |
955 normal->SelectAll(); | 955 normal->SelectAll(); |
956 ::SendMessage(normal->GetTestingHandle(), WM_PASTE, 0, 0); | 956 ::SendMessage(normal->GetTestingHandle(), WM_PASTE, 0, 0); |
957 ::GetWindowText(normal->GetTestingHandle(), buffer, 1024); | 957 ::GetWindowText(normal->GetTestingHandle(), buffer, 1024); |
958 EXPECT_EQ(kReadOnlyText, std::wstring(buffer)); | 958 EXPECT_EQ(kReadOnlyText, string16(buffer)); |
959 widget->CloseNow(); | 959 widget->CloseNow(); |
960 } | 960 } |
961 #endif | 961 #endif |
962 | 962 |
963 //////////////////////////////////////////////////////////////////////////////// | 963 //////////////////////////////////////////////////////////////////////////////// |
964 // Accelerators | 964 // Accelerators |
965 //////////////////////////////////////////////////////////////////////////////// | 965 //////////////////////////////////////////////////////////////////////////////// |
966 bool TestView::AcceleratorPressed(const Accelerator& accelerator) { | 966 bool TestView::AcceleratorPressed(const Accelerator& accelerator) { |
967 accelerator_count_map_[accelerator]++; | 967 accelerator_count_map_[accelerator]++; |
968 return true; | 968 return true; |
(...skipping 2092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3061 ScrambleTree(content); | 3061 ScrambleTree(content); |
3062 EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer())); | 3062 EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer())); |
3063 | 3063 |
3064 ScrambleTree(content); | 3064 ScrambleTree(content); |
3065 EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer())); | 3065 EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer())); |
3066 } | 3066 } |
3067 | 3067 |
3068 #endif // VIEWS_COMPOSITOR | 3068 #endif // VIEWS_COMPOSITOR |
3069 | 3069 |
3070 } // namespace views | 3070 } // namespace views |
OLD | NEW |