Path: blob/trunk/cpp/webdriver-interactions/interaction_utils.cpp
2867 views
/*1Licensed to the Software Freedom Conservancy (SFC) under one2or more contributor license agreements. See the NOTICE file3distributed with this work for additional information4regarding copyright ownership. The SFC licenses this file5to you under the Apache License, Version 2.0 (the "License");6you may not use this file except in compliance with the License.7You may obtain a copy of the License at89http://www.apache.org/licenses/LICENSE-2.01011Unless required by applicable law or agreed to in writing, software12distributed under the License is distributed on an "AS IS" BASIS,13WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14See the License for the specific language governing permissions and15limitations under the License.16*/1718#include "stdafx.h"19#include "interaction_utils.h"2021#include <atlbase.h>22#include <atlstr.h>23#include <atlwin.h>24#include <ctime>2526void wait(long millis)27{28clock_t end = clock() + millis;29do {30MSG msg;31if (PeekMessage( &msg, NULL, 0, 0, PM_REMOVE)) {32TranslateMessage(&msg);33DispatchMessage(&msg);34}35Sleep(0);36} while (clock() < end);37}3839void waitWithoutMsgPump(long millis)40{41Sleep(millis);42}4344// "Internet Explorer_Server" + 145#define LONGEST_NAME 254647HWND getChildWindow(HWND hwnd, LPCTSTR name)48{49TCHAR pszClassName[LONGEST_NAME];50HWND hwndtmp = GetWindow(hwnd, GW_CHILD);51while (hwndtmp != NULL) {52::GetClassName(hwndtmp, pszClassName, LONGEST_NAME);53if (lstrcmp(pszClassName, name) == 0) {54return hwndtmp;55}56hwndtmp = GetWindow(hwndtmp, GW_HWNDNEXT);57}58return NULL;59}6061