| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "net/base/capturing_net_log.h" | 6 #include "net/base/capturing_net_log.h" |
| 7 #include "net/base/net_log.h" | 7 #include "net/base/net_log.h" |
| 8 #include "net/base/net_log_unittest.h" | 8 #include "net/base/net_log_unittest.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 namespace net { | 11 namespace net { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 TEST(NetLog, ScopedNetLogEventTest) { | 15 TEST(NetLog, ScopedNetLogEventTest) { |
| 16 CapturingNetLog log(CapturingNetLog::kUnbounded); | 16 CapturingNetLog log; |
| 17 BoundNetLog net_log(BoundNetLog::Make(&log, NetLog::SOURCE_URL_REQUEST)); | 17 BoundNetLog net_log(BoundNetLog::Make(&log, NetLog::SOURCE_URL_REQUEST)); |
| 18 | 18 |
| 19 scoped_ptr<ScopedNetLogEvent> net_log_event( | 19 scoped_ptr<ScopedNetLogEvent> net_log_event( |
| 20 new ScopedNetLogEvent(net_log, NetLog::TYPE_REQUEST_ALIVE, NULL)); | 20 new ScopedNetLogEvent(net_log, NetLog::TYPE_REQUEST_ALIVE, NULL)); |
| 21 | 21 |
| 22 CapturingNetLog::CapturedEntryList entries; | 22 CapturingNetLog::CapturedEntryList entries; |
| 23 log.GetEntries(&entries); | 23 log.GetEntries(&entries); |
| 24 EXPECT_EQ(1u, entries.size()); | 24 EXPECT_EQ(1u, entries.size()); |
| 25 EXPECT_TRUE(LogContainsBeginEvent(entries, 0, NetLog::TYPE_REQUEST_ALIVE)); | 25 EXPECT_TRUE(LogContainsBeginEvent(entries, 0, NetLog::TYPE_REQUEST_ALIVE)); |
| 26 | 26 |
| 27 net_log_event.reset(); | 27 net_log_event.reset(); |
| 28 log.GetEntries(&entries); | 28 log.GetEntries(&entries); |
| 29 EXPECT_EQ(2u, entries.size()); | 29 EXPECT_EQ(2u, entries.size()); |
| 30 EXPECT_TRUE(LogContainsEndEvent(entries, 1, NetLog::TYPE_REQUEST_ALIVE)); | 30 EXPECT_TRUE(LogContainsEndEvent(entries, 1, NetLog::TYPE_REQUEST_ALIVE)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 } // namespace net | 35 } // namespace net |
| OLD | NEW |