Home | History | Annotate | Download | only in corewm
      1 // Copyright (c) 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.
      4 
      5 #ifndef UI_VIEWS_COREWM_TOOLTIP_CONTROLLER_TEST_HELPER_H_
      6 #define UI_VIEWS_COREWM_TOOLTIP_CONTROLLER_TEST_HELPER_H_
      7 
      8 #include "base/logging.h"
      9 #include "base/strings/string16.h"
     10 #include "ui/views/view.h"
     11 #include "ui/views/views_export.h"
     12 
     13 namespace aura {
     14 class Window;
     15 }
     16 
     17 namespace views {
     18 namespace corewm {
     19 
     20 class TooltipController;
     21 
     22 namespace test {
     23 
     24 // TooltipControllerTestHelper provides access to TooltipControllers private
     25 // state.
     26 class TooltipControllerTestHelper {
     27  public:
     28   explicit TooltipControllerTestHelper(TooltipController* controller);
     29   ~TooltipControllerTestHelper();
     30 
     31   TooltipController* controller() { return controller_; }
     32 
     33   // These are mostly cover methods for TooltipController private methods.
     34   string16 GetTooltipText();
     35   aura::Window* GetTooltipWindow();
     36   void FireTooltipTimer();
     37   bool IsTooltipTimerRunning();
     38   void FireTooltipShownTimer();
     39   bool IsTooltipShownTimerRunning();
     40   bool IsTooltipVisible();
     41   static void TrimTooltipToFit(int max_width,
     42                                string16* text,
     43                                int* width,
     44                                int* line_count);
     45 
     46  private:
     47   TooltipController* controller_;
     48 
     49   DISALLOW_COPY_AND_ASSIGN(TooltipControllerTestHelper);
     50 };
     51 
     52 // Trivial View subclass that lets you set the tooltip text.
     53 class TooltipTestView : public views::View {
     54  public:
     55   TooltipTestView();
     56   virtual ~TooltipTestView();
     57 
     58   void set_tooltip_text(string16 tooltip_text) { tooltip_text_ = tooltip_text; }
     59 
     60   // Overridden from views::View
     61   virtual bool GetTooltipText(const gfx::Point& p,
     62                               string16* tooltip) const OVERRIDE;
     63 
     64  private:
     65   string16 tooltip_text_;
     66 
     67   DISALLOW_COPY_AND_ASSIGN(TooltipTestView);
     68 };
     69 
     70 
     71 }  // namespace test
     72 }  // namespace corewm
     73 }  // namespace views
     74 
     75 #endif  // UI_VIEWS_COREWM_TOOLTIP_CONTROLLER_TEST_HELPER_H_
     76