summaryrefslogtreecommitdiffstats
path: root/chrome_frame/test/chrome_frame_test_utils.h
blob: 900f5325b13ed536d676f7ef796331996e9ba828 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_FRAME_TEST_CHROME_FRAME_TEST_UTILS_H_
#define CHROME_FRAME_TEST_CHROME_FRAME_TEST_UTILS_H_

#include <windows.h>

#include "base/basictypes.h"
#include "base/process_util.h"

namespace chrome_frame_test {

bool IsTopLevelWindow(HWND window);
int CloseVisibleWindowsOnAllThreads(HANDLE process);
bool ForceSetForegroundWindow(HWND window);
bool EnsureProcessInForeground(base::ProcessId process_id);

// Iterates through all the characters in the string and simulates
// keyboard input.  The input goes to the currently active application.
bool SendString(const wchar_t* s);

// Sends a virtual key such as VK_TAB, VK_RETURN or a character that has been
// translated to a virtual key.
// The extended flag indicates if this is an extended key
void SendVirtualKey(int16 key, bool extended);

// Translates a single char to a virtual key and calls SendVirtualKey.
void SendChar(char c);

// Sends an ascii string, char by char (calls SendChar for each).
void SendString(const char* s);

// Sends a keystroke to the currently active application with optional
// modifiers set.
bool SendMnemonic(WORD mnemonic_char, bool shift_pressed, bool control_pressed,
                  bool alt_pressed);

base::ProcessHandle LaunchFirefox(const std::wstring& url);
base::ProcessHandle LaunchOpera(const std::wstring& url);
base::ProcessHandle LaunchIE(const std::wstring& url);
base::ProcessHandle LaunchSafari(const std::wstring& url);
base::ProcessHandle LaunchChrome(const std::wstring& url);

// Attempts to close all open IE windows.
// The return value is the number of windows closed.
// @note: this function requires COM to be initialized on the calling thread.
// Since the caller might be running in either MTA or STA, the function does
// not perform this initialization itself.
int CloseAllIEWindows();

extern const wchar_t kIEImageName[];
extern const wchar_t kIEBrokerImageName[];
extern const wchar_t kFirefoxImageName[];
extern const wchar_t kOperaImageName[];
extern const wchar_t kSafariImageName[];
extern const wchar_t kChromeImageName[];

// Displays the chrome frame context menu by posting mouse move messages to
// Chrome
void ShowChromeFrameContextMenu();

// Sends keyboard messages to the chrome frame context menu to select the About
// Chrome frame option.
void SelectAboutChromeFrame();

// Returns a handle to the chrome frame render widget child window.
// Returns NULL on failure.
HWND GetChromeRendererWindow();

}  // namespace chrome_frame_test

#endif  // CHROME_FRAME_CHROMETAB_UNITTESTS_CF_TEST_UTILS_H_