OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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. | |
4 | |
5 #include "components/offline_pages/background/request_coordinator_event_logger.h " | |
6 | |
7 #include "testing/gtest/include/gtest/gtest.h" | |
8 | |
9 namespace offline_internals { | |
fgorski
2016/06/23 16:34:06
I only noticed that now, but why did we go with a
chili
2016/06/24 02:45:50
Oops. brainfart. Fixed.
| |
10 | |
11 namespace { | |
fgorski
2016/06/23 16:34:06
I don't think we need an anonymous namespace here.
chili
2016/06/24 02:45:50
Removed. A couple tests I was looking at had this.
| |
12 | |
13 class RequestCoordinatorEventLoggerTest : public ::testing::Test { | |
fgorski
2016/06/23 16:34:06
Since the fixture is empty you can use TEST() macr
chili
2016/06/24 02:45:51
Done.
| |
14 public: | |
15 RequestCoordinatorEventLoggerTest() {} | |
16 ~RequestCoordinatorEventLoggerTest() {} | |
17 }; | |
18 | |
19 TEST_F(RequestCoordinatorEventLoggerTest, RecordsWhenLoggingIsOn) { | |
20 OfflinePageModelEventLogger logger; | |
Pete Williamson
2016/06/24 00:38:32
Did you mean RequestCoordinatorEventLogger instead
chili
2016/06/24 02:45:51
haha good catch
oops
| |
21 std::vector<std::string> log; | |
22 | |
23 logger.SetIsLogging(true); | |
24 logger.RecordSavePageRequestUpdated("last_n", "pending", "foo"); | |
Pete Williamson
2016/06/24 00:38:32
It might be nice to make last_n, pending, and foo
chili
2016/06/24 02:45:51
Done.
| |
25 logger.GetLogs(log); | |
26 | |
27 EXPECT_EQ(1, log.size()); | |
Pete Williamson
2016/06/24 00:38:32
Can we also test that the content of the logs are
chili
2016/06/24 02:45:51
As explained in the other comment, I ultimately di
Pete Williamson
2016/06/24 16:52:58
OK, I understand that the test will break if we ch
chili
2016/06/24 20:30:10
Added the test.
| |
28 } | |
29 | |
30 TEST_F(RequestCoordinatorEventLoggerTest, RecordsWhenLoggingIsOff) { | |
31 OfflinePageModelEventLogger logger; | |
32 std::vector<std::string> log; | |
33 | |
34 logger.SetIsLogging(false); | |
35 logger.RecordSavePageRequestUpdated("last_n", "pending", "foo"); | |
36 logger.GetLogs(log); | |
37 | |
38 EXPECT_EQ(1, log.size()); | |
39 } | |
40 | |
41 TEST_F(RequestCoordinatorEventLoggerTest, DoesNotExceedMaxSize) { | |
42 OfflinePageModelEventLogger logger; | |
43 std::vector<std::string> log; | |
44 | |
45 logger.SetIsLogging(true); | |
46 for (int i = 0; i < 21; i++) { | |
fgorski
2016/06/23 16:34:06
I am guessing your buffer size is 20.
Could you pl
Pete Williamson
2016/06/24 00:38:31
Maybe you could expose MAX_LOGGED_ACTIVITY_COUNT i
chili
2016/06/24 02:45:51
Done.
| |
47 logger.RecordSavePageRequestUpdated("last_n", "pending", "foo"); | |
48 } | |
49 logger.GetLogs(log); | |
50 | |
51 EXPECT_EQ(20, log.size()); | |
fgorski
2016/06/23 16:34:06
ditto
chili
2016/06/24 02:45:51
Done.
| |
52 } | |
53 | |
54 } // namespace | |
55 | |
56 } // namespace offline_internals | |
OLD | NEW |