| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/mac/scoped_smooth_scrolling_disabler_mac.h" |
| 5 #include "base/string_util.h" | 6 #include "base/string_util.h" |
| 6 #include "base/string16.h" | 7 #include "base/string16.h" |
| 7 #include "chrome/test/base/render_view_test.h" | 8 #include "chrome/test/base/render_view_test.h" |
| 8 #include "content/common/native_web_keyboard_event.h" | 9 #include "content/common/native_web_keyboard_event.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 11 |
| 11 #include <Cocoa/Cocoa.h> | 12 #include <Cocoa/Cocoa.h> |
| 12 #include <Carbon/Carbon.h> // for the kVK_* constants. | 13 #include <Carbon/Carbon.h> // for the kVK_* constants. |
| 13 | 14 |
| 14 NSEvent* CmdDeadKeyEvent(NSEventType type, unsigned short code) { | 15 NSEvent* CmdDeadKeyEvent(NSEventType type, unsigned short code) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 onkeydown='return OnKeyEvent(event);'> | 74 onkeydown='return OnKeyEvent(event);'> |
| 74 <div id='keydown' contenteditable='true'> </div> | 75 <div id='keydown' contenteditable='true'> </div> |
| 75 <div id='scroll' contenteditable='true'> </div> | 76 <div id='scroll' contenteditable='true'> </div> |
| 76 <p>p1 | 77 <p>p1 |
| 77 <p>p2 | 78 <p>p2 |
| 78 </body> | 79 </body> |
| 79 </html> | 80 </html> |
| 80 ); | 81 ); |
| 81 #undef HTML | 82 #undef HTML |
| 82 | 83 |
| 84 base::ScopedSmoothScrollingDisabler disable_smooth_scrolling; |
| 85 |
| 83 const int kMaxOutputCharacters = 1024; | 86 const int kMaxOutputCharacters = 1024; |
| 84 string16 output; | 87 string16 output; |
| 85 char htmlBuffer[2048]; | 88 char htmlBuffer[2048]; |
| 86 | 89 |
| 87 NSEvent* arrowDownKeyDown = CmdDeadKeyEvent(NSKeyDown, kVK_DownArrow); | 90 NSEvent* arrowDownKeyDown = CmdDeadKeyEvent(NSKeyDown, kVK_DownArrow); |
| 88 NSEvent* arrowUpKeyDown = CmdDeadKeyEvent(NSKeyDown, kVK_UpArrow); | 91 NSEvent* arrowUpKeyDown = CmdDeadKeyEvent(NSKeyDown, kVK_UpArrow); |
| 89 | 92 |
| 90 // First test when javascript does not eat keypresses -- should scroll. | 93 // First test when javascript does not eat keypresses -- should scroll. |
| 91 sprintf(htmlBuffer, kRawHtml, "true"); | 94 sprintf(htmlBuffer, kRawHtml, "true"); |
| 92 view_->set_send_content_state_immediately(true); | 95 view_->set_send_content_state_immediately(true); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 const char* kArrowUpNoScroll = | 133 const char* kArrowUpNoScroll = |
| 131 "38,false,false,true,false\np1\n\np2"; | 134 "38,false,false,true,false\np1\n\np2"; |
| 132 view_->OnSetEditCommandsForNextKeyEvent( | 135 view_->OnSetEditCommandsForNextKeyEvent( |
| 133 EditCommands(1, EditCommand("moveToBeginningOfDocument", ""))); | 136 EditCommands(1, EditCommand("moveToBeginningOfDocument", ""))); |
| 134 SendNativeKeyEvent(NativeWebKeyboardEvent(arrowUpKeyDown)); | 137 SendNativeKeyEvent(NativeWebKeyboardEvent(arrowUpKeyDown)); |
| 135 ProcessPendingMessages(); | 138 ProcessPendingMessages(); |
| 136 output = GetMainFrame()->contentAsText(kMaxOutputCharacters); | 139 output = GetMainFrame()->contentAsText(kMaxOutputCharacters); |
| 137 EXPECT_EQ(kArrowUpNoScroll, UTF16ToASCII(output)); | 140 EXPECT_EQ(kArrowUpNoScroll, UTF16ToASCII(output)); |
| 138 } | 141 } |
| 139 | 142 |
| OLD | NEW |