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