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

Side by Side Diff: ui/views/view_unittest.cc

Issue 2007503002: Views: Replace resource ids with ui::TextEditCommand enum for text editing commands in Textfield. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added file deleted during rename. Created 4 years, 6 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
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 "ui/views/view.h" 5 #include "ui/views/view.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
(...skipping 2011 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 2022
2023 normal->SetText(kNormalText); 2023 normal->SetText(kNormalText);
2024 read_only->SetText(kReadOnlyText); 2024 read_only->SetText(kReadOnlyText);
2025 password->SetText(kPasswordText); 2025 password->SetText(kPasswordText);
2026 2026
2027 // 2027 //
2028 // Test cut. 2028 // Test cut.
2029 // 2029 //
2030 2030
2031 normal->SelectAll(false); 2031 normal->SelectAll(false);
2032 normal->ExecuteCommand(IDS_APP_CUT); 2032 normal->ExecuteCommand(IDS_APP_CUT, 0);
2033 base::string16 result; 2033 base::string16 result;
2034 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result); 2034 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
2035 EXPECT_EQ(kNormalText, result); 2035 EXPECT_EQ(kNormalText, result);
2036 normal->SetText(kNormalText); // Let's revert to the original content. 2036 normal->SetText(kNormalText); // Let's revert to the original content.
2037 2037
2038 read_only->SelectAll(false); 2038 read_only->SelectAll(false);
2039 read_only->ExecuteCommand(IDS_APP_CUT); 2039 read_only->ExecuteCommand(IDS_APP_CUT, 0);
2040 result.clear(); 2040 result.clear();
2041 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result); 2041 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
2042 // Cut should have failed, so the clipboard content should not have changed. 2042 // Cut should have failed, so the clipboard content should not have changed.
2043 EXPECT_EQ(kNormalText, result); 2043 EXPECT_EQ(kNormalText, result);
2044 2044
2045 password->SelectAll(false); 2045 password->SelectAll(false);
2046 password->ExecuteCommand(IDS_APP_CUT); 2046 password->ExecuteCommand(IDS_APP_CUT, 0);
2047 result.clear(); 2047 result.clear();
2048 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result); 2048 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
2049 // Cut should have failed, so the clipboard content should not have changed. 2049 // Cut should have failed, so the clipboard content should not have changed.
2050 EXPECT_EQ(kNormalText, result); 2050 EXPECT_EQ(kNormalText, result);
2051 2051
2052 // 2052 //
2053 // Test copy. 2053 // Test copy.
2054 // 2054 //
2055 2055
2056 // Start with |read_only| to observe a change in clipboard text. 2056 // Start with |read_only| to observe a change in clipboard text.
2057 read_only->SelectAll(false); 2057 read_only->SelectAll(false);
2058 read_only->ExecuteCommand(IDS_APP_COPY); 2058 read_only->ExecuteCommand(IDS_APP_COPY, 0);
2059 result.clear(); 2059 result.clear();
2060 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result); 2060 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
2061 EXPECT_EQ(kReadOnlyText, result); 2061 EXPECT_EQ(kReadOnlyText, result);
2062 2062
2063 normal->SelectAll(false); 2063 normal->SelectAll(false);
2064 normal->ExecuteCommand(IDS_APP_COPY); 2064 normal->ExecuteCommand(IDS_APP_COPY, 0);
2065 result.clear(); 2065 result.clear();
2066 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result); 2066 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
2067 EXPECT_EQ(kNormalText, result); 2067 EXPECT_EQ(kNormalText, result);
2068 2068
2069 password->SelectAll(false); 2069 password->SelectAll(false);
2070 password->ExecuteCommand(IDS_APP_COPY); 2070 password->ExecuteCommand(IDS_APP_COPY, 0);
2071 result.clear(); 2071 result.clear();
2072 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result); 2072 clipboard->ReadText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
2073 // Text cannot be copied from an obscured field; the clipboard won't change. 2073 // Text cannot be copied from an obscured field; the clipboard won't change.
2074 EXPECT_EQ(kNormalText, result); 2074 EXPECT_EQ(kNormalText, result);
2075 2075
2076 // 2076 //
2077 // Test paste. 2077 // Test paste.
2078 // 2078 //
2079 2079
2080 // Attempting to paste kNormalText in a read-only text-field should fail. 2080 // Attempting to paste kNormalText in a read-only text-field should fail.
2081 read_only->SelectAll(false); 2081 read_only->SelectAll(false);
2082 read_only->ExecuteCommand(IDS_APP_PASTE); 2082 read_only->ExecuteCommand(IDS_APP_PASTE, 0);
2083 EXPECT_EQ(kReadOnlyText, read_only->text()); 2083 EXPECT_EQ(kReadOnlyText, read_only->text());
2084 2084
2085 password->SelectAll(false); 2085 password->SelectAll(false);
2086 password->ExecuteCommand(IDS_APP_PASTE); 2086 password->ExecuteCommand(IDS_APP_PASTE, 0);
2087 EXPECT_EQ(kNormalText, password->text()); 2087 EXPECT_EQ(kNormalText, password->text());
2088 2088
2089 // Copy from |read_only| to observe a change in the normal textfield text. 2089 // Copy from |read_only| to observe a change in the normal textfield text.
2090 read_only->SelectAll(false); 2090 read_only->SelectAll(false);
2091 read_only->ExecuteCommand(IDS_APP_COPY); 2091 read_only->ExecuteCommand(IDS_APP_COPY, 0);
2092 normal->SelectAll(false); 2092 normal->SelectAll(false);
2093 normal->ExecuteCommand(IDS_APP_PASTE); 2093 normal->ExecuteCommand(IDS_APP_PASTE, 0);
2094 EXPECT_EQ(kReadOnlyText, normal->text()); 2094 EXPECT_EQ(kReadOnlyText, normal->text());
2095 widget->CloseNow(); 2095 widget->CloseNow();
2096 } 2096 }
2097 2097
2098 //////////////////////////////////////////////////////////////////////////////// 2098 ////////////////////////////////////////////////////////////////////////////////
2099 // Accelerators 2099 // Accelerators
2100 //////////////////////////////////////////////////////////////////////////////// 2100 ////////////////////////////////////////////////////////////////////////////////
2101 bool TestView::AcceleratorPressed(const ui::Accelerator& accelerator) { 2101 bool TestView::AcceleratorPressed(const ui::Accelerator& accelerator) {
2102 accelerator_count_map_[accelerator]++; 2102 accelerator_count_map_[accelerator]++;
2103 return true; 2103 return true;
(...skipping 2464 matching lines...) Expand 10 before | Expand all | Expand 10 after
4568 widget.Init(params); 4568 widget.Init(params);
4569 4569
4570 AddViewWithChildLayer(widget.GetRootView()); 4570 AddViewWithChildLayer(widget.GetRootView());
4571 ViewThatAddsViewInOnNativeThemeChanged* v = 4571 ViewThatAddsViewInOnNativeThemeChanged* v =
4572 new ViewThatAddsViewInOnNativeThemeChanged; 4572 new ViewThatAddsViewInOnNativeThemeChanged;
4573 widget.GetRootView()->AddChildView(v); 4573 widget.GetRootView()->AddChildView(v);
4574 EXPECT_TRUE(v->on_native_theme_changed_called()); 4574 EXPECT_TRUE(v->on_native_theme_changed_called());
4575 } 4575 }
4576 4576
4577 } // namespace views 4577 } // namespace views
OLDNEW
« ui/views/controls/textfield/textfield.cc ('K') | « ui/views/controls/textfield/textfield.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698