| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "chrome/browser/automation/ui_controls.h" | 6 #include "chrome/browser/automation/ui_controls.h" |
| 7 #include "chrome/browser/bookmarks/bookmark_model.h" | 7 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 8 #include "chrome/browser/page_navigator.h" | 8 #include "chrome/browser/page_navigator.h" |
| 9 #include "chrome/browser/profile.h" | 9 #include "chrome/browser/profile.h" |
| 10 #include "chrome/browser/views/bookmark_bar_view.h" | 10 #include "chrome/browser/views/bookmark_bar_view.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 private: | 236 private: |
| 237 void Step2() { | 237 void Step2() { |
| 238 // Menu should be showing. | 238 // Menu should be showing. |
| 239 ChromeViews::MenuItemView* menu = bb_view_->GetMenu(); | 239 ChromeViews::MenuItemView* menu = bb_view_->GetMenu(); |
| 240 ASSERT_TRUE(menu != NULL && menu->GetSubmenu()->IsShowing()); | 240 ASSERT_TRUE(menu != NULL && menu->GetSubmenu()->IsShowing()); |
| 241 | 241 |
| 242 // Click on 0x0, which should trigger closing menu. | 242 // Click on 0x0, which should trigger closing menu. |
| 243 // NOTE: this code assume there is a left margin, which is currently | 243 // NOTE: this code assume there is a left margin, which is currently |
| 244 // true. If that changes, this code will need to find another empty space | 244 // true. If that changes, this code will need to find another empty space |
| 245 // to press the mouse on. | 245 // to press the mouse on. |
| 246 CPoint mouse_loc(0, 0); | 246 gfx::Point mouse_loc; |
| 247 ChromeViews::View::ConvertPointToScreen(bb_view_, &mouse_loc); | 247 ChromeViews::View::ConvertPointToScreen(bb_view_, &mouse_loc); |
| 248 ui_controls::SendMouseMove(0, 0); | 248 ui_controls::SendMouseMove(0, 0); |
| 249 ui_controls::SendMouseEventsNotifyWhenDone( | 249 ui_controls::SendMouseEventsNotifyWhenDone( |
| 250 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, | 250 ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, |
| 251 CreateEventTask(this, &BookmarkBarViewTest2::Step3)); | 251 CreateEventTask(this, &BookmarkBarViewTest2::Step3)); |
| 252 } | 252 } |
| 253 | 253 |
| 254 void Step3() { | 254 void Step3() { |
| 255 // The menu shouldn't be showing. | 255 // The menu shouldn't be showing. |
| 256 ChromeViews::MenuItemView* menu = bb_view_->GetMenu(); | 256 ChromeViews::MenuItemView* menu = bb_view_->GetMenu(); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 421 |
| 422 // Move mouse to center of menu and press button. | 422 // Move mouse to center of menu and press button. |
| 423 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, | 423 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, |
| 424 ui_controls::DOWN, | 424 ui_controls::DOWN, |
| 425 CreateEventTask(this, &BookmarkBarViewTest5::Step3)); | 425 CreateEventTask(this, &BookmarkBarViewTest5::Step3)); |
| 426 } | 426 } |
| 427 | 427 |
| 428 void Step3() { | 428 void Step3() { |
| 429 ChromeViews::MenuItemView* target_menu = | 429 ChromeViews::MenuItemView* target_menu = |
| 430 bb_view_->GetMenu()->GetSubmenu()->GetMenuItemAt(1); | 430 bb_view_->GetMenu()->GetSubmenu()->GetMenuItemAt(1); |
| 431 CPoint loc(1, target_menu->height() - 1); | 431 gfx::Point loc(1, target_menu->height() - 1); |
| 432 ChromeViews::View::ConvertPointToScreen(target_menu, &loc); | 432 ChromeViews::View::ConvertPointToScreen(target_menu, &loc); |
| 433 | 433 |
| 434 // Start a drag. | 434 // Start a drag. |
| 435 ui_controls::SendMouseMoveNotifyWhenDone(loc.x + 10, loc.y, | 435 ui_controls::SendMouseMoveNotifyWhenDone(loc.x() + 10, loc.y(), |
| 436 CreateEventTask(this, &BookmarkBarViewTest5::Step4)); | 436 CreateEventTask(this, &BookmarkBarViewTest5::Step4)); |
| 437 | 437 |
| 438 // See comment above this method as to why we do this. | 438 // See comment above this method as to why we do this. |
| 439 ScheduleMouseMoveInBackground(loc.x, loc.y); | 439 ScheduleMouseMoveInBackground(loc.x(), loc.y()); |
| 440 } | 440 } |
| 441 | 441 |
| 442 void Step4() { | 442 void Step4() { |
| 443 // Drop the item so that it's now the second item. | 443 // Drop the item so that it's now the second item. |
| 444 ChromeViews::MenuItemView* target_menu = | 444 ChromeViews::MenuItemView* target_menu = |
| 445 bb_view_->GetMenu()->GetSubmenu()->GetMenuItemAt(1); | 445 bb_view_->GetMenu()->GetSubmenu()->GetMenuItemAt(1); |
| 446 CPoint loc(1, target_menu->height() - 1); | 446 gfx::Point loc(1, target_menu->height() - 1); |
| 447 ChromeViews::View::ConvertPointToScreen(target_menu, &loc); | 447 ChromeViews::View::ConvertPointToScreen(target_menu, &loc); |
| 448 ui_controls::SendMouseMove(loc.x, loc.y); | 448 ui_controls::SendMouseMove(loc.x(), loc.y()); |
| 449 | 449 |
| 450 ui_controls::SendMouseEventsNotifyWhenDone(ui_controls::LEFT, | 450 ui_controls::SendMouseEventsNotifyWhenDone(ui_controls::LEFT, |
| 451 ui_controls::UP, | 451 ui_controls::UP, |
| 452 CreateEventTask(this, &BookmarkBarViewTest5::Step5)); | 452 CreateEventTask(this, &BookmarkBarViewTest5::Step5)); |
| 453 } | 453 } |
| 454 | 454 |
| 455 void Step5() { | 455 void Step5() { |
| 456 GURL url = model_->GetBookmarkBarNode()->GetChild(0)->GetChild(1)->GetURL(); | 456 GURL url = model_->GetBookmarkBarNode()->GetChild(0)->GetChild(1)->GetURL(); |
| 457 ASSERT_TRUE(url == url_dragging_); | 457 ASSERT_TRUE(url == url_dragging_); |
| 458 Done(); | 458 Done(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 // Move mouse to center of menu and press button. | 530 // Move mouse to center of menu and press button. |
| 531 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, | 531 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, |
| 532 ui_controls::DOWN, | 532 ui_controls::DOWN, |
| 533 CreateEventTask(this, &BookmarkBarViewTest7::Step3)); | 533 CreateEventTask(this, &BookmarkBarViewTest7::Step3)); |
| 534 } | 534 } |
| 535 | 535 |
| 536 void Step3() { | 536 void Step3() { |
| 537 // Drag over other button. | 537 // Drag over other button. |
| 538 ChromeViews::TextButton* other_button = | 538 ChromeViews::TextButton* other_button = |
| 539 bb_view_->other_bookmarked_button(); | 539 bb_view_->other_bookmarked_button(); |
| 540 CPoint loc(other_button->width() / 2, other_button->height() / 2); | 540 gfx::Point loc(other_button->width() / 2, other_button->height() / 2); |
| 541 ChromeViews::View::ConvertPointToScreen(other_button, &loc); | 541 ChromeViews::View::ConvertPointToScreen(other_button, &loc); |
| 542 | 542 |
| 543 // Start a drag. | 543 // Start a drag. |
| 544 ui_controls::SendMouseMoveNotifyWhenDone(loc.x + 10, loc.y, | 544 ui_controls::SendMouseMoveNotifyWhenDone(loc.x() + 10, loc.y(), |
| 545 NewRunnableMethod(this, &BookmarkBarViewTest7::Step4)); | 545 NewRunnableMethod(this, &BookmarkBarViewTest7::Step4)); |
| 546 | 546 |
| 547 // See comment above this method as to why we do this. | 547 // See comment above this method as to why we do this. |
| 548 ScheduleMouseMoveInBackground(loc.x, loc.y); | 548 ScheduleMouseMoveInBackground(loc.x(), loc.y()); |
| 549 } | 549 } |
| 550 | 550 |
| 551 void Step4() { | 551 void Step4() { |
| 552 ChromeViews::MenuItemView* drop_menu = bb_view_->GetDropMenu(); | 552 ChromeViews::MenuItemView* drop_menu = bb_view_->GetDropMenu(); |
| 553 ASSERT_TRUE(drop_menu != NULL); | 553 ASSERT_TRUE(drop_menu != NULL); |
| 554 ASSERT_TRUE(drop_menu->GetSubmenu()->IsShowing()); | 554 ASSERT_TRUE(drop_menu->GetSubmenu()->IsShowing()); |
| 555 | 555 |
| 556 ChromeViews::MenuItemView* target_menu = | 556 ChromeViews::MenuItemView* target_menu = |
| 557 drop_menu->GetSubmenu()->GetMenuItemAt(0); | 557 drop_menu->GetSubmenu()->GetMenuItemAt(0); |
| 558 CPoint loc(1, 1); | 558 gfx::Point loc(1, 1); |
| 559 ChromeViews::View::ConvertPointToScreen(target_menu, &loc); | 559 ChromeViews::View::ConvertPointToScreen(target_menu, &loc); |
| 560 ui_controls::SendMouseMove(loc.x, loc.y); | 560 ui_controls::SendMouseMove(loc.x(), loc.y()); |
| 561 ui_controls::SendMouseEventsNotifyWhenDone( | 561 ui_controls::SendMouseEventsNotifyWhenDone( |
| 562 ui_controls::LEFT, ui_controls::UP, | 562 ui_controls::LEFT, ui_controls::UP, |
| 563 CreateEventTask(this, &BookmarkBarViewTest7::Step5)); | 563 CreateEventTask(this, &BookmarkBarViewTest7::Step5)); |
| 564 } | 564 } |
| 565 | 565 |
| 566 void Step5() { | 566 void Step5() { |
| 567 ASSERT_TRUE(model_->other_node()->GetChild(0)->GetURL() == url_dragging_); | 567 ASSERT_TRUE(model_->other_node()->GetChild(0)->GetURL() == url_dragging_); |
| 568 Done(); | 568 Done(); |
| 569 } | 569 } |
| 570 | 570 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 // Move mouse to center of menu and press button. | 603 // Move mouse to center of menu and press button. |
| 604 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, | 604 ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, |
| 605 ui_controls::DOWN, | 605 ui_controls::DOWN, |
| 606 CreateEventTask(this, &BookmarkBarViewTest8::Step3)); | 606 CreateEventTask(this, &BookmarkBarViewTest8::Step3)); |
| 607 } | 607 } |
| 608 | 608 |
| 609 void Step3() { | 609 void Step3() { |
| 610 // Drag over other button. | 610 // Drag over other button. |
| 611 ChromeViews::TextButton* other_button = | 611 ChromeViews::TextButton* other_button = |
| 612 bb_view_->other_bookmarked_button(); | 612 bb_view_->other_bookmarked_button(); |
| 613 CPoint loc(other_button->width() / 2, other_button->height() / 2); | 613 gfx::Point loc(other_button->width() / 2, other_button->height() / 2); |
| 614 ChromeViews::View::ConvertPointToScreen(other_button, &loc); | 614 ChromeViews::View::ConvertPointToScreen(other_button, &loc); |
| 615 | 615 |
| 616 // Start a drag. | 616 // Start a drag. |
| 617 ui_controls::SendMouseMoveNotifyWhenDone(loc.x + 10, loc.y, | 617 ui_controls::SendMouseMoveNotifyWhenDone(loc.x() + 10, loc.y(), |
| 618 NewRunnableMethod(this, &BookmarkBarViewTest8::Step4)); | 618 NewRunnableMethod(this, &BookmarkBarViewTest8::Step4)); |
| 619 | 619 |
| 620 // See comment above this method as to why we do this. | 620 // See comment above this method as to why we do this. |
| 621 ScheduleMouseMoveInBackground(loc.x, loc.y); | 621 ScheduleMouseMoveInBackground(loc.x(), loc.y()); |
| 622 } | 622 } |
| 623 | 623 |
| 624 void Step4() { | 624 void Step4() { |
| 625 ChromeViews::MenuItemView* drop_menu = bb_view_->GetDropMenu(); | 625 ChromeViews::MenuItemView* drop_menu = bb_view_->GetDropMenu(); |
| 626 ASSERT_TRUE(drop_menu != NULL); | 626 ASSERT_TRUE(drop_menu != NULL); |
| 627 ASSERT_TRUE(drop_menu->GetSubmenu()->IsShowing()); | 627 ASSERT_TRUE(drop_menu->GetSubmenu()->IsShowing()); |
| 628 | 628 |
| 629 // Now drag back over first menu. | 629 // Now drag back over first menu. |
| 630 ChromeViews::TextButton* button = bb_view_->GetBookmarkButton(0); | 630 ChromeViews::TextButton* button = bb_view_->GetBookmarkButton(0); |
| 631 CPoint loc(button->width() / 2, button->height() / 2); | 631 gfx::Point loc(button->width() / 2, button->height() / 2); |
| 632 ChromeViews::View::ConvertPointToScreen(button, &loc); | 632 ChromeViews::View::ConvertPointToScreen(button, &loc); |
| 633 ui_controls::SendMouseMoveNotifyWhenDone(loc.x, loc.y, | 633 ui_controls::SendMouseMoveNotifyWhenDone(loc.x(), loc.y(), |
| 634 NewRunnableMethod(this, &BookmarkBarViewTest8::Step5)); | 634 NewRunnableMethod(this, &BookmarkBarViewTest8::Step5)); |
| 635 } | 635 } |
| 636 | 636 |
| 637 void Step5() { | 637 void Step5() { |
| 638 // Drop on folder F11. | 638 // Drop on folder F11. |
| 639 ChromeViews::MenuItemView* drop_menu = bb_view_->GetDropMenu(); | 639 ChromeViews::MenuItemView* drop_menu = bb_view_->GetDropMenu(); |
| 640 ASSERT_TRUE(drop_menu != NULL); | 640 ASSERT_TRUE(drop_menu != NULL); |
| 641 ASSERT_TRUE(drop_menu->GetSubmenu()->IsShowing()); | 641 ASSERT_TRUE(drop_menu->GetSubmenu()->IsShowing()); |
| 642 | 642 |
| 643 ChromeViews::MenuItemView* target_menu = | 643 ChromeViews::MenuItemView* target_menu = |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 } | 675 } |
| 676 | 676 |
| 677 private: | 677 private: |
| 678 void Step2() { | 678 void Step2() { |
| 679 // Menu should be showing. | 679 // Menu should be showing. |
| 680 ChromeViews::MenuItemView* menu = bb_view_->GetMenu(); | 680 ChromeViews::MenuItemView* menu = bb_view_->GetMenu(); |
| 681 ASSERT_TRUE(menu != NULL); | 681 ASSERT_TRUE(menu != NULL); |
| 682 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); | 682 ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); |
| 683 | 683 |
| 684 first_menu_ = menu->GetSubmenu()->GetMenuItemAt(0); | 684 first_menu_ = menu->GetSubmenu()->GetMenuItemAt(0); |
| 685 CPoint menu_loc; | 685 gfx::Point menu_loc; |
| 686 ChromeViews::View::ConvertPointToScreen(first_menu_, &menu_loc); | 686 ChromeViews::View::ConvertPointToScreen(first_menu_, &menu_loc); |
| 687 start_y_ = menu_loc.y; | 687 start_y_ = menu_loc.y(); |
| 688 | 688 |
| 689 // Move the mouse over the scroll button. | 689 // Move the mouse over the scroll button. |
| 690 ChromeViews::View* scroll_container = menu->GetSubmenu()->GetParent(); | 690 ChromeViews::View* scroll_container = menu->GetSubmenu()->GetParent(); |
| 691 ASSERT_TRUE(scroll_container != NULL); | 691 ASSERT_TRUE(scroll_container != NULL); |
| 692 scroll_container = scroll_container->GetParent(); | 692 scroll_container = scroll_container->GetParent(); |
| 693 ASSERT_TRUE(scroll_container != NULL); | 693 ASSERT_TRUE(scroll_container != NULL); |
| 694 ChromeViews::View* scroll_down_button = scroll_container->GetChildViewAt(1); | 694 ChromeViews::View* scroll_down_button = scroll_container->GetChildViewAt(1); |
| 695 ASSERT_TRUE(scroll_down_button); | 695 ASSERT_TRUE(scroll_down_button); |
| 696 CPoint loc(scroll_down_button->width() / 2, | 696 gfx::Point loc(scroll_down_button->width() / 2, |
| 697 scroll_down_button->height() / 2); | 697 scroll_down_button->height() / 2); |
| 698 ChromeViews::View::ConvertPointToScreen(scroll_down_button, &loc); | 698 ChromeViews::View::ConvertPointToScreen(scroll_down_button, &loc); |
| 699 ui_controls::SendMouseMoveNotifyWhenDone( | 699 ui_controls::SendMouseMoveNotifyWhenDone( |
| 700 loc.x, loc.y, CreateEventTask(this, &BookmarkBarViewTest9::Step3)); | 700 loc.x(), loc.y(), CreateEventTask(this, &BookmarkBarViewTest9::Step3)); |
| 701 } | 701 } |
| 702 | 702 |
| 703 void Step3() { | 703 void Step3() { |
| 704 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 704 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 705 NewRunnableMethod(this, &BookmarkBarViewTest9::Step4), 200); | 705 NewRunnableMethod(this, &BookmarkBarViewTest9::Step4), 200); |
| 706 } | 706 } |
| 707 | 707 |
| 708 void Step4() { | 708 void Step4() { |
| 709 CPoint menu_loc; | 709 gfx::Point menu_loc; |
| 710 ChromeViews::View::ConvertPointToScreen(first_menu_, &menu_loc); | 710 ChromeViews::View::ConvertPointToScreen(first_menu_, &menu_loc); |
| 711 ASSERT_NE(start_y_, menu_loc.y); | 711 ASSERT_NE(start_y_, menu_loc.y()); |
| 712 | 712 |
| 713 // Hide menu. | 713 // Hide menu. |
| 714 bb_view_->GetMenu()->GetMenuController()->Cancel(true); | 714 bb_view_->GetMenu()->GetMenuController()->Cancel(true); |
| 715 | 715 |
| 716 Done(); | 716 Done(); |
| 717 } | 717 } |
| 718 | 718 |
| 719 int start_y_; | 719 int start_y_; |
| 720 ChromeViews::MenuItemView* first_menu_; | 720 ChromeViews::MenuItemView* first_menu_; |
| 721 }; | 721 }; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 | 819 |
| 820 void Step8() { | 820 void Step8() { |
| 821 ASSERT_TRUE( | 821 ASSERT_TRUE( |
| 822 model_->GetBookmarkBarNode()->GetChild(0)->GetChild(0)->GetURL() == | 822 model_->GetBookmarkBarNode()->GetChild(0)->GetChild(0)->GetURL() == |
| 823 navigator_.url_); | 823 navigator_.url_); |
| 824 Done(); | 824 Done(); |
| 825 } | 825 } |
| 826 }; | 826 }; |
| 827 | 827 |
| 828 VIEW_TEST(BookmarkBarViewTest10, KeyEvents) | 828 VIEW_TEST(BookmarkBarViewTest10, KeyEvents) |
| OLD | NEW |