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

Side by Side Diff: components/doodle/doodle_service_unittest.cc

Issue 2833473002: Record NTP.LogoShownTime for timely refreshs only (Closed)
Patch Set: Created 3 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "components/doodle/doodle_service.h" 5 #include "components/doodle/doodle_service.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 ASSERT_THAT(fetcher()->num_pending_callbacks(), Eq(0u)); 483 ASSERT_THAT(fetcher()->num_pending_callbacks(), Eq(0u));
484 484
485 // The outcome should still have been recorded, but not the time - we only 485 // The outcome should still have been recorded, but not the time - we only
486 // record that for successful downloads. 486 // record that for successful downloads.
487 histograms.ExpectUniqueSample("Doodle.ConfigDownloadOutcome", 487 histograms.ExpectUniqueSample("Doodle.ConfigDownloadOutcome",
488 7, // OUTCOME_REFRESH_INTERVAL_NOT_PASSED 488 7, // OUTCOME_REFRESH_INTERVAL_NOT_PASSED
489 1); 489 1);
490 histograms.ExpectTotalCount("Doodle.ConfigDownloadTime", 0); 490 histograms.ExpectTotalCount("Doodle.ConfigDownloadTime", 0);
491 } 491 }
492 492
493 TEST_F(DoodleServiceTest, RefreshReturnsFalseOnlyForSkippedRefreshAttempts) {
494 // Create a service with some refresh interval.
495 RecreateService(/*min_refresh_interval=*/base::TimeDelta::FromMinutes(10));
496
497 // Trigger a refresh within the min refresh interval that is not skipped.
tschumann 2017/04/20 18:53:11 if find the last part of the sentence extremely co
fhorschig 2017/04/24 13:52:35 Yes, changed/merged.
498 EXPECT_TRUE(service()->Refresh());
499 fetcher()->ServeAllCallbacks(DoodleState::NO_DOODLE, base::TimeDelta(),
tschumann 2017/04/20 18:53:11 can you explain the parameters with /**/ comments?
fhorschig 2017/04/24 13:52:35 Done.
500 base::nullopt);
501
502 // Request a refresh before the min refresh interval has passed.
503 task_runner()->FastForwardBy(base::TimeDelta::FromMinutes(5));
tschumann 2017/04/20 18:53:11 why forward the time at all?
fhorschig 2017/04/24 13:52:35 Gone.
504 EXPECT_FALSE(service()->Refresh());
505
506 // This should not have resulted in a request.
tschumann 2017/04/20 18:53:11 nit: combine this comment with the one above and w
fhorschig 2017/04/24 13:52:34 Done.
507 EXPECT_THAT(fetcher()->num_pending_callbacks(), Eq(0u));
508 }
509
493 TEST_F(DoodleServiceTest, DoesNotRecordMetricsAtStartup) { 510 TEST_F(DoodleServiceTest, DoesNotRecordMetricsAtStartup) {
494 // Creating the service should not emit any histogram samples. 511 // Creating the service should not emit any histogram samples.
495 base::HistogramTester histograms; 512 base::HistogramTester histograms;
496 RecreateServiceWithZeroRefreshInterval(); 513 RecreateServiceWithZeroRefreshInterval();
497 ASSERT_THAT(service()->config(), Eq(base::nullopt)); 514 ASSERT_THAT(service()->config(), Eq(base::nullopt));
498 histograms.ExpectTotalCount("Doodle.ConfigDownloadOutcome", 0); 515 histograms.ExpectTotalCount("Doodle.ConfigDownloadOutcome", 0);
499 histograms.ExpectTotalCount("Doodle.ConfigDownloadTime", 0); 516 histograms.ExpectTotalCount("Doodle.ConfigDownloadTime", 0);
500 } 517 }
501 518
502 TEST_F(DoodleServiceTest, DoesNotRecordMetricsAtStartupWithConfig) { 519 TEST_F(DoodleServiceTest, DoesNotRecordMetricsAtStartupWithConfig) {
(...skipping 26 matching lines...) Expand all
529 // Fast-forward time so that the config expires. 546 // Fast-forward time so that the config expires.
530 task_runner()->FastForwardBy(base::TimeDelta::FromHours(1)); 547 task_runner()->FastForwardBy(base::TimeDelta::FromHours(1));
531 ASSERT_THAT(service()->config(), Eq(base::nullopt)); 548 ASSERT_THAT(service()->config(), Eq(base::nullopt));
532 549
533 // This should not have resulted in any metrics being emitted. 550 // This should not have resulted in any metrics being emitted.
534 histograms.ExpectTotalCount("Doodle.ConfigDownloadOutcome", 0); 551 histograms.ExpectTotalCount("Doodle.ConfigDownloadOutcome", 0);
535 histograms.ExpectTotalCount("Doodle.ConfigDownloadTime", 0); 552 histograms.ExpectTotalCount("Doodle.ConfigDownloadTime", 0);
536 } 553 }
537 554
538 } // namespace doodle 555 } // namespace doodle
OLDNEW
« components/doodle/doodle_service.h ('K') | « components/doodle/doodle_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698