Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(592)

Side by Side Diff: ash/test/test_launcher_delegate.h

Issue 22429004: Refactor LauncherDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for OpenBrowserUsingShelfOnOhterDisplay fail Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
12 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
13 #include "ui/aura/window_observer.h" 14 #include "ui/aura/window_observer.h"
14 15
15 namespace ash { 16 namespace ash {
16 17
17 class LauncherModel; 18 class LauncherModel;
18 19
19 namespace test { 20 namespace test {
20 21
21 // Test implementation of LauncherDelegate. 22 // Test implementation of LauncherDelegate.
22 // Tests may create icons for windows by calling AddLauncherItem 23 // Tests may create icons for windows by calling AddLauncherItem
23 class TestLauncherDelegate : public LauncherDelegate, 24 class TestLauncherDelegate : public LauncherDelegate,
25 public LauncherItemDelegate,
24 public aura::WindowObserver { 26 public aura::WindowObserver {
25 public: 27 public:
26 explicit TestLauncherDelegate(LauncherModel* model); 28 explicit TestLauncherDelegate(LauncherModel* model);
27 virtual ~TestLauncherDelegate(); 29 virtual ~TestLauncherDelegate();
28 30
29 void AddLauncherItem(aura::Window* window); 31 void AddLauncherItem(aura::Window* window);
30 void AddLauncherItem(aura::Window* window, LauncherItemStatus status); 32 void AddLauncherItem(aura::Window* window, LauncherItemStatus status);
31 void RemoveLauncherItemForWindow(aura::Window* window); 33 void RemoveLauncherItemForWindow(aura::Window* window);
32 34
33 static TestLauncherDelegate* instance() { return instance_; } 35 static TestLauncherDelegate* instance() { return instance_; }
34 36
35 // WindowObserver implementation 37 // WindowObserver implementation
36 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; 38 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE;
37 virtual void OnWindowHierarchyChanging( 39 virtual void OnWindowHierarchyChanging(
38 const HierarchyChangeParams& params) OVERRIDE; 40 const HierarchyChangeParams& params) OVERRIDE;
39 41
40 // LauncherDelegate implementation. 42 // LauncherDelegate implementation.
43 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE;
44 virtual void OnLauncherCreated(Launcher* launcher) OVERRIDE;
45 virtual void OnLauncherDestroyed(Launcher* launcher) OVERRIDE;
46 virtual LauncherID GetLauncherIDForAppID(const std::string& app_id) OVERRIDE;
47 virtual const std::string& GetAppIDForLauncherID(LauncherID id) OVERRIDE;
48 virtual void PinAppWithID(const std::string& app_id) OVERRIDE;
49 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE;
50 virtual void UnpinAppWithID(const std::string& app_id) OVERRIDE;
51
52 // LauncherItemDelegate implementation.
41 virtual void ItemSelected(const LauncherItem& item, 53 virtual void ItemSelected(const LauncherItem& item,
42 const ui::Event& event) OVERRIDE; 54 const ui::Event& event) OVERRIDE;
43 virtual base::string16 GetTitle(const LauncherItem& item) OVERRIDE; 55 virtual base::string16 GetTitle(const LauncherItem& item) OVERRIDE;
44 virtual ui::MenuModel* CreateContextMenu(const LauncherItem& item, 56 virtual ui::MenuModel* CreateContextMenu(const LauncherItem& item,
45 aura::RootWindow* root) OVERRIDE; 57 aura::RootWindow* root) OVERRIDE;
46 virtual ash::LauncherMenuModel* CreateApplicationMenu( 58 virtual ash::LauncherMenuModel* CreateApplicationMenu(
47 const LauncherItem& item, 59 const LauncherItem& item,
48 int event_flags) OVERRIDE; 60 int event_flags) OVERRIDE;
49 virtual ash::LauncherID GetIDByWindow(aura::Window* window) OVERRIDE;
50 virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE; 61 virtual bool IsDraggable(const ash::LauncherItem& item) OVERRIDE;
51 virtual bool ShouldShowTooltip(const LauncherItem& item) OVERRIDE; 62 virtual bool ShouldShowTooltip(const LauncherItem& item) OVERRIDE;
52 virtual void OnLauncherCreated(Launcher* launcher) OVERRIDE;
53 virtual void OnLauncherDestroyed(Launcher* launcher) OVERRIDE;
54 virtual LauncherID GetLauncherIDForAppID(const std::string& app_id) OVERRIDE;
55 virtual const std::string& GetAppIDForLauncherID(LauncherID id) OVERRIDE;
56 virtual void PinAppWithID(const std::string& app_id) OVERRIDE;
57 virtual bool IsAppPinned(const std::string& app_id) OVERRIDE;
58 virtual void UnpinAppWithID(const std::string& app_id) OVERRIDE;
59 63
60 private: 64 private:
61 typedef std::map<aura::Window*, ash::LauncherID> WindowToID; 65 typedef std::map<aura::Window*, ash::LauncherID> WindowToID;
62 typedef std::set<aura::Window*> ObservedWindows; 66 typedef std::set<aura::Window*> ObservedWindows;
63 67
64 static TestLauncherDelegate* instance_; 68 static TestLauncherDelegate* instance_;
65 69
66 aura::Window* GetWindowByID(ash::LauncherID id); 70 aura::Window* GetWindowByID(ash::LauncherID id);
67 71
68 LauncherModel* model_; 72 LauncherModel* model_;
69 73
70 // Maps from window to the id we gave it. 74 // Maps from window to the id we gave it.
71 WindowToID window_to_id_; 75 WindowToID window_to_id_;
72 76
73 DISALLOW_COPY_AND_ASSIGN(TestLauncherDelegate); 77 DISALLOW_COPY_AND_ASSIGN(TestLauncherDelegate);
74 }; 78 };
75 79
76 } // namespace test 80 } // namespace test
77 } // namespace ash 81 } // namespace ash
78 82
79 #endif // ASH_TEST_TEST_LAUNCHER_DELEGATE_H_ 83 #endif // ASH_TEST_TEST_LAUNCHER_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698