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 "chrome_frame/test/ie_event_sink.h" | 5 #include "chrome_frame/test/ie_event_sink.h" |
6 | 6 |
7 #include <shlguid.h> | 7 #include <shlguid.h> |
8 #include <shobjidl.h> | 8 #include <shobjidl.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "base/stringprintf.h" | 16 #include "base/stringprintf.h" |
17 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
| 18 #include "base/test/test_timeouts.h" |
18 #include "base/time.h" | 19 #include "base/time.h" |
19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
20 #include "base/win/scoped_bstr.h" | 21 #include "base/win/scoped_bstr.h" |
21 #include "base/win/scoped_handle.h" | 22 #include "base/win/scoped_handle.h" |
22 #include "base/win/scoped_variant.h" | 23 #include "base/win/scoped_variant.h" |
23 #include "chrome_frame/test/chrome_frame_test_utils.h" | 24 #include "chrome_frame/test/chrome_frame_test_utils.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 | 26 |
26 using base::win::ScopedBstr; | 27 using base::win::ScopedBstr; |
27 | 28 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 EXPECT_HRESULT_SUCCEEDED( | 311 EXPECT_HRESULT_SUCCEEDED( |
311 chrome_frame_->postMessage(message_bstr, target_variant)); | 312 chrome_frame_->postMessage(message_bstr, target_variant)); |
312 } | 313 } |
313 | 314 |
314 void IEEventSink::SetFocusToRenderer() { | 315 void IEEventSink::SetFocusToRenderer() { |
315 simulate_input::SetKeyboardFocusToWindow(GetRendererWindow()); | 316 simulate_input::SetKeyboardFocusToWindow(GetRendererWindow()); |
316 } | 317 } |
317 | 318 |
318 void IEEventSink::SendKeys(const char* input_string) { | 319 void IEEventSink::SendKeys(const char* input_string) { |
319 HWND window = GetRendererWindow(); | 320 HWND window = GetRendererWindow(); |
320 const base::TimeDelta kMessageSleep = base::TimeDelta::FromMilliseconds(50); | 321 simulate_input::SetKeyboardFocusToWindow(window); |
| 322 const base::TimeDelta kMessageSleep = TestTimeouts::tiny_timeout(); |
321 const base::StringPiece codes(input_string); | 323 const base::StringPiece codes(input_string); |
322 for (size_t i = 0; i < codes.length(); ++i) { | 324 for (size_t i = 0; i < codes.length(); ++i) { |
323 char character = codes[i]; | 325 char character = codes[i]; |
324 UINT virtual_key = 0; | 326 UINT virtual_key = 0; |
325 | 327 |
326 if (character >= 'a' && character <= 'z') { | 328 if (character >= 'a' && character <= 'z') { |
327 // VK_A - VK_Z are ASCII 'A' - 'Z'. | 329 // VK_A - VK_Z are ASCII 'A' - 'Z'. |
328 virtual_key = 'A' + (character - 'a'); | 330 virtual_key = 'A' + (character - 'a'); |
329 } else if (character >= '0' && character <= '9') { | 331 } else if (character >= '0' && character <= '9') { |
330 // VK_0 - VK_9 are ASCII '0' - '9'. | 332 // VK_0 - VK_9 are ASCII '0' - '9'. |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 source.Receive(), NULL, NULL)); | 771 source.Receive(), NULL, NULL)); |
770 } | 772 } |
771 } | 773 } |
772 | 774 |
773 if (listener_) | 775 if (listener_) |
774 listener_->OnMessage(V_BSTR(&data), V_BSTR(&origin), V_BSTR(&source)); | 776 listener_->OnMessage(V_BSTR(&data), V_BSTR(&origin), V_BSTR(&source)); |
775 return S_OK; | 777 return S_OK; |
776 } | 778 } |
777 | 779 |
778 } // namespace chrome_frame_test | 780 } // namespace chrome_frame_test |
OLD | NEW |