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