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

Unified Diff: views/controls/textfield/native_textfield_views_unittest.cc

Issue 8570002: Fix a cause of flakyness in NativeTextfieldViewsTest.ReadOnlyTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/textfield/native_textfield_views_unittest.cc
===================================================================
--- views/controls/textfield/native_textfield_views_unittest.cc (revision 109873)
+++ views/controls/textfield/native_textfield_views_unittest.cc (working copy)
@@ -248,6 +248,19 @@
}
}
+ string16 GetClipboardText() const {
+ string16 text;
+ views::ViewsDelegate::views_delegate->GetClipboard()->
+ ReadText(ui::Clipboard::BUFFER_STANDARD, &text);
+ return text;
+ }
+
+ void SetClipboardText(const std::string& text) {
+ ui::ScopedClipboardWriter clipboard_writer(
+ views::ViewsDelegate::views_delegate->GetClipboard());
+ clipboard_writer.WriteText(ASCIIToUTF16(text));
+ }
+
View* GetFocusedView() {
return widget_->GetFocusManager()->GetFocusedView();
}
@@ -302,6 +315,17 @@
return textfield_view_->GetTextInputType();
}
+ void VerifyTextfieldContextMenuContents(bool textfield_has_selection,
+ ui::MenuModel* menu_model) {
+ EXPECT_TRUE(menu_model->IsEnabledAt(4 /* Separator */));
+ EXPECT_TRUE(menu_model->IsEnabledAt(5 /* SELECT ALL */));
+ EXPECT_EQ(textfield_has_selection, menu_model->IsEnabledAt(0 /* CUT */));
+ EXPECT_EQ(textfield_has_selection, menu_model->IsEnabledAt(1 /* COPY */));
+ EXPECT_EQ(textfield_has_selection, menu_model->IsEnabledAt(3 /* DELETE */));
+ string16 str(GetClipboardText());
+ EXPECT_NE(str.empty(), menu_model->IsEnabledAt(2 /* PASTE */));
+ }
+
// We need widget to populate wrapper class.
Widget* widget_;
@@ -649,19 +673,6 @@
EXPECT_EQ(1, GetFocusedView()->id());
}
-void VerifyTextfieldContextMenuContents(bool textfield_has_selection,
- ui::MenuModel* menu_model) {
- EXPECT_TRUE(menu_model->IsEnabledAt(4 /* Separator */));
- EXPECT_TRUE(menu_model->IsEnabledAt(5 /* SELECT ALL */));
- EXPECT_EQ(textfield_has_selection, menu_model->IsEnabledAt(0 /* CUT */));
- EXPECT_EQ(textfield_has_selection, menu_model->IsEnabledAt(1 /* COPY */));
- EXPECT_EQ(textfield_has_selection, menu_model->IsEnabledAt(3 /* DELETE */));
- string16 str;
- views::ViewsDelegate::views_delegate->GetClipboard()->
- ReadText(ui::Clipboard::BUFFER_STANDARD, &str);
- EXPECT_NE(str.empty(), menu_model->IsEnabledAt(2 /* PASTE */));
-}
-
TEST_F(NativeTextfieldViewsTest, ContextMenuDisplayTest) {
InitTextfield(Textfield::STYLE_DEFAULT);
textfield_->SetText(ASCIIToUTF16("hello world"));
@@ -984,11 +995,10 @@
EXPECT_STR_EQ(" one two three ", textfield_->GetSelectedText());
// CUT&PASTE does not work, but COPY works
+ SetClipboardText("Test");
SendKeyEvent(ui::VKEY_X, false, true);
EXPECT_STR_EQ(" one two three ", textfield_->GetSelectedText());
- string16 str;
- views::ViewsDelegate::views_delegate->GetClipboard()->
- ReadText(ui::Clipboard::BUFFER_STANDARD, &str);
+ string16 str(GetClipboardText());
EXPECT_STR_NE(" one two three ", str);
SendKeyEvent(ui::VKEY_C, false, true);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698