| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "base/string16.h" | 6 #include "base/string16.h" |
| 7 #include "chrome/test/base/render_view_test.h" | |
| 8 #include "content/common/native_web_keyboard_event.h" | 7 #include "content/common/native_web_keyboard_event.h" |
| 9 #include "content/renderer/render_view_impl.h" | 8 #include "content/renderer/render_view_impl.h" |
| 9 #include "content/test/render_view_test.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 #include <Cocoa/Cocoa.h> | 12 #include <Cocoa/Cocoa.h> |
| 13 #include <Carbon/Carbon.h> // for the kVK_* constants. | 13 #include <Carbon/Carbon.h> // for the kVK_* constants. |
| 14 | 14 |
| 15 NSEvent* CmdDeadKeyEvent(NSEventType type, unsigned short code) { | 15 NSEvent* CmdDeadKeyEvent(NSEventType type, unsigned short code) { |
| 16 UniChar uniChar = 0; | 16 UniChar uniChar = 0; |
| 17 switch(code) { | 17 switch(code) { |
| 18 case kVK_UpArrow: | 18 case kVK_UpArrow: |
| 19 uniChar = NSUpArrowFunctionKey; | 19 uniChar = NSUpArrowFunctionKey; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 33 windowNumber:0 | 33 windowNumber:0 |
| 34 context:nil | 34 context:nil |
| 35 characters:s | 35 characters:s |
| 36 charactersIgnoringModifiers:s | 36 charactersIgnoringModifiers:s |
| 37 isARepeat:NO | 37 isARepeat:NO |
| 38 keyCode:code]; | 38 keyCode:code]; |
| 39 } | 39 } |
| 40 | 40 |
| 41 // Test that cmd-up/down scrolls the page exactly if it is not intercepted by | 41 // Test that cmd-up/down scrolls the page exactly if it is not intercepted by |
| 42 // javascript. | 42 // javascript. |
| 43 TEST_F(RenderViewTest, MacTestCmdUp) { | 43 TEST_F(content::RenderViewTest, MacTestCmdUp) { |
| 44 // Some preprocessor trickery so that we can have literal html in our source, | 44 // Some preprocessor trickery so that we can have literal html in our source, |
| 45 // makes it easier to copy html to and from an html file for testing (the | 45 // makes it easier to copy html to and from an html file for testing (the |
| 46 // preprocessor will remove the newlines at the line ends, turning this into | 46 // preprocessor will remove the newlines at the line ends, turning this into |
| 47 // a single long line). | 47 // a single long line). |
| 48 #define HTML(s) #s | 48 #define HTML(s) #s |
| 49 const char* kRawHtml = HTML( | 49 const char* kRawHtml = HTML( |
| 50 <html> | 50 <html> |
| 51 <head><title></title> | 51 <head><title></title> |
| 52 <script type='text/javascript' language='javascript'> | 52 <script type='text/javascript' language='javascript'> |
| 53 function OnKeyEvent(ev) { | 53 function OnKeyEvent(ev) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 const char* kArrowUpNoScroll = | 137 const char* kArrowUpNoScroll = |
| 138 "38,false,false,true,false\np1\n\np2"; | 138 "38,false,false,true,false\np1\n\np2"; |
| 139 view->OnSetEditCommandsForNextKeyEvent( | 139 view->OnSetEditCommandsForNextKeyEvent( |
| 140 EditCommands(1, EditCommand("moveToBeginningOfDocument", ""))); | 140 EditCommands(1, EditCommand("moveToBeginningOfDocument", ""))); |
| 141 SendNativeKeyEvent(NativeWebKeyboardEvent(arrowUpKeyDown)); | 141 SendNativeKeyEvent(NativeWebKeyboardEvent(arrowUpKeyDown)); |
| 142 ProcessPendingMessages(); | 142 ProcessPendingMessages(); |
| 143 output = GetMainFrame()->contentAsText(kMaxOutputCharacters); | 143 output = GetMainFrame()->contentAsText(kMaxOutputCharacters); |
| 144 EXPECT_EQ(kArrowUpNoScroll, UTF16ToASCII(output)); | 144 EXPECT_EQ(kArrowUpNoScroll, UTF16ToASCII(output)); |
| 145 } | 145 } |
| 146 | 146 |
| OLD | NEW |