BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / sync_file_system / logger_unittest.cc
blobaad548ab221281079c2bdaa884a34f1f1061d94b
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
3 // found in the LICENSE file.
5 #include "chrome/browser/sync_file_system/logger.h"
6 #include "testing/gtest/include/gtest/gtest.h"
8 using drive::EventLogger;
10 namespace sync_file_system {
12 namespace {
14 // Logs one event at each supported LogSeverity level.
15 void LogSampleEvents() {
16 util::Log(logging::LOG_INFO, FROM_HERE, "Info test message");
17 util::Log(logging::LOG_WARNING, FROM_HERE, "Warning test message");
18 util::Log(logging::LOG_ERROR, FROM_HERE, "Error test message");
21 bool ContainsString(std::string contains_string, EventLogger::Event event) {
22 return event.what.find(contains_string) != std::string::npos;
25 } // namespace
27 class LoggerTest : public testing::Test {
28 public:
29 LoggerTest() {}
31 void SetUp() override {
32 logging::SetMinLogLevel(logging::LOG_INFO);
33 util::ClearLog();
36 private:
37 DISALLOW_COPY_AND_ASSIGN(LoggerTest);
40 TEST_F(LoggerTest, GetLogHistory) {
41 LogSampleEvents();
43 const std::vector<EventLogger::Event> log = util::GetLogHistory();
44 ASSERT_EQ(3u, log.size());
45 EXPECT_TRUE(ContainsString("Info test message", log[0]));
46 EXPECT_TRUE(ContainsString("Warning test message", log[1]));
47 EXPECT_TRUE(ContainsString("Error test message", log[2]));
50 TEST_F(LoggerTest, ClearLog) {
51 LogSampleEvents();
52 EXPECT_EQ(3u, util::GetLogHistory().size());
54 util::ClearLog();
55 EXPECT_EQ(0u, util::GetLogHistory().size());
59 } // namespace sync_file_system