summaryrefslogtreecommitdiffstats
path: root/ui/events/test/test_event_processor.cc
blob: 6515ca6a67cf299f79cab3e025d9a2a6c111650e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/events/test/test_event_processor.h"

#include <utility>

#include "ui/events/event_target.h"

namespace ui {
namespace test {

TestEventProcessor::TestEventProcessor()
    : should_processing_occur_(true),
      num_times_processing_started_(0),
      num_times_processing_finished_(0) {
}

TestEventProcessor::~TestEventProcessor() {}

void TestEventProcessor::SetRoot(scoped_ptr<EventTarget> root) {
  root_ = std::move(root);
}

void TestEventProcessor::Reset() {
  should_processing_occur_ = true;
  num_times_processing_started_ = 0;
  num_times_processing_finished_ = 0;
}

bool TestEventProcessor::CanDispatchToTarget(EventTarget* target) {
  return true;
}

EventTarget* TestEventProcessor::GetRootTarget() {
  return root_.get();
}

EventDispatchDetails TestEventProcessor::OnEventFromSource(Event* event) {
  return EventProcessor::OnEventFromSource(event);
}

void TestEventProcessor::OnEventProcessingStarted(Event* event) {
  num_times_processing_started_++;
  if (!should_processing_occur_)
    event->SetHandled();
}

void TestEventProcessor::OnEventProcessingFinished(Event* event) {
  num_times_processing_finished_++;
}

}  // namespace test
}  // namespace ui