summaryrefslogtreecommitdiffstats
path: root/net/base/net_log_unittest.cc
blob: c9258a9599aae98c4ccdc0131c7986131cef59e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) 2012 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 "base/memory/scoped_ptr.h"
#include "net/base/capturing_net_log.h"
#include "net/base/net_log.h"
#include "net/base/net_log_unittest.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace net {

namespace {

TEST(NetLog, ScopedNetLogEventTest) {
  CapturingNetLog log(CapturingNetLog::kUnbounded);
  BoundNetLog net_log(BoundNetLog::Make(&log, NetLog::SOURCE_URL_REQUEST));

  scoped_ptr<ScopedNetLogEvent> net_log_event(
      new ScopedNetLogEvent(net_log, NetLog::TYPE_REQUEST_ALIVE, NULL));

  CapturingNetLog::EntryList entries;
  log.GetEntries(&entries);
  EXPECT_EQ(1u, entries.size());
  EXPECT_TRUE(LogContainsBeginEvent(entries, 0, NetLog::TYPE_REQUEST_ALIVE));

  net_log_event.reset();
  log.GetEntries(&entries);
  EXPECT_EQ(2u, entries.size());
  EXPECT_TRUE(LogContainsEndEvent(entries, 1, NetLog::TYPE_REQUEST_ALIVE));
}

}  // namespace

}  // namespace net