Index: components/ntp_snippets/user_classifier.cc |
diff --git a/components/ntp_snippets/user_classifier.cc b/components/ntp_snippets/user_classifier.cc |
index a9122343a1ee3e2977c2416e02121463455b04e1..d25cb2256a1d36bc822d2529f99bf62738eee321 100644 |
--- a/components/ntp_snippets/user_classifier.cc |
+++ b/components/ntp_snippets/user_classifier.cc |
@@ -267,6 +267,10 @@ double UserClassifier::GetEstimatedAvgTime(Metric metric) const { |
} |
UserClassifier::UserClass UserClassifier::GetUserClass() const { |
+ // The pref_service_ can be null in tests. |
+ if (!pref_service_) |
+ return UserClass::ACTIVE_NTP_USER; |
+ |
if (GetEstimatedAvgTime(Metric::NTP_OPENED) >= |
rare_user_opens_ntp_at_most_once_per_hours_) { |
return UserClass::RARE_NTP_USER; |