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

Unified Diff: net/proxy/dhcp_proxy_script_adapter_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
« no previous file with comments | « net/http/http_stream_parser_unittest.cc ('k') | net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc
diff --git a/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc b/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc
index b114eb59deb4bc15805a600bccd7a4065edfd8a6..6f4a508047be3913189f097ba712dbd62f361437 100644
--- a/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc
+++ b/net/proxy/dhcp_proxy_script_adapter_fetcher_win_unittest.cc
@@ -15,9 +15,14 @@
#include "net/proxy/mock_proxy_script_fetcher.h"
#include "net/proxy/proxy_script_fetcher_impl.h"
#include "net/test/embedded_test_server/embedded_test_server.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 {
@@ -176,7 +181,7 @@ TEST(DhcpProxyScriptAdapterFetcher, NormalCaseURLNotInDhcp) {
client.RunTest();
client.WaitForResult(ERR_PAC_NOT_IN_DHCP);
ASSERT_TRUE(client.fetcher_->DidFinish());
- EXPECT_EQ(ERR_PAC_NOT_IN_DHCP, client.fetcher_->GetResult());
+ EXPECT_THAT(client.fetcher_->GetResult(), IsError(ERR_PAC_NOT_IN_DHCP));
EXPECT_EQ(base::string16(L""), client.fetcher_->GetPacScript());
}
@@ -185,7 +190,7 @@ TEST(DhcpProxyScriptAdapterFetcher, NormalCaseURLInDhcp) {
client.RunTest();
client.WaitForResult(OK);
ASSERT_TRUE(client.fetcher_->DidFinish());
- EXPECT_EQ(OK, client.fetcher_->GetResult());
+ EXPECT_THAT(client.fetcher_->GetResult(), IsOk());
EXPECT_EQ(base::string16(L"bingo"), client.fetcher_->GetPacScript());
EXPECT_EQ(GURL(kPacUrl), client.fetcher_->GetPacURL());
}
@@ -208,7 +213,7 @@ TEST(DhcpProxyScriptAdapterFetcher, TimeoutDuringDhcp) {
client.WaitForResult(ERR_TIMED_OUT);
ASSERT_TRUE(client.fetcher_->DidFinish());
- EXPECT_EQ(ERR_TIMED_OUT, client.fetcher_->GetResult());
+ EXPECT_THAT(client.fetcher_->GetResult(), IsError(ERR_TIMED_OUT));
EXPECT_EQ(base::string16(L""), client.fetcher_->GetPacScript());
EXPECT_EQ(GURL(), client.fetcher_->GetPacURL());
client.FinishTestAllowCleanup();
@@ -221,7 +226,7 @@ TEST(DhcpProxyScriptAdapterFetcher, CancelWhileDhcp) {
base::RunLoop().RunUntilIdle();
ASSERT_FALSE(client.fetcher_->DidFinish());
ASSERT_TRUE(client.fetcher_->WasCancelled());
- EXPECT_EQ(ERR_ABORTED, client.fetcher_->GetResult());
+ EXPECT_THAT(client.fetcher_->GetResult(), IsError(ERR_ABORTED));
EXPECT_EQ(base::string16(L""), client.fetcher_->GetPacScript());
EXPECT_EQ(GURL(), client.fetcher_->GetPacURL());
client.FinishTestAllowCleanup();
@@ -242,7 +247,7 @@ TEST(DhcpProxyScriptAdapterFetcher, CancelWhileFetcher) {
base::RunLoop().RunUntilIdle();
ASSERT_FALSE(client.fetcher_->DidFinish());
ASSERT_TRUE(client.fetcher_->WasCancelled());
- EXPECT_EQ(ERR_ABORTED, client.fetcher_->GetResult());
+ EXPECT_THAT(client.fetcher_->GetResult(), IsError(ERR_ABORTED));
EXPECT_EQ(base::string16(L""), client.fetcher_->GetPacScript());
// GetPacURL() still returns the URL fetched in this case.
EXPECT_EQ(GURL(kPacUrl), client.fetcher_->GetPacURL());
@@ -257,7 +262,7 @@ TEST(DhcpProxyScriptAdapterFetcher, CancelAtCompletion) {
// Canceling after you're done should have no effect, so these
// are identical expectations to the NormalCaseURLInDhcp test.
ASSERT_TRUE(client.fetcher_->DidFinish());
- EXPECT_EQ(OK, client.fetcher_->GetResult());
+ EXPECT_THAT(client.fetcher_->GetResult(), IsOk());
EXPECT_EQ(base::string16(L"bingo"), client.fetcher_->GetPacScript());
EXPECT_EQ(GURL(kPacUrl), client.fetcher_->GetPacURL());
client.FinishTestAllowCleanup();
@@ -304,7 +309,7 @@ TEST(DhcpProxyScriptAdapterFetcher, MockDhcpRealFetch) {
client.RunTest();
client.WaitForResult(OK);
ASSERT_TRUE(client.fetcher_->DidFinish());
- EXPECT_EQ(OK, client.fetcher_->GetResult());
+ EXPECT_THAT(client.fetcher_->GetResult(), IsOk());
EXPECT_EQ(base::string16(L"-downloadable.pac-\n"),
client.fetcher_->GetPacScript());
EXPECT_EQ(configured_url,
« no previous file with comments | « net/http/http_stream_parser_unittest.cc ('k') | net/proxy/dhcp_proxy_script_fetcher_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698