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

Side by Side Diff: chrome/browser/sync_file_system/logger_unittest.cc

Issue 2494133002: Fix a data race in multiple unit tests processes. (Closed)
Patch Set: fix logger test 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 | « base/test/test_support_android.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/macros.h" 5 #include "base/macros.h"
6 #include "chrome/browser/sync_file_system/logger.h" 6 #include "chrome/browser/sync_file_system/logger.h"
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 using drive::EventLogger; 9 using drive::EventLogger;
10 10
(...skipping 13 matching lines...) Expand all
24 return event.what.find(contains_string) != std::string::npos; 24 return event.what.find(contains_string) != std::string::npos;
25 } 25 }
26 26
27 } // namespace 27 } // namespace
28 28
29 class LoggerTest : public testing::Test { 29 class LoggerTest : public testing::Test {
30 public: 30 public:
31 LoggerTest() {} 31 LoggerTest() {}
32 32
33 void SetUp() override { 33 void SetUp() override {
34 logging::SetMinLogLevel(logging::LOG_INFO);
35 util::ClearLog(); 34 util::ClearLog();
36 } 35 }
37 36
38 private: 37 private:
39 DISALLOW_COPY_AND_ASSIGN(LoggerTest); 38 DISALLOW_COPY_AND_ASSIGN(LoggerTest);
40 }; 39 };
41 40
42 TEST_F(LoggerTest, GetLogHistory) { 41 TEST_F(LoggerTest, GetLogHistory) {
43 LogSampleEvents(); 42 LogSampleEvents();
44 43
45 const std::vector<EventLogger::Event> log = util::GetLogHistory(); 44 const std::vector<EventLogger::Event> log = util::GetLogHistory();
46 ASSERT_EQ(3u, log.size()); 45 ASSERT_EQ(3u, log.size());
47 EXPECT_TRUE(ContainsString("Info test message", log[0])); 46 EXPECT_TRUE(ContainsString("Info test message", log[0]));
48 EXPECT_TRUE(ContainsString("Warning test message", log[1])); 47 EXPECT_TRUE(ContainsString("Warning test message", log[1]));
49 EXPECT_TRUE(ContainsString("Error test message", log[2])); 48 EXPECT_TRUE(ContainsString("Error test message", log[2]));
50 } 49 }
51 50
52 TEST_F(LoggerTest, ClearLog) { 51 TEST_F(LoggerTest, ClearLog) {
53 LogSampleEvents(); 52 LogSampleEvents();
54 EXPECT_EQ(3u, util::GetLogHistory().size()); 53 EXPECT_EQ(3u, util::GetLogHistory().size());
55 54
56 util::ClearLog(); 55 util::ClearLog();
57 EXPECT_EQ(0u, util::GetLogHistory().size()); 56 EXPECT_EQ(0u, util::GetLogHistory().size());
58 } 57 }
59 58
60 59
61 } // namespace sync_file_system 60 } // namespace sync_file_system
OLDNEW
« no previous file with comments | « base/test/test_support_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698