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
3 // found in the LICENSE file.
5 #ifndef ASH_TEST_SHELF_VIEW_TEST_API_H_
6 #define ASH_TEST_SHELF_VIEW_TEST_API_H_
8 #include "ash/shelf/shelf_item_delegate.h"
9 #include "ash/shelf/shelf_item_types.h"
10 #include "base/basictypes.h"
28 class ShelfButtonPressedMetricTracker
;
34 // Use the api in this class to test ShelfView.
35 class ShelfViewTestAPI
{
37 explicit ShelfViewTestAPI(ShelfView
* shelf_view
);
40 // Number of icons displayed.
43 // Retrieve the button at |index|.
44 ShelfButton
* GetButton(int index
);
46 // First visible button index.
47 int GetFirstVisibleIndex();
49 // Last visible button index.
50 int GetLastVisibleIndex();
52 // Gets current/ideal bounds for button at |index|.
53 const gfx::Rect
& GetBoundsByIndex(int index
);
54 const gfx::Rect
& GetIdealBoundsByIndex(int index
);
56 // Returns true if overflow button is visible.
57 bool IsOverflowButtonVisible();
59 // Makes shelf view show its overflow bubble.
60 void ShowOverflowBubble();
62 // Sets animation duration in milliseconds for test.
63 void SetAnimationDuration(int duration_ms
);
65 // Runs message loop and waits until all add/remove animations are done.
66 void RunMessageLoopUntilAnimationsDone();
68 // An accessor for |shelf_view|.
69 ShelfView
* shelf_view() { return shelf_view_
; }
71 // An accessor for overflow bubble.
72 OverflowBubble
* overflow_bubble();
74 // Returns the preferred size of |shelf_view_|.
75 gfx::Size
GetPreferredSize();
77 // Returns the button size.
80 // Returns the button space size.
81 int GetButtonSpacing();
83 // Wrapper for ShelfView::ButtonPressed.
84 void ButtonPressed(views::Button
* sender
, const ui::Event
& event
);
86 // Wrapper for ShelfView::SameDragType.
87 bool SameDragType(ShelfItemType typea
, ShelfItemType typeb
) const;
89 // Sets ShelfDelegate.
90 void SetShelfDelegate(ShelfDelegate
* delegate
);
92 // Returns re-insertable bounds in screen.
93 gfx::Rect
GetBoundsForDragInsertInScreen();
95 // Returns true if item is ripped off.
96 bool IsRippedOffFromShelf();
98 // Returns true if an item is ripped off and entered into shelf.
99 bool DraggedItemFromOverflowToShelf();
101 // An accessor for |shelf_button_pressed_metric_tracker_|.
102 ShelfButtonPressedMetricTracker
* shelf_button_pressed_metric_tracker();
105 ShelfView
* shelf_view_
;
107 DISALLOW_COPY_AND_ASSIGN(ShelfViewTestAPI
);
113 #endif // ASH_TEST_SHELF_VIEW_TEST_API_H_