| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/controls/scroll_view.h" | 5 #include "ui/views/controls/scroll_view.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/test/test_timeouts.h" | 9 #include "base/test/test_timeouts.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/views/border.h" | 12 #include "ui/views/border.h" |
| 13 #include "ui/views/controls/scrollbar/base_scroll_bar_thumb.h" | 13 #include "ui/views/controls/scrollbar/base_scroll_bar_thumb.h" |
| 14 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h" | 14 #include "ui/views/controls/scrollbar/overlay_scroll_bar.h" |
| 15 #include "ui/views/controls/scrollbar/scroll_bar_views.h" | 15 #include "ui/views/controls/scrollbar/scroll_bar_views.h" |
| 16 #include "ui/views/test/test_views.h" | 16 #include "ui/views/test/test_views.h" |
| 17 #include "ui/views/test/views_test_base.h" |
| 17 #include "ui/views/test/widget_test.h" | 18 #include "ui/views/test/widget_test.h" |
| 18 | 19 |
| 19 #if defined(OS_MACOSX) | 20 #if defined(OS_MACOSX) |
| 20 #include "ui/base/test/scoped_preferred_scroller_style_mac.h" | 21 #include "ui/base/test/scoped_preferred_scroller_style_mac.h" |
| 21 #endif | 22 #endif |
| 22 | 23 |
| 23 enum ScrollBarOrientation { HORIZONTAL, VERTICAL }; | 24 enum ScrollBarOrientation { HORIZONTAL, VERTICAL }; |
| 24 | 25 |
| 25 namespace views { | 26 namespace views { |
| 26 namespace test { | 27 namespace test { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 ui::MouseEvent TestLeftMouseAt(const gfx::Point& location, ui::EventType type) { | 122 ui::MouseEvent TestLeftMouseAt(const gfx::Point& location, ui::EventType type) { |
| 122 return ui::MouseEvent(type, location, location, base::TimeTicks(), | 123 return ui::MouseEvent(type, location, location, base::TimeTicks(), |
| 123 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); | 124 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); |
| 124 } | 125 } |
| 125 | 126 |
| 126 } // namespace | 127 } // namespace |
| 127 | 128 |
| 128 using test::ScrollViewTestApi; | 129 using test::ScrollViewTestApi; |
| 129 | 130 |
| 130 // Simple test harness for testing a ScrollView directly. | 131 // Simple test harness for testing a ScrollView directly. |
| 131 class ScrollViewTest : public testing::Test { | 132 class ScrollViewTest : public ViewsTestBase { |
| 132 public: | 133 public: |
| 133 ScrollViewTest() {} | 134 ScrollViewTest() {} |
| 134 | 135 |
| 135 View* InstallContents() { | 136 View* InstallContents() { |
| 136 const gfx::Rect default_outer_bounds(0, 0, 100, 100); | 137 const gfx::Rect default_outer_bounds(0, 0, 100, 100); |
| 137 View* contents = new View; | 138 View* contents = new View; |
| 138 scroll_view_.SetContents(contents); | 139 scroll_view_.SetContents(contents); |
| 139 scroll_view_.SetBoundsRect(default_outer_bounds); | 140 scroll_view_.SetBoundsRect(default_outer_bounds); |
| 140 return contents; | 141 return contents; |
| 141 } | 142 } |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 // Scroll via ScrollView API. Should be reflected on the impl side. | 889 // Scroll via ScrollView API. Should be reflected on the impl side. |
| 889 offset.set_y(kDefaultHeight * 4); | 890 offset.set_y(kDefaultHeight * 4); |
| 890 scroll_view->contents()->ScrollRectToVisible(offset); | 891 scroll_view->contents()->ScrollRectToVisible(offset); |
| 891 EXPECT_EQ(gfx::ScrollOffset(0, offset.y()), test_api.CurrentOffset()); | 892 EXPECT_EQ(gfx::ScrollOffset(0, offset.y()), test_api.CurrentOffset()); |
| 892 | 893 |
| 893 EXPECT_TRUE(compositor->GetScrollOffsetForLayer(layer_id, &impl_offset)); | 894 EXPECT_TRUE(compositor->GetScrollOffsetForLayer(layer_id, &impl_offset)); |
| 894 EXPECT_EQ(gfx::ScrollOffset(0, offset.y()), impl_offset); | 895 EXPECT_EQ(gfx::ScrollOffset(0, offset.y()), impl_offset); |
| 895 } | 896 } |
| 896 | 897 |
| 897 } // namespace views | 898 } // namespace views |
| OLD | NEW |