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

Side by Side Diff: components/ntp_snippets/remote/request_throttler_unittest.cc

Issue 2395123002: Connecting UserClassifier to NtpSnippetsFetcher (Closed)
Patch Set: Unit-test fix Created 4 years, 2 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 2016 The Chromium Authors. All rights reserved. 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 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/ntp_snippets/remote/request_throttler.h" 5 #include "components/ntp_snippets/remote/request_throttler.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "components/ntp_snippets/pref_names.h" 10 #include "components/ntp_snippets/pref_names.h"
11 #include "components/prefs/pref_registry_simple.h" 11 #include "components/prefs/pref_registry_simple.h"
12 #include "components/prefs/testing_pref_service.h" 12 #include "components/prefs/testing_pref_service.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 namespace { 15 namespace {
16 const int kCounterQuota = 2; 16 const int kCounterQuota = 2;
17 } // namespace 17 } // namespace
18 18
19 namespace ntp_snippets { 19 namespace ntp_snippets {
20 20
21 class RequestThrottlerTest : public testing::Test { 21 class RequestThrottlerTest : public testing::Test {
22 public: 22 public:
23 RequestThrottlerTest() { 23 RequestThrottlerTest() {
24 RequestThrottler::RegisterProfilePrefs(test_prefs_.registry()); 24 RequestThrottler::RegisterProfilePrefs(test_prefs_.registry());
25 // Use any arbitrary RequestType for this unittest. 25 // Use any arbitrary RequestType for this unittest.
26 throttler_.reset(new RequestThrottler( 26 throttler_.reset(new RequestThrottler(
27 &test_prefs_, 27 &test_prefs_, RequestThrottler::RequestType::
28 RequestThrottler::RequestType::CONTENT_SUGGESTION_FETCHER)); 28 CONTENT_SUGGESTION_FETCHER_ACTIVE_NTP_USER));
29 throttler_->quota_ = kCounterQuota; 29 throttler_->quota_ = kCounterQuota;
30 } 30 }
31 31
32 protected: 32 protected:
33 TestingPrefServiceSimple test_prefs_; 33 TestingPrefServiceSimple test_prefs_;
34 std::unique_ptr<RequestThrottler> throttler_; 34 std::unique_ptr<RequestThrottler> throttler_;
35 35
36 private: 36 private:
37 DISALLOW_COPY_AND_ASSIGN(RequestThrottlerTest); 37 DISALLOW_COPY_AND_ASSIGN(RequestThrottlerTest);
38 }; 38 };
(...skipping 24 matching lines...) Expand all
63 // yesterday. 63 // yesterday.
64 int now_day = (base::Time::Now() - base::Time::UnixEpoch()).InDays(); 64 int now_day = (base::Time::Now() - base::Time::UnixEpoch()).InDays();
65 test_prefs_.SetInteger(ntp_snippets::prefs::kSnippetFetcherRequestsDay, 65 test_prefs_.SetInteger(ntp_snippets::prefs::kSnippetFetcherRequestsDay,
66 now_day - 1); 66 now_day - 1);
67 67
68 // The quota should get reset as the day has changed. 68 // The quota should get reset as the day has changed.
69 EXPECT_TRUE(throttler_->DemandQuotaForRequest(false)); 69 EXPECT_TRUE(throttler_->DemandQuotaForRequest(false));
70 } 70 }
71 71
72 } // namespace ntp_snippets 72 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/remote/request_throttler.cc ('k') | components/ntp_snippets/user_classifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698