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.
4
5#ifndef ASH_TEST_SHELF_VIEW_TEST_API_H_
6#define ASH_TEST_SHELF_VIEW_TEST_API_H_
7
8#include "ash/shelf/shelf_item_types.h"
9#include "base/basictypes.h"
10
11namespace gfx {
12class Rect;
13class Size;
14}
15
16namespace ui {
17class Event;
18}
19
20namespace views {
21class Button;
22}
23
24namespace ash {
25class OverflowBubble;
26class ShelfButton;
27class ShelfDelegate;
28class ShelfView;
29
30namespace test {
31
32// Use the api in this class to test ShelfView.
33class ShelfViewTestAPI {
34 public:
35  explicit ShelfViewTestAPI(ShelfView* shelf_view);
36  ~ShelfViewTestAPI();
37
38  // Number of icons displayed.
39  int GetButtonCount();
40
41  // Retrieve the button at |index|.
42  ShelfButton* GetButton(int index);
43
44  // First visible button index.
45  int GetFirstVisibleIndex();
46
47  // Last visible button index.
48  int GetLastVisibleIndex();
49
50  // Gets current/ideal bounds for button at |index|.
51  const gfx::Rect& GetBoundsByIndex(int index);
52  const gfx::Rect& GetIdealBoundsByIndex(int index);
53
54  // Returns true if overflow button is visible.
55  bool IsOverflowButtonVisible();
56
57  // Makes shelf view show its overflow bubble.
58  void ShowOverflowBubble();
59
60  // Sets animation duration in milliseconds for test.
61  void SetAnimationDuration(int duration_ms);
62
63  // Runs message loop and waits until all add/remove animations are done.
64  void RunMessageLoopUntilAnimationsDone();
65
66  // An accessor for |shelf_view|.
67  ShelfView* shelf_view() { return shelf_view_; }
68
69  // An accessor for overflow bubble.
70  OverflowBubble* overflow_bubble();
71
72  // Returns the preferred size of |shelf_view_|.
73  gfx::Size GetPreferredSize();
74
75  // Returns the button size.
76  int GetButtonSize();
77
78  // Returns the button space size.
79  int GetButtonSpacing();
80
81  // Wrapper for ShelfView::ButtonPressed.
82  void ButtonPressed(views::Button* sender, const ui::Event& event);
83
84  // Wrapper for ShelfView::SameDragType.
85  bool SameDragType(ShelfItemType typea, ShelfItemType typeb) const;
86
87  // Sets ShelfDelegate.
88  void SetShelfDelegate(ShelfDelegate* delegate);
89
90  // Returns re-insertable bounds in screen.
91  gfx::Rect GetBoundsForDragInsertInScreen();
92
93  // Returns true if item is ripped off.
94  bool IsRippedOffFromShelf();
95
96  // Returns true if an item is ripped off and entered into shelf.
97  bool DraggedItemFromOverflowToShelf();
98
99 private:
100  ShelfView* shelf_view_;
101
102  DISALLOW_COPY_AND_ASSIGN(ShelfViewTestAPI);
103};
104
105}  // namespace test
106}  // namespace ash
107
108#endif  // ASH_TEST_SHELF_VIEW_TEST_API_H_
109