Home | History | Annotate | Download | only in tests
      1 // Copyright (c) 2011 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 "ppapi/tests/test_scrollbar.h"
      6 
      7 #include <cstring>
      8 
      9 #include "ppapi/c/pp_input_event.h"
     10 #include "ppapi/cpp/input_event.h"
     11 #include "ppapi/cpp/instance.h"
     12 #include "ppapi/cpp/rect.h"
     13 #include "ppapi/tests/testing_instance.h"
     14 
     15 REGISTER_TEST_CASE(Scrollbar);
     16 
     17 TestScrollbar::TestScrollbar(TestingInstance* instance)
     18     : TestCase(instance),
     19       WidgetClient_Dev(instance),
     20       scrollbar_(instance, true),
     21       scrollbar_value_changed_(false) {
     22 }
     23 
     24 bool TestScrollbar::Init() {
     25   return CheckTestingInterface();
     26 }
     27 
     28 void TestScrollbar::RunTests(const std::string& filter) {
     29   RUN_TEST(HandleEvent, filter);
     30 }
     31 
     32 std::string TestScrollbar::TestHandleEvent() {
     33   pp::Rect location;
     34   location.set_width(1000);
     35   location.set_height(1000);
     36   scrollbar_.SetLocation(location);
     37 
     38   scrollbar_.SetDocumentSize(10000);
     39 
     40   pp::Core* core = pp::Module::Get()->core();
     41   pp::KeyboardInputEvent input_event(
     42       instance_, PP_INPUTEVENT_TYPE_KEYDOWN,
     43       core->GetTimeTicks(),
     44       0,  // Modifier.
     45       0x28,  // Key code = VKEY_DOWN.
     46       pp::Var());
     47   scrollbar_.HandleEvent(input_event);
     48 
     49   return scrollbar_value_changed_ ?
     50       "" : "Didn't get callback for scrollbar value change";
     51 }
     52 
     53 void TestScrollbar::InvalidateWidget(pp::Widget_Dev widget,
     54                                      const pp::Rect& dirty_rect) {
     55 }
     56 
     57 void TestScrollbar::ScrollbarValueChanged(pp::Scrollbar_Dev scrollbar,
     58                                           uint32_t value) {
     59   if (scrollbar == scrollbar_)
     60     scrollbar_value_changed_ = true;
     61 }
     62 
     63 void TestScrollbar::ScrollbarOverlayChanged(pp::Scrollbar_Dev scrollbar,
     64                                             bool type) {
     65 }
     66