| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_COMMON_TEST_TEST_SHELF_DELEGATE_H_ | 5 #ifndef ASH_COMMON_TEST_TEST_SHELF_DELEGATE_H_ |
| 6 #define ASH_COMMON_TEST_TEST_SHELF_DELEGATE_H_ | 6 #define ASH_COMMON_TEST_TEST_SHELF_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "ash/common/shelf/shelf_delegate.h" | 12 #include "ash/common/shelf/shelf_delegate.h" |
| 13 #include "ash/common/wm_window_observer.h" | |
| 14 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "ui/aura/window_observer.h" |
| 15 | 15 |
| 16 namespace ash { | 16 namespace ash { |
| 17 |
| 18 class WmWindow; |
| 19 |
| 17 namespace test { | 20 namespace test { |
| 18 | 21 |
| 19 class ShelfInitializer; | 22 class ShelfInitializer; |
| 20 | 23 |
| 21 // Test implementation of ShelfDelegate. | 24 // Test implementation of ShelfDelegate. |
| 22 // Tests may create icons for windows by calling AddShelfItem(). | 25 // Tests may create icons for windows by calling AddShelfItem(). |
| 23 class TestShelfDelegate : public ShelfDelegate, public WmWindowObserver { | 26 class TestShelfDelegate : public ShelfDelegate, public aura::WindowObserver { |
| 24 public: | 27 public: |
| 25 TestShelfDelegate(); | 28 TestShelfDelegate(); |
| 26 ~TestShelfDelegate() override; | 29 ~TestShelfDelegate() override; |
| 27 | 30 |
| 28 // Adds a ShelfItem for the given |window|. The ShelfItem's status will be | 31 // Adds a ShelfItem for the given |window|. The ShelfItem's status will be |
| 29 // STATUS_CLOSED. | 32 // STATUS_CLOSED. |
| 30 void AddShelfItem(WmWindow* window); | 33 void AddShelfItem(WmWindow* window); |
| 31 | 34 |
| 32 // Adds a ShelfItem for the given |window| and adds a mapping from the added | 35 // Adds a ShelfItem for the given |window| and adds a mapping from the added |
| 33 // ShelfItem's ShelfID to the given |app_id|. The ShelfItem's status will be | 36 // ShelfItem's ShelfID to the given |app_id|. The ShelfItem's status will be |
| 34 // STATUS_CLOSED. | 37 // STATUS_CLOSED. |
| 35 void AddShelfItem(WmWindow* window, const std::string& app_id); | 38 void AddShelfItem(WmWindow* window, const std::string& app_id); |
| 36 | 39 |
| 37 // Adds a ShelfItem for the given |window| with the specified |status|. | 40 // Adds a ShelfItem for the given |window| with the specified |status|. |
| 38 void AddShelfItem(WmWindow* window, ShelfItemStatus status); | 41 void AddShelfItem(WmWindow* window, ShelfItemStatus status); |
| 39 | 42 |
| 40 // Removes the ShelfItem for the specified |window| and unpins it if it was | 43 // Removes the ShelfItem for the specified |window| and unpins it if it was |
| 41 // pinned. The |window|'s ShelfID to app id mapping will be removed if it | 44 // pinned. The |window|'s ShelfID to app id mapping will be removed if it |
| 42 // exists. | 45 // exists. |
| 43 void RemoveShelfItemForWindow(WmWindow* window); | 46 void RemoveShelfItemForWindow(WmWindow* window); |
| 44 | 47 |
| 45 static TestShelfDelegate* instance() { return instance_; } | 48 static TestShelfDelegate* instance() { return instance_; } |
| 46 | 49 |
| 47 // WindowObserver implementation | 50 // WindowObserver implementation |
| 48 void OnWindowDestroying(WmWindow* window) override; | 51 void OnWindowDestroying(aura::Window* window) override; |
| 49 void OnWindowTreeChanging(WmWindow* window, | 52 void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override; |
| 50 const TreeChangeParams& params) override; | |
| 51 | 53 |
| 52 // ShelfDelegate implementation. | 54 // ShelfDelegate implementation. |
| 53 ShelfID GetShelfIDForAppID(const std::string& app_id) override; | 55 ShelfID GetShelfIDForAppID(const std::string& app_id) override; |
| 54 ShelfID GetShelfIDForAppIDAndLaunchID(const std::string& app_id, | 56 ShelfID GetShelfIDForAppIDAndLaunchID(const std::string& app_id, |
| 55 const std::string& launch_id) override; | 57 const std::string& launch_id) override; |
| 56 bool HasShelfIDToAppIDMapping(ShelfID id) const override; | 58 bool HasShelfIDToAppIDMapping(ShelfID id) const override; |
| 57 const std::string& GetAppIDForShelfID(ShelfID id) override; | 59 const std::string& GetAppIDForShelfID(ShelfID id) override; |
| 58 void PinAppWithID(const std::string& app_id) override; | 60 void PinAppWithID(const std::string& app_id) override; |
| 59 bool IsAppPinned(const std::string& app_id) override; | 61 bool IsAppPinned(const std::string& app_id) override; |
| 60 void UnpinAppWithID(const std::string& app_id) override; | 62 void UnpinAppWithID(const std::string& app_id) override; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 75 // Tracks the ShelfID to app id mappings. | 77 // Tracks the ShelfID to app id mappings. |
| 76 std::map<ShelfID, std::string> shelf_id_to_app_id_map_; | 78 std::map<ShelfID, std::string> shelf_id_to_app_id_map_; |
| 77 | 79 |
| 78 DISALLOW_COPY_AND_ASSIGN(TestShelfDelegate); | 80 DISALLOW_COPY_AND_ASSIGN(TestShelfDelegate); |
| 79 }; | 81 }; |
| 80 | 82 |
| 81 } // namespace test | 83 } // namespace test |
| 82 } // namespace ash | 84 } // namespace ash |
| 83 | 85 |
| 84 #endif // ASH_COMMON_TEST_TEST_SHELF_DELEGATE_H_ | 86 #endif // ASH_COMMON_TEST_TEST_SHELF_DELEGATE_H_ |
| OLD | NEW |