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

Side by Side Diff: views/controls/textfield/native_textfield_views_unittest.cc

Issue 6287002: Fix for broken build (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 11 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_views.cc ('k') | no next file » | 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) 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 "base/auto_reset.h" 5 #include "base/auto_reset.h"
6 #include "base/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/base/clipboard/clipboard.h" 9 #include "ui/base/clipboard/clipboard.h"
10 #include "ui/base/keycodes/keyboard_codes.h" 10 #include "ui/base/keycodes/keyboard_codes.h"
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 // Cycle back to the last textfield. 390 // Cycle back to the last textfield.
391 widget_->GetFocusManager()->AdvanceFocus(true); 391 widget_->GetFocusManager()->AdvanceFocus(true);
392 EXPECT_EQ(3, GetFocusedView()->GetID()); 392 EXPECT_EQ(3, GetFocusedView()->GetID());
393 393
394 // Request focus should still work. 394 // Request focus should still work.
395 textfield_->RequestFocus(); 395 textfield_->RequestFocus();
396 EXPECT_EQ(1, GetFocusedView()->GetID()); 396 EXPECT_EQ(1, GetFocusedView()->GetID());
397 } 397 }
398 398
399 void VerifyTextfieldContextMenuContents(bool textfield_has_selection, 399 void VerifyTextfieldContextMenuContents(bool textfield_has_selection,
400 menus::MenuModel* menu_model) { 400 ui::MenuModel* menu_model) {
401 EXPECT_TRUE(menu_model->IsEnabledAt(4 /* Separator */)); 401 EXPECT_TRUE(menu_model->IsEnabledAt(4 /* Separator */));
402 EXPECT_TRUE(menu_model->IsEnabledAt(5 /* SELECT ALL */)); 402 EXPECT_TRUE(menu_model->IsEnabledAt(5 /* SELECT ALL */));
403 EXPECT_EQ(textfield_has_selection, menu_model->IsEnabledAt(0 /* CUT */)); 403 EXPECT_EQ(textfield_has_selection, menu_model->IsEnabledAt(0 /* CUT */));
404 EXPECT_EQ(textfield_has_selection, menu_model->IsEnabledAt(1 /* COPY */)); 404 EXPECT_EQ(textfield_has_selection, menu_model->IsEnabledAt(1 /* COPY */));
405 EXPECT_EQ(textfield_has_selection, menu_model->IsEnabledAt(3 /* DELETE */)); 405 EXPECT_EQ(textfield_has_selection, menu_model->IsEnabledAt(3 /* DELETE */));
406 string16 str; 406 string16 str;
407 views::ViewsDelegate::views_delegate->GetClipboard() 407 views::ViewsDelegate::views_delegate->GetClipboard()
408 ->ReadText(ui::Clipboard::BUFFER_STANDARD, &str); 408 ->ReadText(ui::Clipboard::BUFFER_STANDARD, &str);
409 EXPECT_NE(str.empty(), menu_model->IsEnabledAt(2 /* PASTE */)); 409 EXPECT_NE(str.empty(), menu_model->IsEnabledAt(2 /* PASTE */));
410 } 410 }
411 411
412 TEST_F(NativeTextfieldViewsTest, ContextMenuDisplayTest) { 412 TEST_F(NativeTextfieldViewsTest, ContextMenuDisplayTest) {
413 scoped_ptr<TestViewsDelegate> test_views_delegate(new TestViewsDelegate()); 413 scoped_ptr<TestViewsDelegate> test_views_delegate(new TestViewsDelegate());
414 AutoReset<views::ViewsDelegate*> auto_reset( 414 AutoReset<views::ViewsDelegate*> auto_reset(
415 &views::ViewsDelegate::views_delegate, test_views_delegate.get()); 415 &views::ViewsDelegate::views_delegate, test_views_delegate.get());
416 views::ViewsDelegate::views_delegate = test_views_delegate.get(); 416 views::ViewsDelegate::views_delegate = test_views_delegate.get();
417 InitTextfield(Textfield::STYLE_DEFAULT); 417 InitTextfield(Textfield::STYLE_DEFAULT);
418 textfield_->SetText(ASCIIToUTF16("hello world")); 418 textfield_->SetText(ASCIIToUTF16("hello world"));
419 EXPECT_TRUE(GetContextMenu()); 419 EXPECT_TRUE(GetContextMenu());
420 VerifyTextfieldContextMenuContents(false, GetContextMenu()->model()); 420 VerifyTextfieldContextMenuContents(false, GetContextMenu()->model());
421 421
422 textfield_->SelectAll(); 422 textfield_->SelectAll();
423 VerifyTextfieldContextMenuContents(true, GetContextMenu()->model()); 423 VerifyTextfieldContextMenuContents(true, GetContextMenu()->model());
424 } 424 }
425 425
426 } // namespace views 426 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/textfield/native_textfield_views.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698