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

Side by Side 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, 1 month 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/base/net_log_util.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "base/values.h"
9 #include "net/base/net_errors.h"
10 #include "net/base/test_completion_callback.h"
11 #include "net/http/http_cache.h"
12 #include "net/http/http_transaction.h"
13 #include "net/url_request/url_request_test_util.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15
16 namespace net {
17
18 namespace {
19
20 // Make sure GetNetConstants doesn't crash.
21 TEST(NetLogUtil, GetNetConstants) {
22 scoped_ptr<base::Value> constants(GetNetConstants());
23 }
24
25 // Make sure GetNetInfo doesn't crash when called on contexts with and without
26 // caches, and they have the same number of elements.
27 TEST(NetLogUtil, GetNetInfo) {
28 TestURLRequestContext context;
29 net::HttpCache* http_cache = context.http_transaction_factory()->GetCache();
30
31 // Get NetInfo when there's no cache backend (It's only created on first use).
32 EXPECT_FALSE(http_cache->GetCurrentBackend());
33 scoped_ptr<base::DictionaryValue> net_info_without_cache(
34 GetNetInfo(&context, NET_INFO_ALL_SOURCES));
35 EXPECT_FALSE(http_cache->GetCurrentBackend());
36 EXPECT_GT(net_info_without_cache->size(), 0u);
37
38 // Fore creation of a cache backend, and get NetInfo again.
39 disk_cache::Backend* backend = NULL;
40 EXPECT_EQ(
41 OK,
42 context.http_transaction_factory()->GetCache()->GetBackend(
43 &backend, TestCompletionCallback().callback()));
44 EXPECT_TRUE(http_cache->GetCurrentBackend());
45 scoped_ptr<base::DictionaryValue> net_info_with_cache(
46 GetNetInfo(&context, NET_INFO_ALL_SOURCES));
47 EXPECT_GT(net_info_with_cache->size(), 0u);
48
49 EXPECT_EQ(net_info_without_cache->size(), net_info_with_cache->size());
50 }
51
52 } // namespace
53
54 } // namespace net
OLDNEW
« 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