Linux: Fix error: suggest explicit braces to avoid ambiguous ‘else’ [-Werror=dangling-else] with gcc 7.1

This commit is contained in:
Sergey Linev 2017-08-11 16:56:52 +00:00 committed by Marshall Greenblatt
parent 76eb49196e
commit 5b12134a45
8 changed files with 29 additions and 17 deletions

View File

@ -68,8 +68,9 @@ class TestDeleteCookiesCallback : public CefDeleteCookiesCallback {
: expected_num_deleted_(expected_num_deleted), event_(event) {}
void OnComplete(int num_deleted) override {
if (expected_num_deleted_ != kIgnoreNumDeleted)
if (expected_num_deleted_ != kIgnoreNumDeleted) {
EXPECT_EQ(expected_num_deleted_, num_deleted);
}
event_->Signal();
}

View File

@ -271,8 +271,9 @@ class DownloadTestHandler : public TestHandler {
EXPECT_TRUE(download_item.get());
EXPECT_TRUE(callback.get());
if (got_on_before_download_)
if (got_on_before_download_) {
EXPECT_EQ(download_id_, download_item->GetId());
}
EXPECT_LE(0LL, download_item->GetCurrentSpeed());
EXPECT_LE(0, download_item->GetPercentComplete());

View File

@ -730,10 +730,11 @@ class SinglePersistentQueryTestHandler : public SingleLoadTestHandler {
AssertMainBrowser(browser);
AssertMainFrame(frame);
if (test_type_ == SUCCESS)
if (test_type_ == SUCCESS) {
EXPECT_STREQ("success", message.c_str());
else if (test_type_ == FAILURE)
} else if (test_type_ == FAILURE) {
EXPECT_STREQ("failure", message.c_str());
}
got_notify_.yes();

View File

@ -185,10 +185,11 @@ class HistoryNavRendererTest : public ClientAppRenderer::Delegate,
EXPECT_EQ(RT_SUB_RESOURCE, request->GetResourceType());
EXPECT_EQ(TT_EXPLICIT, request->GetTransitionType());
if (item.action == NA_LOAD)
if (item.action == NA_LOAD) {
EXPECT_EQ(NAVIGATION_OTHER, navigation_type);
else if (item.action == NA_BACK || item.action == NA_FORWARD)
} else if (item.action == NA_BACK || item.action == NA_FORWARD) {
EXPECT_EQ(NAVIGATION_BACK_FORWARD, navigation_type);
}
if (nav_ > 0) {
const NavListItem& last_item = kHNavList[nav_ - 1];
@ -423,11 +424,12 @@ class HistoryNavTestHandler : public TestHandler {
EXPECT_STREQ(item.target, url.c_str());
EXPECT_EQ(RT_MAIN_FRAME, request->GetResourceType());
if (item.action == NA_LOAD)
if (item.action == NA_LOAD) {
EXPECT_EQ(TT_EXPLICIT, request->GetTransitionType());
else if (item.action == NA_BACK || item.action == NA_FORWARD)
} else if (item.action == NA_BACK || item.action == NA_FORWARD) {
EXPECT_EQ(TT_EXPLICIT | TT_FORWARD_BACK_FLAG,
request->GetTransitionType());
}
if (nav_ > 0) {
const NavListItem& last_item = kHNavList[nav_ - 1];
@ -449,11 +451,12 @@ class HistoryNavTestHandler : public TestHandler {
const NavListItem& item = kHNavList[nav_];
EXPECT_EQ(RT_MAIN_FRAME, request->GetResourceType());
if (item.action == NA_LOAD)
if (item.action == NA_LOAD) {
EXPECT_EQ(TT_EXPLICIT, request->GetTransitionType());
else if (item.action == NA_BACK || item.action == NA_FORWARD)
} else if (item.action == NA_BACK || item.action == NA_FORWARD) {
EXPECT_EQ(TT_EXPLICIT | TT_FORWARD_BACK_FLAG,
request->GetTransitionType());
}
got_before_resource_load_[nav_].yes();
@ -494,10 +497,11 @@ class HistoryNavTestHandler : public TestHandler {
got_load_start_[nav_].yes();
if (item.action == NA_LOAD)
if (item.action == NA_LOAD) {
EXPECT_EQ(TT_EXPLICIT, transition_type);
else if (item.action == NA_BACK || item.action == NA_FORWARD)
} else if (item.action == NA_BACK || item.action == NA_FORWARD) {
EXPECT_EQ(TT_EXPLICIT | TT_FORWARD_BACK_FLAG, transition_type);
}
std::string url1 = browser->GetMainFrame()->GetURL();
std::string url2 = frame->GetURL();

View File

@ -558,8 +558,9 @@ class PluginTestHandler : public RoutingTestHandler,
EXPECT_TRUE(got_on_load_end_pdf1_);
EXPECT_TRUE(got_on_load_end_pdf2_);
if (HasRequestContextHandler())
if (HasRequestContextHandler()) {
EXPECT_TRUE(got_on_before_plugin_load_pdf_);
}
}
} else if (url_ == kPdfDirectUrl) {
// Load the PDF file directly.
@ -567,8 +568,9 @@ class PluginTestHandler : public RoutingTestHandler,
EXPECT_TRUE(got_on_load_end_pdf1_);
EXPECT_FALSE(got_on_load_end_pdf2_);
if (HasRequestContextHandler())
if (HasRequestContextHandler()) {
EXPECT_TRUE(got_on_before_plugin_load_pdf_);
}
} else {
NOTREACHED();
}

View File

@ -161,8 +161,9 @@ class TestSchemeHandler : public TestHandler {
#if defined(OS_LINUX)
// CustomStandardXHR* tests are flaky on Linux, sometimes returning
// ERR_ABORTED. Make the tests less flaky by also accepting that value.
if (!(test_results_->expected_error_code == 0 && errorCode == ERR_ABORTED))
if (!(test_results_->expected_error_code == 0 && errorCode == ERR_ABORTED)) {
EXPECT_EQ(test_results_->expected_error_code, errorCode);
}
#else
// Check that the error code matches the expectation.
EXPECT_EQ(test_results_->expected_error_code, errorCode);

View File

@ -344,8 +344,9 @@ void TestHandler::DestroyTest() {
void TestHandler::OnTestTimeout(int timeout_ms, bool treat_as_error) {
EXPECT_UI_THREAD();
if (treat_as_error)
if (treat_as_error) {
EXPECT_TRUE(false) << "Test timed out after " << timeout_ms << "ms";
}
DestroyTest();
}

View File

@ -8,8 +8,9 @@
void TestMapEqual(const CefRequest::HeaderMap& map1,
const CefRequest::HeaderMap& map2,
bool allowExtras) {
if (!allowExtras)
if (!allowExtras) {
EXPECT_EQ(map1.size(), map2.size());
}
TestMapNoDuplicates(map1);
TestMapNoDuplicates(map2);