1 // Copyright 2015 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.
5 #include "net/log/net_log_capture_mode.h"
7 #include "testing/gtest/include/gtest/gtest.h"
13 TEST(NetLogCaptureMode
, None
) {
14 NetLogCaptureMode mode
= NetLogCaptureMode::None();
16 EXPECT_FALSE(mode
.enabled());
17 EXPECT_FALSE(mode
.include_cookies_and_credentials());
18 EXPECT_FALSE(mode
.include_socket_bytes());
20 EXPECT_EQ(mode
, NetLogCaptureMode::None());
21 EXPECT_NE(mode
, NetLogCaptureMode::Default());
22 EXPECT_NE(mode
, NetLogCaptureMode::IncludeCookiesAndCredentials());
23 EXPECT_NE(mode
, NetLogCaptureMode::IncludeSocketBytes());
24 EXPECT_EQ(mode
.ToInternalValueForTesting(),
25 NetLogCaptureMode::None().ToInternalValueForTesting());
28 TEST(NetLogCaptureMode
, Default
) {
29 NetLogCaptureMode mode
= NetLogCaptureMode::Default();
31 EXPECT_TRUE(mode
.enabled());
32 EXPECT_FALSE(mode
.include_cookies_and_credentials());
33 EXPECT_FALSE(mode
.include_socket_bytes());
35 EXPECT_NE(mode
, NetLogCaptureMode::None());
36 EXPECT_EQ(mode
, NetLogCaptureMode::Default());
37 EXPECT_NE(mode
, NetLogCaptureMode::IncludeCookiesAndCredentials());
38 EXPECT_NE(mode
, NetLogCaptureMode::IncludeSocketBytes());
39 EXPECT_EQ(mode
.ToInternalValueForTesting(),
40 NetLogCaptureMode::Default().ToInternalValueForTesting());
43 TEST(NetLogCaptureMode
, IncludeCookiesAndCredentials
) {
44 NetLogCaptureMode mode
= NetLogCaptureMode::IncludeCookiesAndCredentials();
46 EXPECT_TRUE(mode
.enabled());
47 EXPECT_TRUE(mode
.include_cookies_and_credentials());
48 EXPECT_FALSE(mode
.include_socket_bytes());
50 EXPECT_NE(mode
, NetLogCaptureMode::None());
51 EXPECT_NE(mode
, NetLogCaptureMode::Default());
52 EXPECT_EQ(mode
, NetLogCaptureMode::IncludeCookiesAndCredentials());
53 EXPECT_NE(mode
, NetLogCaptureMode::IncludeSocketBytes());
54 EXPECT_EQ(mode
.ToInternalValueForTesting(),
55 NetLogCaptureMode::IncludeCookiesAndCredentials()
56 .ToInternalValueForTesting());
59 TEST(NetLogCaptureMode
, IncludeSocketBytes
) {
60 NetLogCaptureMode mode
= NetLogCaptureMode::IncludeSocketBytes();
62 EXPECT_TRUE(mode
.enabled());
63 EXPECT_TRUE(mode
.include_cookies_and_credentials());
64 EXPECT_TRUE(mode
.include_socket_bytes());
66 EXPECT_NE(mode
, NetLogCaptureMode::None());
67 EXPECT_NE(mode
, NetLogCaptureMode::Default());
68 EXPECT_NE(mode
, NetLogCaptureMode::IncludeCookiesAndCredentials());
69 EXPECT_EQ(mode
, NetLogCaptureMode::IncludeSocketBytes());
71 mode
.ToInternalValueForTesting(),
72 NetLogCaptureMode::IncludeSocketBytes().ToInternalValueForTesting());
75 TEST(NetLogCaptureMode
, Max
) {
76 NetLogCaptureMode none
= NetLogCaptureMode::None();
77 NetLogCaptureMode all
= NetLogCaptureMode::IncludeSocketBytes();
78 NetLogCaptureMode cookies
= NetLogCaptureMode::IncludeCookiesAndCredentials();
79 NetLogCaptureMode def
= NetLogCaptureMode::Default();
81 EXPECT_EQ(all
, NetLogCaptureMode::Max(none
, all
));
82 EXPECT_EQ(all
, NetLogCaptureMode::Max(all
, none
));
84 EXPECT_EQ(cookies
, NetLogCaptureMode::Max(def
, cookies
));
85 EXPECT_EQ(cookies
, NetLogCaptureMode::Max(cookies
, def
));
87 EXPECT_EQ(all
, NetLogCaptureMode::Max(def
, all
));
88 EXPECT_EQ(all
, NetLogCaptureMode::Max(all
, def
));