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:
Marshall Greenblatt
2015-01-09 23:40:26 +00:00
parent ba198e9ef1
commit 054300874d
22 changed files with 420 additions and 72 deletions

View File

@@ -16,9 +16,6 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "tests/unittests/routing_test_handler.h"
// Comment out this define to disable the unit test timeout.
#define TIMEOUT_ENABLED 1
namespace {
const char kTestUrl[] = "http://tests-srh/test.html";
@@ -106,11 +103,8 @@ class ReadTestHandler : public RoutingTestHandler {
// Create the browser.
CreateBrowser(kTestUrl);
#if defined(TIMEOUT_ENABLED)
// Time out the test after a reasonable period of time.
CefPostDelayedTask(TID_UI,
base::Bind(&ReadTestHandler::DestroyTest, this), 3000);
#endif
SetTestTimeout();
}
CefRefPtr<CefResourceHandler> GetResourceHandler(
@@ -183,9 +177,11 @@ class ReadTestHandler : public RoutingTestHandler {
TEST(StreamResourceHandlerTest, ReadWillBlock) {
CefRefPtr<ReadTestHandler> handler = new ReadTestHandler(true);
handler->ExecuteTest();
ReleaseAndWaitForDestructor(handler);
}
TEST(StreamResourceHandlerTest, ReadWontBlock) {
CefRefPtr<ReadTestHandler> handler = new ReadTestHandler(false);
handler->ExecuteTest();
ReleaseAndWaitForDestructor(handler);
}