mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Improvements to unit test behavior.
- Standardize the test timeout implementation using a new TestHandler::SetTestTimeout method and enable timeouts for almost all tests. The test timeout can be disabled globally using a new `--disable-test-timeout` command-line flag. - Wait for TestHandler object destruction at the end of each test using a new ReleaseAndWaitForDestructor function. This avoids test state leakage and verifies that no object references are leaked. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@1964 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -15,9 +15,6 @@
|
||||
#include "tests/unittests/test_handler.h"
|
||||
#include "tests/unittests/test_util.h"
|
||||
|
||||
// Comment out this define to disable the unit test timeout.
|
||||
#define TIMEOUT_ENABLED 1
|
||||
|
||||
// Verify Set/Get methods for CefRequest, CefPostData and CefPostDataElement.
|
||||
TEST(RequestTest, SetGet) {
|
||||
// CefRequest CreateRequest
|
||||
@@ -149,6 +146,9 @@ class RequestSendRecvTestHandler : public TestHandler {
|
||||
|
||||
// Create the browser
|
||||
CreateBrowser("about:blank");
|
||||
|
||||
// Time out the test after a reasonable period of time.
|
||||
SetTestTimeout();
|
||||
}
|
||||
|
||||
void OnAfterCreated(CefRefPtr<CefBrowser> browser) override {
|
||||
@@ -204,6 +204,8 @@ TEST(RequestTest, SendRecv) {
|
||||
|
||||
ASSERT_TRUE(handler->got_before_resource_load_);
|
||||
ASSERT_TRUE(handler->got_resource_handler_);
|
||||
|
||||
ReleaseAndWaitForDestructor(handler);
|
||||
}
|
||||
|
||||
namespace {
|
||||
@@ -437,11 +439,8 @@ class TypeTestHandler : public TestHandler {
|
||||
|
||||
CreateBrowser(std::string(kTypeTestOrigin) + "main.html");
|
||||
|
||||
#if defined(TIMEOUT_ENABLED)
|
||||
// Time out the test after a reasonable period of time.
|
||||
CefPostDelayedTask(TID_UI, base::Bind(&TypeTestHandler::DestroyTest, this),
|
||||
2000);
|
||||
#endif
|
||||
SetTestTimeout();
|
||||
}
|
||||
|
||||
bool OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
|
||||
@@ -536,6 +535,7 @@ TEST(RequestTest, ResourceAndTransitionType) {
|
||||
CefRefPtr<TypeTestHandler> handler =
|
||||
new TypeTestHandler();
|
||||
handler->ExecuteTest();
|
||||
ReleaseAndWaitForDestructor(handler);
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user