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

Unified Diff: components/offline_pages/background/request_coordinator_event_logger_unittest.cc

Issue 2089413002: [Offline Pages] Create a event/activity logger (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address initial comments Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: components/offline_pages/background/request_coordinator_event_logger_unittest.cc
diff --git a/components/offline_pages/background/request_coordinator_event_logger_unittest.cc b/components/offline_pages/background/request_coordinator_event_logger_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a8ce29b7cf5394668e14d16e2a74573d0750eaf5
--- /dev/null
+++ b/components/offline_pages/background/request_coordinator_event_logger_unittest.cc
@@ -0,0 +1,54 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/offline_pages/background/request_coordinator_event_logger.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace offline_pages {
+
+namespace {
+
+const char kNamespace[] = "last_n";
+const char kStatus[] = "pending";
+const char kId[] = "foo";
+
+} // namespace
fgorski 2016/06/24 18:17:33 nit: we use two spaces after } } //
chili 2016/06/24 20:30:10 Done.
+
+TEST(RequestCoordinatorEventLoggerTest, RecordsWhenLoggingIsOn) {
+ RequestCoordinatorEventLogger logger;
+ std::vector<std::string> log;
+
+ logger.SetIsLogging(true);
+ logger.RecordSavePageRequestUpdated(kNamespace, kStatus, kId);
+ logger.GetLogs(log);
+
+ EXPECT_EQ(1, log.size());
+}
+
+TEST(RequestCoordinatorEventLoggerTest, RecordsWhenLoggingIsOff) {
+ RequestCoordinatorEventLogger logger;
+ std::vector<std::string> log;
+
+ logger.SetIsLogging(false);
+ logger.RecordSavePageRequestUpdated(kNamespace, kStatus, kId);
+ logger.GetLogs(log);
+
+ EXPECT_EQ(1, log.size());
+}
+
+TEST(RequestCoordinatorEventLoggerTest, DoesNotExceedMaxSize) {
+ RequestCoordinatorEventLogger logger;
+ std::vector<std::string> log;
+
+ logger.SetIsLogging(true);
+ for (int i = 0; i < kMaxLogCount + 1; ++i) {
+ logger.RecordSavePageRequestUpdated(kNamespace, kStatus, kId);
+ }
+ logger.GetLogs(log);
+
+ EXPECT_EQ(kMaxLogCount, log.size());
+}
+
+} // namespace offline_internals
fgorski 2016/06/24 18:17:33 please update to } // (two spaces) and fix the na
chili 2016/06/24 20:30:10 Done.

Powered by Google App Engine
This is Rietveld 408576698