#ifndef CHROME_BROWSER_UI_VIEWS_MENU_TEST_BASE_H_
#define CHROME_BROWSER_UI_VIEWS_MENU_TEST_BASE_H_
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/test/base/view_event_test_base.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/views/controls/button/menu_button_listener.h"
#include "ui/views/controls/menu/menu_delegate.h"
namespace views {
class MenuButton;
class MenuItemView;
class MenuRunner;
}
class MenuTestBase : public ViewEventTestBase,
public views::MenuButtonListener,
public views::MenuDelegate {
public:
MenuTestBase();
virtual ~MenuTestBase();
virtual void Click(views::View* view, const base::Closure& next);
void KeyPress(ui::KeyboardCode keycode, const base::Closure& next);
views::MenuItemView* menu() {
return menu_;
}
int last_command() const {
return last_command_;
}
protected:
virtual void BuildMenu(views::MenuItemView* menu) = 0;
virtual void DoTestWithMenuOpen() = 0;
virtual void SetUp() OVERRIDE;
virtual void TearDown() OVERRIDE;
virtual views::View* CreateContentsView() OVERRIDE;
virtual void DoTestOnMessageLoop() OVERRIDE;
virtual gfx::Size GetPreferredSize() OVERRIDE;
virtual void OnMenuButtonClicked(views::View* source,
const gfx::Point& point) OVERRIDE;
virtual void ExecuteCommand(int id) OVERRIDE;
private:
views::MenuButton* button_;
views::MenuItemView* menu_;
scoped_ptr<views::MenuRunner> menu_runner_;
int last_command_;
DISALLOW_COPY_AND_ASSIGN(MenuTestBase);
};
#endif