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

Unified Diff: net/url_request/view_cache_helper_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/url_request/url_request_unittest.cc ('k') | net/websockets/websocket_basic_stream_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/view_cache_helper_unittest.cc
diff --git a/net/url_request/view_cache_helper_unittest.cc b/net/url_request/view_cache_helper_unittest.cc
index e21e05ef4edd92cce40f18ccf8714545f9fe8e1d..c0a5f8c79b56892afc204a5ef2b4e7ac31b7c726 100644
--- a/net/url_request/view_cache_helper_unittest.cc
+++ b/net/url_request/view_cache_helper_unittest.cc
@@ -11,9 +11,13 @@
#include "net/disk_cache/disk_cache.h"
#include "net/http/http_cache.h"
#include "net/http/http_transaction_test_util.h"
+#include "net/test/gtest_util.h"
#include "net/url_request/url_request_context.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+using net::test::IsOk;
+
namespace net {
namespace {
@@ -80,7 +84,7 @@ void WriteToEntry(disk_cache::Backend* cache, const std::string& key,
rv = cb.GetResult(rv);
if (rv != OK) {
rv = cache->OpenEntry(key, &entry, cb.callback());
- ASSERT_EQ(OK, cb.GetResult(rv));
+ ASSERT_THAT(cb.GetResult(rv), IsOk());
}
WriteHeaders(entry, 0, data0);
@@ -96,7 +100,7 @@ void FillCache(URLRequestContext* context) {
int rv =
context->http_transaction_factory()->GetCache()->GetBackend(
&cache, cb.callback());
- ASSERT_EQ(OK, cb.GetResult(rv));
+ ASSERT_THAT(cb.GetResult(rv), IsOk());
std::string empty;
WriteToEntry(cache, "first", "some", empty, empty);
@@ -113,7 +117,7 @@ TEST(ViewCacheHelper, EmptyCache) {
TestCompletionCallback cb;
std::string prefix, data;
int rv = helper.GetContentsHTML(&context, prefix, &data, cb.callback());
- EXPECT_EQ(OK, cb.GetResult(rv));
+ EXPECT_THAT(cb.GetResult(rv), IsOk());
EXPECT_FALSE(data.empty());
}
@@ -126,7 +130,7 @@ TEST(ViewCacheHelper, ListContents) {
std::string prefix, data;
TestCompletionCallback cb;
int rv = helper.GetContentsHTML(&context, prefix, &data, cb.callback());
- EXPECT_EQ(OK, cb.GetResult(rv));
+ EXPECT_THAT(cb.GetResult(rv), IsOk());
EXPECT_EQ(0U, data.find("<html>"));
EXPECT_NE(std::string::npos, data.find("</html>"));
@@ -148,7 +152,7 @@ TEST(ViewCacheHelper, DumpEntry) {
std::string data;
TestCompletionCallback cb;
int rv = helper.GetEntryInfoHTML("second", &context, &data, cb.callback());
- EXPECT_EQ(OK, cb.GetResult(rv));
+ EXPECT_THAT(cb.GetResult(rv), IsOk());
EXPECT_EQ(0U, data.find("<html>"));
EXPECT_NE(std::string::npos, data.find("</html>"));
@@ -174,7 +178,7 @@ TEST(ViewCacheHelper, Prefix) {
std::string prefix("prefix:");
TestCompletionCallback cb;
int rv = helper.GetContentsHTML(&context, prefix, &data, cb.callback());
- EXPECT_EQ(OK, cb.GetResult(rv));
+ EXPECT_THAT(cb.GetResult(rv), IsOk());
EXPECT_EQ(0U, data.find("<html>"));
EXPECT_NE(std::string::npos, data.find("</html>"));
@@ -192,12 +196,12 @@ TEST(ViewCacheHelper, TruncatedFlag) {
int rv =
context.http_transaction_factory()->GetCache()->GetBackend(
&cache, cb.callback());
- ASSERT_EQ(OK, cb.GetResult(rv));
+ ASSERT_THAT(cb.GetResult(rv), IsOk());
std::string key("the key");
disk_cache::Entry* entry;
rv = cache->CreateEntry(key, &entry, cb.callback());
- ASSERT_EQ(OK, cb.GetResult(rv));
+ ASSERT_THAT(cb.GetResult(rv), IsOk());
// RESPONSE_INFO_TRUNCATED defined on response_info.cc
int flags = 1 << 12;
@@ -207,7 +211,7 @@ TEST(ViewCacheHelper, TruncatedFlag) {
std::string data;
TestCompletionCallback cb1;
rv = helper.GetEntryInfoHTML(key, &context, &data, cb1.callback());
- EXPECT_EQ(OK, cb1.GetResult(rv));
+ EXPECT_THAT(cb1.GetResult(rv), IsOk());
EXPECT_NE(std::string::npos, data.find("RESPONSE_INFO_TRUNCATED"));
}
« no previous file with comments | « net/url_request/url_request_unittest.cc ('k') | net/websockets/websocket_basic_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698