Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ui / events / test / test_event_processor.cc
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/events/test/test_event_processor.h"
6
7 #include "ui/events/event_target.h"
8
9 namespace ui {
10 namespace test {
11
12 TestEventProcessor::TestEventProcessor()
13     : should_processing_occur_(true),
14       num_times_processing_started_(0),
15       num_times_processing_finished_(0) {
16 }
17
18 TestEventProcessor::~TestEventProcessor() {}
19
20 void TestEventProcessor::SetRoot(scoped_ptr<EventTarget> root) {
21   root_ = root.Pass();
22 }
23
24 void TestEventProcessor::Reset() {
25   should_processing_occur_ = true;
26   num_times_processing_started_ = 0;
27   num_times_processing_finished_ = 0;
28 }
29
30 bool TestEventProcessor::CanDispatchToTarget(EventTarget* target) {
31   return true;
32 }
33
34 EventTarget* TestEventProcessor::GetRootTarget() {
35   return root_.get();
36 }
37
38 EventDispatchDetails TestEventProcessor::OnEventFromSource(Event* event) {
39   return EventProcessor::OnEventFromSource(event);
40 }
41
42 void TestEventProcessor::OnEventProcessingStarted(Event* event) {
43   num_times_processing_started_++;
44   if (!should_processing_occur_)
45     event->SetHandled();
46 }
47
48 void TestEventProcessor::OnEventProcessingFinished(Event* event) {
49   num_times_processing_finished_++;
50 }
51
52 }  // namespace test
53 }  // namespace ui