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

Side by Side Diff: chrome/browser/chromeos/drive/event_logger_unittest.cc

Issue 14247011: drive: Change EventLogger to take printf format (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/drive/event_logger.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/drive/event_logger.h" 5 #include "chrome/browser/chromeos/drive/event_logger.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 8
9 namespace drive { 9 namespace drive {
10 10
11 TEST(DriveEventLoggerTest, BasicLogging) { 11 TEST(EventLoggerTest, BasicLogging) {
12 EventLogger logger(3); // At most 3 events are kept. 12 EventLogger logger(3); // At most 3 events are kept.
13 EXPECT_EQ(0U, logger.history().size()); 13 EXPECT_EQ(0U, logger.history().size());
14 14
15 logger.Log("first"); 15 logger.Log("first");
16 logger.Log("second"); 16 logger.Log("%dnd", 2);
17 logger.Log("third"); 17 logger.Log("third");
18 18
19 // Events are recorded in the chronological order with sequential IDs. 19 // Events are recorded in the chronological order with sequential IDs.
20 ASSERT_EQ(3U, logger.history().size()); 20 ASSERT_EQ(3U, logger.history().size());
21 EXPECT_EQ(0, logger.history()[0].id); 21 EXPECT_EQ(0, logger.history()[0].id);
22 EXPECT_EQ(std::string("first"), logger.history()[0].what); 22 EXPECT_EQ("first", logger.history()[0].what);
23 EXPECT_EQ(1, logger.history()[1].id); 23 EXPECT_EQ(1, logger.history()[1].id);
24 EXPECT_EQ(std::string("second"), logger.history()[1].what); 24 EXPECT_EQ("2nd", logger.history()[1].what);
25 EXPECT_EQ(2, logger.history()[2].id); 25 EXPECT_EQ(2, logger.history()[2].id);
26 EXPECT_EQ(std::string("third"), logger.history()[2].what); 26 EXPECT_EQ("third", logger.history()[2].what);
27 27
28 logger.Log("fourth"); 28 logger.Log("fourth");
29 // It does not log events beyond the specified. 29 // It does not log events beyond the specified.
30 ASSERT_EQ(3U, logger.history().size()); 30 ASSERT_EQ(3U, logger.history().size());
31 // The oldest events is pushed out. 31 // The oldest events is pushed out.
32 EXPECT_EQ(1, logger.history()[0].id); 32 EXPECT_EQ(1, logger.history()[0].id);
33 EXPECT_EQ(std::string("second"), logger.history()[0].what); 33 EXPECT_EQ("2nd", logger.history()[0].what);
34 EXPECT_EQ(2, logger.history()[1].id); 34 EXPECT_EQ(2, logger.history()[1].id);
35 EXPECT_EQ(std::string("third"), logger.history()[1].what); 35 EXPECT_EQ("third", logger.history()[1].what);
36 EXPECT_EQ(3, logger.history()[2].id); 36 EXPECT_EQ(3, logger.history()[2].id);
37 EXPECT_EQ(std::string("fourth"), logger.history()[2].what); 37 EXPECT_EQ("fourth", logger.history()[2].what);
38 } 38 }
39 39
40 } // namespace drive 40 } // namespace drive
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/drive/event_logger.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698