Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(419)

Side by Side Diff: net/log/net_log_capture_mode_unittest.cc

Issue 1122483004: Remove NetLog::GetCaptureMode() and NetLogCaptureMode::None() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mmenke_refactor
Patch Set: rename HasObservers --> IsCapturing Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 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 "net/log/net_log_capture_mode.h" 5 #include "net/log/net_log_capture_mode.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace net { 9 namespace net {
10 10
11 namespace { 11 namespace {
12 12
13 TEST(NetLogCaptureMode, None) { 13 TEST(NetLogCaptureMode, DefaultConstructor) {
14 NetLogCaptureMode mode = NetLogCaptureMode::None(); 14 EXPECT_EQ(NetLogCaptureMode(), NetLogCaptureMode::Default());
15
16 EXPECT_FALSE(mode.enabled());
17 EXPECT_FALSE(mode.include_cookies_and_credentials());
18 EXPECT_FALSE(mode.include_socket_bytes());
19
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());
26 } 15 }
27 16
28 TEST(NetLogCaptureMode, Default) { 17 TEST(NetLogCaptureMode, Default) {
29 NetLogCaptureMode mode = NetLogCaptureMode::Default(); 18 NetLogCaptureMode mode = NetLogCaptureMode::Default();
30 19
31 EXPECT_TRUE(mode.enabled());
32 EXPECT_FALSE(mode.include_cookies_and_credentials()); 20 EXPECT_FALSE(mode.include_cookies_and_credentials());
33 EXPECT_FALSE(mode.include_socket_bytes()); 21 EXPECT_FALSE(mode.include_socket_bytes());
34 22
35 EXPECT_NE(mode, NetLogCaptureMode::None());
36 EXPECT_EQ(mode, NetLogCaptureMode::Default()); 23 EXPECT_EQ(mode, NetLogCaptureMode::Default());
37 EXPECT_NE(mode, NetLogCaptureMode::IncludeCookiesAndCredentials()); 24 EXPECT_NE(mode, NetLogCaptureMode::IncludeCookiesAndCredentials());
38 EXPECT_NE(mode, NetLogCaptureMode::IncludeSocketBytes()); 25 EXPECT_NE(mode, NetLogCaptureMode::IncludeSocketBytes());
39 EXPECT_EQ(mode.ToInternalValueForTesting(), 26 EXPECT_EQ(mode.ToInternalValueForTesting(),
40 NetLogCaptureMode::Default().ToInternalValueForTesting()); 27 NetLogCaptureMode::Default().ToInternalValueForTesting());
mmenke 2015/05/06 15:14:42 Hrm...Do we even care about testing this any more?
eroman 2015/05/06 17:01:04 We can get rid of ToInternalValueForTesting() but
41 } 28 }
42 29
43 TEST(NetLogCaptureMode, IncludeCookiesAndCredentials) { 30 TEST(NetLogCaptureMode, IncludeCookiesAndCredentials) {
44 NetLogCaptureMode mode = NetLogCaptureMode::IncludeCookiesAndCredentials(); 31 NetLogCaptureMode mode = NetLogCaptureMode::IncludeCookiesAndCredentials();
45 32
46 EXPECT_TRUE(mode.enabled());
47 EXPECT_TRUE(mode.include_cookies_and_credentials()); 33 EXPECT_TRUE(mode.include_cookies_and_credentials());
48 EXPECT_FALSE(mode.include_socket_bytes()); 34 EXPECT_FALSE(mode.include_socket_bytes());
49 35
50 EXPECT_NE(mode, NetLogCaptureMode::None());
51 EXPECT_NE(mode, NetLogCaptureMode::Default()); 36 EXPECT_NE(mode, NetLogCaptureMode::Default());
52 EXPECT_EQ(mode, NetLogCaptureMode::IncludeCookiesAndCredentials()); 37 EXPECT_EQ(mode, NetLogCaptureMode::IncludeCookiesAndCredentials());
53 EXPECT_NE(mode, NetLogCaptureMode::IncludeSocketBytes()); 38 EXPECT_NE(mode, NetLogCaptureMode::IncludeSocketBytes());
54 EXPECT_EQ(mode.ToInternalValueForTesting(), 39 EXPECT_EQ(mode.ToInternalValueForTesting(),
55 NetLogCaptureMode::IncludeCookiesAndCredentials() 40 NetLogCaptureMode::IncludeCookiesAndCredentials()
56 .ToInternalValueForTesting()); 41 .ToInternalValueForTesting());
57 } 42 }
58 43
59 TEST(NetLogCaptureMode, IncludeSocketBytes) { 44 TEST(NetLogCaptureMode, IncludeSocketBytes) {
60 NetLogCaptureMode mode = NetLogCaptureMode::IncludeSocketBytes(); 45 NetLogCaptureMode mode = NetLogCaptureMode::IncludeSocketBytes();
61 46
62 EXPECT_TRUE(mode.enabled());
63 EXPECT_TRUE(mode.include_cookies_and_credentials()); 47 EXPECT_TRUE(mode.include_cookies_and_credentials());
64 EXPECT_TRUE(mode.include_socket_bytes()); 48 EXPECT_TRUE(mode.include_socket_bytes());
65 49
66 EXPECT_NE(mode, NetLogCaptureMode::None());
67 EXPECT_NE(mode, NetLogCaptureMode::Default()); 50 EXPECT_NE(mode, NetLogCaptureMode::Default());
68 EXPECT_NE(mode, NetLogCaptureMode::IncludeCookiesAndCredentials()); 51 EXPECT_NE(mode, NetLogCaptureMode::IncludeCookiesAndCredentials());
69 EXPECT_EQ(mode, NetLogCaptureMode::IncludeSocketBytes()); 52 EXPECT_EQ(mode, NetLogCaptureMode::IncludeSocketBytes());
70 EXPECT_EQ( 53 EXPECT_EQ(
71 mode.ToInternalValueForTesting(), 54 mode.ToInternalValueForTesting(),
72 NetLogCaptureMode::IncludeSocketBytes().ToInternalValueForTesting()); 55 NetLogCaptureMode::IncludeSocketBytes().ToInternalValueForTesting());
73 } 56 }
74 57
75 TEST(NetLogCaptureMode, Max) {
76 NetLogCaptureMode none = NetLogCaptureMode::None();
77 NetLogCaptureMode all = NetLogCaptureMode::IncludeSocketBytes();
78 NetLogCaptureMode cookies = NetLogCaptureMode::IncludeCookiesAndCredentials();
79 NetLogCaptureMode def = NetLogCaptureMode::Default();
80
81 EXPECT_EQ(all, NetLogCaptureMode::Max(none, all));
82 EXPECT_EQ(all, NetLogCaptureMode::Max(all, none));
83
84 EXPECT_EQ(cookies, NetLogCaptureMode::Max(def, cookies));
85 EXPECT_EQ(cookies, NetLogCaptureMode::Max(cookies, def));
86
87 EXPECT_EQ(all, NetLogCaptureMode::Max(def, all));
88 EXPECT_EQ(all, NetLogCaptureMode::Max(all, def));
89 }
90
91 } // namespace 58 } // namespace
92 59
93 } // namespace net 60 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698