summaryrefslogtreecommitdiffstats
path: root/ui/base/animation/test_animation_delegate.h
blob: e6c40476a6bddb3d0b72e02c051116c676d54c3f (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
// Copyright (c) 2011 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.

#ifndef UI_BASE_ANIMATION_TEST_ANIMATION_DELEGATE_H_
#define UI_BASE_ANIMATION_TEST_ANIMATION_DELEGATE_H_
#pragma once

#include "base/message_loop.h"
#include "ui/base/animation/animation_delegate.h"

namespace ui {

// Trivial AnimationDelegate implementation. AnimationEnded/Canceled quit the
// message loop.
class TestAnimationDelegate : public AnimationDelegate {
 public:
  TestAnimationDelegate() : canceled_(false), finished_(false) {
  }

  virtual void AnimationEnded(const Animation* animation) {
    finished_ = true;
    MessageLoop::current()->Quit();
  }

  virtual void AnimationCanceled(const Animation* animation) {
    finished_ = true;
    canceled_ = true;
    MessageLoop::current()->Quit();
  }

  bool finished() const {
    return finished_;
  }

  bool canceled() const {
    return canceled_;
  }

 private:
  bool canceled_;
  bool finished_;

  DISALLOW_COPY_AND_ASSIGN(TestAnimationDelegate);
};

}  // namespace ui

#endif  // UI_BASE_ANIMATION_TEST_ANIMATION_DELEGATE_H_