Home | History | Annotate | Download | only in test
      1 // Copyright 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 #include "cc/test/fake_scrollbar.h"
      6 
      7 #include "third_party/skia/include/core/SkCanvas.h"
      8 
      9 namespace cc {
     10 
     11 FakeScrollbar::FakeScrollbar()
     12     : paint_(false),
     13       has_thumb_(false),
     14       is_overlay_(false),
     15       thumb_thickness_(10),
     16       thumb_length_(5),
     17       track_rect_(0, 0, 100, 10),
     18       fill_color_(SK_ColorGREEN) {}
     19 
     20 FakeScrollbar::FakeScrollbar(bool paint, bool has_thumb, bool is_overlay)
     21     : paint_(paint),
     22       has_thumb_(has_thumb),
     23       is_overlay_(is_overlay),
     24       thumb_thickness_(10),
     25       thumb_length_(5),
     26       track_rect_(0, 0, 100, 10),
     27       fill_color_(SK_ColorGREEN) {}
     28 
     29 FakeScrollbar::~FakeScrollbar() {}
     30 
     31 ScrollbarOrientation FakeScrollbar::Orientation() const {
     32   return HORIZONTAL;
     33 }
     34 
     35 bool FakeScrollbar::IsLeftSideVerticalScrollbar() const {
     36   return false;
     37 }
     38 
     39 gfx::Point FakeScrollbar::Location() const { return location_; }
     40 
     41 bool FakeScrollbar::IsOverlay() const { return is_overlay_; }
     42 
     43 bool FakeScrollbar::HasThumb() const { return has_thumb_; }
     44 
     45 int FakeScrollbar::ThumbThickness() const {
     46   return thumb_thickness_;
     47 }
     48 
     49 int FakeScrollbar::ThumbLength() const {
     50   return thumb_length_;
     51 }
     52 
     53 gfx::Rect FakeScrollbar::TrackRect() const {
     54   return track_rect_;
     55 }
     56 
     57 void FakeScrollbar::PaintPart(SkCanvas* canvas,
     58                              ScrollbarPart part,
     59                              gfx::Rect content_rect) {
     60   if (!paint_)
     61     return;
     62 
     63   // Fill the scrollbar with a different color each time.
     64   fill_color_++;
     65   canvas->clear(SK_ColorBLACK | fill_color_);
     66 }
     67 
     68 }  // namespace cc
     69