Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ash / test / test_shelf_delegate.h
blob342d1445a1ffc4393167f346d9e9d4fc94aa1ddc
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
3 // found in the LICENSE file.
5 #ifndef ASH_TEST_TEST_SHELF_DELEGATE_H_
6 #define ASH_TEST_TEST_SHELF_DELEGATE_H_
8 #include <map>
9 #include <set>
10 #include <string>
12 #include "ash/shelf/shelf_delegate.h"
13 #include "base/compiler_specific.h"
14 #include "ui/aura/window_observer.h"
16 namespace ash {
18 class ShelfModel;
20 namespace test {
22 // Test implementation of ShelfDelegate.
23 // Tests may create icons for windows by calling AddShelfItem().
24 class TestShelfDelegate : public ShelfDelegate, public aura::WindowObserver {
25 public:
26 explicit TestShelfDelegate(ShelfModel* model);
27 ~TestShelfDelegate() override;
29 // Adds a ShelfItem for the given |window|. The ShelfItem's status will be
30 // STATUS_CLOSED.
31 void AddShelfItem(aura::Window* window);
33 // Adds a ShelfItem for the given |window| and adds a mapping from the added
34 // ShelfItem's ShelfID to the given |app_id|. The ShelfItem's status will be
35 // STATUS_CLOSED.
36 void AddShelfItem(aura::Window* window, const std::string& app_id);
38 // Adds a ShelfItem for the given |window| with the specified |status|.
39 void AddShelfItem(aura::Window* window, ShelfItemStatus status);
41 // Removes the ShelfItem for the specified |window| and unpins it if it was
42 // pinned. The |window|'s ShelfID to app id mapping will be removed if it
43 // exists.
44 void RemoveShelfItemForWindow(aura::Window* window);
46 static TestShelfDelegate* instance() { return instance_; }
48 // WindowObserver implementation
49 void OnWindowDestroying(aura::Window* window) override;
50 void OnWindowHierarchyChanging(const HierarchyChangeParams& params) override;
52 // ShelfDelegate implementation.
53 void OnShelfCreated(Shelf* shelf) override;
54 void OnShelfDestroyed(Shelf* shelf) override;
55 ShelfID GetShelfIDForAppID(const std::string& app_id) override;
56 bool HasShelfIDToAppIDMapping(ShelfID id) const override;
57 const std::string& GetAppIDForShelfID(ShelfID id) override;
58 void PinAppWithID(const std::string& app_id) override;
59 bool CanPin() const override;
60 bool IsAppPinned(const std::string& app_id) override;
61 void UnpinAppWithID(const std::string& app_id) override;
63 private:
64 // Adds a mapping from a ShelfID to an app id.
65 void AddShelfIDToAppIDMapping(ShelfID shelf_id, const std::string& app_id);
67 // Removes the mapping from a ShelfID to an app id.
68 void RemoveShelfIDToAppIDMapping(ShelfID shelf_id);
70 static TestShelfDelegate* instance_;
72 ShelfModel* model_;
74 std::set<std::string> pinned_apps_;
76 // Tracks the ShelfID to app id mappings.
77 std::map<ShelfID, std::string> shelf_id_to_app_id_map_;
79 DISALLOW_COPY_AND_ASSIGN(TestShelfDelegate);
82 } // namespace test
83 } // namespace ash
85 #endif // ASH_TEST_TEST_SHELF_DELEGATE_H_