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. 4 5 #ifndef UI_AURA_TEST_TEST_ACTIVATION_CLIENT_H_ 6 #define UI_AURA_TEST_TEST_ACTIVATION_CLIENT_H_ 7 8 #include "base/compiler_specific.h" 9 #include "base/logging.h" 10 #include "ui/aura/client/activation_client.h" 11 #include "ui/aura/window_observer.h" 12 13 namespace aura { 14 class RootWindow; 15 namespace client { 16 class ActivationChangeObserver; 17 } 18 19 namespace test { 20 21 class TestActivationClient : public client::ActivationClient, 22 public WindowObserver { 23 public: 24 explicit TestActivationClient(RootWindow* root_window); 25 virtual ~TestActivationClient(); 26 27 // Overridden from client::ActivationClient: 28 virtual void AddObserver(client::ActivationChangeObserver* observer) OVERRIDE; 29 virtual void RemoveObserver( 30 client::ActivationChangeObserver* observer) OVERRIDE; 31 virtual void ActivateWindow(Window* window) OVERRIDE; 32 virtual void DeactivateWindow(Window* window) OVERRIDE; 33 virtual Window* GetActiveWindow() OVERRIDE; 34 virtual Window* GetActivatableWindow(Window* window) OVERRIDE; 35 virtual Window* GetToplevelWindow(Window* window) OVERRIDE; 36 virtual bool OnWillFocusWindow(Window* window, 37 const ui::Event* event) OVERRIDE; 38 virtual bool CanActivateWindow(Window* window) const OVERRIDE; 39 40 // Overridden from WindowObserver: 41 virtual void OnWindowDestroyed(Window* window) OVERRIDE; 42 43 private: 44 void RemoveActiveWindow(Window* window); 45 46 // This class explicitly does NOT store the active window in a window property 47 // to make sure that ActivationChangeObserver is not treated as part of the 48 // aura API. Assumptions to that end will cause tests that use this client to 49 // fail. 50 std::vector<Window*> active_windows_; 51 52 // The window which was active before the currently active one. 53 Window* last_active_; 54 55 ObserverList<client::ActivationChangeObserver> observers_; 56 57 DISALLOW_COPY_AND_ASSIGN(TestActivationClient); 58 }; 59 60 } // namespace test 61 } // namespace aura 62 63 #endif // UI_AURA_TEST_TEST_ACTIVATION_CLIENT_H_ 64