| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_TEST_TEST_LAUNCHER_DELEGATE_H_ | 5 #ifndef ASH_TEST_TEST_LAUNCHER_DELEGATE_H_ |
| 6 #define ASH_TEST_TEST_LAUNCHER_DELEGATE_H_ | 6 #define ASH_TEST_TEST_LAUNCHER_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "ash/launcher/launcher_delegate.h" | 11 #include "ash/launcher/launcher_delegate.h" |
| 12 #include "ash/launcher/launcher_item_delegate.h" | |
| 13 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 14 #include "ui/aura/window_observer.h" | 13 #include "ui/aura/window_observer.h" |
| 15 | 14 |
| 16 namespace ash { | 15 namespace ash { |
| 17 | 16 |
| 18 class LauncherModel; | 17 class LauncherModel; |
| 19 | 18 |
| 20 namespace test { | 19 namespace test { |
| 21 | 20 |
| 22 // Test implementation of LauncherDelegate. | 21 // Test implementation of LauncherDelegate. |
| 23 // Tests may create icons for windows by calling AddLauncherItem | 22 // Tests may create icons for windows by calling AddLauncherItem |
| 24 class TestLauncherDelegate : public LauncherDelegate, | 23 class TestLauncherDelegate : public LauncherDelegate, |
| 25 public LauncherItemDelegate, | |
| 26 public aura::WindowObserver { | 24 public aura::WindowObserver { |
| 27 public: | 25 public: |
| 28 explicit TestLauncherDelegate(LauncherModel* model); | 26 explicit TestLauncherDelegate(LauncherModel* model); |
| 29 virtual ~TestLauncherDelegate(); | 27 virtual ~TestLauncherDelegate(); |
| 30 | 28 |
| 31 void AddLauncherItem(aura::Window* window); | 29 void AddLauncherItem(aura::Window* window); |
| 32 void AddLauncherItem(aura::Window* window, LauncherItemStatus status); | 30 void AddLauncherItem(aura::Window* window, LauncherItemStatus status); |
| 33 void RemoveLauncherItemForWindow(aura::Window* window); | 31 void RemoveLauncherItemForWindow(aura::Window* window); |
| 34 | 32 |
| 35 static TestLauncherDelegate* instance() { return instance_; } | 33 static TestLauncherDelegate* instance() { return instance_; } |
| 36 | 34 |
| 37 // WindowObserver implementation | 35 // WindowObserver implementation |
| 38 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 36 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
| 39 virtual void OnWindowHierarchyChanging( | 37 virtual void OnWindowHierarchyChanging( |
| 40 const HierarchyChangeParams& params) OVERRIDE; | 38 const HierarchyChangeParams& params) OVERRIDE; |
| 41 | 39 |
| 42 // LauncherDelegate implementation. | 40 // LauncherDelegate implementation. |
| 43 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE; | 41 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE; |
| 44 virtual void OnLauncherCreated(Launcher* launcher) OVERRIDE; | 42 virtual void OnLauncherCreated(Launcher* launcher) OVERRIDE; |
| 45 virtual void OnLauncherDestroyed(Launcher* launcher) OVERRIDE; | 43 virtual void OnLauncherDestroyed(Launcher* launcher) OVERRIDE; |
| 46 virtual LauncherID GetLauncherIDForAppID(const std::string& app_id) OVERRIDE; | 44 virtual LauncherID GetLauncherIDForAppID(const std::string& app_id) OVERRIDE; |
| 47 virtual const std::string& GetAppIDForLauncherID(LauncherID id) OVERRIDE; | 45 virtual const std::string& GetAppIDForLauncherID(LauncherID id) OVERRIDE; |
| 48 virtual void PinAppWithID(const std::string& app_id) OVERRIDE; | 46 virtual void PinAppWithID(const std::string& app_id) OVERRIDE; |
| 49 virtual bool CanPin() const OVERRIDE; | 47 virtual bool CanPin() const OVERRIDE; |
| 50 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE; | 48 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE; |
| 51 virtual void UnpinAppWithID(const std::string& app_id) OVERRIDE; | 49 virtual void UnpinAppWithID(const std::string& app_id) OVERRIDE; |
| 52 | 50 |
| 53 // LauncherItemDelegate implementation. | |
| 54 virtual void ItemSelected(const LauncherItem& item, | |
| 55 const ui::Event& event) OVERRIDE; | |
| 56 virtual base::string16 GetTitle(const LauncherItem& item) OVERRIDE; | |
| 57 virtual ui::MenuModel* CreateContextMenu(const LauncherItem& item, | |
| 58 aura::RootWindow* root) OVERRIDE; | |
| 59 virtual ash::LauncherMenuModel* CreateApplicationMenu( | |
| 60 const LauncherItem& item, | |
| 61 int event_flags) OVERRIDE; | |
| 62 virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE; | |
| 63 virtual bool ShouldShowTooltip(const LauncherItem& item) OVERRIDE; | |
| 64 | |
| 65 private: | 51 private: |
| 66 typedef std::map<aura::Window*, ash::LauncherID> WindowToID; | 52 typedef std::map<aura::Window*, ash::LauncherID> WindowToID; |
| 67 typedef std::set<aura::Window*> ObservedWindows; | 53 typedef std::set<aura::Window*> ObservedWindows; |
| 68 | 54 |
| 69 static TestLauncherDelegate* instance_; | 55 static TestLauncherDelegate* instance_; |
| 70 | 56 |
| 71 aura::Window* GetWindowByID(ash::LauncherID id); | |
| 72 | |
| 73 LauncherModel* model_; | 57 LauncherModel* model_; |
| 74 | 58 |
| 75 // Maps from window to the id we gave it. | 59 // Maps from window to the id we gave it. |
| 76 WindowToID window_to_id_; | 60 WindowToID window_to_id_; |
| 77 | 61 |
| 78 DISALLOW_COPY_AND_ASSIGN(TestLauncherDelegate); | 62 DISALLOW_COPY_AND_ASSIGN(TestLauncherDelegate); |
| 79 }; | 63 }; |
| 80 | 64 |
| 81 } // namespace test | 65 } // namespace test |
| 82 } // namespace ash | 66 } // namespace ash |
| 83 | 67 |
| 84 #endif // ASH_TEST_TEST_LAUNCHER_DELEGATE_H_ | 68 #endif // ASH_TEST_TEST_LAUNCHER_DELEGATE_H_ |
| OLD | NEW |