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_
12 #include "ash/shelf/shelf_delegate.h"
13 #include "base/compiler_specific.h"
14 #include "ui/aura/window_observer.h"
22 // Test implementation of ShelfDelegate.
23 // Tests may create icons for windows by calling AddShelfItem().
24 class TestShelfDelegate
: public ShelfDelegate
, public aura::WindowObserver
{
26 explicit TestShelfDelegate(ShelfModel
* model
);
27 ~TestShelfDelegate() override
;
29 // Adds a ShelfItem for the given |window|. The ShelfItem's status will be
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
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
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
;
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_
;
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
);
85 #endif // ASH_TEST_TEST_SHELF_DELEGATE_H_