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

Unified Diff: net/base/net_log_util_unittest.cc

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 2 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/base/net_log_util.cc ('k') | net/base/network_change_notifier_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/net_log_util_unittest.cc
diff --git a/net/base/net_log_util_unittest.cc b/net/base/net_log_util_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e5cc3a33fb2479566b5d87f9f9496a2ce6dd226f
--- /dev/null
+++ b/net/base/net_log_util_unittest.cc
@@ -0,0 +1,54 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/base/net_log_util.h"
+
+#include "base/memory/scoped_ptr.h"
+#include "base/values.h"
+#include "net/base/net_errors.h"
+#include "net/base/test_completion_callback.h"
+#include "net/http/http_cache.h"
+#include "net/http/http_transaction.h"
+#include "net/url_request/url_request_test_util.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+namespace {
+
+// Make sure GetNetConstants doesn't crash.
+TEST(NetLogUtil, GetNetConstants) {
+ scoped_ptr<base::Value> constants(GetNetConstants());
+}
+
+// Make sure GetNetInfo doesn't crash when called on contexts with and without
+// caches, and they have the same number of elements.
+TEST(NetLogUtil, GetNetInfo) {
+ TestURLRequestContext context;
+ net::HttpCache* http_cache = context.http_transaction_factory()->GetCache();
+
+ // Get NetInfo when there's no cache backend (It's only created on first use).
+ EXPECT_FALSE(http_cache->GetCurrentBackend());
+ scoped_ptr<base::DictionaryValue> net_info_without_cache(
+ GetNetInfo(&context, NET_INFO_ALL_SOURCES));
+ EXPECT_FALSE(http_cache->GetCurrentBackend());
+ EXPECT_GT(net_info_without_cache->size(), 0u);
+
+ // Fore creation of a cache backend, and get NetInfo again.
+ disk_cache::Backend* backend = NULL;
+ EXPECT_EQ(
+ OK,
+ context.http_transaction_factory()->GetCache()->GetBackend(
+ &backend, TestCompletionCallback().callback()));
+ EXPECT_TRUE(http_cache->GetCurrentBackend());
+ scoped_ptr<base::DictionaryValue> net_info_with_cache(
+ GetNetInfo(&context, NET_INFO_ALL_SOURCES));
+ EXPECT_GT(net_info_with_cache->size(), 0u);
+
+ EXPECT_EQ(net_info_without_cache->size(), net_info_with_cache->size());
+}
+
+} // namespace
+
+} // namespace net
« no previous file with comments | « net/base/net_log_util.cc ('k') | net/base/network_change_notifier_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698