OLD | NEW |
---|---|
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 <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 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
946 result.clear(); | 946 result.clear(); |
947 clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result); | 947 clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result); |
948 EXPECT_EQ(kReadOnlyText, result); | 948 EXPECT_EQ(kReadOnlyText, result); |
949 | 949 |
950 normal->SelectAll(); | 950 normal->SelectAll(); |
951 ::SendMessage(normal->GetTestingHandle(), WM_COPY, 0, 0); | 951 ::SendMessage(normal->GetTestingHandle(), WM_COPY, 0, 0); |
952 result.clear(); | 952 result.clear(); |
953 clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result); | 953 clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result); |
954 EXPECT_EQ(kNormalText, result); | 954 EXPECT_EQ(kNormalText, result); |
955 | 955 |
956 // We don't let you copy from an obscured field, clipboard should not change. | |
956 password->SelectAll(); | 957 password->SelectAll(); |
957 ::SendMessage(password->GetTestingHandle(), WM_COPY, 0, 0); | 958 ::SendMessage(password->GetTestingHandle(), WM_COPY, 0, 0); |
958 result.clear(); | 959 result.clear(); |
959 clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result); | 960 clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result); |
960 // We don't let you copy from an obscured field, clipboard should not have | |
961 // changed. | |
962 EXPECT_EQ(kNormalText, result); | 961 EXPECT_EQ(kNormalText, result); |
962 // But copying is allowed when STYLE_OBSCURED is clear, even if the text input | |
963 // type is still PASSWORD. | |
964 password->SetObscured(false); | |
965 ::SendMessage(password->GetTestingHandle(), WM_COPY, 0, 0); | |
966 result.clear(); | |
967 clipboard.ReadText(ui::Clipboard::BUFFER_STANDARD, &result); | |
968 EXPECT_EQ(kPasswordText, result); | |
969 password->SetObscured(true); | |
oshima
2012/01/30 23:56:24
can you add tests in native_textfied_views as well
| |
963 | 970 |
964 // | 971 // |
965 // Test Paste. | 972 // Test Paste. |
966 // | 973 // |
967 // Note that we use GetWindowText instead of Textfield::GetText below as the | 974 // Note that we use GetWindowText instead of Textfield::GetText below as the |
968 // text in the Textfield class is synced to the text of the HWND on | 975 // text in the Textfield class is synced to the text of the HWND on |
969 // WM_KEYDOWN messages that we are not simulating here. | 976 // WM_KEYDOWN messages that we are not simulating here. |
970 | 977 |
971 // Attempting to copy kNormalText in a read-only text-field should fail. | 978 // Attempting to replace the text in a read-only text-field should fail. |
972 read_only->SelectAll(); | 979 read_only->SelectAll(); |
973 ::SendMessage(read_only->GetTestingHandle(), WM_KEYDOWN, 0, 0); | 980 ::SendMessage(read_only->GetTestingHandle(), WM_KEYDOWN, 0, 0); |
974 wchar_t buffer[1024] = { 0 }; | 981 wchar_t buffer[1024] = { 0 }; |
975 ::GetWindowText(read_only->GetTestingHandle(), buffer, 1024); | 982 ::GetWindowText(read_only->GetTestingHandle(), buffer, 1024); |
976 EXPECT_EQ(kReadOnlyText, string16(buffer)); | 983 EXPECT_EQ(kReadOnlyText, string16(buffer)); |
977 | 984 |
985 // Pasting into a password field should work. | |
986 normal->SelectAll(); | |
987 ::SendMessage(normal->GetTestingHandle(), WM_COPY, 0, 0); | |
978 password->SelectAll(); | 988 password->SelectAll(); |
979 ::SendMessage(password->GetTestingHandle(), WM_PASTE, 0, 0); | 989 ::SendMessage(password->GetTestingHandle(), WM_PASTE, 0, 0); |
980 ::GetWindowText(password->GetTestingHandle(), buffer, 1024); | 990 ::GetWindowText(password->GetTestingHandle(), buffer, 1024); |
981 EXPECT_EQ(kNormalText, string16(buffer)); | 991 EXPECT_EQ(kNormalText, string16(buffer)); |
982 | 992 |
983 // Copy from read_only so the string we are pasting is not the same as the | 993 // Copy from read_only so the string we are pasting is not the same as the |
984 // current one. | 994 // current one. |
985 read_only->SelectAll(); | 995 read_only->SelectAll(); |
986 ::SendMessage(read_only->GetTestingHandle(), WM_COPY, 0, 0); | 996 ::SendMessage(read_only->GetTestingHandle(), WM_COPY, 0, 0); |
987 normal->SelectAll(); | 997 normal->SelectAll(); |
(...skipping 2139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3127 // Move c1 to the front. The layers should have moved too. | 3137 // Move c1 to the front. The layers should have moved too. |
3128 content->ReorderChildView(c1, -1); | 3138 content->ReorderChildView(c1, -1); |
3129 EXPECT_EQ(c1->layer(), parent_layer->children()[1]); | 3139 EXPECT_EQ(c1->layer(), parent_layer->children()[1]); |
3130 EXPECT_EQ(c2->layer(), parent_layer->children()[0]); | 3140 EXPECT_EQ(c2->layer(), parent_layer->children()[0]); |
3131 } | 3141 } |
3132 #endif | 3142 #endif |
3133 | 3143 |
3134 #endif // VIEWS_COMPOSITOR | 3144 #endif // VIEWS_COMPOSITOR |
3135 | 3145 |
3136 } // namespace views | 3146 } // namespace views |
OLD | NEW |