diff options
Diffstat (limited to 'ppapi/tests/test_scrollbar.cc')
-rw-r--r-- | ppapi/tests/test_scrollbar.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/ppapi/tests/test_scrollbar.cc b/ppapi/tests/test_scrollbar.cc new file mode 100644 index 0000000..fc5bd9d --- /dev/null +++ b/ppapi/tests/test_scrollbar.cc @@ -0,0 +1,50 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ppapi/tests/test_scrollbar.h" + +#include "ppapi/c/pp_input_event.h" +#include "ppapi/cpp/instance.h" +#include "ppapi/cpp/rect.h" +#include "ppapi/tests/testing_instance.h" + +REGISTER_TEST_CASE(Scrollbar); + +TestScrollbar::TestScrollbar(TestingInstance* instance) + : TestCase(instance), + WidgetClient_Dev(instance), + scrollbar_(*instance, true), + scrollbar_value_changed_(false) { +} + +void TestScrollbar::RunTest() { + instance_->LogTest("HandleEvent", TestHandleEvent()); +} + +std::string TestScrollbar::TestHandleEvent() { + pp::Rect location; + location.set_width(1000); + location.set_height(1000); + scrollbar_.SetLocation(location); + + scrollbar_.SetDocumentSize(10000); + + PP_InputEvent event; + event.type = PP_INPUTEVENT_TYPE_KEYDOWN; + event.u.key.key_code = 0x28; // VKEY_DOWN + scrollbar_.HandleEvent(event); + + return scrollbar_value_changed_ ? + "" : "Didn't get callback for scrollbar value change"; +} + +void TestScrollbar::InvalidateWidget(pp::Widget_Dev widget, + const pp::Rect& dirty_rect) { +} + +void TestScrollbar::ScrollbarValueChanged(pp::Scrollbar_Dev scrollbar, + uint32_t value) { + if (scrollbar == scrollbar_) + scrollbar_value_changed_ = true; +} |