OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/chrome_frame_test_utils.h" | 5 #include "chrome_frame/test/chrome_frame_test_utils.h" |
6 | 6 |
7 #include <atlbase.h> | 7 #include <atlbase.h> |
8 #include <atlwin.h> | 8 #include <atlwin.h> |
9 #include <iepmapi.h> | 9 #include <iepmapi.h> |
10 | 10 |
| 11 #include "base/message_loop.h" |
11 #include "base/registry.h" // to find IE and firefox | 12 #include "base/registry.h" // to find IE and firefox |
12 #include "base/scoped_handle.h" | 13 #include "base/scoped_handle.h" |
13 #include "base/scoped_comptr_win.h" | 14 #include "base/scoped_comptr_win.h" |
14 #include "base/string_util.h" | 15 #include "base/string_util.h" |
15 #include "base/win_util.h" | 16 #include "base/win_util.h" |
16 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" |
17 | 19 |
18 namespace chrome_frame_test { | 20 namespace chrome_frame_test { |
19 | 21 |
20 const wchar_t kIEImageName[] = L"iexplore.exe"; | 22 const wchar_t kIEImageName[] = L"iexplore.exe"; |
21 const wchar_t kIEBrokerImageName[] = L"ieuser.exe"; | 23 const wchar_t kIEBrokerImageName[] = L"ieuser.exe"; |
22 const wchar_t kFirefoxImageName[] = L"firefox.exe"; | 24 const wchar_t kFirefoxImageName[] = L"firefox.exe"; |
23 const wchar_t kOperaImageName[] = L"opera.exe"; | 25 const wchar_t kOperaImageName[] = L"opera.exe"; |
24 const wchar_t kSafariImageName[] = L"safari.exe"; | 26 const wchar_t kSafariImageName[] = L"safari.exe"; |
25 const wchar_t kChromeImageName[] = L"chrome.exe"; | 27 const wchar_t kChromeImageName[] = L"chrome.exe"; |
26 | 28 |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 browser->Quit(); | 407 browser->Quit(); |
406 ++ret; | 408 ++ret; |
407 } | 409 } |
408 } | 410 } |
409 } | 411 } |
410 } | 412 } |
411 | 413 |
412 return ret; | 414 return ret; |
413 } | 415 } |
414 | 416 |
| 417 void ShowChromeFrameContextMenuTask() { |
| 418 static const int kChromeFrameContextMenuTimeout = 500; |
| 419 HWND renderer_window = GetChromeRendererWindow(); |
| 420 EXPECT_TRUE(IsWindow(renderer_window)); |
| 421 |
| 422 // Bring up the context menu in the Chrome renderer window. |
| 423 PostMessage(renderer_window, WM_RBUTTONDOWN, MK_RBUTTON, MAKELPARAM(50, 50)); |
| 424 PostMessage(renderer_window, WM_RBUTTONUP, MK_RBUTTON, MAKELPARAM(50, 50)); |
| 425 |
| 426 MessageLoop::current()->PostDelayedTask( |
| 427 FROM_HERE, |
| 428 NewRunnableFunction(SelectAboutChromeFrame), |
| 429 kChromeFrameContextMenuTimeout); |
| 430 } |
| 431 |
| 432 void ShowChromeFrameContextMenu() { |
| 433 static const int kContextMenuDelay = 5000; |
| 434 |
| 435 MessageLoop::current()->PostDelayedTask( |
| 436 FROM_HERE, |
| 437 NewRunnableFunction(ShowChromeFrameContextMenuTask), |
| 438 kContextMenuDelay); |
| 439 } |
| 440 |
| 441 void SelectAboutChromeFrame() { |
| 442 // Send a key up message to enable the About chrome frame option to be |
| 443 // selected followed by a return to select it. |
| 444 chrome_frame_test::SendVirtualKey(VK_UP); |
| 445 chrome_frame_test::SendVirtualKey(VK_RETURN); |
| 446 } |
| 447 |
| 448 BOOL CALLBACK FindChromeRendererWindowProc( |
| 449 HWND window, LPARAM lParam) { |
| 450 HWND* target_window = reinterpret_cast<HWND*>(lParam); |
| 451 wchar_t class_name[MAX_PATH] = {0}; |
| 452 |
| 453 GetClassName(window, class_name, arraysize(class_name)); |
| 454 if (!_wcsicmp(class_name, L"Chrome_RenderWidgetHostHWND")) { |
| 455 *target_window = window; |
| 456 return FALSE; |
| 457 } |
| 458 |
| 459 return TRUE; |
| 460 } |
| 461 |
| 462 BOOL CALLBACK EnumHostBrowserWindowProc( |
| 463 HWND window, LPARAM lParam) { |
| 464 EnumChildWindows(window, FindChromeRendererWindowProc, lParam); |
| 465 HWND* target_window = reinterpret_cast<HWND*>(lParam); |
| 466 if (IsWindow(*target_window)) |
| 467 return FALSE; |
| 468 return TRUE; |
| 469 } |
| 470 |
| 471 HWND GetChromeRendererWindow() { |
| 472 HWND chrome_window = NULL; |
| 473 EnumWindows(EnumHostBrowserWindowProc, |
| 474 reinterpret_cast<LPARAM>(&chrome_window)); |
| 475 return chrome_window; |
| 476 } |
| 477 |
415 } // namespace chrome_frame_test | 478 } // namespace chrome_frame_test |
OLD | NEW |