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

Side by Side Diff: components/proximity_auth/logging/logging_unittest.cc

Issue 2497833002: support multiple log message handlers in base/logging.h (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « components/crash/content/app/crashpad.cc ('k') | content/gpu/gpu_child_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "components/proximity_auth/logging/logging.h" 5 #include "components/proximity_auth/logging/logging.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/numerics/safe_conversions.h" 10 #include "base/numerics/safe_conversions.h"
(...skipping 25 matching lines...) Expand all
36 } // namespace 36 } // namespace
37 37
38 class ProximityAuthLoggingTest : public testing::Test { 38 class ProximityAuthLoggingTest : public testing::Test {
39 public: 39 public:
40 ProximityAuthLoggingTest() : previous_handler_(NULL) {} 40 ProximityAuthLoggingTest() : previous_handler_(NULL) {}
41 41
42 void SetUp() override { 42 void SetUp() override {
43 LogBuffer::GetInstance()->Clear(); 43 LogBuffer::GetInstance()->Clear();
44 g_standard_logs.Get().clear(); 44 g_standard_logs.Get().clear();
45 45
46 previous_handler_ = logging::GetLogMessageHandler(); 46 logging::AddLogMessageHandler(&HandleStandardLogMessage);
47 logging::SetLogMessageHandler(&HandleStandardLogMessage);
48 } 47 }
49 48
50 void TearDown() override { logging::SetLogMessageHandler(previous_handler_); } 49 void TearDown() override {
51 50 logging::RemoveLogMessageHandler(&HandleStandardLogMessage);
52 private: 51 }
53 logging::LogMessageHandlerFunction previous_handler_;
54 }; 52 };
55 53
56 TEST_F(ProximityAuthLoggingTest, LogsSavedToBuffer) { 54 TEST_F(ProximityAuthLoggingTest, LogsSavedToBuffer) {
57 int base_line_number = __LINE__; 55 int base_line_number = __LINE__;
58 PA_LOG(INFO) << kLog1; 56 PA_LOG(INFO) << kLog1;
59 PA_LOG(WARNING) << kLog2; 57 PA_LOG(WARNING) << kLog2;
60 PA_LOG(ERROR) << kLog3; 58 PA_LOG(ERROR) << kLog3;
61 59
62 auto* logs = LogBuffer::GetInstance()->logs(); 60 auto* logs = LogBuffer::GetInstance()->logs();
63 ASSERT_EQ(3u, logs->size()); 61 ASSERT_EQ(3u, logs->size());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 PA_LOG(WARNING) << kLog2; 108 PA_LOG(WARNING) << kLog2;
111 PA_LOG(ERROR) << kLog3; 109 PA_LOG(ERROR) << kLog3;
112 110
113 ASSERT_EQ(3u, g_standard_logs.Get().size()); 111 ASSERT_EQ(3u, g_standard_logs.Get().size());
114 EXPECT_NE(std::string::npos, g_standard_logs.Get()[0].find(kLog1)); 112 EXPECT_NE(std::string::npos, g_standard_logs.Get()[0].find(kLog1));
115 EXPECT_NE(std::string::npos, g_standard_logs.Get()[1].find(kLog2)); 113 EXPECT_NE(std::string::npos, g_standard_logs.Get()[1].find(kLog2));
116 EXPECT_NE(std::string::npos, g_standard_logs.Get()[2].find(kLog3)); 114 EXPECT_NE(std::string::npos, g_standard_logs.Get()[2].find(kLog3));
117 } 115 }
118 116
119 } // namespace proximity_auth 117 } // namespace proximity_auth
OLDNEW
« no previous file with comments | « components/crash/content/app/crashpad.cc ('k') | content/gpu/gpu_child_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698