Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
|
eroman
2014/10/28 21:59:41
On a side note: I think we are at the point where
mmenke
2014/10/29 15:44:55
Makes sense.
Such a CL would also be a good time
| |
| 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 | |
| OLD | NEW |