| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS 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 <sys/file.h> | 5 #include <sys/file.h> |
| 6 | 6 |
| 7 #include <base/eintr_wrapper.h> | 7 #include <base/eintr_wrapper.h> |
| 8 #include <base/file_util.h> | 8 #include <base/file_util.h> |
| 9 #include <base/logging.h> | 9 #include <base/logging.h> |
| 10 #include <base/string_util.h> | 10 #include <base/string_util.h> |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 223 |
| 224 counter_.Init(kTestRecordFile, &Reporter, this); | 224 counter_.Init(kTestRecordFile, &Reporter, this); |
| 225 ExpectReporterCall(/* tag */ 30, /* count */ 90); | 225 ExpectReporterCall(/* tag */ 30, /* count */ 90); |
| 226 counter_.Update(/* tag */ 31, /* count */ 60); | 226 counter_.Update(/* tag */ 31, /* count */ 60); |
| 227 EXPECT_PRED_FORMAT2(AssertRecord, /* day */ 31, /* seconds */ 60); | 227 EXPECT_PRED_FORMAT2(AssertRecord, /* day */ 31, /* seconds */ 60); |
| 228 EXPECT_EQ(TaggedCounter::kRecordValid, counter_.record_state_); | 228 EXPECT_EQ(TaggedCounter::kRecordValid, counter_.record_state_); |
| 229 | 229 |
| 230 ExpectReporterCall(/* tag */ 31, /* count */ 60); | 230 ExpectReporterCall(/* tag */ 31, /* count */ 60); |
| 231 counter_.Init(kTestRecordFile, &Reporter, this); | 231 counter_.Init(kTestRecordFile, &Reporter, this); |
| 232 counter_.Update(/* tag */ 32, /* count */ 0); | 232 counter_.Update(/* tag */ 32, /* count */ 0); |
| 233 EXPECT_TRUE(AssertNoOrEmptyRecordFile()); | 233 EXPECT_PRED_FORMAT2(AssertRecord, /* day */ 32, /* seconds */ 0); |
| 234 EXPECT_EQ(TaggedCounter::kRecordNull, counter_.record_state_); | 234 EXPECT_EQ(TaggedCounter::kRecordValid, counter_.record_state_); |
| 235 } | 235 } |
| 236 | 236 |
| 237 TEST_F(TaggedCounterTest, Update) { | 237 TEST_F(TaggedCounterTest, Update) { |
| 238 counter_.Update(/* tag */ 20, /* count */ 30); | 238 counter_.Update(/* tag */ 20, /* count */ 30); |
| 239 EXPECT_PRED_FORMAT2(AssertRecord, /* day */ 20, /* seconds */ 30); | 239 EXPECT_PRED_FORMAT2(AssertRecord, /* day */ 20, /* seconds */ 30); |
| 240 EXPECT_EQ(TaggedCounter::kRecordValid, counter_.record_state_); | 240 EXPECT_EQ(TaggedCounter::kRecordValid, counter_.record_state_); |
| 241 | 241 |
| 242 counter_.Update(/* tag */ 20, /* count */ 40); | 242 counter_.Update(/* tag */ 20, /* count */ 40); |
| 243 EXPECT_PRED_FORMAT2(AssertRecord, /* day */ 20, /* seconds */ 70); | 243 EXPECT_PRED_FORMAT2(AssertRecord, /* day */ 20, /* seconds */ 70); |
| 244 EXPECT_EQ(TaggedCounter::kRecordValid, counter_.record_state_); | 244 EXPECT_EQ(TaggedCounter::kRecordValid, counter_.record_state_); |
| 245 | 245 |
| 246 ExpectReporterCall(/* tag */ 20, /* count */ 70); | 246 ExpectReporterCall(/* tag */ 20, /* count */ 70); |
| 247 counter_.Update(/* tag */ 21, /* count */ 15); | 247 counter_.Update(/* tag */ 21, /* count */ 15); |
| 248 EXPECT_PRED_FORMAT2(AssertRecord, /* day */ 21, /* seconds */ 15); | 248 EXPECT_PRED_FORMAT2(AssertRecord, /* day */ 21, /* seconds */ 15); |
| 249 EXPECT_EQ(TaggedCounter::kRecordValid, counter_.record_state_); | 249 EXPECT_EQ(TaggedCounter::kRecordValid, counter_.record_state_); |
| 250 | 250 |
| 251 ExpectReporterCall(/* tag */ 21, /* count */ 15); | 251 ExpectReporterCall(/* tag */ 21, /* count */ 15); |
| 252 counter_.Update(/* tag */ 22, /* count */ 0); | 252 counter_.Update(/* tag */ 22, /* count */ 0); |
| 253 EXPECT_TRUE(AssertNoOrEmptyRecordFile()); | 253 EXPECT_PRED_FORMAT2(AssertRecord, /* day */ 22, /* seconds */ 0); |
| 254 EXPECT_EQ(TaggedCounter::kRecordNull, counter_.record_state_); | 254 EXPECT_EQ(TaggedCounter::kRecordValid, counter_.record_state_); |
| 255 } | 255 } |
| 256 | 256 |
| 257 } // namespace chromeos_metrics | 257 } // namespace chromeos_metrics |
| 258 | 258 |
| 259 int main(int argc, char** argv) { | 259 int main(int argc, char** argv) { |
| 260 testing::InitGoogleTest(&argc, argv); | 260 testing::InitGoogleTest(&argc, argv); |
| 261 return RUN_ALL_TESTS(); | 261 return RUN_ALL_TESTS(); |
| 262 } | 262 } |
| OLD | NEW |