Chromium Code Reviews| 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.
|