Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1088)

Unified Diff: net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc

Issue 2109503009: Refactor net tests to use GMock matchers for checking net::Error results (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert changes to contents.txt files Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
diff --git a/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc b/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
index 40bc928647b2cafd3c89f7f0199319c606132bbc..3c5c4f0584f4fce3c20ec7b36d5982d8689809c1 100644
--- a/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
+++ b/net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc
@@ -15,9 +15,14 @@
#include "base/timer/elapsed_timer.h"
#include "net/base/completion_callback.h"
#include "net/proxy/dhcp_proxy_script_adapter_fetcher_win.h"
+#include "net/test/gtest_util.h"
#include "net/url_request/url_request_test_util.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+using net::test::IsError;
+using net::test::IsOk;
+
namespace net {
namespace {
@@ -384,7 +389,7 @@ class FetcherClient {
int result = fetcher_.Fetch(
&pac_text_,
base::Bind(&FetcherClient::OnCompletion, base::Unretained(this)));
- ASSERT_EQ(ERR_IO_PENDING, result);
+ ASSERT_THAT(result, IsError(ERR_IO_PENDING));
}
void RunMessageLoopUntilComplete() {
@@ -436,7 +441,7 @@ void TestNormalCaseURLConfiguredOneAdapter(FetcherClient* client) {
client->fetcher_.PushBackAdapter("a", adapter_fetcher.release());
client->RunTest();
client->RunMessageLoopUntilComplete();
- ASSERT_EQ(OK, client->result_);
+ ASSERT_THAT(client->result_, IsOk());
ASSERT_EQ(L"bingo", client->pac_text_);
}
@@ -455,7 +460,7 @@ void TestNormalCaseURLConfiguredMultipleAdapters(FetcherClient* client) {
"third", true, OK, L"rocko", base::TimeDelta::FromMilliseconds(1));
client->RunTest();
client->RunMessageLoopUntilComplete();
- ASSERT_EQ(OK, client->result_);
+ ASSERT_THAT(client->result_, IsOk());
ASSERT_EQ(L"bingo", client->pac_text_);
}
@@ -477,7 +482,7 @@ void TestNormalCaseURLConfiguredMultipleAdaptersWithTimeout(
"third", true, OK, L"rocko", base::TimeDelta::FromMilliseconds(1));
client->RunTest();
client->RunMessageLoopUntilComplete();
- ASSERT_EQ(OK, client->result_);
+ ASSERT_THAT(client->result_, IsOk());
ASSERT_EQ(L"rocko", client->pac_text_);
}
@@ -506,7 +511,7 @@ void TestFailureCaseURLConfiguredMultipleAdaptersWithTimeout(
base::TimeDelta::FromMilliseconds(1));
client->RunTest();
client->RunMessageLoopUntilComplete();
- ASSERT_EQ(ERR_PAC_STATUS_NOT_OK, client->result_);
+ ASSERT_THAT(client->result_, IsError(ERR_PAC_STATUS_NOT_OK));
ASSERT_EQ(L"", client->pac_text_);
}
@@ -531,7 +536,7 @@ void TestFailureCaseNoURLConfigured(FetcherClient* client) {
base::TimeDelta::FromMilliseconds(1));
client->RunTest();
client->RunMessageLoopUntilComplete();
- ASSERT_EQ(ERR_PAC_NOT_IN_DHCP, client->result_);
+ ASSERT_THAT(client->result_, IsError(ERR_PAC_NOT_IN_DHCP));
ASSERT_EQ(L"", client->pac_text_);
}
@@ -543,7 +548,7 @@ TEST(DhcpProxyScriptFetcherWin, FailureCaseNoURLConfigured) {
void TestFailureCaseNoDhcpAdapters(FetcherClient* client) {
client->RunTest();
client->RunMessageLoopUntilComplete();
- ASSERT_EQ(ERR_PAC_NOT_IN_DHCP, client->result_);
+ ASSERT_THAT(client->result_, IsError(ERR_PAC_NOT_IN_DHCP));
ASSERT_EQ(L"", client->pac_text_);
ASSERT_EQ(0, client->fetcher_.num_fetchers_created_);
}
« no previous file with comments | « net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc ('k') | net/proxy/mojo_proxy_resolver_factory_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698