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 "base/strings/string16.h" | 5 #include "base/strings/string16.h" |
6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
7 #include "content/public/browser/native_web_keyboard_event.h" | 7 #include "content/public/browser/native_web_keyboard_event.h" |
8 #include "content/public/test/render_view_test.h" | 8 #include "content/public/test/render_view_test.h" |
9 #include "content/renderer/render_view_impl.h" | 9 #include "content/renderer/render_view_impl.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 ); | 79 ); |
80 #undef HTML | 80 #undef HTML |
81 | 81 |
82 WebPreferences prefs; | 82 WebPreferences prefs; |
83 prefs.enable_scroll_animator = false; | 83 prefs.enable_scroll_animator = false; |
84 | 84 |
85 RenderViewImpl* view = static_cast<RenderViewImpl*>(view_); | 85 RenderViewImpl* view = static_cast<RenderViewImpl*>(view_); |
86 view->OnUpdateWebPreferences(prefs); | 86 view->OnUpdateWebPreferences(prefs); |
87 | 87 |
88 const int kMaxOutputCharacters = 1024; | 88 const int kMaxOutputCharacters = 1024; |
89 string16 output; | 89 base::string16 output; |
90 | 90 |
91 NSEvent* arrowDownKeyDown = CmdDeadKeyEvent(NSKeyDown, kVK_DownArrow); | 91 NSEvent* arrowDownKeyDown = CmdDeadKeyEvent(NSKeyDown, kVK_DownArrow); |
92 NSEvent* arrowUpKeyDown = CmdDeadKeyEvent(NSKeyDown, kVK_UpArrow); | 92 NSEvent* arrowUpKeyDown = CmdDeadKeyEvent(NSKeyDown, kVK_UpArrow); |
93 | 93 |
94 // First test when javascript does not eat keypresses -- should scroll. | 94 // First test when javascript does not eat keypresses -- should scroll. |
95 view->set_send_content_state_immediately(true); | 95 view->set_send_content_state_immediately(true); |
96 LoadHTML(kRawHtml); | 96 LoadHTML(kRawHtml); |
97 render_thread_->sink().ClearMessages(); | 97 render_thread_->sink().ClearMessages(); |
98 | 98 |
99 const char* kArrowDownScrollDown = "40,false,false,true,false\n10144\np1"; | 99 const char* kArrowDownScrollDown = "40,false,false,true,false\n10144\np1"; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 view->OnSetEditCommandsForNextKeyEvent( | 132 view->OnSetEditCommandsForNextKeyEvent( |
133 EditCommands(1, EditCommand("moveToBeginningOfDocument", ""))); | 133 EditCommands(1, EditCommand("moveToBeginningOfDocument", ""))); |
134 SendNativeKeyEvent(NativeWebKeyboardEvent(arrowUpKeyDown)); | 134 SendNativeKeyEvent(NativeWebKeyboardEvent(arrowUpKeyDown)); |
135 ProcessPendingMessages(); | 135 ProcessPendingMessages(); |
136 ExecuteJavaScript("scroll.textContent = window.pageYOffset"); | 136 ExecuteJavaScript("scroll.textContent = window.pageYOffset"); |
137 output = GetMainFrame()->contentAsText(kMaxOutputCharacters); | 137 output = GetMainFrame()->contentAsText(kMaxOutputCharacters); |
138 EXPECT_EQ(kArrowUpNoScroll, UTF16ToASCII(output)); | 138 EXPECT_EQ(kArrowUpNoScroll, UTF16ToASCII(output)); |
139 } | 139 } |
140 | 140 |
141 } // namespace content | 141 } // namespace content |
OLD | NEW |