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

@@ -58,6 +58,9 @@ class GeolocationTestHandler : public TestHandler {
// Create the browser
CreateBrowser(kTestUrl);
// Time out the test after a reasonable period of time.
SetTestTimeout();
}
void OnLoadEnd(CefRefPtr<CefBrowser> browser,
@@ -146,6 +149,7 @@ TEST(GeolocationTest, HandlerAllow) {
new GeolocationTestHandler(TEST_ALLOW, false);
handler->ExecuteTest();
EXPECT_TRUE(handler->got_allow_);
ReleaseAndWaitForDestructor(handler);
}
TEST(GeolocationTest, HandlerAllowAsync) {
@@ -153,6 +157,7 @@ TEST(GeolocationTest, HandlerAllowAsync) {
new GeolocationTestHandler(TEST_ALLOW, true);
handler->ExecuteTest();
EXPECT_TRUE(handler->got_allow_);
ReleaseAndWaitForDestructor(handler);
}
TEST(GeolocationTest, HandlerDeny) {
@@ -160,6 +165,7 @@ TEST(GeolocationTest, HandlerDeny) {
new GeolocationTestHandler(TEST_DENY, false);
handler->ExecuteTest();
EXPECT_TRUE(handler->got_deny_);
ReleaseAndWaitForDestructor(handler);
}
TEST(GeolocationTest, HandlerDenyAsync) {
@@ -167,6 +173,7 @@ TEST(GeolocationTest, HandlerDenyAsync) {
new GeolocationTestHandler(TEST_DENY, true);
handler->ExecuteTest();
EXPECT_TRUE(handler->got_deny_);
ReleaseAndWaitForDestructor(handler);
}
TEST(GeolocationTest, HandlerCancel) {
@@ -174,6 +181,7 @@ TEST(GeolocationTest, HandlerCancel) {
new GeolocationTestHandler(TEST_CANCEL, false);
handler->ExecuteTest();
EXPECT_TRUE(handler->got_cancel_);
ReleaseAndWaitForDestructor(handler);
}