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/basictypes.h" | 5 #include "base/basictypes.h" |
6 | 6 |
7 #include "base/memory/shared_memory.h" | 7 #include "base/memory/shared_memory.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
(...skipping 2056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2067 view()->OnNavigate(params); | 2067 view()->OnNavigate(params); |
2068 | 2068 |
2069 // An error occurred. | 2069 // An error occurred. |
2070 view()->didFailProvisionalLoad(web_frame, error); | 2070 view()->didFailProvisionalLoad(web_frame, error); |
2071 ProcessPendingMessages(); | 2071 ProcessPendingMessages(); |
2072 const int kMaxOutputCharacters = 22; | 2072 const int kMaxOutputCharacters = 22; |
2073 EXPECT_EQ("A suffusion of yellow.", | 2073 EXPECT_EQ("A suffusion of yellow.", |
2074 UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); | 2074 UTF16ToASCII(web_frame->contentAsText(kMaxOutputCharacters))); |
2075 } | 2075 } |
2076 | 2076 |
| 2077 // Tests if IME API's candidatewindow* events sent from browser are handled |
| 2078 // in renderer. |
| 2079 TEST_F(RenderViewImplTest, SendCandidateWindowEvents) { |
| 2080 // Sends an HTML with an <input> element and scripts to the renderer. |
| 2081 // The script handles all 3 of candidatewindow* events for an |
| 2082 // InputMethodContext object and once it received 'show', 'update', 'hide' |
| 2083 // should appear in the result div. |
| 2084 LoadHTML("<input id='test'>" |
| 2085 "<div id='result'>Result: </div>" |
| 2086 "<script>" |
| 2087 "window.onload = function() {" |
| 2088 " var result = document.getElementById('result');" |
| 2089 " var test = document.getElementById('test');" |
| 2090 " test.focus();" |
| 2091 " var context = test.inputMethodContext;" |
| 2092 " if (context) {" |
| 2093 " context.oncandidatewindowshow = function() {" |
| 2094 " result.innerText += 'show'; };" |
| 2095 " context.oncandidatewindowupdate = function(){" |
| 2096 " result.innerText += 'update'; };" |
| 2097 " context.oncandidatewindowhide = function(){" |
| 2098 " result.innerText += 'hide'; };" |
| 2099 " }" |
| 2100 "};" |
| 2101 "</script>"); |
| 2102 |
| 2103 // Fire candidatewindow events. |
| 2104 view()->OnCandidateWindowShown(); |
| 2105 view()->OnCandidateWindowUpdated(); |
| 2106 view()->OnCandidateWindowHidden(); |
| 2107 |
| 2108 // Retrieve the content and check if it is expected. |
| 2109 const int kMaxOutputCharacters = 50; |
| 2110 std::string output = UTF16ToUTF8( |
| 2111 GetMainFrame()->contentAsText(kMaxOutputCharacters)); |
| 2112 EXPECT_EQ(output, "\nResult:showupdatehide"); |
| 2113 } |
| 2114 |
2077 } // namespace content | 2115 } // namespace content |
OLD | NEW |