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

Side by Side Diff: chrome/browser/metrics/variations/variations_request_scheduler_mobile_unittest.cc

Issue 147723010: Expose a method in VariationsService to trigger a seed fetch. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 10 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
(Empty)
1 // Copyright 2013 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 "chrome/browser/metrics/variations/variations_request_scheduler_mobile. h"
6
7 #include "base/bind.h"
8 #include "base/prefs/pref_registry_simple.h"
9 #include "base/prefs/testing_pref_service.h"
10 #include "chrome/common/pref_names.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace chrome_variations {
14
15 namespace {
16
17 // Simple method used to verify a Callback has been triggered.
18 void SetToOne(int *n) {
19 *n = 1;
20 }
21
22 } // namespace
23
24 TEST(VariationsRequestSchedulerMobileTest, StartNoRun) {
25 TestingPrefServiceSimple prefs;
26 // Initialize to as if it was just fetched.
27 prefs.registry()->RegisterInt64Pref(
28 prefs::kVariationsLastFetchTime, base::Time::Now().ToInternalValue());
29 int executed = 0;
30 const base::Closure task = base::Bind(&SetToOne, &executed);
31 VariationsRequestSchedulerMobile scheduler(task, &prefs);
32 scheduler.Start();
33 // We expect it the task to not have triggered.
34 EXPECT_EQ(0, executed);
35 }
36
37 TEST(VariationsRequestSchedulerMobileTest, StartRun) {
38 TestingPrefServiceSimple prefs;
39 // Verify it doesn't take more than a day.
40 base::Time old = base::Time::Now() - base::TimeDelta::FromHours(24);
41 prefs.registry()->RegisterInt64Pref(
42 prefs::kVariationsLastFetchTime, old.ToInternalValue());
43 int executed = 0;
44 const base::Closure task = base::Bind(&SetToOne, &executed);
45 VariationsRequestSchedulerMobile scheduler(task, &prefs);
46 scheduler.Start();
47 // We expect the task to have triggered.
48 EXPECT_EQ(1, executed);
49 }
50
51 } // namespace chrome_variations
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698