1// Copyright (c) 2010 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/capturing_net_log.h"
6#include "net/base/net_log.h"
7#include "net/base/net_log_unittest.h"
8#include "testing/gtest/include/gtest/gtest.h"
9
10namespace net {
11
12namespace {
13
14TEST(NetLog, ScopedNetLogEventTest) {
15  CapturingNetLog log(CapturingNetLog::kUnbounded);
16  BoundNetLog net_log(BoundNetLog::Make(&log, NetLog::SOURCE_URL_REQUEST));
17
18  scoped_ptr<ScopedNetLogEvent> net_log_event(
19      new ScopedNetLogEvent(net_log, NetLog::TYPE_REQUEST_ALIVE, NULL));
20
21  CapturingNetLog::EntryList entries;
22  log.GetEntries(&entries);
23  EXPECT_EQ(1u, entries.size());
24  EXPECT_TRUE(LogContainsBeginEvent(entries, 0, NetLog::TYPE_REQUEST_ALIVE));
25
26  net_log_event.reset();
27  log.GetEntries(&entries);
28  EXPECT_EQ(2u, entries.size());
29  EXPECT_TRUE(LogContainsEndEvent(entries, 1, NetLog::TYPE_REQUEST_ALIVE));
30}
31
32}  // namespace
33
34}  // namespace net
35