Removed 'anonymous' from namespace, added whitespace in thread_restrictions.cc
[chromium-blink-merge.git] / ash / test / test_activation_delegate.h
blob9c3ddbb8654d43ccb1014cbbf28291d4af6c6cd9
1 // Copyright (c) 2012 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.
5 #ifndef ASH_TEST_TEST_ACTIVATION_DELEGATE_H_
6 #define ASH_TEST_TEST_ACTIVATION_DELEGATE_H_
8 #include "base/compiler_specific.h"
9 #include "base/logging.h"
10 #include "ui/events/event_handler.h"
11 #include "ui/wm/public/activation_change_observer.h"
12 #include "ui/wm/public/activation_delegate.h"
14 namespace aura {
15 class Window;
18 namespace ash {
19 namespace test {
21 // A test ActivationDelegate that can be used to track activation changes for
22 // an aura::Window.
23 class TestActivationDelegate : public aura::client::ActivationDelegate,
24 public aura::client::ActivationChangeObserver {
25 public:
26 TestActivationDelegate();
27 explicit TestActivationDelegate(bool activate);
29 // Associates this delegate with a Window.
30 void SetWindow(aura::Window* window);
32 bool window_was_active() const { return window_was_active_; }
33 void set_activate(bool v) { activate_ = v; }
34 int activated_count() const { return activated_count_; }
35 int lost_active_count() const { return lost_active_count_; }
36 int should_activate_count() const { return should_activate_count_; }
37 void Clear() {
38 activated_count_ = lost_active_count_ = should_activate_count_ = 0;
39 window_was_active_ = false;
42 // Overridden from aura::client::ActivationDelegate:
43 bool ShouldActivate() const override;
45 private:
46 // Overridden from aura::client::ActivationChangeObserver:
47 void OnWindowActivated(
48 aura::client::ActivationChangeObserver::ActivationReason reason,
49 aura::Window* gained_active,
50 aura::Window* lost_active) override;
52 aura::Window* window_;
53 bool window_was_active_;
54 bool activate_;
55 int activated_count_;
56 int lost_active_count_;
57 mutable int should_activate_count_;
59 DISALLOW_COPY_AND_ASSIGN(TestActivationDelegate);
62 } // namespace test
63 } // namespace ash
65 #endif // ASH_TEST_TEST_ACTIVATION_DELEGATE_H_