This source file includes following definitions.
- menu_closed_
- SetUp
- TearDown
- CreateContentsView
- GetPreferredSize
- IsCommandIdChecked
- IsCommandIdEnabled
- GetAcceleratorForCommandId
- ExecuteCommand
- MenuWillShow
- MenuClosed
- DoTestOnMessageLoop
- Step1
- Step2
- Step3
- Step4
- Step5
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/ui/views/toolbar/toolbar_button.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "chrome/test/base/view_event_test_base.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/base/test/ui_controls.h"
class ToolbarButtonDragTest : public ViewEventTestBase,
ui::SimpleMenuModel::Delegate {
public:
ToolbarButtonDragTest()
: button_(NULL),
menu_shown_(false),
menu_closed_(false) {
}
virtual ~ToolbarButtonDragTest() {
}
virtual void SetUp() OVERRIDE {
button_ = new ToolbarButton(NULL, new ui::SimpleMenuModel(this));
ViewEventTestBase::SetUp();
}
virtual void TearDown() OVERRIDE {
ViewEventTestBase::TearDown();
}
virtual views::View* CreateContentsView() OVERRIDE {
return button_;
}
virtual gfx::Size GetPreferredSize() OVERRIDE {
return button_->GetPreferredSize();
}
virtual bool IsCommandIdChecked(int id) const OVERRIDE {
return false;
}
virtual bool IsCommandIdEnabled(int id) const OVERRIDE {
return true;
}
virtual bool GetAcceleratorForCommandId(
int id,
ui::Accelerator* accelerator) OVERRIDE {
return false;
}
virtual void ExecuteCommand(int id, int event_flags) OVERRIDE {
}
virtual void MenuWillShow(ui::SimpleMenuModel* ) OVERRIDE {
menu_shown_ = true;
}
virtual void MenuClosed(ui::SimpleMenuModel* ) OVERRIDE {
menu_closed_ = true;
}
virtual void DoTestOnMessageLoop() OVERRIDE {
ui_test_utils::MoveMouseToCenterAndPress(
button_,
ui_controls::LEFT,
ui_controls::DOWN,
CreateEventTask(this, &ToolbarButtonDragTest::Step1));
}
void Step1() {
gfx::Point view_center;
views::View::ConvertPointToScreen(button_, &view_center);
ui_controls::SendMouseMoveNotifyWhenDone(
view_center.x(), view_center.y() + 50,
CreateEventTask(this, &ToolbarButtonDragTest::Step2));
}
void Step2() {
ASSERT_TRUE(menu_shown_);
ui_controls::SendMouseEventsNotifyWhenDone(
ui_controls::LEFT,
ui_controls::UP,
CreateEventTask(this, &ToolbarButtonDragTest::Step3));
}
void Step3() {
ui_test_utils::MoveMouseToCenterAndPress(
button_,
ui_controls::LEFT,
ui_controls::DOWN | ui_controls::UP,
CreateEventTask(this, &ToolbarButtonDragTest::Step4));
}
void Step4() {
base::MessageLoopForUI::current()->PostTask(
FROM_HERE, CreateEventTask(this, &ToolbarButtonDragTest::Step5));
}
void Step5() {
ASSERT_TRUE(menu_closed_);
Done();
}
private:
ToolbarButton* button_;
bool menu_shown_;
bool menu_closed_;
};
VIEW_TEST(ToolbarButtonDragTest, DISABLED_DragActivation)