OLD | NEW |
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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 DISALLOW_COPY_AND_ASSIGN(FocusManagerTest); | 255 DISALLOW_COPY_AND_ASSIGN(FocusManagerTest); |
256 }; | 256 }; |
257 | 257 |
258 // BorderView is a view containing a native window with its own view hierarchy. | 258 // BorderView is a view containing a native window with its own view hierarchy. |
259 // It is interesting to test focus traversal from a view hierarchy to an inner | 259 // It is interesting to test focus traversal from a view hierarchy to an inner |
260 // view hierarchy. | 260 // view hierarchy. |
261 class BorderView : public NativeViewHost { | 261 class BorderView : public NativeViewHost { |
262 public: | 262 public: |
263 explicit BorderView(View* child) : child_(child), widget_(NULL) { | 263 explicit BorderView(View* child) : child_(child), widget_(NULL) { |
264 DCHECK(child); | 264 DCHECK(child); |
265 SetFocusable(false); | 265 set_focusable(false); |
266 } | 266 } |
267 | 267 |
268 virtual ~BorderView() {} | 268 virtual ~BorderView() {} |
269 | 269 |
270 virtual internal::RootView* GetContentsRootView() { | 270 virtual internal::RootView* GetContentsRootView() { |
271 return static_cast<internal::RootView*>(widget_->GetRootView()); | 271 return static_cast<internal::RootView*>(widget_->GetRootView()); |
272 } | 272 } |
273 | 273 |
274 virtual FocusTraversable* GetFocusTraversable() { | 274 virtual FocusTraversable* GetFocusTraversable() { |
275 return static_cast<internal::RootView*>(widget_->GetRootView()); | 275 return static_cast<internal::RootView*>(widget_->GetRootView()); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 // NativeButton * kThumbnailStarID | 458 // NativeButton * kThumbnailStarID |
459 // NativeButton * kThumbnailSuperStarID | 459 // NativeButton * kThumbnailSuperStarID |
460 | 460 |
461 content_view_->set_background( | 461 content_view_->set_background( |
462 Background::CreateSolidBackground(SK_ColorWHITE)); | 462 Background::CreateSolidBackground(SK_ColorWHITE)); |
463 | 463 |
464 Checkbox* cb = new Checkbox(L"This is a checkbox"); | 464 Checkbox* cb = new Checkbox(L"This is a checkbox"); |
465 content_view_->AddChildView(cb); | 465 content_view_->AddChildView(cb); |
466 // In this fast paced world, who really has time for non hard-coded layout? | 466 // In this fast paced world, who really has time for non hard-coded layout? |
467 cb->SetBounds(10, 10, 200, 20); | 467 cb->SetBounds(10, 10, 200, 20); |
468 cb->SetID(kTopCheckBoxID); | 468 cb->set_id(kTopCheckBoxID); |
469 | 469 |
470 left_container_ = new PaneView(); | 470 left_container_ = new PaneView(); |
471 left_container_->set_border(Border::CreateSolidBorder(1, SK_ColorBLACK)); | 471 left_container_->set_border(Border::CreateSolidBorder(1, SK_ColorBLACK)); |
472 left_container_->set_background( | 472 left_container_->set_background( |
473 Background::CreateSolidBackground(240, 240, 240)); | 473 Background::CreateSolidBackground(240, 240, 240)); |
474 left_container_->SetID(kLeftContainerID); | 474 left_container_->set_id(kLeftContainerID); |
475 content_view_->AddChildView(left_container_); | 475 content_view_->AddChildView(left_container_); |
476 left_container_->SetBounds(10, 35, 250, 200); | 476 left_container_->SetBounds(10, 35, 250, 200); |
477 | 477 |
478 int label_x = 5; | 478 int label_x = 5; |
479 int label_width = 50; | 479 int label_width = 50; |
480 int label_height = 15; | 480 int label_height = 15; |
481 int text_field_width = 150; | 481 int text_field_width = 150; |
482 int y = 10; | 482 int y = 10; |
483 int gap_between_labels = 10; | 483 int gap_between_labels = 10; |
484 | 484 |
485 Label* label = new Label(L"Apple:"); | 485 Label* label = new Label(L"Apple:"); |
486 label->SetID(kAppleLabelID); | 486 label->set_id(kAppleLabelID); |
487 left_container_->AddChildView(label); | 487 left_container_->AddChildView(label); |
488 label->SetBounds(label_x, y, label_width, label_height); | 488 label->SetBounds(label_x, y, label_width, label_height); |
489 | 489 |
490 Textfield* text_field = new Textfield(); | 490 Textfield* text_field = new Textfield(); |
491 text_field->SetID(kAppleTextfieldID); | 491 text_field->set_id(kAppleTextfieldID); |
492 left_container_->AddChildView(text_field); | 492 left_container_->AddChildView(text_field); |
493 text_field->SetBounds(label_x + label_width + 5, y, | 493 text_field->SetBounds(label_x + label_width + 5, y, |
494 text_field_width, label_height); | 494 text_field_width, label_height); |
495 | 495 |
496 y += label_height + gap_between_labels; | 496 y += label_height + gap_between_labels; |
497 | 497 |
498 label = new Label(L"Orange:"); | 498 label = new Label(L"Orange:"); |
499 label->SetID(kOrangeLabelID); | 499 label->set_id(kOrangeLabelID); |
500 left_container_->AddChildView(label); | 500 left_container_->AddChildView(label); |
501 label->SetBounds(label_x, y, label_width, label_height); | 501 label->SetBounds(label_x, y, label_width, label_height); |
502 | 502 |
503 text_field = new Textfield(); | 503 text_field = new Textfield(); |
504 text_field->SetID(kOrangeTextfieldID); | 504 text_field->set_id(kOrangeTextfieldID); |
505 left_container_->AddChildView(text_field); | 505 left_container_->AddChildView(text_field); |
506 text_field->SetBounds(label_x + label_width + 5, y, | 506 text_field->SetBounds(label_x + label_width + 5, y, |
507 text_field_width, label_height); | 507 text_field_width, label_height); |
508 | 508 |
509 y += label_height + gap_between_labels; | 509 y += label_height + gap_between_labels; |
510 | 510 |
511 label = new Label(L"Banana:"); | 511 label = new Label(L"Banana:"); |
512 label->SetID(kBananaLabelID); | 512 label->set_id(kBananaLabelID); |
513 left_container_->AddChildView(label); | 513 left_container_->AddChildView(label); |
514 label->SetBounds(label_x, y, label_width, label_height); | 514 label->SetBounds(label_x, y, label_width, label_height); |
515 | 515 |
516 text_field = new Textfield(); | 516 text_field = new Textfield(); |
517 text_field->SetID(kBananaTextfieldID); | 517 text_field->set_id(kBananaTextfieldID); |
518 left_container_->AddChildView(text_field); | 518 left_container_->AddChildView(text_field); |
519 text_field->SetBounds(label_x + label_width + 5, y, | 519 text_field->SetBounds(label_x + label_width + 5, y, |
520 text_field_width, label_height); | 520 text_field_width, label_height); |
521 | 521 |
522 y += label_height + gap_between_labels; | 522 y += label_height + gap_between_labels; |
523 | 523 |
524 label = new Label(L"Kiwi:"); | 524 label = new Label(L"Kiwi:"); |
525 label->SetID(kKiwiLabelID); | 525 label->set_id(kKiwiLabelID); |
526 left_container_->AddChildView(label); | 526 left_container_->AddChildView(label); |
527 label->SetBounds(label_x, y, label_width, label_height); | 527 label->SetBounds(label_x, y, label_width, label_height); |
528 | 528 |
529 text_field = new Textfield(); | 529 text_field = new Textfield(); |
530 text_field->SetID(kKiwiTextfieldID); | 530 text_field->set_id(kKiwiTextfieldID); |
531 left_container_->AddChildView(text_field); | 531 left_container_->AddChildView(text_field); |
532 text_field->SetBounds(label_x + label_width + 5, y, | 532 text_field->SetBounds(label_x + label_width + 5, y, |
533 text_field_width, label_height); | 533 text_field_width, label_height); |
534 | 534 |
535 y += label_height + gap_between_labels; | 535 y += label_height + gap_between_labels; |
536 | 536 |
537 NativeButton* button = new NativeButton(NULL, L"Click me"); | 537 NativeButton* button = new NativeButton(NULL, L"Click me"); |
538 button->SetBounds(label_x, y + 10, 80, 30); | 538 button->SetBounds(label_x, y + 10, 80, 30); |
539 button->SetID(kFruitButtonID); | 539 button->set_id(kFruitButtonID); |
540 left_container_->AddChildView(button); | 540 left_container_->AddChildView(button); |
541 y += 40; | 541 y += 40; |
542 | 542 |
543 cb = new Checkbox(L"This is another check box"); | 543 cb = new Checkbox(L"This is another check box"); |
544 cb->SetBounds(label_x + label_width + 5, y, 180, 20); | 544 cb->SetBounds(label_x + label_width + 5, y, 180, 20); |
545 cb->SetID(kFruitCheckBoxID); | 545 cb->set_id(kFruitCheckBoxID); |
546 left_container_->AddChildView(cb); | 546 left_container_->AddChildView(cb); |
547 y += 20; | 547 y += 20; |
548 | 548 |
549 Combobox* combobox = new Combobox(&combobox_model_); | 549 Combobox* combobox = new Combobox(&combobox_model_); |
550 combobox->SetBounds(label_x + label_width + 5, y, 150, 30); | 550 combobox->SetBounds(label_x + label_width + 5, y, 150, 30); |
551 combobox->SetID(kComboboxID); | 551 combobox->set_id(kComboboxID); |
552 left_container_->AddChildView(combobox); | 552 left_container_->AddChildView(combobox); |
553 | 553 |
554 right_container_ = new PaneView(); | 554 right_container_ = new PaneView(); |
555 right_container_->set_border(Border::CreateSolidBorder(1, SK_ColorBLACK)); | 555 right_container_->set_border(Border::CreateSolidBorder(1, SK_ColorBLACK)); |
556 right_container_->set_background( | 556 right_container_->set_background( |
557 Background::CreateSolidBackground(240, 240, 240)); | 557 Background::CreateSolidBackground(240, 240, 240)); |
558 right_container_->SetID(kRightContainerID); | 558 right_container_->set_id(kRightContainerID); |
559 content_view_->AddChildView(right_container_); | 559 content_view_->AddChildView(right_container_); |
560 right_container_->SetBounds(270, 35, 300, 200); | 560 right_container_->SetBounds(270, 35, 300, 200); |
561 | 561 |
562 y = 10; | 562 y = 10; |
563 int radio_button_height = 18; | 563 int radio_button_height = 18; |
564 int gap_between_radio_buttons = 10; | 564 int gap_between_radio_buttons = 10; |
565 RadioButton* radio_button = new RadioButton(L"Asparagus", 1); | 565 RadioButton* radio_button = new RadioButton(L"Asparagus", 1); |
566 radio_button->SetID(kAsparagusButtonID); | 566 radio_button->set_id(kAsparagusButtonID); |
567 right_container_->AddChildView(radio_button); | 567 right_container_->AddChildView(radio_button); |
568 radio_button->SetBounds(5, y, 70, radio_button_height); | 568 radio_button->SetBounds(5, y, 70, radio_button_height); |
569 radio_button->SetGroup(1); | 569 radio_button->set_group(1); |
570 y += radio_button_height + gap_between_radio_buttons; | 570 y += radio_button_height + gap_between_radio_buttons; |
571 radio_button = new RadioButton(L"Broccoli", 1); | 571 radio_button = new RadioButton(L"Broccoli", 1); |
572 radio_button->SetID(kBroccoliButtonID); | 572 radio_button->set_id(kBroccoliButtonID); |
573 right_container_->AddChildView(radio_button); | 573 right_container_->AddChildView(radio_button); |
574 radio_button->SetBounds(5, y, 70, radio_button_height); | 574 radio_button->SetBounds(5, y, 70, radio_button_height); |
575 radio_button->SetGroup(1); | 575 radio_button->set_group(1); |
576 RadioButton* radio_button_to_check = radio_button; | 576 RadioButton* radio_button_to_check = radio_button; |
577 y += radio_button_height + gap_between_radio_buttons; | 577 y += radio_button_height + gap_between_radio_buttons; |
578 radio_button = new RadioButton(L"Cauliflower", 1); | 578 radio_button = new RadioButton(L"Cauliflower", 1); |
579 radio_button->SetID(kCauliflowerButtonID); | 579 radio_button->set_id(kCauliflowerButtonID); |
580 right_container_->AddChildView(radio_button); | 580 right_container_->AddChildView(radio_button); |
581 radio_button->SetBounds(5, y, 70, radio_button_height); | 581 radio_button->SetBounds(5, y, 70, radio_button_height); |
582 radio_button->SetGroup(1); | 582 radio_button->set_group(1); |
583 y += radio_button_height + gap_between_radio_buttons; | 583 y += radio_button_height + gap_between_radio_buttons; |
584 | 584 |
585 View* inner_container = new View(); | 585 View* inner_container = new View(); |
586 inner_container->set_border(Border::CreateSolidBorder(1, SK_ColorBLACK)); | 586 inner_container->set_border(Border::CreateSolidBorder(1, SK_ColorBLACK)); |
587 inner_container->set_background( | 587 inner_container->set_background( |
588 Background::CreateSolidBackground(230, 230, 230)); | 588 Background::CreateSolidBackground(230, 230, 230)); |
589 inner_container->SetID(kInnerContainerID); | 589 inner_container->set_id(kInnerContainerID); |
590 right_container_->AddChildView(inner_container); | 590 right_container_->AddChildView(inner_container); |
591 inner_container->SetBounds(100, 10, 150, 180); | 591 inner_container->SetBounds(100, 10, 150, 180); |
592 | 592 |
593 ScrollView* scroll_view = new ScrollView(); | 593 ScrollView* scroll_view = new ScrollView(); |
594 scroll_view->SetID(kScrollViewID); | 594 scroll_view->set_id(kScrollViewID); |
595 inner_container->AddChildView(scroll_view); | 595 inner_container->AddChildView(scroll_view); |
596 scroll_view->SetBounds(1, 1, 148, 178); | 596 scroll_view->SetBounds(1, 1, 148, 178); |
597 | 597 |
598 View* scroll_content = new View(); | 598 View* scroll_content = new View(); |
599 scroll_content->SetBounds(0, 0, 200, 200); | 599 scroll_content->SetBounds(0, 0, 200, 200); |
600 scroll_content->set_background( | 600 scroll_content->set_background( |
601 Background::CreateSolidBackground(200, 200, 200)); | 601 Background::CreateSolidBackground(200, 200, 200)); |
602 scroll_view->SetContents(scroll_content); | 602 scroll_view->SetContents(scroll_content); |
603 | 603 |
604 static const wchar_t* const kTitles[] = { | 604 static const wchar_t* const kTitles[] = { |
605 L"Rosetta", L"Stupeur et tremblement", L"The diner game", | 605 L"Rosetta", L"Stupeur et tremblement", L"The diner game", |
606 L"Ridicule", L"Le placard", L"Les Visiteurs", L"Amelie", | 606 L"Ridicule", L"Le placard", L"Les Visiteurs", L"Amelie", |
607 L"Joyeux Noel", L"Camping", L"Brice de Nice", | 607 L"Joyeux Noel", L"Camping", L"Brice de Nice", |
608 L"Taxi", L"Asterix" | 608 L"Taxi", L"Asterix" |
609 }; | 609 }; |
610 | 610 |
611 static const int kIDs[] = { | 611 static const int kIDs[] = { |
612 kRosettaLinkID, kStupeurEtTremblementLinkID, kDinerGameLinkID, | 612 kRosettaLinkID, kStupeurEtTremblementLinkID, kDinerGameLinkID, |
613 kRidiculeLinkID, kClosetLinkID, kVisitingLinkID, kAmelieLinkID, | 613 kRidiculeLinkID, kClosetLinkID, kVisitingLinkID, kAmelieLinkID, |
614 kJoyeuxNoelLinkID, kCampingLinkID, kBriceDeNiceLinkID, | 614 kJoyeuxNoelLinkID, kCampingLinkID, kBriceDeNiceLinkID, |
615 kTaxiLinkID, kAsterixLinkID | 615 kTaxiLinkID, kAsterixLinkID |
616 }; | 616 }; |
617 | 617 |
618 DCHECK(arraysize(kTitles) == arraysize(kIDs)); | 618 DCHECK(arraysize(kTitles) == arraysize(kIDs)); |
619 | 619 |
620 y = 5; | 620 y = 5; |
621 for (size_t i = 0; i < arraysize(kTitles); ++i) { | 621 for (size_t i = 0; i < arraysize(kTitles); ++i) { |
622 Link* link = new Link(kTitles[i]); | 622 Link* link = new Link(kTitles[i]); |
623 link->SetHorizontalAlignment(Label::ALIGN_LEFT); | 623 link->SetHorizontalAlignment(Label::ALIGN_LEFT); |
624 link->SetID(kIDs[i]); | 624 link->set_id(kIDs[i]); |
625 scroll_content->AddChildView(link); | 625 scroll_content->AddChildView(link); |
626 link->SetBounds(5, y, 300, 15); | 626 link->SetBounds(5, y, 300, 15); |
627 y += 15; | 627 y += 15; |
628 } | 628 } |
629 | 629 |
630 y = 250; | 630 y = 250; |
631 int width = 60; | 631 int width = 60; |
632 button = new NativeButton(NULL, L"OK"); | 632 button = new NativeButton(NULL, L"OK"); |
633 button->SetID(kOKButtonID); | 633 button->set_id(kOKButtonID); |
634 button->SetIsDefault(true); | 634 button->SetIsDefault(true); |
635 | 635 |
636 content_view_->AddChildView(button); | 636 content_view_->AddChildView(button); |
637 button->SetBounds(150, y, width, 30); | 637 button->SetBounds(150, y, width, 30); |
638 | 638 |
639 button = new NativeButton(NULL, L"Cancel"); | 639 button = new NativeButton(NULL, L"Cancel"); |
640 button->SetID(kCancelButtonID); | 640 button->set_id(kCancelButtonID); |
641 content_view_->AddChildView(button); | 641 content_view_->AddChildView(button); |
642 button->SetBounds(220, y, width, 30); | 642 button->SetBounds(220, y, width, 30); |
643 | 643 |
644 button = new NativeButton(NULL, L"Help"); | 644 button = new NativeButton(NULL, L"Help"); |
645 button->SetID(kHelpButtonID); | 645 button->set_id(kHelpButtonID); |
646 content_view_->AddChildView(button); | 646 content_view_->AddChildView(button); |
647 button->SetBounds(290, y, width, 30); | 647 button->SetBounds(290, y, width, 30); |
648 | 648 |
649 y += 40; | 649 y += 40; |
650 | 650 |
651 // Left bottom box with style checkboxes. | 651 // Left bottom box with style checkboxes. |
652 View* contents = new View(); | 652 View* contents = new View(); |
653 contents->set_background(Background::CreateSolidBackground(SK_ColorWHITE)); | 653 contents->set_background(Background::CreateSolidBackground(SK_ColorWHITE)); |
654 cb = new Checkbox(L"Bold"); | 654 cb = new Checkbox(L"Bold"); |
655 contents->AddChildView(cb); | 655 contents->AddChildView(cb); |
656 cb->SetBounds(10, 10, 50, 20); | 656 cb->SetBounds(10, 10, 50, 20); |
657 cb->SetID(kBoldCheckBoxID); | 657 cb->set_id(kBoldCheckBoxID); |
658 | 658 |
659 cb = new Checkbox(L"Italic"); | 659 cb = new Checkbox(L"Italic"); |
660 contents->AddChildView(cb); | 660 contents->AddChildView(cb); |
661 cb->SetBounds(70, 10, 50, 20); | 661 cb->SetBounds(70, 10, 50, 20); |
662 cb->SetID(kItalicCheckBoxID); | 662 cb->set_id(kItalicCheckBoxID); |
663 | 663 |
664 cb = new Checkbox(L"Underlined"); | 664 cb = new Checkbox(L"Underlined"); |
665 contents->AddChildView(cb); | 665 contents->AddChildView(cb); |
666 cb->SetBounds(130, 10, 70, 20); | 666 cb->SetBounds(130, 10, 70, 20); |
667 cb->SetID(kUnderlinedCheckBoxID); | 667 cb->set_id(kUnderlinedCheckBoxID); |
668 | 668 |
669 Link* link = new Link(L"Help"); | 669 Link* link = new Link(L"Help"); |
670 contents->AddChildView(link); | 670 contents->AddChildView(link); |
671 link->SetBounds(10, 35, 70, 10); | 671 link->SetBounds(10, 35, 70, 10); |
672 link->SetID(kStyleHelpLinkID); | 672 link->set_id(kStyleHelpLinkID); |
673 | 673 |
674 text_field = new Textfield(); | 674 text_field = new Textfield(); |
675 contents->AddChildView(text_field); | 675 contents->AddChildView(text_field); |
676 text_field->SetBounds(10, 50, 100, 20); | 676 text_field->SetBounds(10, 50, 100, 20); |
677 text_field->SetID(kStyleTextEditID); | 677 text_field->set_id(kStyleTextEditID); |
678 | 678 |
679 style_tab_ = new TabbedPane(); | 679 style_tab_ = new TabbedPane(); |
680 style_tab_->SetID(kStyleContainerID); | 680 style_tab_->set_id(kStyleContainerID); |
681 content_view_->AddChildView(style_tab_); | 681 content_view_->AddChildView(style_tab_); |
682 style_tab_->SetBounds(10, y, 210, 100); | 682 style_tab_->SetBounds(10, y, 210, 100); |
683 style_tab_->AddTab(L"Style", contents); | 683 style_tab_->AddTab(L"Style", contents); |
684 style_tab_->AddTab(L"Other", new View()); | 684 style_tab_->AddTab(L"Other", new View()); |
685 | 685 |
686 // Right bottom box with search. | 686 // Right bottom box with search. |
687 contents = new View(); | 687 contents = new View(); |
688 contents->set_background(Background::CreateSolidBackground(SK_ColorWHITE)); | 688 contents->set_background(Background::CreateSolidBackground(SK_ColorWHITE)); |
689 text_field = new Textfield(); | 689 text_field = new Textfield(); |
690 contents->AddChildView(text_field); | 690 contents->AddChildView(text_field); |
691 text_field->SetBounds(10, 10, 100, 20); | 691 text_field->SetBounds(10, 10, 100, 20); |
692 text_field->SetID(kSearchTextfieldID); | 692 text_field->set_id(kSearchTextfieldID); |
693 | 693 |
694 button = new NativeButton(NULL, L"Search"); | 694 button = new NativeButton(NULL, L"Search"); |
695 contents->AddChildView(button); | 695 contents->AddChildView(button); |
696 button->SetBounds(112, 5, 60, 30); | 696 button->SetBounds(112, 5, 60, 30); |
697 button->SetID(kSearchButtonID); | 697 button->set_id(kSearchButtonID); |
698 | 698 |
699 link = new Link(L"Help"); | 699 link = new Link(L"Help"); |
700 link->SetHorizontalAlignment(Label::ALIGN_LEFT); | 700 link->SetHorizontalAlignment(Label::ALIGN_LEFT); |
701 link->SetID(kHelpLinkID); | 701 link->set_id(kHelpLinkID); |
702 contents->AddChildView(link); | 702 contents->AddChildView(link); |
703 link->SetBounds(175, 10, 30, 20); | 703 link->SetBounds(175, 10, 30, 20); |
704 | 704 |
705 search_border_view_ = new BorderView(contents); | 705 search_border_view_ = new BorderView(contents); |
706 search_border_view_->SetID(kSearchContainerID); | 706 search_border_view_->set_id(kSearchContainerID); |
707 | 707 |
708 content_view_->AddChildView(search_border_view_); | 708 content_view_->AddChildView(search_border_view_); |
709 search_border_view_->SetBounds(300, y, 240, 50); | 709 search_border_view_->SetBounds(300, y, 240, 50); |
710 | 710 |
711 y += 60; | 711 y += 60; |
712 | 712 |
713 contents = new View(); | 713 contents = new View(); |
714 contents->SetFocusable(true); | 714 contents->set_focusable(true); |
715 contents->set_background(Background::CreateSolidBackground(SK_ColorBLUE)); | 715 contents->set_background(Background::CreateSolidBackground(SK_ColorBLUE)); |
716 contents->SetID(kThumbnailContainerID); | 716 contents->set_id(kThumbnailContainerID); |
717 button = new NativeButton(NULL, L"Star"); | 717 button = new NativeButton(NULL, L"Star"); |
718 contents->AddChildView(button); | 718 contents->AddChildView(button); |
719 button->SetBounds(5, 5, 50, 30); | 719 button->SetBounds(5, 5, 50, 30); |
720 button->SetID(kThumbnailStarID); | 720 button->set_id(kThumbnailStarID); |
721 button = new NativeButton(NULL, L"SuperStar"); | 721 button = new NativeButton(NULL, L"SuperStar"); |
722 contents->AddChildView(button); | 722 contents->AddChildView(button); |
723 button->SetBounds(60, 5, 100, 30); | 723 button->SetBounds(60, 5, 100, 30); |
724 button->SetID(kThumbnailSuperStarID); | 724 button->set_id(kThumbnailSuperStarID); |
725 | 725 |
726 content_view_->AddChildView(contents); | 726 content_view_->AddChildView(contents); |
727 contents->SetBounds(250, y, 200, 50); | 727 contents->SetBounds(250, y, 200, 50); |
728 // We can only call RadioButton::SetChecked() on the radio-button is part of | 728 // We can only call RadioButton::SetChecked() on the radio-button is part of |
729 // the view hierarchy. | 729 // the view hierarchy. |
730 radio_button_to_check->SetChecked(true); | 730 radio_button_to_check->SetChecked(true); |
731 } | 731 } |
732 | 732 |
733 //////////////////////////////////////////////////////////////////////////////// | 733 //////////////////////////////////////////////////////////////////////////////// |
734 // The tests | 734 // The tests |
(...skipping 11 matching lines...) Expand all Loading... |
746 } | 746 } |
747 | 747 |
748 FocusTestEventType type; | 748 FocusTestEventType type; |
749 int view_id; | 749 int view_id; |
750 }; | 750 }; |
751 | 751 |
752 class SimpleTestView : public View { | 752 class SimpleTestView : public View { |
753 public: | 753 public: |
754 SimpleTestView(std::vector<FocusTestEvent>* event_list, int view_id) | 754 SimpleTestView(std::vector<FocusTestEvent>* event_list, int view_id) |
755 : event_list_(event_list) { | 755 : event_list_(event_list) { |
756 SetFocusable(true); | 756 set_focusable(true); |
757 SetID(view_id); | 757 set_id(view_id); |
758 } | 758 } |
759 | 759 |
760 virtual void OnFocus() { | 760 virtual void OnFocus() { |
761 event_list_->push_back(FocusTestEvent(ON_FOCUS, GetID())); | 761 event_list_->push_back(FocusTestEvent(ON_FOCUS, id())); |
762 } | 762 } |
763 | 763 |
764 virtual void OnBlur() { | 764 virtual void OnBlur() { |
765 event_list_->push_back(FocusTestEvent(ON_BLUR, GetID())); | 765 event_list_->push_back(FocusTestEvent(ON_BLUR, id())); |
766 } | 766 } |
767 | 767 |
768 private: | 768 private: |
769 std::vector<FocusTestEvent>* event_list_; | 769 std::vector<FocusTestEvent>* event_list_; |
770 }; | 770 }; |
771 | 771 |
772 // Tests that the appropriate Focus related methods are called when a View | 772 // Tests that the appropriate Focus related methods are called when a View |
773 // gets/loses focus. | 773 // gets/loses focus. |
774 TEST_F(FocusManagerTest, ViewFocusCallbacks) { | 774 TEST_F(FocusManagerTest, ViewFocusCallbacks) { |
775 std::vector<FocusTestEvent> event_list; | 775 std::vector<FocusTestEvent> event_list; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 const std::vector<ViewPair>& focus_changes() const { return focus_changes_; } | 811 const std::vector<ViewPair>& focus_changes() const { return focus_changes_; } |
812 void ClearFocusChanges() { focus_changes_.clear(); } | 812 void ClearFocusChanges() { focus_changes_.clear(); } |
813 | 813 |
814 private: | 814 private: |
815 // A vector of which views lost/gained focus. | 815 // A vector of which views lost/gained focus. |
816 std::vector<ViewPair> focus_changes_; | 816 std::vector<ViewPair> focus_changes_; |
817 }; | 817 }; |
818 | 818 |
819 TEST_F(FocusManagerTest, FocusChangeListener) { | 819 TEST_F(FocusManagerTest, FocusChangeListener) { |
820 View* view1 = new View(); | 820 View* view1 = new View(); |
821 view1->SetFocusable(true); | 821 view1->set_focusable(true); |
822 View* view2 = new View(); | 822 View* view2 = new View(); |
823 view2->SetFocusable(true); | 823 view2->set_focusable(true); |
824 content_view_->AddChildView(view1); | 824 content_view_->AddChildView(view1); |
825 content_view_->AddChildView(view2); | 825 content_view_->AddChildView(view2); |
826 | 826 |
827 TestFocusChangeListener listener; | 827 TestFocusChangeListener listener; |
828 AddFocusChangeListener(&listener); | 828 AddFocusChangeListener(&listener); |
829 | 829 |
830 // Visual Studio 2010 has problems converting NULL to the null pointer for | 830 // Visual Studio 2010 has problems converting NULL to the null pointer for |
831 // std::pair. See http://connect.microsoft.com/VisualStudio/feedback/details/
520043/error-converting-from-null-to-a-pointer-type-in-std-pair | 831 // std::pair. See http://connect.microsoft.com/VisualStudio/feedback/details/
520043/error-converting-from-null-to-a-pointer-type-in-std-pair |
832 // It will work if we pass nullptr. | 832 // It will work if we pass nullptr. |
833 #if defined(_MSC_VER) && _MSC_VER >= 1600 | 833 #if defined(_MSC_VER) && _MSC_VER >= 1600 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 #if defined(OS_WIN) | 961 #if defined(OS_WIN) |
962 | 962 |
963 // Test that when activating/deactivating the top window, the focus is stored/ | 963 // Test that when activating/deactivating the top window, the focus is stored/ |
964 // restored properly. | 964 // restored properly. |
965 TEST_F(FocusManagerTest, FocusStoreRestore) { | 965 TEST_F(FocusManagerTest, FocusStoreRestore) { |
966 // Simulate an activate, otherwise the deactivate isn't going to do anything. | 966 // Simulate an activate, otherwise the deactivate isn't going to do anything. |
967 SimulateActivateWindow(); | 967 SimulateActivateWindow(); |
968 | 968 |
969 NativeButton* button = new NativeButton(NULL, L"Press me"); | 969 NativeButton* button = new NativeButton(NULL, L"Press me"); |
970 View* view = new View(); | 970 View* view = new View(); |
971 view->SetFocusable(true); | 971 view->set_focusable(true); |
972 | 972 |
973 content_view_->AddChildView(button); | 973 content_view_->AddChildView(button); |
974 button->SetBounds(10, 10, 200, 30); | 974 button->SetBounds(10, 10, 200, 30); |
975 content_view_->AddChildView(view); | 975 content_view_->AddChildView(view); |
976 message_loop()->RunAllPending(); | 976 message_loop()->RunAllPending(); |
977 | 977 |
978 TestFocusChangeListener listener; | 978 TestFocusChangeListener listener; |
979 AddFocusChangeListener(&listener); | 979 AddFocusChangeListener(&listener); |
980 | 980 |
981 view->RequestFocus(); | 981 view->RequestFocus(); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 | 1078 |
1079 // Let's traverse the whole focus hierarchy (several times, to make sure it | 1079 // Let's traverse the whole focus hierarchy (several times, to make sure it |
1080 // loops OK). | 1080 // loops OK). |
1081 GetFocusManager()->ClearFocus(); | 1081 GetFocusManager()->ClearFocus(); |
1082 for (int i = 0; i < 3; ++i) { | 1082 for (int i = 0; i < 3; ++i) { |
1083 for (size_t j = 0; j < arraysize(kTraversalIDs); j++) { | 1083 for (size_t j = 0; j < arraysize(kTraversalIDs); j++) { |
1084 GetFocusManager()->AdvanceFocus(false); | 1084 GetFocusManager()->AdvanceFocus(false); |
1085 View* focused_view = GetFocusManager()->GetFocusedView(); | 1085 View* focused_view = GetFocusManager()->GetFocusedView(); |
1086 EXPECT_TRUE(focused_view != NULL); | 1086 EXPECT_TRUE(focused_view != NULL); |
1087 if (focused_view) | 1087 if (focused_view) |
1088 EXPECT_EQ(kTraversalIDs[j], focused_view->GetID()); | 1088 EXPECT_EQ(kTraversalIDs[j], focused_view->id()); |
1089 } | 1089 } |
1090 } | 1090 } |
1091 | 1091 |
1092 // Let's traverse in reverse order. | 1092 // Let's traverse in reverse order. |
1093 GetFocusManager()->ClearFocus(); | 1093 GetFocusManager()->ClearFocus(); |
1094 for (int i = 0; i < 3; ++i) { | 1094 for (int i = 0; i < 3; ++i) { |
1095 for (int j = arraysize(kTraversalIDs) - 1; j >= 0; --j) { | 1095 for (int j = arraysize(kTraversalIDs) - 1; j >= 0; --j) { |
1096 GetFocusManager()->AdvanceFocus(true); | 1096 GetFocusManager()->AdvanceFocus(true); |
1097 View* focused_view = GetFocusManager()->GetFocusedView(); | 1097 View* focused_view = GetFocusManager()->GetFocusedView(); |
1098 EXPECT_TRUE(focused_view != NULL); | 1098 EXPECT_TRUE(focused_view != NULL); |
1099 if (focused_view) | 1099 if (focused_view) |
1100 EXPECT_EQ(kTraversalIDs[j], focused_view->GetID()); | 1100 EXPECT_EQ(kTraversalIDs[j], focused_view->id()); |
1101 } | 1101 } |
1102 } | 1102 } |
1103 } | 1103 } |
1104 | 1104 |
1105 TEST_F(FocusTraversalTest, TraversalWithNonEnabledViews) { | 1105 TEST_F(FocusTraversalTest, TraversalWithNonEnabledViews) { |
1106 const int kDisabledIDs[] = { | 1106 const int kDisabledIDs[] = { |
1107 kBananaTextfieldID, kFruitCheckBoxID, kComboboxID, kAsparagusButtonID, | 1107 kBananaTextfieldID, kFruitCheckBoxID, kComboboxID, kAsparagusButtonID, |
1108 kCauliflowerButtonID, kClosetLinkID, kVisitingLinkID, kBriceDeNiceLinkID, | 1108 kCauliflowerButtonID, kClosetLinkID, kVisitingLinkID, kBriceDeNiceLinkID, |
1109 kTaxiLinkID, kAsterixLinkID, kHelpButtonID, kBoldCheckBoxID, | 1109 kTaxiLinkID, kAsterixLinkID, kHelpButtonID, kBoldCheckBoxID, |
1110 kSearchTextfieldID, kHelpLinkID }; | 1110 kSearchTextfieldID, kHelpLinkID }; |
(...skipping 20 matching lines...) Expand all Loading... |
1131 | 1131 |
1132 View* focused_view; | 1132 View* focused_view; |
1133 // Let's do one traversal (several times, to make sure it loops ok). | 1133 // Let's do one traversal (several times, to make sure it loops ok). |
1134 GetFocusManager()->ClearFocus(); | 1134 GetFocusManager()->ClearFocus(); |
1135 for (int i = 0; i < 3; ++i) { | 1135 for (int i = 0; i < 3; ++i) { |
1136 for (size_t j = 0; j < arraysize(kTraversalIDs); j++) { | 1136 for (size_t j = 0; j < arraysize(kTraversalIDs); j++) { |
1137 GetFocusManager()->AdvanceFocus(false); | 1137 GetFocusManager()->AdvanceFocus(false); |
1138 focused_view = GetFocusManager()->GetFocusedView(); | 1138 focused_view = GetFocusManager()->GetFocusedView(); |
1139 EXPECT_TRUE(focused_view != NULL); | 1139 EXPECT_TRUE(focused_view != NULL); |
1140 if (focused_view) | 1140 if (focused_view) |
1141 EXPECT_EQ(kTraversalIDs[j], focused_view->GetID()); | 1141 EXPECT_EQ(kTraversalIDs[j], focused_view->id()); |
1142 } | 1142 } |
1143 } | 1143 } |
1144 | 1144 |
1145 // Same thing in reverse. | 1145 // Same thing in reverse. |
1146 GetFocusManager()->ClearFocus(); | 1146 GetFocusManager()->ClearFocus(); |
1147 for (int i = 0; i < 3; ++i) { | 1147 for (int i = 0; i < 3; ++i) { |
1148 for (int j = arraysize(kTraversalIDs) - 1; j >= 0; --j) { | 1148 for (int j = arraysize(kTraversalIDs) - 1; j >= 0; --j) { |
1149 GetFocusManager()->AdvanceFocus(true); | 1149 GetFocusManager()->AdvanceFocus(true); |
1150 focused_view = GetFocusManager()->GetFocusedView(); | 1150 focused_view = GetFocusManager()->GetFocusedView(); |
1151 EXPECT_TRUE(focused_view != NULL); | 1151 EXPECT_TRUE(focused_view != NULL); |
1152 if (focused_view) | 1152 if (focused_view) |
1153 EXPECT_EQ(kTraversalIDs[j], focused_view->GetID()); | 1153 EXPECT_EQ(kTraversalIDs[j], focused_view->id()); |
1154 } | 1154 } |
1155 } | 1155 } |
1156 } | 1156 } |
1157 | 1157 |
1158 TEST_F(FocusTraversalTest, TraversalWithInvisibleViews) { | 1158 TEST_F(FocusTraversalTest, TraversalWithInvisibleViews) { |
1159 const int kInvisibleIDs[] = { kTopCheckBoxID, kOKButtonID, | 1159 const int kInvisibleIDs[] = { kTopCheckBoxID, kOKButtonID, |
1160 kThumbnailContainerID }; | 1160 kThumbnailContainerID }; |
1161 | 1161 |
1162 const int kTraversalIDs[] = { kAppleTextfieldID, kOrangeTextfieldID, | 1162 const int kTraversalIDs[] = { kAppleTextfieldID, kOrangeTextfieldID, |
1163 kBananaTextfieldID, kKiwiTextfieldID, kFruitButtonID, kFruitCheckBoxID, | 1163 kBananaTextfieldID, kKiwiTextfieldID, kFruitButtonID, kFruitCheckBoxID, |
(...skipping 19 matching lines...) Expand all Loading... |
1183 | 1183 |
1184 View* focused_view; | 1184 View* focused_view; |
1185 // Let's do one traversal (several times, to make sure it loops ok). | 1185 // Let's do one traversal (several times, to make sure it loops ok). |
1186 GetFocusManager()->ClearFocus(); | 1186 GetFocusManager()->ClearFocus(); |
1187 for (int i = 0; i < 3; ++i) { | 1187 for (int i = 0; i < 3; ++i) { |
1188 for (size_t j = 0; j < arraysize(kTraversalIDs); j++) { | 1188 for (size_t j = 0; j < arraysize(kTraversalIDs); j++) { |
1189 GetFocusManager()->AdvanceFocus(false); | 1189 GetFocusManager()->AdvanceFocus(false); |
1190 focused_view = GetFocusManager()->GetFocusedView(); | 1190 focused_view = GetFocusManager()->GetFocusedView(); |
1191 EXPECT_TRUE(focused_view != NULL); | 1191 EXPECT_TRUE(focused_view != NULL); |
1192 if (focused_view) | 1192 if (focused_view) |
1193 EXPECT_EQ(kTraversalIDs[j], focused_view->GetID()); | 1193 EXPECT_EQ(kTraversalIDs[j], focused_view->id()); |
1194 } | 1194 } |
1195 } | 1195 } |
1196 | 1196 |
1197 // Same thing in reverse. | 1197 // Same thing in reverse. |
1198 GetFocusManager()->ClearFocus(); | 1198 GetFocusManager()->ClearFocus(); |
1199 for (int i = 0; i < 3; ++i) { | 1199 for (int i = 0; i < 3; ++i) { |
1200 for (int j = arraysize(kTraversalIDs) - 1; j >= 0; --j) { | 1200 for (int j = arraysize(kTraversalIDs) - 1; j >= 0; --j) { |
1201 GetFocusManager()->AdvanceFocus(true); | 1201 GetFocusManager()->AdvanceFocus(true); |
1202 focused_view = GetFocusManager()->GetFocusedView(); | 1202 focused_view = GetFocusManager()->GetFocusedView(); |
1203 EXPECT_TRUE(focused_view != NULL); | 1203 EXPECT_TRUE(focused_view != NULL); |
1204 if (focused_view) | 1204 if (focused_view) |
1205 EXPECT_EQ(kTraversalIDs[j], focused_view->GetID()); | 1205 EXPECT_EQ(kTraversalIDs[j], focused_view->id()); |
1206 } | 1206 } |
1207 } | 1207 } |
1208 } | 1208 } |
1209 | 1209 |
1210 TEST_F(FocusTraversalTest, PaneTraversal) { | 1210 TEST_F(FocusTraversalTest, PaneTraversal) { |
1211 // Tests trapping the traversal within a pane - useful for full | 1211 // Tests trapping the traversal within a pane - useful for full |
1212 // keyboard accessibility for toolbars. | 1212 // keyboard accessibility for toolbars. |
1213 | 1213 |
1214 // First test the left container. | 1214 // First test the left container. |
1215 const int kLeftTraversalIDs[] = { | 1215 const int kLeftTraversalIDs[] = { |
1216 kAppleTextfieldID, | 1216 kAppleTextfieldID, |
1217 kOrangeTextfieldID, kBananaTextfieldID, kKiwiTextfieldID, | 1217 kOrangeTextfieldID, kBananaTextfieldID, kKiwiTextfieldID, |
1218 kFruitButtonID, kFruitCheckBoxID, kComboboxID }; | 1218 kFruitButtonID, kFruitCheckBoxID, kComboboxID }; |
1219 | 1219 |
1220 FocusSearch focus_search_left(left_container_, true, false); | 1220 FocusSearch focus_search_left(left_container_, true, false); |
1221 left_container_->EnablePaneFocus(&focus_search_left); | 1221 left_container_->EnablePaneFocus(&focus_search_left); |
1222 FindViewByID(kComboboxID)->RequestFocus(); | 1222 FindViewByID(kComboboxID)->RequestFocus(); |
1223 | 1223 |
1224 // Traverse the focus hierarchy within the pane several times. | 1224 // Traverse the focus hierarchy within the pane several times. |
1225 for (int i = 0; i < 3; ++i) { | 1225 for (int i = 0; i < 3; ++i) { |
1226 for (size_t j = 0; j < arraysize(kLeftTraversalIDs); j++) { | 1226 for (size_t j = 0; j < arraysize(kLeftTraversalIDs); j++) { |
1227 GetFocusManager()->AdvanceFocus(false); | 1227 GetFocusManager()->AdvanceFocus(false); |
1228 View* focused_view = GetFocusManager()->GetFocusedView(); | 1228 View* focused_view = GetFocusManager()->GetFocusedView(); |
1229 EXPECT_TRUE(focused_view != NULL); | 1229 EXPECT_TRUE(focused_view != NULL); |
1230 if (focused_view) | 1230 if (focused_view) |
1231 EXPECT_EQ(kLeftTraversalIDs[j], focused_view->GetID()); | 1231 EXPECT_EQ(kLeftTraversalIDs[j], focused_view->id()); |
1232 } | 1232 } |
1233 } | 1233 } |
1234 | 1234 |
1235 // Traverse in reverse order. | 1235 // Traverse in reverse order. |
1236 FindViewByID(kAppleTextfieldID)->RequestFocus(); | 1236 FindViewByID(kAppleTextfieldID)->RequestFocus(); |
1237 for (int i = 0; i < 3; ++i) { | 1237 for (int i = 0; i < 3; ++i) { |
1238 for (int j = arraysize(kLeftTraversalIDs) - 1; j >= 0; --j) { | 1238 for (int j = arraysize(kLeftTraversalIDs) - 1; j >= 0; --j) { |
1239 GetFocusManager()->AdvanceFocus(true); | 1239 GetFocusManager()->AdvanceFocus(true); |
1240 View* focused_view = GetFocusManager()->GetFocusedView(); | 1240 View* focused_view = GetFocusManager()->GetFocusedView(); |
1241 EXPECT_TRUE(focused_view != NULL); | 1241 EXPECT_TRUE(focused_view != NULL); |
1242 if (focused_view) | 1242 if (focused_view) |
1243 EXPECT_EQ(kLeftTraversalIDs[j], focused_view->GetID()); | 1243 EXPECT_EQ(kLeftTraversalIDs[j], focused_view->id()); |
1244 } | 1244 } |
1245 } | 1245 } |
1246 | 1246 |
1247 // Now test the right container, but this time with accessibility mode. | 1247 // Now test the right container, but this time with accessibility mode. |
1248 // Make some links not focusable, but mark one of them as | 1248 // Make some links not focusable, but mark one of them as |
1249 // "accessibility focusable", so it should show up in the traversal. | 1249 // "accessibility focusable", so it should show up in the traversal. |
1250 const int kRightTraversalIDs[] = { | 1250 const int kRightTraversalIDs[] = { |
1251 kBroccoliButtonID, kDinerGameLinkID, kRidiculeLinkID, | 1251 kBroccoliButtonID, kDinerGameLinkID, kRidiculeLinkID, |
1252 kClosetLinkID, kVisitingLinkID, kAmelieLinkID, kJoyeuxNoelLinkID, | 1252 kClosetLinkID, kVisitingLinkID, kAmelieLinkID, kJoyeuxNoelLinkID, |
1253 kCampingLinkID, kBriceDeNiceLinkID, kTaxiLinkID, kAsterixLinkID }; | 1253 kCampingLinkID, kBriceDeNiceLinkID, kTaxiLinkID, kAsterixLinkID }; |
1254 | 1254 |
1255 FocusSearch focus_search_right(right_container_, true, true); | 1255 FocusSearch focus_search_right(right_container_, true, true); |
1256 right_container_->EnablePaneFocus(&focus_search_right); | 1256 right_container_->EnablePaneFocus(&focus_search_right); |
1257 FindViewByID(kRosettaLinkID)->SetFocusable(false); | 1257 FindViewByID(kRosettaLinkID)->set_focusable(false); |
1258 FindViewByID(kStupeurEtTremblementLinkID)->SetFocusable(false); | 1258 FindViewByID(kStupeurEtTremblementLinkID)->set_focusable(false); |
1259 FindViewByID(kDinerGameLinkID)->set_accessibility_focusable(true); | 1259 FindViewByID(kDinerGameLinkID)->set_accessibility_focusable(true); |
1260 FindViewByID(kDinerGameLinkID)->SetFocusable(false); | 1260 FindViewByID(kDinerGameLinkID)->set_focusable(false); |
1261 FindViewByID(kAsterixLinkID)->RequestFocus(); | 1261 FindViewByID(kAsterixLinkID)->RequestFocus(); |
1262 | 1262 |
1263 // Traverse the focus hierarchy within the pane several times. | 1263 // Traverse the focus hierarchy within the pane several times. |
1264 for (int i = 0; i < 3; ++i) { | 1264 for (int i = 0; i < 3; ++i) { |
1265 for (size_t j = 0; j < arraysize(kRightTraversalIDs); j++) { | 1265 for (size_t j = 0; j < arraysize(kRightTraversalIDs); j++) { |
1266 GetFocusManager()->AdvanceFocus(false); | 1266 GetFocusManager()->AdvanceFocus(false); |
1267 View* focused_view = GetFocusManager()->GetFocusedView(); | 1267 View* focused_view = GetFocusManager()->GetFocusedView(); |
1268 EXPECT_TRUE(focused_view != NULL); | 1268 EXPECT_TRUE(focused_view != NULL); |
1269 if (focused_view) | 1269 if (focused_view) |
1270 EXPECT_EQ(kRightTraversalIDs[j], focused_view->GetID()); | 1270 EXPECT_EQ(kRightTraversalIDs[j], focused_view->id()); |
1271 } | 1271 } |
1272 } | 1272 } |
1273 | 1273 |
1274 // Traverse in reverse order. | 1274 // Traverse in reverse order. |
1275 FindViewByID(kBroccoliButtonID)->RequestFocus(); | 1275 FindViewByID(kBroccoliButtonID)->RequestFocus(); |
1276 for (int i = 0; i < 3; ++i) { | 1276 for (int i = 0; i < 3; ++i) { |
1277 for (int j = arraysize(kRightTraversalIDs) - 1; j >= 0; --j) { | 1277 for (int j = arraysize(kRightTraversalIDs) - 1; j >= 0; --j) { |
1278 GetFocusManager()->AdvanceFocus(true); | 1278 GetFocusManager()->AdvanceFocus(true); |
1279 View* focused_view = GetFocusManager()->GetFocusedView(); | 1279 View* focused_view = GetFocusManager()->GetFocusedView(); |
1280 EXPECT_TRUE(focused_view != NULL); | 1280 EXPECT_TRUE(focused_view != NULL); |
1281 if (focused_view) | 1281 if (focused_view) |
1282 EXPECT_EQ(kRightTraversalIDs[j], focused_view->GetID()); | 1282 EXPECT_EQ(kRightTraversalIDs[j], focused_view->id()); |
1283 } | 1283 } |
1284 } | 1284 } |
1285 | 1285 |
1286 } | 1286 } |
1287 | 1287 |
1288 // Counts accelerator calls. | 1288 // Counts accelerator calls. |
1289 class TestAcceleratorTarget : public AcceleratorTarget { | 1289 class TestAcceleratorTarget : public AcceleratorTarget { |
1290 public: | 1290 public: |
1291 explicit TestAcceleratorTarget(bool process_accelerator) | 1291 explicit TestAcceleratorTarget(bool process_accelerator) |
1292 : accelerator_count_(0), process_accelerator_(process_accelerator) {} | 1292 : accelerator_count_(0), process_accelerator_(process_accelerator) {} |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1721 | 1721 |
1722 // Focus manager should be the last one to destruct. | 1722 // Focus manager should be the last one to destruct. |
1723 ASSERT_STREQ("FocusManagerDtorTracked", dtor_tracker_[2].c_str()); | 1723 ASSERT_STREQ("FocusManagerDtorTracked", dtor_tracker_[2].c_str()); |
1724 | 1724 |
1725 // Clear window_ so that we don't try to close it again. | 1725 // Clear window_ so that we don't try to close it again. |
1726 window_ = NULL; | 1726 window_ = NULL; |
1727 } | 1727 } |
1728 | 1728 |
1729 | 1729 |
1730 } // namespace views | 1730 } // namespace views |
OLD | NEW |