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

Side by Side Diff: components/feature_engagement_tracker/internal/feature_config_condition_validator_unittest.cc

Issue 2911123003: Metrics for feature engagement tracker. (Closed)
Patch Set: Created 3 years, 6 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/feature_engagement_tracker/internal/feature_config_conditio n_validator.h" 5 #include "components/feature_engagement_tracker/internal/feature_config_conditio n_validator.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 9
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 143
144 TEST_F(FeatureConfigConditionValidatorTest, ModelNotReadyShouldFail) { 144 TEST_F(FeatureConfigConditionValidatorTest, ModelNotReadyShouldFail) {
145 base::test::ScopedFeatureList scoped_feature_list; 145 base::test::ScopedFeatureList scoped_feature_list;
146 scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {}); 146 scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
147 147
148 model_.SetIsReady(false); 148 model_.SetIsReady(false);
149 149
150 ConditionValidator::Result result = 150 ConditionValidator::Result result =
151 GetResultForDayZero(GetValidFeatureConfig()); 151 GetResultForDayZero(GetValidFeatureConfig());
152 EXPECT_FALSE(result.NoErrors()); 152 EXPECT_FALSE(result.NoErrors());
153 EXPECT_FALSE(result.model_ready_ok); 153 EXPECT_FALSE(result.event_model_ready_ok);
154 } 154 }
155 155
156 TEST_F(FeatureConfigConditionValidatorTest, ConfigInvalidShouldFail) { 156 TEST_F(FeatureConfigConditionValidatorTest, ConfigInvalidShouldFail) {
157 base::test::ScopedFeatureList scoped_feature_list; 157 base::test::ScopedFeatureList scoped_feature_list;
158 scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {}); 158 scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
159 159
160 ConditionValidator::Result result = GetResultForDayZero(FeatureConfig()); 160 ConditionValidator::Result result = GetResultForDayZero(FeatureConfig());
161 EXPECT_FALSE(result.NoErrors()); 161 EXPECT_FALSE(result.NoErrors());
162 EXPECT_FALSE(result.config_ok); 162 EXPECT_FALSE(result.config_ok);
163 } 163 }
164 164
165 TEST_F(FeatureConfigConditionValidatorTest, MultipleErrorsShouldBeSet) { 165 TEST_F(FeatureConfigConditionValidatorTest, MultipleErrorsShouldBeSet) {
166 base::test::ScopedFeatureList scoped_feature_list; 166 base::test::ScopedFeatureList scoped_feature_list;
167 scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {}); 167 scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
168 168
169 model_.SetIsReady(false); 169 model_.SetIsReady(false);
170 170
171 ConditionValidator::Result result = GetResultForDayZero(FeatureConfig()); 171 ConditionValidator::Result result = GetResultForDayZero(FeatureConfig());
172 EXPECT_FALSE(result.NoErrors()); 172 EXPECT_FALSE(result.NoErrors());
173 EXPECT_FALSE(result.model_ready_ok); 173 EXPECT_FALSE(result.event_model_ready_ok);
174 EXPECT_FALSE(result.config_ok); 174 EXPECT_FALSE(result.config_ok);
175 } 175 }
176 176
177 TEST_F(FeatureConfigConditionValidatorTest, ReadyModelEmptyConfig) { 177 TEST_F(FeatureConfigConditionValidatorTest, ReadyModelEmptyConfig) {
178 base::test::ScopedFeatureList scoped_feature_list; 178 base::test::ScopedFeatureList scoped_feature_list;
179 scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {}); 179 scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
180 180
181 EXPECT_TRUE(GetResultForDayZero(GetValidFeatureConfig()).NoErrors()); 181 EXPECT_TRUE(GetResultForDayZero(GetValidFeatureConfig()).NoErrors());
182 } 182 }
183 183
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 EventConfig("event1", Comparator(EQUAL, 0), 101u, 0)); 529 EventConfig("event1", Comparator(EQUAL, 0), 101u, 0));
530 config.event_configs.insert( 530 config.event_configs.insert(
531 EventConfig("event2", Comparator(EQUAL, 0), 101u, 0)); 531 EventConfig("event2", Comparator(EQUAL, 0), 101u, 0));
532 result = validator_.MeetsConditions(kTestFeatureFoo, config, model_, 532 result = validator_.MeetsConditions(kTestFeatureFoo, config, model_,
533 availability_model_, current_day); 533 availability_model_, current_day);
534 EXPECT_FALSE(result.NoErrors()); 534 EXPECT_FALSE(result.NoErrors());
535 EXPECT_FALSE(result.preconditions_ok); 535 EXPECT_FALSE(result.preconditions_ok);
536 } 536 }
537 537
538 } // namespace feature_engagement_tracker 538 } // namespace feature_engagement_tracker
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698