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

Side by Side Diff: ui/views/controls/combobox/combobox_unittest.cc

Issue 1904753002: MenuButton: support Mac look & feel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cache arrow images Created 4 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/controls/combobox/combobox.h" 5 #include "ui/views/controls/combobox/combobox.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 18 matching lines...) Expand all
29 29
30 using test::ComboboxTestApi; 30 using test::ComboboxTestApi;
31 31
32 namespace { 32 namespace {
33 33
34 // A wrapper of Combobox to intercept the result of OnKeyPressed() and 34 // A wrapper of Combobox to intercept the result of OnKeyPressed() and
35 // OnKeyReleased() methods. 35 // OnKeyReleased() methods.
36 class TestCombobox : public Combobox { 36 class TestCombobox : public Combobox {
37 public: 37 public:
38 explicit TestCombobox(ui::ComboboxModel* model) 38 explicit TestCombobox(ui::ComboboxModel* model)
39 : Combobox(model), 39 : TestCombobox(model, Combobox::STYLE_NORMAL) {}
tapted 2016/04/26 05:05:58 In this case I think things are better without the
Elly Fong-Jones 2016/04/26 17:41:26 Done.
40 key_handled_(false), 40 TestCombobox(ui::ComboboxModel* model, Combobox::Style style)
41 key_received_(false) {} 41 : Combobox(model, style), key_handled_(false), key_received_(false) {}
42 42
43 bool OnKeyPressed(const ui::KeyEvent& e) override { 43 bool OnKeyPressed(const ui::KeyEvent& e) override {
44 key_received_ = true; 44 key_received_ = true;
45 key_handled_ = Combobox::OnKeyPressed(e); 45 key_handled_ = Combobox::OnKeyPressed(e);
46 return key_handled_; 46 return key_handled_;
47 } 47 }
48 48
49 bool OnKeyReleased(const ui::KeyEvent& e) override { 49 bool OnKeyReleased(const ui::KeyEvent& e) override {
50 key_received_ = true; 50 key_received_ = true;
51 key_handled_ = Combobox::OnKeyReleased(e); 51 key_handled_ = Combobox::OnKeyReleased(e);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 public: 189 public:
190 ComboboxTest() : widget_(NULL), combobox_(NULL) {} 190 ComboboxTest() : widget_(NULL), combobox_(NULL) {}
191 191
192 void TearDown() override { 192 void TearDown() override {
193 if (widget_) 193 if (widget_)
194 widget_->Close(); 194 widget_->Close();
195 ViewsTestBase::TearDown(); 195 ViewsTestBase::TearDown();
196 } 196 }
197 197
198 void InitCombobox(const std::set<int>* separators) { 198 void InitCombobox(const std::set<int>* separators) {
199 InitCombobox(separators, Combobox::STYLE_NORMAL);
200 }
201
202 void InitCombobox(const std::set<int>* separators, Combobox::Style style) {
199 model_.reset(new TestComboboxModel()); 203 model_.reset(new TestComboboxModel());
200 204
201 if (separators) 205 if (separators)
202 model_->SetSeparators(*separators); 206 model_->SetSeparators(*separators);
203 207
204 ASSERT_FALSE(combobox_); 208 ASSERT_FALSE(combobox_);
205 combobox_ = new TestCombobox(model_.get()); 209 combobox_ = new TestCombobox(model_.get(), style);
206 test_api_.reset(new ComboboxTestApi(combobox_)); 210 test_api_.reset(new ComboboxTestApi(combobox_));
207 combobox_->set_id(1); 211 combobox_->set_id(1);
208 212
209 widget_ = new Widget; 213 widget_ = new Widget;
210 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); 214 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
211 params.bounds = gfx::Rect(200, 200, 200, 200); 215 params.bounds = gfx::Rect(200, 200, 200, 200);
212 widget_->Init(params); 216 widget_->Init(params);
213 View* container = new View(); 217 View* container = new View();
214 widget_->SetContentsView(container); 218 widget_->SetContentsView(container);
215 container->AddChildView(combobox_); 219 container->AddChildView(combobox_);
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 // Verifies selecting the first matching value (and returning whether found). 444 // Verifies selecting the first matching value (and returning whether found).
441 TEST_F(ComboboxTest, SelectValue) { 445 TEST_F(ComboboxTest, SelectValue) {
442 InitCombobox(NULL); 446 InitCombobox(NULL);
443 ASSERT_EQ(model_->GetDefaultIndex(), combobox_->selected_index()); 447 ASSERT_EQ(model_->GetDefaultIndex(), combobox_->selected_index());
444 EXPECT_TRUE(combobox_->SelectValue(ASCIIToUTF16("PEANUT BUTTER"))); 448 EXPECT_TRUE(combobox_->SelectValue(ASCIIToUTF16("PEANUT BUTTER")));
445 EXPECT_EQ(0, combobox_->selected_index()); 449 EXPECT_EQ(0, combobox_->selected_index());
446 EXPECT_TRUE(combobox_->SelectValue(ASCIIToUTF16("JELLY"))); 450 EXPECT_TRUE(combobox_->SelectValue(ASCIIToUTF16("JELLY")));
447 EXPECT_EQ(1, combobox_->selected_index()); 451 EXPECT_EQ(1, combobox_->selected_index());
448 EXPECT_FALSE(combobox_->SelectValue(ASCIIToUTF16("BANANAS"))); 452 EXPECT_FALSE(combobox_->SelectValue(ASCIIToUTF16("BANANAS")));
449 EXPECT_EQ(1, combobox_->selected_index()); 453 EXPECT_EQ(1, combobox_->selected_index());
454 }
450 455
456 TEST_F(ComboboxTest, SelectValueActionStyle) {
451 // With the action style, the selected index is always 0. 457 // With the action style, the selected index is always 0.
452 combobox_->SetStyle(Combobox::STYLE_ACTION); 458 InitCombobox(NULL, Combobox::STYLE_ACTION);
tapted 2016/04/26 05:05:58 nit: since it's changing, any added code should be
Elly Fong-Jones 2016/04/26 17:41:26 Done.
453 EXPECT_FALSE(combobox_->SelectValue(ASCIIToUTF16("PEANUT BUTTER"))); 459 EXPECT_FALSE(combobox_->SelectValue(ASCIIToUTF16("PEANUT BUTTER")));
454 EXPECT_EQ(0, combobox_->selected_index()); 460 EXPECT_EQ(0, combobox_->selected_index());
455 EXPECT_FALSE(combobox_->SelectValue(ASCIIToUTF16("JELLY"))); 461 EXPECT_FALSE(combobox_->SelectValue(ASCIIToUTF16("JELLY")));
456 EXPECT_EQ(0, combobox_->selected_index()); 462 EXPECT_EQ(0, combobox_->selected_index());
457 EXPECT_FALSE(combobox_->SelectValue(ASCIIToUTF16("BANANAS"))); 463 EXPECT_FALSE(combobox_->SelectValue(ASCIIToUTF16("BANANAS")));
458 EXPECT_EQ(0, combobox_->selected_index()); 464 EXPECT_EQ(0, combobox_->selected_index());
459 } 465 }
460 466
461 TEST_F(ComboboxTest, SelectIndexActionStyle) { 467 TEST_F(ComboboxTest, SelectIndexActionStyle) {
462 InitCombobox(NULL);
463
464 // With the action style, the selected index is always 0. 468 // With the action style, the selected index is always 0.
465 combobox_->SetStyle(Combobox::STYLE_ACTION); 469 InitCombobox(NULL, Combobox::STYLE_ACTION);
466 combobox_->SetSelectedIndex(1); 470 combobox_->SetSelectedIndex(1);
467 EXPECT_EQ(0, combobox_->selected_index()); 471 EXPECT_EQ(0, combobox_->selected_index());
468 combobox_->SetSelectedIndex(2); 472 combobox_->SetSelectedIndex(2);
469 EXPECT_EQ(0, combobox_->selected_index()); 473 EXPECT_EQ(0, combobox_->selected_index());
470 combobox_->SetSelectedIndex(3); 474 combobox_->SetSelectedIndex(3);
471 EXPECT_EQ(0, combobox_->selected_index()); 475 EXPECT_EQ(0, combobox_->selected_index());
472 } 476 }
473 477
474 TEST_F(ComboboxTest, ListenerHandlesDelete) { 478 TEST_F(ComboboxTest, ListenerHandlesDelete) {
475 TestComboboxModel model; 479 TestComboboxModel model;
476 480
477 // |combobox| will be deleted on change. 481 // |combobox| will be deleted on change.
478 TestCombobox* combobox = new TestCombobox(&model); 482 TestCombobox* combobox = new TestCombobox(&model);
479 std::unique_ptr<EvilListener> evil_listener(new EvilListener()); 483 std::unique_ptr<EvilListener> evil_listener(new EvilListener());
480 combobox->set_listener(evil_listener.get()); 484 combobox->set_listener(evil_listener.get());
481 ASSERT_NO_FATAL_FAILURE(ComboboxTestApi(combobox).PerformActionAt(2)); 485 ASSERT_NO_FATAL_FAILURE(ComboboxTestApi(combobox).PerformActionAt(2));
482 EXPECT_TRUE(evil_listener->deleted()); 486 EXPECT_TRUE(evil_listener->deleted());
483 487
484 // With STYLE_ACTION 488 // With STYLE_ACTION
485 // |combobox| will be deleted on change. 489 // |combobox| will be deleted on change.
486 combobox = new TestCombobox(&model); 490 combobox = new TestCombobox(&model, Combobox::STYLE_ACTION);
487 evil_listener.reset(new EvilListener()); 491 evil_listener.reset(new EvilListener());
488 combobox->set_listener(evil_listener.get()); 492 combobox->set_listener(evil_listener.get());
489 combobox->SetStyle(Combobox::STYLE_ACTION);
490 ASSERT_NO_FATAL_FAILURE(ComboboxTestApi(combobox).PerformActionAt(2)); 493 ASSERT_NO_FATAL_FAILURE(ComboboxTestApi(combobox).PerformActionAt(2));
491 EXPECT_TRUE(evil_listener->deleted()); 494 EXPECT_TRUE(evil_listener->deleted());
492 } 495 }
493 496
494 TEST_F(ComboboxTest, Click) { 497 TEST_F(ComboboxTest, Click) {
495 InitCombobox(NULL); 498 InitCombobox(NULL);
496 499
497 TestComboboxListener listener; 500 TestComboboxListener listener;
498 combobox_->set_listener(&listener); 501 combobox_->set_listener(&listener);
499 502
(...skipping 29 matching lines...) Expand all
529 532
530 TEST_F(ComboboxTest, NotifyOnClickWithReturnKey) { 533 TEST_F(ComboboxTest, NotifyOnClickWithReturnKey) {
531 InitCombobox(NULL); 534 InitCombobox(NULL);
532 535
533 TestComboboxListener listener; 536 TestComboboxListener listener;
534 combobox_->set_listener(&listener); 537 combobox_->set_listener(&listener);
535 538
536 // With STYLE_NORMAL, the click event is ignored. 539 // With STYLE_NORMAL, the click event is ignored.
537 SendKeyEvent(ui::VKEY_RETURN); 540 SendKeyEvent(ui::VKEY_RETURN);
538 EXPECT_FALSE(listener.on_perform_action_called()); 541 EXPECT_FALSE(listener.on_perform_action_called());
542 }
543
544 TEST_F(ComboboxTest, NotifyOnClickWithReturnKeyActionStyle) {
545 InitCombobox(NULL, Combobox::STYLE_ACTION);
546
547 TestComboboxListener listener;
548 combobox_->set_listener(&listener);
539 549
540 // With STYLE_ACTION, the click event is notified. 550 // With STYLE_ACTION, the click event is notified.
541 combobox_->SetStyle(Combobox::STYLE_ACTION);
542 SendKeyEvent(ui::VKEY_RETURN); 551 SendKeyEvent(ui::VKEY_RETURN);
543 EXPECT_TRUE(listener.on_perform_action_called()); 552 EXPECT_TRUE(listener.on_perform_action_called());
544 EXPECT_EQ(0, listener.perform_action_index()); 553 EXPECT_EQ(0, listener.perform_action_index());
545 } 554 }
546 555
547 TEST_F(ComboboxTest, NotifyOnClickWithSpaceKey) { 556 TEST_F(ComboboxTest, NotifyOnClickWithSpaceKey) {
548 InitCombobox(NULL); 557 InitCombobox(NULL);
549 558
550 TestComboboxListener listener; 559 TestComboboxListener listener;
551 combobox_->set_listener(&listener); 560 combobox_->set_listener(&listener);
552 561
553 // With STYLE_NORMAL, the click event is ignored. 562 // With STYLE_NORMAL, the click event is ignored.
554 SendKeyEvent(ui::VKEY_SPACE); 563 SendKeyEvent(ui::VKEY_SPACE);
555 EXPECT_FALSE(listener.on_perform_action_called()); 564 EXPECT_FALSE(listener.on_perform_action_called());
556 SendKeyEventWithType(ui::VKEY_SPACE, ui::ET_KEY_RELEASED); 565 SendKeyEventWithType(ui::VKEY_SPACE, ui::ET_KEY_RELEASED);
557 EXPECT_FALSE(listener.on_perform_action_called()); 566 EXPECT_FALSE(listener.on_perform_action_called());
567 }
568
569 TEST_F(ComboboxTest, NotifyOnClickWithSpaceKeyActionStyle) {
570 InitCombobox(NULL, Combobox::STYLE_ACTION);
571
572 TestComboboxListener listener;
573 combobox_->set_listener(&listener);
558 574
559 // With STYLE_ACTION, the click event is notified after releasing. 575 // With STYLE_ACTION, the click event is notified after releasing.
560 combobox_->SetStyle(Combobox::STYLE_ACTION);
561 SendKeyEvent(ui::VKEY_SPACE); 576 SendKeyEvent(ui::VKEY_SPACE);
562 EXPECT_FALSE(listener.on_perform_action_called()); 577 EXPECT_FALSE(listener.on_perform_action_called());
563 SendKeyEventWithType(ui::VKEY_SPACE, ui::ET_KEY_RELEASED); 578 SendKeyEventWithType(ui::VKEY_SPACE, ui::ET_KEY_RELEASED);
564 EXPECT_TRUE(listener.on_perform_action_called()); 579 EXPECT_TRUE(listener.on_perform_action_called());
565 EXPECT_EQ(0, listener.perform_action_index()); 580 EXPECT_EQ(0, listener.perform_action_index());
566 } 581 }
567 582
568 TEST_F(ComboboxTest, NotifyOnClickWithMouse) { 583 TEST_F(ComboboxTest, NotifyOnClickWithMouse) {
569 InitCombobox(NULL); 584 InitCombobox(NULL, Combobox::STYLE_ACTION);
570 585
571 TestComboboxListener listener; 586 TestComboboxListener listener;
572 combobox_->set_listener(&listener); 587 combobox_->set_listener(&listener);
573 588
574 combobox_->SetStyle(Combobox::STYLE_ACTION);
575 combobox_->Layout(); 589 combobox_->Layout();
576 590
577 // Click the right side (arrow button). The menu is shown. 591 // Click the right side (arrow button). The menu is shown.
578 int menu_show_count = 0; 592 int menu_show_count = 0;
579 test_api_->InstallTestMenuRunner(&menu_show_count); 593 test_api_->InstallTestMenuRunner(&menu_show_count);
580 EXPECT_EQ(0, menu_show_count); 594 EXPECT_EQ(0, menu_show_count);
581 PerformClick(gfx::Point(combobox_->x() + combobox_->width() - 1, 595 PerformClick(gfx::Point(combobox_->x() + combobox_->width() - 1,
582 combobox_->y() + combobox_->height() / 2)); 596 combobox_->y() + combobox_->height() / 2));
583 EXPECT_FALSE(listener.on_perform_action_called()); 597 EXPECT_FALSE(listener.on_perform_action_called());
584 EXPECT_EQ(1, menu_show_count); 598 EXPECT_EQ(1, menu_show_count);
585 599
586 // Click the left side (text button). The click event is notified. 600 // Click the left side (text button). The click event is notified.
587 test_api_->InstallTestMenuRunner(&menu_show_count); 601 test_api_->InstallTestMenuRunner(&menu_show_count);
588 PerformClick(gfx::Point(combobox_->x() + 1, 602 PerformClick(gfx::Point(combobox_->x() + 1,
589 combobox_->y() + combobox_->height() / 2)); 603 combobox_->y() + combobox_->height() / 2));
590 EXPECT_TRUE(listener.on_perform_action_called()); 604 EXPECT_TRUE(listener.on_perform_action_called());
591 EXPECT_EQ(1, menu_show_count); // Unchanged. 605 EXPECT_EQ(1, menu_show_count); // Unchanged.
592 EXPECT_EQ(0, listener.perform_action_index()); 606 EXPECT_EQ(0, listener.perform_action_index());
593 } 607 }
594 608
595 TEST_F(ComboboxTest, ConsumingPressKeyEvents) { 609 TEST_F(ComboboxTest, ConsumingPressKeyEvents) {
596 InitCombobox(NULL); 610 InitCombobox(NULL);
597 611
598 EXPECT_FALSE(combobox_->OnKeyPressed( 612 EXPECT_FALSE(combobox_->OnKeyPressed(
599 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE))); 613 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE)));
600 EXPECT_FALSE(combobox_->OnKeyPressed( 614 EXPECT_FALSE(combobox_->OnKeyPressed(
601 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_SPACE, ui::EF_NONE))); 615 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_SPACE, ui::EF_NONE)));
616 }
602 617
618 TEST_F(ComboboxTest, ConsumingPressKeyEventsActionStyle) {
619 InitCombobox(NULL, Combobox::STYLE_ACTION);
603 // When the combobox's style is STYLE_ACTION, pressing events of a space key 620 // When the combobox's style is STYLE_ACTION, pressing events of a space key
604 // or an enter key will be consumed. 621 // or an enter key will be consumed.
605 combobox_->SetStyle(Combobox::STYLE_ACTION);
606 EXPECT_TRUE(combobox_->OnKeyPressed( 622 EXPECT_TRUE(combobox_->OnKeyPressed(
607 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE))); 623 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_RETURN, ui::EF_NONE)));
608 EXPECT_TRUE(combobox_->OnKeyPressed( 624 EXPECT_TRUE(combobox_->OnKeyPressed(
609 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_SPACE, ui::EF_NONE))); 625 ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_SPACE, ui::EF_NONE)));
610 } 626 }
611 627
612 TEST_F(ComboboxTest, ContentWidth) { 628 TEST_F(ComboboxTest, ContentWidth) {
613 std::vector<std::string> values; 629 std::vector<std::string> values;
614 VectorComboboxModel model(&values); 630 VectorComboboxModel model(&values);
615 TestCombobox combobox(&model); 631 TestCombobox combobox(&model);
632 TestCombobox action_combobox(&model, Combobox::STYLE_ACTION);
616 ComboboxTestApi test_api(&combobox); 633 ComboboxTestApi test_api(&combobox);
634 ComboboxTestApi action_test_api(&action_combobox);
617 635
618 std::string long_item = "this is the long item"; 636 std::string long_item = "this is the long item";
619 std::string short_item = "s"; 637 std::string short_item = "s";
620 638
621 values.resize(1); 639 values.resize(1);
622 values[0] = long_item; 640 values[0] = long_item;
623 combobox.ModelChanged(); 641 combobox.ModelChanged();
642 action_combobox.ModelChanged();
624 643
625 const int long_item_width = test_api.content_size().width(); 644 const int long_item_width = test_api.content_size().width();
626 645
627 values[0] = short_item; 646 values[0] = short_item;
628 combobox.ModelChanged(); 647 combobox.ModelChanged();
648 action_combobox.ModelChanged();
629 649
630 const int short_item_width = test_api.content_size().width(); 650 const int short_item_width = test_api.content_size().width();
631 651
632 values.resize(2); 652 values.resize(2);
633 values[0] = short_item; 653 values[0] = short_item;
634 values[1] = long_item; 654 values[1] = long_item;
635 combobox.ModelChanged(); 655 combobox.ModelChanged();
656 action_combobox.ModelChanged();
636 657
637 // When the style is STYLE_NORMAL, the width will fit with the longest item. 658 // When the style is STYLE_NORMAL, the width will fit with the longest item.
638 combobox.SetStyle(Combobox::STYLE_NORMAL);
639 EXPECT_EQ(long_item_width, test_api.content_size().width()); 659 EXPECT_EQ(long_item_width, test_api.content_size().width());
640 660
641 // When the style is STYLE_ACTION, the width will fit with the selected item's 661 // When the style is STYLE_ACTION, the width will fit with the selected item's
642 // width. 662 // width.
643 combobox.SetStyle(Combobox::STYLE_ACTION); 663 EXPECT_EQ(short_item_width, action_test_api.content_size().width());
644 EXPECT_EQ(short_item_width, test_api.content_size().width());
645 } 664 }
646 665
647 // Test that model updates preserve the selected index, so long as it is in 666 // Test that model updates preserve the selected index, so long as it is in
648 // range. 667 // range.
649 TEST_F(ComboboxTest, ModelChanged) { 668 TEST_F(ComboboxTest, ModelChanged) {
650 InitCombobox(nullptr); 669 InitCombobox(nullptr);
651 670
652 EXPECT_EQ(0, combobox_->GetSelectedRow()); 671 EXPECT_EQ(0, combobox_->GetSelectedRow());
653 EXPECT_EQ(10, combobox_->GetRowCount()); 672 EXPECT_EQ(10, combobox_->GetRowCount());
654 673
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 EXPECT_FALSE(menu_model->IsItemCheckedAt(0)); 770 EXPECT_FALSE(menu_model->IsItemCheckedAt(0));
752 EXPECT_TRUE(menu_model->IsItemCheckedAt(1)); 771 EXPECT_TRUE(menu_model->IsItemCheckedAt(1));
753 #else 772 #else
754 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(0)); 773 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(0));
755 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(1)); 774 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(1));
756 #endif 775 #endif
757 776
758 EXPECT_EQ(ASCIIToUTF16("PEANUT BUTTER"), menu_model->GetLabelAt(0)); 777 EXPECT_EQ(ASCIIToUTF16("PEANUT BUTTER"), menu_model->GetLabelAt(0));
759 EXPECT_EQ(ASCIIToUTF16("JELLY"), menu_model->GetLabelAt(1)); 778 EXPECT_EQ(ASCIIToUTF16("JELLY"), menu_model->GetLabelAt(1));
760 779
761 // Check that with STYLE_ACTION, the first item (only) is not shown. 780 // Check that with STYLE_ACTION, the first item (only) is not shown.
tapted 2016/04/26 05:05:58 this comment should move be above the next test ca
Elly Fong-Jones 2016/04/26 17:41:26 Done.
762 EXPECT_TRUE(menu_model->IsVisibleAt(0)); 781 EXPECT_TRUE(menu_model->IsVisibleAt(0));
763 combobox_->SetStyle(Combobox::STYLE_ACTION); 782 }
783
784 TEST_F(ComboboxTest, MenuModelActionStyle) {
785 const int kSeparatorIndex = 3;
786 std::set<int> separators;
787 separators.insert(kSeparatorIndex);
788 InitCombobox(&separators, Combobox::STYLE_ACTION);
789
790 ui::MenuModel* menu_model = test_api_->menu_model();
791
792 EXPECT_EQ(TestComboboxModel::kItemCount, menu_model->GetItemCount());
793 EXPECT_EQ(ui::MenuModel::TYPE_SEPARATOR,
794 menu_model->GetTypeAt(kSeparatorIndex));
795
796 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(0));
797 EXPECT_EQ(ui::MenuModel::TYPE_COMMAND, menu_model->GetTypeAt(1));
798
799 EXPECT_EQ(ASCIIToUTF16("PEANUT BUTTER"), menu_model->GetLabelAt(0));
800 EXPECT_EQ(ASCIIToUTF16("JELLY"), menu_model->GetLabelAt(1));
801
764 EXPECT_FALSE(menu_model->IsVisibleAt(0)); 802 EXPECT_FALSE(menu_model->IsVisibleAt(0));
765 EXPECT_TRUE(menu_model->IsVisibleAt(1)); 803 EXPECT_TRUE(menu_model->IsVisibleAt(1));
766 } 804 }
767 805
768 } // namespace views 806 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698