| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_FRAME_TEST_CHROME_FRAME_TEST_UTILS_H_ | 5 #ifndef CHROME_FRAME_TEST_CHROME_FRAME_TEST_UTILS_H_ |
| 6 #define CHROME_FRAME_TEST_CHROME_FRAME_TEST_UTILS_H_ | 6 #define CHROME_FRAME_TEST_CHROME_FRAME_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include <atlbase.h> | 8 #include <atlbase.h> |
| 9 #include <atlcom.h> | 9 #include <atlcom.h> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 338 |
| 339 // Returns the profile path to be used for IE. This varies as per version. | 339 // Returns the profile path to be used for IE. This varies as per version. |
| 340 FilePath GetProfilePathForIE(); | 340 FilePath GetProfilePathForIE(); |
| 341 | 341 |
| 342 // Returns the version of the exe passed in. | 342 // Returns the version of the exe passed in. |
| 343 std::wstring GetExeVersion(const std::wstring& exe_path); | 343 std::wstring GetExeVersion(const std::wstring& exe_path); |
| 344 | 344 |
| 345 // Returns the version of Internet Explorer on the machine. | 345 // Returns the version of Internet Explorer on the machine. |
| 346 IEVersion GetInstalledIEVersion(); | 346 IEVersion GetInstalledIEVersion(); |
| 347 | 347 |
| 348 // Returns the folder for CF test data. |
| 349 FilePath GetTestDataFolder(); |
| 350 |
| 351 // Returns the path portion of the url. |
| 352 std::wstring GetPathFromUrl(const std::wstring& url); |
| 353 |
| 354 // Returns the path and query portion of the url. |
| 355 std::wstring GetPathAndQueryFromUrl(const std::wstring& url); |
| 356 |
| 357 // Adds the CF meta tag to the html page. Returns true if successful. |
| 358 bool AddCFMetaTag(std::string* html_data); |
| 359 |
| 348 // Posts a delayed task to send an extended keystroke |repeat| times with an | 360 // Posts a delayed task to send an extended keystroke |repeat| times with an |
| 349 // optional modifier via SendInput. Following this, the enter key is sent. | 361 // optional modifier via SendInput. Following this, the enter key is sent. |
| 350 void DelaySendExtendedKeysEnter(TimedMsgLoop* loop, int delay, char c, | 362 void DelaySendExtendedKeysEnter(TimedMsgLoop* loop, int delay, char c, |
| 351 int repeat, simulate_input::Modifier mod); | 363 int repeat, simulate_input::Modifier mod); |
| 352 | 364 |
| 353 // A convenience class to close all open IE windows at the end | 365 // A convenience class to close all open IE windows at the end |
| 354 // of a scope. It's more convenient to do it this way than to | 366 // of a scope. It's more convenient to do it this way than to |
| 355 // explicitly call chrome_frame_test::CloseAllIEWindows at the | 367 // explicitly call chrome_frame_test::CloseAllIEWindows at the |
| 356 // end of a test since part of the test's cleanup code may be | 368 // end of a test since part of the test's cleanup code may be |
| 357 // in object destructors that would run after CloseAllIEWindows | 369 // in object destructors that would run after CloseAllIEWindows |
| 358 // would get called. | 370 // would get called. |
| 359 // Ideally all IE windows should be closed when this happens so | 371 // Ideally all IE windows should be closed when this happens so |
| 360 // if the test ran normally, we should not have any windows to | 372 // if the test ran normally, we should not have any windows to |
| 361 // close at this point. | 373 // close at this point. |
| 362 class CloseIeAtEndOfScope { | 374 class CloseIeAtEndOfScope { |
| 363 public: | 375 public: |
| 364 CloseIeAtEndOfScope() {} | 376 CloseIeAtEndOfScope() {} |
| 365 ~CloseIeAtEndOfScope() { | 377 ~CloseIeAtEndOfScope() { |
| 366 int closed = CloseAllIEWindows(); | 378 int closed = CloseAllIEWindows(); |
| 367 DLOG_IF(ERROR, closed != 0) | 379 DLOG_IF(ERROR, closed != 0) |
| 368 << StringPrintf("Closed %i windows forcefully", closed); | 380 << StringPrintf("Closed %i windows forcefully", closed); |
| 369 } | 381 } |
| 370 }; | 382 }; |
| 371 | 383 |
| 372 // Specialization of CComObjectStackEx that performs object cleanup via | |
| 373 // calling Base::Uninitialize() before we get to CComObjectStackEx' destructor. | |
| 374 // The CComObjectStackEx destructor expects the reference count to be 0 | |
| 375 // or it will throw an assert. To work around that and to avoid having to | |
| 376 // explicitly call Uninitialize() at the end of every test, we override the | |
| 377 // destructor here to perform the cleanup. | |
| 378 template <class Base> | |
| 379 class ComStackObjectWithUninitialize : public CComObjectStackEx<Base> { | |
| 380 public: | |
| 381 virtual ~ComStackObjectWithUninitialize() { | |
| 382 Base::Uninitialize(); | |
| 383 } | |
| 384 }; | |
| 385 | |
| 386 // Starts the Chrome crash service which enables us to gather crash dumps | 384 // Starts the Chrome crash service which enables us to gather crash dumps |
| 387 // during test runs. | 385 // during test runs. |
| 388 base::ProcessHandle StartCrashService(); | 386 base::ProcessHandle StartCrashService(); |
| 389 | 387 |
| 390 } // namespace chrome_frame_test | 388 } // namespace chrome_frame_test |
| 391 | 389 |
| 392 #endif // CHROME_FRAME_TEST_CHROME_FRAME_TEST_UTILS_H_ | 390 #endif // CHROME_FRAME_TEST_CHROME_FRAME_TEST_UTILS_H_ |
| OLD | NEW |