blob: 9c3ddbb8654d43ccb1014cbbf28291d4af6c6cd9 [file] [log] [blame]
// Copyright (c) 2012 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 "base/compiler_specific.h"
#include "base/logging.h"
#include "ui/events/event_handler.h"
#include "ui/wm/public/activation_change_observer.h"
#include "ui/wm/public/activation_delegate.h"
namespace aura {
class Window;
namespace ash {
namespace test {
// A test ActivationDelegate that can be used to track activation changes for
// an aura::Window.
class TestActivationDelegate : public aura::client::ActivationDelegate,
public aura::client::ActivationChangeObserver {
explicit TestActivationDelegate(bool activate);
// Associates this delegate with a Window.
void SetWindow(aura::Window* window);
bool window_was_active() const { return window_was_active_; }
void set_activate(bool v) { activate_ = v; }
int activated_count() const { return activated_count_; }
int lost_active_count() const { return lost_active_count_; }
int should_activate_count() const { return should_activate_count_; }
void Clear() {
activated_count_ = lost_active_count_ = should_activate_count_ = 0;
window_was_active_ = false;
// Overridden from aura::client::ActivationDelegate:
bool ShouldActivate() const override;
// Overridden from aura::client::ActivationChangeObserver:
void OnWindowActivated(
aura::client::ActivationChangeObserver::ActivationReason reason,
aura::Window* gained_active,
aura::Window* lost_active) override;
aura::Window* window_;
bool window_was_active_;
bool activate_;
int activated_count_;
int lost_active_count_;
mutable int should_activate_count_;
} // namespace test
} // namespace ash