#ifndef UI_EVENTS_TEST_TEST_EVENT_TARGET_H_
#define UI_EVENTS_TEST_TEST_EVENT_TARGET_H_
#include <set>
#include <string>
#include <vector>
#include "base/memory/scoped_vector.h"
#include "ui/events/event_target.h"
typedef std::vector<std::string> HandlerSequenceRecorder;
namespace gfx {
class Point;
}
namespace ui {
namespace test {
class TestEventTarget : public EventTarget {
public:
TestEventTarget();
virtual ~TestEventTarget();
void AddChild(scoped_ptr<TestEventTarget> child);
scoped_ptr<TestEventTarget> RemoveChild(TestEventTarget* child);
TestEventTarget* parent() { return parent_; }
void set_mark_events_as_handled(bool handle) {
mark_events_as_handled_ = handle;
}
TestEventTarget* child_at(int index) { return children_[index]; }
size_t child_count() const { return children_.size(); }
void SetEventTargeter(scoped_ptr<EventTargeter> targeter);
bool DidReceiveEvent(ui::EventType type) const;
void ResetReceivedEvents();
void set_recorder(HandlerSequenceRecorder* recorder) {
recorder_ = recorder;
}
void set_target_name(const std::string& target_name) {
target_name_ = target_name;
}
protected:
bool Contains(TestEventTarget* target) const;
virtual bool CanAcceptEvent(const ui::Event& event) OVERRIDE;
virtual EventTarget* GetParentTarget() OVERRIDE;
virtual scoped_ptr<EventTargetIterator> GetChildIterator() const OVERRIDE;
virtual EventTargeter* GetEventTargeter() OVERRIDE;
virtual void OnEvent(Event* event) OVERRIDE;
private:
void set_parent(TestEventTarget* parent) { parent_ = parent; }
TestEventTarget* parent_;
ScopedVector<TestEventTarget> children_;
scoped_ptr<EventTargeter> targeter_;
bool mark_events_as_handled_;
std::set<ui::EventType> received_;
HandlerSequenceRecorder* recorder_;
std::string target_name_;
DISALLOW_COPY_AND_ASSIGN(TestEventTarget);
};
}
}
#endif