summaryrefslogtreecommitdiff
path: root/chromium/components/feature_engagement
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/feature_engagement')
-rw-r--r--chromium/components/feature_engagement/internal/BUILD.gn8
-rw-r--r--chromium/components/feature_engagement/internal/android/java/src/org/chromium/components/feature_engagement/internal/TrackerImpl.java141
-rw-r--r--chromium/components/feature_engagement/internal/chrome_variations_configuration_unittest.cc199
-rw-r--r--chromium/components/feature_engagement/internal/editable_configuration_unittest.cc28
-rw-r--r--chromium/components/feature_engagement/internal/feature_config_condition_validator_unittest.cc272
-rw-r--r--chromium/components/feature_engagement/internal/feature_config_event_storage_validator_unittest.cc32
-rw-r--r--chromium/components/feature_engagement/internal/never_availability_model_unittest.cc16
-rw-r--r--chromium/components/feature_engagement/internal/never_condition_validator_unittest.cc20
-rw-r--r--chromium/components/feature_engagement/internal/once_condition_validator_unittest.cc58
-rw-r--r--chromium/components/feature_engagement/internal/persistent_availability_store_unittest.cc103
-rw-r--r--chromium/components/feature_engagement/internal/persistent_event_store.cc5
-rw-r--r--chromium/components/feature_engagement/internal/single_invalid_configuration_unittest.cc14
-rw-r--r--chromium/components/feature_engagement/internal/test/BUILD.gn4
-rw-r--r--chromium/components/feature_engagement/internal/tracker_impl_unittest.cc220
-rw-r--r--chromium/components/feature_engagement/public/BUILD.gn6
-rw-r--r--chromium/components/feature_engagement/public/android/java/src/org/chromium/components/feature_engagement/EventConstants.java167
-rw-r--r--chromium/components/feature_engagement/public/android/java/src/org/chromium/components/feature_engagement/FeatureConstants.java75
-rw-r--r--chromium/components/feature_engagement/public/android/java/src/org/chromium/components/feature_engagement/Tracker.java115
-rw-r--r--chromium/components/feature_engagement/public/event_constants.cc1
-rw-r--r--chromium/components/feature_engagement/public/event_constants.h5
-rw-r--r--chromium/components/feature_engagement/public/feature_constants.cc4
-rw-r--r--chromium/components/feature_engagement/public/feature_constants.h2
-rw-r--r--chromium/components/feature_engagement/public/feature_list.cc2
-rw-r--r--chromium/components/feature_engagement/public/feature_list.h4
24 files changed, 1035 insertions, 466 deletions
diff --git a/chromium/components/feature_engagement/internal/BUILD.gn b/chromium/components/feature_engagement/internal/BUILD.gn
index 6c7a6c5f37c..9c056121d60 100644
--- a/chromium/components/feature_engagement/internal/BUILD.gn
+++ b/chromium/components/feature_engagement/internal/BUILD.gn
@@ -2,12 +2,14 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//build/config/jumbo.gni")
+
if (is_android) {
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
}
-static_library("internal") {
+jumbo_static_library("internal") {
visibility = [
":*",
"//components/feature_engagement",
@@ -88,7 +90,7 @@ static_library("internal") {
}
}
-source_set("unit_tests") {
+jumbo_source_set("unit_tests") {
testonly = true
visibility = [ "//components/feature_engagement:unit_tests" ]
@@ -139,7 +141,7 @@ if (is_android) {
deps = [
"//base:base_java",
"//components/feature_engagement/public:public_java",
- "//third_party/android_tools:android_support_annotations_java",
+ "//third_party/android_deps:android_support_annotations_java",
]
}
diff --git a/chromium/components/feature_engagement/internal/android/java/src/org/chromium/components/feature_engagement/internal/TrackerImpl.java b/chromium/components/feature_engagement/internal/android/java/src/org/chromium/components/feature_engagement/internal/TrackerImpl.java
new file mode 100644
index 00000000000..66139824c17
--- /dev/null
+++ b/chromium/components/feature_engagement/internal/android/java/src/org/chromium/components/feature_engagement/internal/TrackerImpl.java
@@ -0,0 +1,141 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.components.feature_engagement.internal;
+
+import android.support.annotation.CheckResult;
+import android.support.annotation.Nullable;
+
+import org.chromium.base.Callback;
+import org.chromium.base.annotations.CalledByNative;
+import org.chromium.base.annotations.JNINamespace;
+import org.chromium.base.annotations.NativeCall;
+import org.chromium.components.feature_engagement.Tracker;
+import org.chromium.components.feature_engagement.TriggerState;
+
+/**
+ * Java side of the JNI bridge between TrackerImpl in Java
+ * and C++. All method calls are delegated to the native C++ class.
+ */
+@JNINamespace("feature_engagement")
+public class TrackerImpl implements Tracker {
+ /**
+ * A JNI-wrapper for the native DisplayLockHandle.
+ * The C++ counterpart is DisplayLockHandleAndroid.
+ */
+ private static class DisplayLockHandleAndroid implements DisplayLockHandle {
+ @CalledByNative("DisplayLockHandleAndroid")
+ private static DisplayLockHandleAndroid create(long nativePtr) {
+ return new DisplayLockHandleAndroid(nativePtr);
+ }
+
+ long mNativePtr;
+
+ private DisplayLockHandleAndroid(long nativePtr) {
+ mNativePtr = nativePtr;
+ }
+
+ @CalledByNative("DisplayLockHandleAndroid")
+ private void clearNativePtr() {
+ mNativePtr = 0;
+ }
+
+ @Override
+ public void release() {
+ assert mNativePtr != 0;
+ nativeRelease(mNativePtr);
+ assert mNativePtr == 0;
+ }
+
+ @NativeCall("DisplayLockHandleAndroid")
+ private native void nativeRelease(long nativeDisplayLockHandleAndroid);
+ }
+
+ /**
+ * The pointer to the feature_engagement::TrackerImplAndroid JNI bridge.
+ */
+ private long mNativePtr;
+
+ @CalledByNative
+ private static TrackerImpl create(long nativePtr) {
+ return new TrackerImpl(nativePtr);
+ }
+
+ private TrackerImpl(long nativePtr) {
+ mNativePtr = nativePtr;
+ }
+
+ @Override
+ public void notifyEvent(String event) {
+ assert mNativePtr != 0;
+ nativeNotifyEvent(mNativePtr, event);
+ }
+
+ @Override
+ public boolean shouldTriggerHelpUI(String feature) {
+ assert mNativePtr != 0;
+ return nativeShouldTriggerHelpUI(mNativePtr, feature);
+ }
+
+ @Override
+ public boolean wouldTriggerHelpUI(String feature) {
+ assert mNativePtr != 0;
+ return nativeWouldTriggerHelpUI(mNativePtr, feature);
+ }
+
+ @Override
+ @TriggerState
+ public int getTriggerState(String feature) {
+ assert mNativePtr != 0;
+ return nativeGetTriggerState(mNativePtr, feature);
+ }
+
+ @Override
+ public void dismissed(String feature) {
+ assert mNativePtr != 0;
+ nativeDismissed(mNativePtr, feature);
+ }
+
+ @Override
+ @CheckResult
+ @Nullable
+ public DisplayLockHandle acquireDisplayLock() {
+ assert mNativePtr != 0;
+ return nativeAcquireDisplayLock(mNativePtr);
+ }
+
+ @Override
+ public boolean isInitialized() {
+ assert mNativePtr != 0;
+ return nativeIsInitialized(mNativePtr);
+ }
+
+ @Override
+ public void addOnInitializedCallback(Callback<Boolean> callback) {
+ assert mNativePtr != 0;
+ nativeAddOnInitializedCallback(mNativePtr, callback);
+ }
+
+ @CalledByNative
+ private void clearNativePtr() {
+ mNativePtr = 0;
+ }
+
+ @CalledByNative
+ private long getNativePtr() {
+ assert mNativePtr != 0;
+ return mNativePtr;
+ }
+
+ private native void nativeNotifyEvent(long nativeTrackerImplAndroid, String event);
+ private native boolean nativeShouldTriggerHelpUI(long nativeTrackerImplAndroid, String feature);
+ private native boolean nativeWouldTriggerHelpUI(long nativeTrackerImplAndroid, String feature);
+ @TriggerState
+ private native int nativeGetTriggerState(long nativeTrackerImplAndroid, String feature);
+ private native void nativeDismissed(long nativeTrackerImplAndroid, String feature);
+ private native DisplayLockHandleAndroid nativeAcquireDisplayLock(long nativeTrackerImplAndroid);
+ private native boolean nativeIsInitialized(long nativeTrackerImplAndroid);
+ private native void nativeAddOnInitializedCallback(
+ long nativeTrackerImplAndroid, Callback<Boolean> callback);
+}
diff --git a/chromium/components/feature_engagement/internal/chrome_variations_configuration_unittest.cc b/chromium/components/feature_engagement/internal/chrome_variations_configuration_unittest.cc
index 222cf1f791d..b4db135a381 100644
--- a/chromium/components/feature_engagement/internal/chrome_variations_configuration_unittest.cc
+++ b/chromium/components/feature_engagement/internal/chrome_variations_configuration_unittest.cc
@@ -22,12 +22,12 @@ namespace feature_engagement {
namespace {
-const base::Feature kTestFeatureFoo{"test_foo",
- base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kTestFeatureBar{"test_bar",
- base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kTestFeatureQux{"test_qux",
- base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kChromeTestFeatureFoo{"test_foo",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kChromeTestFeatureBar{"test_bar",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kChromeTestFeatureQux{"test_qux",
+ base::FEATURE_DISABLED_BY_DEFAULT};
const char kFooTrialName[] = "FooTrial";
const char kBarTrialName[] = "BarTrial";
@@ -52,25 +52,28 @@ class ChromeVariationsConfigurationTest : public ::testing::Test {
base::FieldTrialList::CreateFieldTrial(kBarTrialName, kGroupName);
base::FieldTrial* qux_trial =
base::FieldTrialList::CreateFieldTrial(kQuxTrialName, kGroupName);
- trials_[kTestFeatureFoo.name] = foo_trial;
- trials_[kTestFeatureBar.name] = bar_trial;
- trials_[kTestFeatureQux.name] = qux_trial;
+ trials_[kChromeTestFeatureFoo.name] = foo_trial;
+ trials_[kChromeTestFeatureBar.name] = bar_trial;
+ trials_[kChromeTestFeatureQux.name] = qux_trial;
std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
feature_list->RegisterFieldTrialOverride(
- kTestFeatureFoo.name, base::FeatureList::OVERRIDE_ENABLE_FEATURE,
+ kChromeTestFeatureFoo.name, base::FeatureList::OVERRIDE_ENABLE_FEATURE,
foo_trial);
feature_list->RegisterFieldTrialOverride(
- kTestFeatureBar.name, base::FeatureList::OVERRIDE_ENABLE_FEATURE,
+ kChromeTestFeatureBar.name, base::FeatureList::OVERRIDE_ENABLE_FEATURE,
bar_trial);
feature_list->RegisterFieldTrialOverride(
- kTestFeatureQux.name, base::FeatureList::OVERRIDE_ENABLE_FEATURE,
+ kChromeTestFeatureQux.name, base::FeatureList::OVERRIDE_ENABLE_FEATURE,
qux_trial);
scoped_feature_list.InitWithFeatureList(std::move(feature_list));
- EXPECT_EQ(foo_trial, base::FeatureList::GetFieldTrial(kTestFeatureFoo));
- EXPECT_EQ(bar_trial, base::FeatureList::GetFieldTrial(kTestFeatureBar));
- EXPECT_EQ(qux_trial, base::FeatureList::GetFieldTrial(kTestFeatureQux));
+ EXPECT_EQ(foo_trial,
+ base::FeatureList::GetFieldTrial(kChromeTestFeatureFoo));
+ EXPECT_EQ(bar_trial,
+ base::FeatureList::GetFieldTrial(kChromeTestFeatureBar));
+ EXPECT_EQ(qux_trial,
+ base::FeatureList::GetFieldTrial(kChromeTestFeatureQux));
}
void TearDown() override {
@@ -96,12 +99,12 @@ class ChromeVariationsConfigurationTest : public ::testing::Test {
foo_params["event_used"] = "name:u;comparator:any;window:0;storage:1";
foo_params["event_trigger"] = "name:et;comparator:any;window:0;storage:360";
foo_params["event_0"] = event_config;
- SetFeatureParams(kTestFeatureFoo, foo_params);
+ SetFeatureParams(kChromeTestFeatureFoo, foo_params);
- std::vector<const base::Feature*> features = {&kTestFeatureFoo};
+ std::vector<const base::Feature*> features = {&kChromeTestFeatureFoo};
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_FALSE(foo.valid);
}
@@ -120,15 +123,16 @@ class ChromeVariationsConfigurationTest : public ::testing::Test {
TEST_F(ChromeVariationsConfigurationTest,
DisabledFeatureShouldHaveInvalidConfig) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({}, {kTestFeatureFoo});
+ scoped_feature_list.InitWithFeatures({}, {kChromeTestFeatureFoo});
FeatureVector features;
- features.push_back(&kTestFeatureFoo);
+ features.push_back(&kChromeTestFeatureFoo);
base::HistogramTester histogram_tester;
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo_config = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo_config =
+ configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_FALSE(foo_config.valid);
histogram_tester.ExpectBucketCount(
kConfigParseEventName,
@@ -148,13 +152,13 @@ TEST_F(ChromeVariationsConfigurationTest, ParseSingleFeature) {
"name:user_opened_app_menu;comparator:<=0;window:120;storage:180";
foo_params["event_3"] =
"name:user_opened_downloads_home;comparator:any;window:0;storage:360";
- SetFeatureParams(kTestFeatureFoo, foo_params);
+ SetFeatureParams(kChromeTestFeatureFoo, foo_params);
base::HistogramTester histogram_tester;
- std::vector<const base::Feature*> features = {&kTestFeatureFoo};
+ std::vector<const base::Feature*> features = {&kChromeTestFeatureFoo};
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_TRUE(foo.valid);
histogram_tester.ExpectBucketCount(
kConfigParseEventName,
@@ -179,13 +183,13 @@ TEST_F(ChromeVariationsConfigurationTest, ParseSingleFeature) {
TEST_F(ChromeVariationsConfigurationTest, MissingUsedIsInvalid) {
std::map<std::string, std::string> foo_params;
foo_params["event_trigger"] = "name:et;comparator:any;window:0;storage:360";
- SetFeatureParams(kTestFeatureFoo, foo_params);
+ SetFeatureParams(kChromeTestFeatureFoo, foo_params);
base::HistogramTester histogram_tester;
- std::vector<const base::Feature*> features = {&kTestFeatureFoo};
+ std::vector<const base::Feature*> features = {&kChromeTestFeatureFoo};
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_FALSE(foo.valid);
histogram_tester.ExpectBucketCount(
kConfigParseEventName,
@@ -200,13 +204,13 @@ TEST_F(ChromeVariationsConfigurationTest, MissingUsedIsInvalid) {
TEST_F(ChromeVariationsConfigurationTest, MissingTriggerIsInvalid) {
std::map<std::string, std::string> foo_params;
foo_params["event_used"] = "name:eu;comparator:any;window:0;storage:360";
- SetFeatureParams(kTestFeatureFoo, foo_params);
+ SetFeatureParams(kChromeTestFeatureFoo, foo_params);
base::HistogramTester histogram_tester;
- std::vector<const base::Feature*> features = {&kTestFeatureFoo};
+ std::vector<const base::Feature*> features = {&kChromeTestFeatureFoo};
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_FALSE(foo.valid);
histogram_tester.ExpectBucketCount(
kConfigParseEventName,
@@ -223,13 +227,13 @@ TEST_F(ChromeVariationsConfigurationTest, OnlyTriggerAndUsedIsValid) {
std::map<std::string, std::string> foo_params;
foo_params["event_used"] = "name:eu;comparator:any;window:0;storage:360";
foo_params["event_trigger"] = "name:et;comparator:any;window:0;storage:360";
- SetFeatureParams(kTestFeatureFoo, foo_params);
+ SetFeatureParams(kChromeTestFeatureFoo, foo_params);
base::HistogramTester histogram_tester;
- std::vector<const base::Feature*> features = {&kTestFeatureFoo};
+ std::vector<const base::Feature*> features = {&kChromeTestFeatureFoo};
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_TRUE(foo.valid);
FeatureConfig expected_foo;
@@ -253,10 +257,10 @@ void RunSessionRateImpactTest(ChromeVariationsConfigurationTest* test,
foo_params["event_used"] = "name:eu;comparator:any;window:0;storage:360";
foo_params["event_trigger"] = "name:et;comparator:any;window:0;storage:360";
foo_params["session_rate_impact"] = session_rate_impact_param_value;
- test->SetFeatureParams(kTestFeatureFoo, foo_params);
+ test->SetFeatureParams(kChromeTestFeatureFoo, foo_params);
configuration->ParseFeatureConfigs(features);
- FeatureConfig foo = configuration->GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration->GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_EQ(is_valid, foo.valid);
FeatureConfig expected_foo;
@@ -270,8 +274,8 @@ void RunSessionRateImpactTest(ChromeVariationsConfigurationTest* test,
TEST_F(ChromeVariationsConfigurationTest, SessionRateImpactAll) {
base::HistogramTester histogram_tester;
- RunSessionRateImpactTest(this, &configuration_, {&kTestFeatureFoo}, "all",
- SessionRateImpact(), true /* is_valid */);
+ RunSessionRateImpactTest(this, &configuration_, {&kChromeTestFeatureFoo},
+ "all", SessionRateImpact(), true /* is_valid */);
histogram_tester.ExpectBucketCount(
kConfigParseEventName,
@@ -283,8 +287,8 @@ TEST_F(ChromeVariationsConfigurationTest, SessionRateImpactNone) {
base::HistogramTester histogram_tester;
SessionRateImpact impact;
impact.type = SessionRateImpact::Type::NONE;
- RunSessionRateImpactTest(this, &configuration_, {&kTestFeatureFoo}, "none",
- impact, true /* is_valid */);
+ RunSessionRateImpactTest(this, &configuration_, {&kChromeTestFeatureFoo},
+ "none", impact, true /* is_valid */);
histogram_tester.ExpectBucketCount(
kConfigParseEventName,
@@ -295,8 +299,8 @@ TEST_F(ChromeVariationsConfigurationTest, SessionRateImpactNone) {
TEST_F(ChromeVariationsConfigurationTest, SessionRateImpactExplicitSelf) {
base::HistogramTester histogram_tester;
RunSessionRateImpactTest(
- this, &configuration_, {&kTestFeatureFoo}, "test_foo",
- CreateSessionRateImpactExplicit({kTestFeatureFoo.name}),
+ this, &configuration_, {&kChromeTestFeatureFoo}, "test_foo",
+ CreateSessionRateImpactExplicit({kChromeTestFeatureFoo.name}),
true /* is_valid */);
histogram_tester.ExpectBucketCount(
@@ -308,8 +312,8 @@ TEST_F(ChromeVariationsConfigurationTest, SessionRateImpactExplicitSelf) {
TEST_F(ChromeVariationsConfigurationTest, SessionRateImpactExplicitOther) {
base::HistogramTester histogram_tester;
RunSessionRateImpactTest(
- this, &configuration_, {&kTestFeatureFoo, &kTestFeatureBar}, "test_bar",
- CreateSessionRateImpactExplicit({kTestFeatureBar.name}),
+ this, &configuration_, {&kChromeTestFeatureFoo, &kChromeTestFeatureBar},
+ "test_bar", CreateSessionRateImpactExplicit({kChromeTestFeatureBar.name}),
true /* is_valid */);
histogram_tester.ExpectBucketCount(
@@ -326,10 +330,10 @@ TEST_F(ChromeVariationsConfigurationTest, SessionRateImpactExplicitMultiple) {
base::HistogramTester histogram_tester;
RunSessionRateImpactTest(
this, &configuration_,
- {&kTestFeatureFoo, &kTestFeatureBar, &kTestFeatureQux},
+ {&kChromeTestFeatureFoo, &kChromeTestFeatureBar, &kChromeTestFeatureQux},
"test_bar,test_qux",
CreateSessionRateImpactExplicit(
- {kTestFeatureBar.name, kTestFeatureQux.name}),
+ {kChromeTestFeatureBar.name, kChromeTestFeatureQux.name}),
true /* is_valid */);
histogram_tester.ExpectBucketCount(
@@ -347,10 +351,10 @@ TEST_F(ChromeVariationsConfigurationTest,
base::HistogramTester histogram_tester;
RunSessionRateImpactTest(
this, &configuration_,
- {&kTestFeatureFoo, &kTestFeatureBar, &kTestFeatureQux},
+ {&kChromeTestFeatureFoo, &kChromeTestFeatureBar, &kChromeTestFeatureQux},
"test_foo,no_feature",
CreateSessionRateImpactExplicit(
- {kTestFeatureBar.name, kTestFeatureQux.name}),
+ {kChromeTestFeatureBar.name, kChromeTestFeatureQux.name}),
true /* is_valid */);
histogram_tester.ExpectBucketCount(
@@ -373,9 +377,10 @@ TEST_F(ChromeVariationsConfigurationTest,
base::HistogramTester histogram_tester;
RunSessionRateImpactTest(
this, &configuration_,
- {&kTestFeatureFoo, &kTestFeatureBar, &kTestFeatureQux}, "test_foo, ",
+ {&kChromeTestFeatureFoo, &kChromeTestFeatureBar, &kChromeTestFeatureQux},
+ "test_foo, ",
CreateSessionRateImpactExplicit(
- {kTestFeatureBar.name, kTestFeatureQux.name}),
+ {kChromeTestFeatureBar.name, kChromeTestFeatureQux.name}),
true /* is_valid */);
histogram_tester.ExpectBucketCount(
@@ -397,7 +402,7 @@ void TestInvalidSessionRateImpactParamValue(
base::HistogramTester histogram_tester;
RunSessionRateImpactTest(
test, configuration,
- {&kTestFeatureFoo, &kTestFeatureBar, &kTestFeatureQux},
+ {&kChromeTestFeatureFoo, &kChromeTestFeatureBar, &kChromeTestFeatureQux},
session_rate_impact_param_value, SessionRateImpact(),
false /* is_valid */);
@@ -520,14 +525,14 @@ TEST_F(ChromeVariationsConfigurationTest, WhitespaceIsValid) {
foo_params["event_6"] = "name:e6;comparator:\n<=7;window:9;storage:400";
foo_params["event_7"] = "name:e7;comparator:<=8\n;window:10;storage:410";
foo_params["session_rate_impact"] = " test_bar, test_qux ";
- SetFeatureParams(kTestFeatureFoo, foo_params);
+ SetFeatureParams(kChromeTestFeatureFoo, foo_params);
base::HistogramTester histogram_tester;
std::vector<const base::Feature*> features = {
- &kTestFeatureFoo, &kTestFeatureBar, &kTestFeatureQux};
+ &kChromeTestFeatureFoo, &kChromeTestFeatureBar, &kChromeTestFeatureQux};
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_TRUE(foo.valid);
FeatureConfig expected_foo;
@@ -551,7 +556,7 @@ TEST_F(ChromeVariationsConfigurationTest, WhitespaceIsValid) {
expected_foo.event_configs.insert(
EventConfig("e7", Comparator(LESS_THAN_OR_EQUAL, 8), 10, 410));
expected_foo.session_rate_impact = CreateSessionRateImpactExplicit(
- {kTestFeatureBar.name, kTestFeatureQux.name});
+ {kChromeTestFeatureBar.name, kChromeTestFeatureQux.name});
EXPECT_EQ(expected_foo, foo);
histogram_tester.ExpectBucketCount(
kConfigParseEventName,
@@ -571,12 +576,12 @@ TEST_F(ChromeVariationsConfigurationTest, IgnoresInvalidConfigKeys) {
foo_params["not_there_yet"] = "bogus value"; // Unrecognized.
foo_params["still_not_there"] = "another bogus value"; // Unrecognized.
foo_params["x_this_is_ignored"] = "this value is ignored"; // Ignored.
- SetFeatureParams(kTestFeatureFoo, foo_params);
+ SetFeatureParams(kChromeTestFeatureFoo, foo_params);
- std::vector<const base::Feature*> features = {&kTestFeatureFoo};
+ std::vector<const base::Feature*> features = {&kChromeTestFeatureFoo};
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_TRUE(foo.valid);
FeatureConfig expected_foo;
@@ -597,12 +602,12 @@ TEST_F(ChromeVariationsConfigurationTest, IgnoresInvalidEventConfigTokens) {
"name:eu;comparator:any;window:0;storage:360;somethingelse:1";
foo_params["event_trigger"] =
"yesway:0;noway:1;name:et;comparator:any;window:0;storage:360";
- SetFeatureParams(kTestFeatureFoo, foo_params);
+ SetFeatureParams(kChromeTestFeatureFoo, foo_params);
- std::vector<const base::Feature*> features = {&kTestFeatureFoo};
+ std::vector<const base::Feature*> features = {&kChromeTestFeatureFoo};
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_TRUE(foo.valid);
FeatureConfig expected_foo;
@@ -663,13 +668,13 @@ TEST_F(ChromeVariationsConfigurationTest,
foo_params["event_used"] = "name:eu;comparator:any;window:1;storage:360";
foo_params["event_trigger"] = "name:et;comparator:any;window:0;storage:360";
foo_params["session_rate"] = "bogus value";
- SetFeatureParams(kTestFeatureFoo, foo_params);
+ SetFeatureParams(kChromeTestFeatureFoo, foo_params);
base::HistogramTester histogram_tester;
- std::vector<const base::Feature*> features = {&kTestFeatureFoo};
+ std::vector<const base::Feature*> features = {&kChromeTestFeatureFoo};
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_FALSE(foo.valid);
histogram_tester.ExpectBucketCount(
kConfigParseEventName,
@@ -687,13 +692,13 @@ TEST_F(ChromeVariationsConfigurationTest,
foo_params["event_used"] = "name:eu;comparator:any;window:0;storage:360";
foo_params["event_trigger"] = "name:et;comparator:any;window:0;storage:360";
foo_params["availability"] = "bogus value";
- SetFeatureParams(kTestFeatureFoo, foo_params);
+ SetFeatureParams(kChromeTestFeatureFoo, foo_params);
base::HistogramTester histogram_tester;
- std::vector<const base::Feature*> features = {&kTestFeatureFoo};
+ std::vector<const base::Feature*> features = {&kChromeTestFeatureFoo};
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_FALSE(foo.valid);
histogram_tester.ExpectBucketCount(
kConfigParseEventName,
@@ -709,13 +714,13 @@ TEST_F(ChromeVariationsConfigurationTest, InvalidUsedCausesInvalidConfig) {
std::map<std::string, std::string> foo_params;
foo_params["event_used"] = "bogus value";
foo_params["event_trigger"] = "name:et;comparator:any;window:0;storage:360";
- SetFeatureParams(kTestFeatureFoo, foo_params);
+ SetFeatureParams(kChromeTestFeatureFoo, foo_params);
base::HistogramTester histogram_tester;
- std::vector<const base::Feature*> features = {&kTestFeatureFoo};
+ std::vector<const base::Feature*> features = {&kChromeTestFeatureFoo};
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_FALSE(foo.valid);
histogram_tester.ExpectBucketCount(
kConfigParseEventName,
@@ -734,13 +739,13 @@ TEST_F(ChromeVariationsConfigurationTest, InvalidTriggerCausesInvalidConfig) {
std::map<std::string, std::string> foo_params;
foo_params["event_used"] = "name:eu;comparator:any;window:0;storage:360";
foo_params["event_trigger"] = "bogus value";
- SetFeatureParams(kTestFeatureFoo, foo_params);
+ SetFeatureParams(kChromeTestFeatureFoo, foo_params);
base::HistogramTester histogram_tester;
- std::vector<const base::Feature*> features = {&kTestFeatureFoo};
+ std::vector<const base::Feature*> features = {&kChromeTestFeatureFoo};
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_FALSE(foo.valid);
histogram_tester.ExpectBucketCount(
kConfigParseEventName,
@@ -763,12 +768,12 @@ TEST_F(ChromeVariationsConfigurationTest,
foo_params["event_used"] = "name:eu;comparator:any;window:0;storage:360";
foo_params["event_trigger"] = "name:et;comparator:any;window:0;storage:360";
foo_params["event_used_0"] = "bogus value";
- SetFeatureParams(kTestFeatureFoo, foo_params);
+ SetFeatureParams(kChromeTestFeatureFoo, foo_params);
- std::vector<const base::Feature*> features = {&kTestFeatureFoo};
+ std::vector<const base::Feature*> features = {&kChromeTestFeatureFoo};
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_FALSE(foo.valid);
}
@@ -778,13 +783,13 @@ TEST_F(ChromeVariationsConfigurationTest,
foo_params["event_used"] = "name:eu;comparator:any;window:0;storage:360";
foo_params["event_trigger"] = "name:et;comparator:any;window:0;storage:360";
foo_params["tracking_only"] = "bogus value";
- SetFeatureParams(kTestFeatureFoo, foo_params);
+ SetFeatureParams(kChromeTestFeatureFoo, foo_params);
base::HistogramTester histogram_tester;
- std::vector<const base::Feature*> features = {&kTestFeatureFoo};
+ std::vector<const base::Feature*> features = {&kChromeTestFeatureFoo};
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_FALSE(foo.valid);
EXPECT_FALSE(foo.tracking_only);
histogram_tester.ExpectBucketCount(
@@ -807,10 +812,10 @@ void RunTrackingOnlyTest(ChromeVariationsConfigurationTest* test,
foo_params["event_used"] = "name:eu;comparator:any;window:0;storage:360";
foo_params["event_trigger"] = "name:et;comparator:any;window:0;storage:360";
foo_params["tracking_only"] = tracking_only_definition;
- test->SetFeatureParams(kTestFeatureFoo, foo_params);
+ test->SetFeatureParams(kChromeTestFeatureFoo, foo_params);
configuration->ParseFeatureConfigs(features);
- FeatureConfig foo = configuration->GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration->GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_EQ(is_valid, foo.valid);
FeatureConfig expected_foo;
@@ -823,7 +828,7 @@ void RunTrackingOnlyTest(ChromeVariationsConfigurationTest* test,
TEST_F(ChromeVariationsConfigurationTest, TrackingOnlyReturnsTrue) {
base::HistogramTester histogram_tester;
- RunTrackingOnlyTest(this, &configuration_, {&kTestFeatureFoo}, "true",
+ RunTrackingOnlyTest(this, &configuration_, {&kChromeTestFeatureFoo}, "true",
true /* expected_value */, true /* is_valid */);
histogram_tester.ExpectBucketCount(
@@ -835,7 +840,7 @@ TEST_F(ChromeVariationsConfigurationTest, TrackingOnlyReturnsTrue) {
TEST_F(ChromeVariationsConfigurationTest,
TrackingOnlyReturnsTrueCaseInsensitive) {
base::HistogramTester histogram_tester;
- RunTrackingOnlyTest(this, &configuration_, {&kTestFeatureFoo}, "tRUe",
+ RunTrackingOnlyTest(this, &configuration_, {&kChromeTestFeatureFoo}, "tRUe",
true /* expected_value */, true /* is_valid */);
histogram_tester.ExpectBucketCount(
@@ -846,7 +851,7 @@ TEST_F(ChromeVariationsConfigurationTest,
TEST_F(ChromeVariationsConfigurationTest, TrackingOnlyReturnsFalse) {
base::HistogramTester histogram_tester;
- RunTrackingOnlyTest(this, &configuration_, {&kTestFeatureFoo}, "false",
+ RunTrackingOnlyTest(this, &configuration_, {&kChromeTestFeatureFoo}, "false",
false /* expected_value */, true /* is_valid */);
histogram_tester.ExpectBucketCount(
@@ -858,7 +863,7 @@ TEST_F(ChromeVariationsConfigurationTest, TrackingOnlyReturnsFalse) {
TEST_F(ChromeVariationsConfigurationTest,
TrackingOnlyReturnsFalseCaseInsensitive) {
base::HistogramTester histogram_tester;
- RunTrackingOnlyTest(this, &configuration_, {&kTestFeatureFoo}, "fALSe",
+ RunTrackingOnlyTest(this, &configuration_, {&kChromeTestFeatureFoo}, "fALSe",
false /* expected_value */, true /* is_valid */);
histogram_tester.ExpectBucketCount(
@@ -878,12 +883,12 @@ TEST_F(ChromeVariationsConfigurationTest, AllComparatorTypesWork) {
foo_params["event_6"] = "name:e6;comparator:!=6;window:26;storage:36";
foo_params["session_rate"] = "!=6";
foo_params["availability"] = ">=1";
- SetFeatureParams(kTestFeatureFoo, foo_params);
+ SetFeatureParams(kChromeTestFeatureFoo, foo_params);
- std::vector<const base::Feature*> features = {&kTestFeatureFoo};
+ std::vector<const base::Feature*> features = {&kChromeTestFeatureFoo};
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_TRUE(foo.valid);
FeatureConfig expected_foo;
@@ -913,12 +918,12 @@ TEST_F(ChromeVariationsConfigurationTest, MultipleEventsWithSameName) {
foo_params["event_3"] = "name:foo;comparator:<=3;window:23;storage:33";
foo_params["session_rate"] = "any";
foo_params["availability"] = ">1";
- SetFeatureParams(kTestFeatureFoo, foo_params);
+ SetFeatureParams(kChromeTestFeatureFoo, foo_params);
- std::vector<const base::Feature*> features = {&kTestFeatureFoo};
+ std::vector<const base::Feature*> features = {&kChromeTestFeatureFoo};
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_TRUE(foo.valid);
FeatureConfig expected_foo;
@@ -942,11 +947,11 @@ TEST_F(ChromeVariationsConfigurationTest, ParseMultipleFeatures) {
"name:foo_trigger;comparator:<1;window:21;storage:31";
foo_params["session_rate"] = "==10";
foo_params["availability"] = "<0";
- SetFeatureParams(kTestFeatureFoo, foo_params);
+ SetFeatureParams(kChromeTestFeatureFoo, foo_params);
std::map<std::string, std::string> bar_params;
bar_params["event_used"] = "name:bar_used;comparator:ANY;window:0;storage:0";
- SetFeatureParams(kTestFeatureBar, bar_params);
+ SetFeatureParams(kChromeTestFeatureBar, bar_params);
std::map<std::string, std::string> qux_params;
qux_params["event_used"] =
@@ -961,13 +966,13 @@ TEST_F(ChromeVariationsConfigurationTest, ParseMultipleFeatures) {
qux_params["event_5"] = "name:q5;comparator:!=15;window:25;storage:35";
qux_params["session_rate"] = "!=13";
qux_params["availability"] = "==0";
- SetFeatureParams(kTestFeatureQux, qux_params);
+ SetFeatureParams(kChromeTestFeatureQux, qux_params);
std::vector<const base::Feature*> features = {
- &kTestFeatureFoo, &kTestFeatureBar, &kTestFeatureQux};
+ &kChromeTestFeatureFoo, &kChromeTestFeatureBar, &kChromeTestFeatureQux};
configuration_.ParseFeatureConfigs(features);
- FeatureConfig foo = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo = configuration_.GetFeatureConfig(kChromeTestFeatureFoo);
EXPECT_TRUE(foo.valid);
FeatureConfig expected_foo;
expected_foo.valid = true;
@@ -978,10 +983,10 @@ TEST_F(ChromeVariationsConfigurationTest, ParseMultipleFeatures) {
expected_foo.availability = Comparator(LESS_THAN, 0);
EXPECT_EQ(expected_foo, foo);
- FeatureConfig bar = configuration_.GetFeatureConfig(kTestFeatureBar);
+ FeatureConfig bar = configuration_.GetFeatureConfig(kChromeTestFeatureBar);
EXPECT_FALSE(bar.valid);
- FeatureConfig qux = configuration_.GetFeatureConfig(kTestFeatureQux);
+ FeatureConfig qux = configuration_.GetFeatureConfig(kChromeTestFeatureQux);
EXPECT_TRUE(qux.valid);
FeatureConfig expected_qux;
expected_qux.valid = true;
diff --git a/chromium/components/feature_engagement/internal/editable_configuration_unittest.cc b/chromium/components/feature_engagement/internal/editable_configuration_unittest.cc
index 817d9881c9d..87d48dc8c90 100644
--- a/chromium/components/feature_engagement/internal/editable_configuration_unittest.cc
+++ b/chromium/components/feature_engagement/internal/editable_configuration_unittest.cc
@@ -14,10 +14,10 @@ namespace feature_engagement {
namespace {
-const base::Feature kTestFeatureFoo{"test_foo",
- base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kTestFeatureBar{"test_bar",
- base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kEditableTestFeatureFoo{"test_foo",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kEditableTestFeatureBar{"test_bar",
+ base::FEATURE_DISABLED_BY_DEFAULT};
class EditableConfigurationTest : public ::testing::Test {
public:
@@ -37,23 +37,23 @@ class EditableConfigurationTest : public ::testing::Test {
TEST_F(EditableConfigurationTest, SingleConfigAddAndGet) {
FeatureConfig foo_config = CreateFeatureConfig("foo", true);
- configuration_.SetConfiguration(&kTestFeatureFoo, foo_config);
+ configuration_.SetConfiguration(&kEditableTestFeatureFoo, foo_config);
const FeatureConfig& foo_config_result =
- configuration_.GetFeatureConfig(kTestFeatureFoo);
+ configuration_.GetFeatureConfig(kEditableTestFeatureFoo);
EXPECT_EQ(foo_config, foo_config_result);
}
TEST_F(EditableConfigurationTest, TwoConfigAddAndGet) {
FeatureConfig foo_config = CreateFeatureConfig("foo", true);
- configuration_.SetConfiguration(&kTestFeatureFoo, foo_config);
+ configuration_.SetConfiguration(&kEditableTestFeatureFoo, foo_config);
FeatureConfig bar_config = CreateFeatureConfig("bar", true);
- configuration_.SetConfiguration(&kTestFeatureBar, bar_config);
+ configuration_.SetConfiguration(&kEditableTestFeatureBar, bar_config);
const FeatureConfig& foo_config_result =
- configuration_.GetFeatureConfig(kTestFeatureFoo);
+ configuration_.GetFeatureConfig(kEditableTestFeatureFoo);
const FeatureConfig& bar_config_result =
- configuration_.GetFeatureConfig(kTestFeatureBar);
+ configuration_.GetFeatureConfig(kEditableTestFeatureBar);
EXPECT_EQ(foo_config, foo_config_result);
EXPECT_EQ(bar_config, bar_config_result);
@@ -61,16 +61,16 @@ TEST_F(EditableConfigurationTest, TwoConfigAddAndGet) {
TEST_F(EditableConfigurationTest, ConfigShouldBeEditable) {
FeatureConfig valid_foo_config = CreateFeatureConfig("foo", true);
- configuration_.SetConfiguration(&kTestFeatureFoo, valid_foo_config);
+ configuration_.SetConfiguration(&kEditableTestFeatureFoo, valid_foo_config);
const FeatureConfig& valid_foo_config_result =
- configuration_.GetFeatureConfig(kTestFeatureFoo);
+ configuration_.GetFeatureConfig(kEditableTestFeatureFoo);
EXPECT_EQ(valid_foo_config, valid_foo_config_result);
FeatureConfig invalid_foo_config = CreateFeatureConfig("foo2", false);
- configuration_.SetConfiguration(&kTestFeatureFoo, invalid_foo_config);
+ configuration_.SetConfiguration(&kEditableTestFeatureFoo, invalid_foo_config);
const FeatureConfig& invalid_foo_config_result =
- configuration_.GetFeatureConfig(kTestFeatureFoo);
+ configuration_.GetFeatureConfig(kEditableTestFeatureFoo);
EXPECT_EQ(invalid_foo_config, invalid_foo_config_result);
}
diff --git a/chromium/components/feature_engagement/internal/feature_config_condition_validator_unittest.cc b/chromium/components/feature_engagement/internal/feature_config_condition_validator_unittest.cc
index ce4a81f0ede..fb47db35620 100644
--- a/chromium/components/feature_engagement/internal/feature_config_condition_validator_unittest.cc
+++ b/chromium/components/feature_engagement/internal/feature_config_condition_validator_unittest.cc
@@ -24,14 +24,14 @@ namespace feature_engagement {
namespace {
-const base::Feature kTestFeatureFoo{"test_foo",
- base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kTestFeatureBar{"test_bar",
- base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kTestFeatureQux{"test_qux",
- base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kTestFeatureXyz{"test_xyz",
- base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kFeatureConfigTestFeatureFoo{
+ "test_foo", base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kFeatureConfigTestFeatureBar{
+ "test_bar", base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kFeatureConfigTestFeatureQux{
+ "test_qux", base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kFeatureConfigTestFeatureXyz{
+ "test_xyz", base::FEATURE_DISABLED_BY_DEFAULT};
FeatureConfig GetValidFeatureConfig() {
FeatureConfig config;
@@ -49,7 +49,7 @@ FeatureConfig GetAcceptingFeatureConfig() {
return config;
}
-SessionRateImpact CreateSessionRateImpactExplicit(
+SessionRateImpact CreateSessionRateImpactTypeExplicit(
std::vector<std::string> affected_features) {
SessionRateImpact impact;
impact.type = SessionRateImpact::Type::EXPLICIT;
@@ -152,21 +152,21 @@ class FeatureConfigConditionValidatorTest : public ::testing::Test {
uint32_t current_day) {
FeatureConfig config = GetAcceptingFeatureConfig();
config.event_configs.insert(EventConfig("event1", comparator, window, 0));
- return validator_.MeetsConditions(kTestFeatureFoo, config, event_model_,
- availability_model_,
+ return validator_.MeetsConditions(kFeatureConfigTestFeatureFoo, config,
+ event_model_, availability_model_,
display_lock_controller_, current_day);
}
ConditionValidator::Result GetResultForDay(const FeatureConfig& config,
uint32_t current_day) {
- return validator_.MeetsConditions(kTestFeatureFoo, config, event_model_,
- availability_model_,
+ return validator_.MeetsConditions(kFeatureConfigTestFeatureFoo, config,
+ event_model_, availability_model_,
display_lock_controller_, current_day);
}
ConditionValidator::Result GetResultForDayZero(const FeatureConfig& config) {
- return validator_.MeetsConditions(kTestFeatureFoo, config, event_model_,
- availability_model_,
+ return validator_.MeetsConditions(kFeatureConfigTestFeatureFoo, config,
+ event_model_, availability_model_,
display_lock_controller_, 0);
}
@@ -192,7 +192,7 @@ class FeatureConfigConditionValidatorTest : public ::testing::Test {
TEST_F(FeatureConfigConditionValidatorTest, ModelNotReadyShouldFail) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
event_model_.SetIsReady(false);
@@ -204,7 +204,7 @@ TEST_F(FeatureConfigConditionValidatorTest, ModelNotReadyShouldFail) {
TEST_F(FeatureConfigConditionValidatorTest, ConfigInvalidShouldFail) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
ConditionValidator::Result result = GetResultForDayZero(FeatureConfig());
EXPECT_FALSE(result.NoErrors());
@@ -213,7 +213,7 @@ TEST_F(FeatureConfigConditionValidatorTest, ConfigInvalidShouldFail) {
TEST_F(FeatureConfigConditionValidatorTest, MultipleErrorsShouldBeSet) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
event_model_.SetIsReady(false);
@@ -225,24 +225,26 @@ TEST_F(FeatureConfigConditionValidatorTest, MultipleErrorsShouldBeSet) {
TEST_F(FeatureConfigConditionValidatorTest, ReadyModelEmptyConfig) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
EXPECT_TRUE(GetResultForDayZero(GetValidFeatureConfig()).NoErrors());
}
TEST_F(FeatureConfigConditionValidatorTest, ReadyModelAcceptingConfig) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
EXPECT_TRUE(GetResultForDayZero(GetAcceptingFeatureConfig()).NoErrors());
}
TEST_F(FeatureConfigConditionValidatorTest, CurrentlyShowing) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo, kTestFeatureBar}, {});
+ scoped_feature_list.InitWithFeatures(
+ {kFeatureConfigTestFeatureFoo, kFeatureConfigTestFeatureBar}, {});
- validator_.NotifyIsShowing(kTestFeatureBar, FeatureConfig(),
- {kTestFeatureFoo.name, kTestFeatureBar.name});
+ validator_.NotifyIsShowing(
+ kFeatureConfigTestFeatureBar, FeatureConfig(),
+ {kFeatureConfigTestFeatureFoo.name, kFeatureConfigTestFeatureBar.name});
ConditionValidator::Result result =
GetResultForDayZero(GetAcceptingFeatureConfig());
EXPECT_FALSE(result.NoErrors());
@@ -251,7 +253,7 @@ TEST_F(FeatureConfigConditionValidatorTest, CurrentlyShowing) {
TEST_F(FeatureConfigConditionValidatorTest, Used) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
FeatureConfig config = GetAcceptingFeatureConfig();
config.used = EventConfig("used", Comparator(LESS_THAN, 0), 0, 0);
@@ -263,7 +265,7 @@ TEST_F(FeatureConfigConditionValidatorTest, Used) {
TEST_F(FeatureConfigConditionValidatorTest, Trigger) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
FeatureConfig config = GetAcceptingFeatureConfig();
config.trigger = EventConfig("trigger", Comparator(LESS_THAN, 0), 0, 0);
@@ -275,7 +277,7 @@ TEST_F(FeatureConfigConditionValidatorTest, Trigger) {
TEST_F(FeatureConfigConditionValidatorTest, SingleOKPrecondition) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
FeatureConfig config = GetAcceptingFeatureConfig();
config.event_configs.insert(EventConfig("event1", Comparator(ANY, 0), 0, 0));
@@ -285,7 +287,7 @@ TEST_F(FeatureConfigConditionValidatorTest, SingleOKPrecondition) {
TEST_F(FeatureConfigConditionValidatorTest, MultipleOKPreconditions) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
FeatureConfig config = GetAcceptingFeatureConfig();
config.event_configs.insert(EventConfig("event1", Comparator(ANY, 0), 0, 0));
@@ -296,7 +298,7 @@ TEST_F(FeatureConfigConditionValidatorTest, MultipleOKPreconditions) {
TEST_F(FeatureConfigConditionValidatorTest, OneOKThenOneFailingPrecondition) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
FeatureConfig config = GetAcceptingFeatureConfig();
config.event_configs.insert(EventConfig("event1", Comparator(ANY, 0), 0, 0));
@@ -310,7 +312,7 @@ TEST_F(FeatureConfigConditionValidatorTest, OneOKThenOneFailingPrecondition) {
TEST_F(FeatureConfigConditionValidatorTest, OneFailingThenOneOKPrecondition) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
FeatureConfig config = GetAcceptingFeatureConfig();
config.event_configs.insert(EventConfig("event1", Comparator(ANY, 0), 0, 0));
@@ -324,7 +326,7 @@ TEST_F(FeatureConfigConditionValidatorTest, OneFailingThenOneOKPrecondition) {
TEST_F(FeatureConfigConditionValidatorTest, TwoFailingPreconditions) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
FeatureConfig config = GetAcceptingFeatureConfig();
config.event_configs.insert(
@@ -339,9 +341,10 @@ TEST_F(FeatureConfigConditionValidatorTest, TwoFailingPreconditions) {
TEST_F(FeatureConfigConditionValidatorTest, SessionRate) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo, kTestFeatureBar}, {});
- std::vector<std::string> all_feature_names = {kTestFeatureFoo.name,
- kTestFeatureBar.name};
+ scoped_feature_list.InitWithFeatures(
+ {kFeatureConfigTestFeatureFoo, kFeatureConfigTestFeatureBar}, {});
+ std::vector<std::string> all_feature_names = {
+ kFeatureConfigTestFeatureFoo.name, kFeatureConfigTestFeatureBar.name};
FeatureConfig foo_config = GetAcceptingFeatureConfig();
foo_config.session_rate = Comparator(LESS_THAN, 2u);
@@ -349,18 +352,21 @@ TEST_F(FeatureConfigConditionValidatorTest, SessionRate) {
EXPECT_TRUE(GetResultForDayZero(foo_config).NoErrors());
- validator_.NotifyIsShowing(kTestFeatureBar, bar_config, all_feature_names);
- validator_.NotifyDismissed(kTestFeatureBar);
+ validator_.NotifyIsShowing(kFeatureConfigTestFeatureBar, bar_config,
+ all_feature_names);
+ validator_.NotifyDismissed(kFeatureConfigTestFeatureBar);
EXPECT_TRUE(GetResultForDayZero(foo_config).NoErrors());
- validator_.NotifyIsShowing(kTestFeatureBar, bar_config, all_feature_names);
- validator_.NotifyDismissed(kTestFeatureBar);
+ validator_.NotifyIsShowing(kFeatureConfigTestFeatureBar, bar_config,
+ all_feature_names);
+ validator_.NotifyDismissed(kFeatureConfigTestFeatureBar);
ConditionValidator::Result result = GetResultForDayZero(foo_config);
EXPECT_FALSE(result.NoErrors());
EXPECT_FALSE(result.session_rate_ok);
- validator_.NotifyIsShowing(kTestFeatureBar, bar_config, all_feature_names);
- validator_.NotifyDismissed(kTestFeatureBar);
+ validator_.NotifyIsShowing(kFeatureConfigTestFeatureBar, bar_config,
+ all_feature_names);
+ validator_.NotifyDismissed(kFeatureConfigTestFeatureBar);
result = GetResultForDayZero(foo_config);
EXPECT_FALSE(result.NoErrors());
EXPECT_FALSE(result.session_rate_ok);
@@ -368,9 +374,10 @@ TEST_F(FeatureConfigConditionValidatorTest, SessionRate) {
TEST_F(FeatureConfigConditionValidatorTest, SessionRateImpactAffectsNone) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo, kTestFeatureBar}, {});
- std::vector<std::string> all_feature_names = {kTestFeatureFoo.name,
- kTestFeatureBar.name};
+ scoped_feature_list.InitWithFeatures(
+ {kFeatureConfigTestFeatureFoo, kFeatureConfigTestFeatureBar}, {});
+ std::vector<std::string> all_feature_names = {
+ kFeatureConfigTestFeatureFoo.name, kFeatureConfigTestFeatureBar.name};
FeatureConfig foo_config = GetAcceptingFeatureConfig();
foo_config.session_rate = Comparator(LESS_THAN, 2u);
@@ -380,28 +387,31 @@ TEST_F(FeatureConfigConditionValidatorTest, SessionRateImpactAffectsNone) {
EXPECT_TRUE(GetResultForDayZero(foo_config).NoErrors());
- validator_.NotifyIsShowing(kTestFeatureBar, affects_none_config,
+ validator_.NotifyIsShowing(kFeatureConfigTestFeatureBar, affects_none_config,
all_feature_names);
- validator_.NotifyDismissed(kTestFeatureBar);
+ validator_.NotifyDismissed(kFeatureConfigTestFeatureBar);
EXPECT_TRUE(GetResultForDayZero(foo_config).NoErrors());
- validator_.NotifyIsShowing(kTestFeatureBar, affects_none_config,
+ validator_.NotifyIsShowing(kFeatureConfigTestFeatureBar, affects_none_config,
all_feature_names);
- validator_.NotifyDismissed(kTestFeatureBar);
+ validator_.NotifyDismissed(kFeatureConfigTestFeatureBar);
EXPECT_TRUE(GetResultForDayZero(foo_config).NoErrors());
- validator_.NotifyIsShowing(kTestFeatureBar, affects_none_config,
+ validator_.NotifyIsShowing(kFeatureConfigTestFeatureBar, affects_none_config,
all_feature_names);
- validator_.NotifyDismissed(kTestFeatureBar);
+ validator_.NotifyDismissed(kFeatureConfigTestFeatureBar);
EXPECT_TRUE(GetResultForDayZero(foo_config).NoErrors());
}
TEST_F(FeatureConfigConditionValidatorTest, SessionRateImpactAffectsExplicit) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitWithFeatures(
- {kTestFeatureFoo, kTestFeatureBar, kTestFeatureQux}, {});
+ {kFeatureConfigTestFeatureFoo, kFeatureConfigTestFeatureBar,
+ kFeatureConfigTestFeatureQux},
+ {});
std::vector<std::string> all_feature_names = {
- kTestFeatureFoo.name, kTestFeatureBar.name, kTestFeatureQux.name};
+ kFeatureConfigTestFeatureFoo.name, kFeatureConfigTestFeatureBar.name,
+ kFeatureConfigTestFeatureQux.name};
FeatureConfig foo_config = GetAcceptingFeatureConfig();
foo_config.session_rate = Comparator(LESS_THAN, 2u);
@@ -410,38 +420,45 @@ TEST_F(FeatureConfigConditionValidatorTest, SessionRateImpactAffectsExplicit) {
FeatureConfig affects_only_foo_config = GetAcceptingFeatureConfig();
affects_only_foo_config.session_rate_impact =
- CreateSessionRateImpactExplicit({kTestFeatureFoo.name});
+ CreateSessionRateImpactTypeExplicit({kFeatureConfigTestFeatureFoo.name});
EXPECT_TRUE(
- GetResultForDayZeroForFeature(kTestFeatureFoo, foo_config).NoErrors());
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureFoo, foo_config)
+ .NoErrors());
EXPECT_TRUE(
- GetResultForDayZeroForFeature(kTestFeatureBar, bar_config).NoErrors());
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureBar, bar_config)
+ .NoErrors());
- validator_.NotifyIsShowing(kTestFeatureQux, affects_only_foo_config,
- all_feature_names);
- validator_.NotifyDismissed(kTestFeatureQux);
+ validator_.NotifyIsShowing(kFeatureConfigTestFeatureQux,
+ affects_only_foo_config, all_feature_names);
+ validator_.NotifyDismissed(kFeatureConfigTestFeatureQux);
EXPECT_TRUE(
- GetResultForDayZeroForFeature(kTestFeatureFoo, foo_config).NoErrors());
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureFoo, foo_config)
+ .NoErrors());
EXPECT_TRUE(
- GetResultForDayZeroForFeature(kTestFeatureBar, bar_config).NoErrors());
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureBar, bar_config)
+ .NoErrors());
- validator_.NotifyIsShowing(kTestFeatureQux, affects_only_foo_config,
- all_feature_names);
- validator_.NotifyDismissed(kTestFeatureQux);
+ validator_.NotifyIsShowing(kFeatureConfigTestFeatureQux,
+ affects_only_foo_config, all_feature_names);
+ validator_.NotifyDismissed(kFeatureConfigTestFeatureQux);
ConditionValidator::Result result =
- GetResultForDayZeroForFeature(kTestFeatureFoo, foo_config);
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureFoo, foo_config);
EXPECT_FALSE(result.NoErrors());
EXPECT_FALSE(result.session_rate_ok);
EXPECT_TRUE(
- GetResultForDayZeroForFeature(kTestFeatureBar, bar_config).NoErrors());
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureBar, bar_config)
+ .NoErrors());
}
TEST_F(FeatureConfigConditionValidatorTest, SessionRateImpactAffectsSelf) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitWithFeatures(
- {kTestFeatureFoo, kTestFeatureBar, kTestFeatureQux}, {});
- std::vector<std::string> all_feature_names = {kTestFeatureFoo.name,
- kTestFeatureBar.name};
+ {kFeatureConfigTestFeatureFoo, kFeatureConfigTestFeatureBar,
+ kFeatureConfigTestFeatureQux},
+ {});
+ std::vector<std::string> all_feature_names = {
+ kFeatureConfigTestFeatureFoo.name, kFeatureConfigTestFeatureBar.name};
FeatureConfig foo_config = GetAcceptingFeatureConfig();
foo_config.session_rate = Comparator(LESS_THAN, 2u);
@@ -450,40 +467,47 @@ TEST_F(FeatureConfigConditionValidatorTest, SessionRateImpactAffectsSelf) {
FeatureConfig affects_only_foo_config = GetAcceptingFeatureConfig();
affects_only_foo_config.session_rate_impact =
- CreateSessionRateImpactExplicit({kTestFeatureFoo.name});
+ CreateSessionRateImpactTypeExplicit({kFeatureConfigTestFeatureFoo.name});
EXPECT_TRUE(
- GetResultForDayZeroForFeature(kTestFeatureFoo, foo_config).NoErrors());
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureFoo, foo_config)
+ .NoErrors());
EXPECT_TRUE(
- GetResultForDayZeroForFeature(kTestFeatureBar, bar_config).NoErrors());
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureBar, bar_config)
+ .NoErrors());
- validator_.NotifyIsShowing(kTestFeatureFoo, affects_only_foo_config,
- all_feature_names);
- validator_.NotifyDismissed(kTestFeatureFoo);
+ validator_.NotifyIsShowing(kFeatureConfigTestFeatureFoo,
+ affects_only_foo_config, all_feature_names);
+ validator_.NotifyDismissed(kFeatureConfigTestFeatureFoo);
EXPECT_TRUE(
- GetResultForDayZeroForFeature(kTestFeatureFoo, foo_config).NoErrors());
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureFoo, foo_config)
+ .NoErrors());
EXPECT_TRUE(
- GetResultForDayZeroForFeature(kTestFeatureBar, bar_config).NoErrors());
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureBar, bar_config)
+ .NoErrors());
- validator_.NotifyIsShowing(kTestFeatureFoo, affects_only_foo_config,
- all_feature_names);
- validator_.NotifyDismissed(kTestFeatureFoo);
+ validator_.NotifyIsShowing(kFeatureConfigTestFeatureFoo,
+ affects_only_foo_config, all_feature_names);
+ validator_.NotifyDismissed(kFeatureConfigTestFeatureFoo);
ConditionValidator::Result result =
- GetResultForDayZeroForFeature(kTestFeatureFoo, foo_config);
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureFoo, foo_config);
EXPECT_FALSE(result.NoErrors());
EXPECT_FALSE(result.session_rate_ok);
EXPECT_TRUE(
- GetResultForDayZeroForFeature(kTestFeatureBar, bar_config).NoErrors());
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureBar, bar_config)
+ .NoErrors());
}
TEST_F(FeatureConfigConditionValidatorTest,
SessionRateImpactAffectsExplicitMultipleFeatures) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitWithFeatures(
- {kTestFeatureFoo, kTestFeatureBar, kTestFeatureQux, kTestFeatureXyz}, {});
+ {kFeatureConfigTestFeatureFoo, kFeatureConfigTestFeatureBar,
+ kFeatureConfigTestFeatureQux, kFeatureConfigTestFeatureXyz},
+ {});
std::vector<std::string> all_feature_names = {
- kTestFeatureFoo.name, kTestFeatureBar.name, kTestFeatureQux.name,
- kTestFeatureXyz.name};
+ kFeatureConfigTestFeatureFoo.name, kFeatureConfigTestFeatureBar.name,
+ kFeatureConfigTestFeatureQux.name, kFeatureConfigTestFeatureXyz.name};
FeatureConfig foo_config = GetAcceptingFeatureConfig();
foo_config.session_rate = Comparator(LESS_THAN, 2u);
@@ -494,44 +518,52 @@ TEST_F(FeatureConfigConditionValidatorTest,
FeatureConfig affects_foo_and_bar_config = GetAcceptingFeatureConfig();
affects_foo_and_bar_config.session_rate_impact =
- CreateSessionRateImpactExplicit(
- {kTestFeatureFoo.name, kTestFeatureBar.name});
+ CreateSessionRateImpactTypeExplicit({kFeatureConfigTestFeatureFoo.name,
+ kFeatureConfigTestFeatureBar.name});
EXPECT_TRUE(
- GetResultForDayZeroForFeature(kTestFeatureFoo, foo_config).NoErrors());
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureFoo, foo_config)
+ .NoErrors());
EXPECT_TRUE(
- GetResultForDayZeroForFeature(kTestFeatureBar, bar_config).NoErrors());
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureBar, bar_config)
+ .NoErrors());
EXPECT_TRUE(
- GetResultForDayZeroForFeature(kTestFeatureXyz, xyz_config).NoErrors());
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureXyz, xyz_config)
+ .NoErrors());
- validator_.NotifyIsShowing(kTestFeatureQux, affects_foo_and_bar_config,
- all_feature_names);
- validator_.NotifyDismissed(kTestFeatureQux);
+ validator_.NotifyIsShowing(kFeatureConfigTestFeatureQux,
+ affects_foo_and_bar_config, all_feature_names);
+ validator_.NotifyDismissed(kFeatureConfigTestFeatureQux);
EXPECT_TRUE(
- GetResultForDayZeroForFeature(kTestFeatureFoo, foo_config).NoErrors());
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureFoo, foo_config)
+ .NoErrors());
EXPECT_TRUE(
- GetResultForDayZeroForFeature(kTestFeatureBar, bar_config).NoErrors());
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureBar, bar_config)
+ .NoErrors());
EXPECT_TRUE(
- GetResultForDayZeroForFeature(kTestFeatureXyz, xyz_config).NoErrors());
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureXyz, xyz_config)
+ .NoErrors());
- validator_.NotifyIsShowing(kTestFeatureQux, affects_foo_and_bar_config,
- all_feature_names);
- validator_.NotifyDismissed(kTestFeatureQux);
+ validator_.NotifyIsShowing(kFeatureConfigTestFeatureQux,
+ affects_foo_and_bar_config, all_feature_names);
+ validator_.NotifyDismissed(kFeatureConfigTestFeatureQux);
ConditionValidator::Result foo_result =
- GetResultForDayZeroForFeature(kTestFeatureFoo, foo_config);
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureFoo, foo_config);
EXPECT_FALSE(foo_result.NoErrors());
EXPECT_FALSE(foo_result.session_rate_ok);
ConditionValidator::Result bar_result =
- GetResultForDayZeroForFeature(kTestFeatureFoo, bar_config);
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureFoo, bar_config);
EXPECT_FALSE(bar_result.NoErrors());
EXPECT_FALSE(bar_result.session_rate_ok);
EXPECT_TRUE(
- GetResultForDayZeroForFeature(kTestFeatureXyz, xyz_config).NoErrors());
+ GetResultForDayZeroForFeature(kFeatureConfigTestFeatureXyz, xyz_config)
+ .NoErrors());
}
TEST_F(FeatureConfigConditionValidatorTest, Availability) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo, kTestFeatureBar}, {});
+ scoped_feature_list.InitWithFeatures(
+ {kFeatureConfigTestFeatureFoo, kFeatureConfigTestFeatureBar}, {});
FeatureConfig config = GetAcceptingFeatureConfig();
EXPECT_TRUE(GetResultForDayZero(config).NoErrors());
@@ -551,7 +583,7 @@ TEST_F(FeatureConfigConditionValidatorTest, Availability) {
// For a feature that became available on day 2 that has to have been
// available for at least 1 day, it should start being accepted on day 3.
- availability_model_.SetAvailability(&kTestFeatureFoo, 2u);
+ availability_model_.SetAvailability(&kFeatureConfigTestFeatureFoo, 2u);
config.availability = Comparator(GREATER_THAN_OR_EQUAL, 1u);
result = GetResultForDay(config, 1u);
EXPECT_FALSE(result.NoErrors());
@@ -564,7 +596,7 @@ TEST_F(FeatureConfigConditionValidatorTest, Availability) {
// For a feature that became available on day 10 that has to have been
// available for at least 3 days, it should start being accepted on day 13.
- availability_model_.SetAvailability(&kTestFeatureFoo, 10u);
+ availability_model_.SetAvailability(&kFeatureConfigTestFeatureFoo, 10u);
config.availability = Comparator(GREATER_THAN_OR_EQUAL, 3u);
result = GetResultForDay(config, 11u);
EXPECT_FALSE(result.NoErrors());
@@ -578,7 +610,7 @@ TEST_F(FeatureConfigConditionValidatorTest, Availability) {
TEST_F(FeatureConfigConditionValidatorTest, SingleEventChangingComparator) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
uint32_t current_day = 102u;
uint32_t window = 10u;
@@ -604,7 +636,7 @@ TEST_F(FeatureConfigConditionValidatorTest, SingleEventChangingComparator) {
TEST_F(FeatureConfigConditionValidatorTest, SingleEventChangingWindow) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
Event event1;
event1.set_name("event1");
@@ -639,7 +671,7 @@ TEST_F(FeatureConfigConditionValidatorTest, SingleEventChangingWindow) {
TEST_F(FeatureConfigConditionValidatorTest, CapEarliestAcceptedDayAtEpoch) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
Event event1;
event1.set_name("event1");
@@ -666,7 +698,7 @@ TEST_F(FeatureConfigConditionValidatorTest, CapEarliestAcceptedDayAtEpoch) {
TEST_F(FeatureConfigConditionValidatorTest, TestMultipleEvents) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
Event event1;
event1.set_name("event1");
@@ -691,7 +723,7 @@ TEST_F(FeatureConfigConditionValidatorTest, TestMultipleEvents) {
config.event_configs.insert(
EventConfig("event2", Comparator(EQUAL, 5u), 99u, 0));
ConditionValidator::Result result = validator_.MeetsConditions(
- kTestFeatureFoo, config, event_model_, availability_model_,
+ kFeatureConfigTestFeatureFoo, config, event_model_, availability_model_,
display_lock_controller_, current_day);
EXPECT_TRUE(result.NoErrors());
@@ -701,8 +733,8 @@ TEST_F(FeatureConfigConditionValidatorTest, TestMultipleEvents) {
EventConfig("event1", Comparator(EQUAL, 20u), 100u, 0));
config.event_configs.insert(
EventConfig("event2", Comparator(EQUAL, 10u), 100u, 0));
- result = validator_.MeetsConditions(kTestFeatureFoo, config, event_model_,
- availability_model_,
+ result = validator_.MeetsConditions(kFeatureConfigTestFeatureFoo, config,
+ event_model_, availability_model_,
display_lock_controller_, current_day);
EXPECT_TRUE(result.NoErrors());
@@ -712,8 +744,8 @@ TEST_F(FeatureConfigConditionValidatorTest, TestMultipleEvents) {
EventConfig("event1", Comparator(EQUAL, 30u), 101u, 0));
config.event_configs.insert(
EventConfig("event2", Comparator(EQUAL, 15u), 101u, 0));
- result = validator_.MeetsConditions(kTestFeatureFoo, config, event_model_,
- availability_model_,
+ result = validator_.MeetsConditions(kFeatureConfigTestFeatureFoo, config,
+ event_model_, availability_model_,
display_lock_controller_, current_day);
EXPECT_TRUE(result.NoErrors());
@@ -724,8 +756,8 @@ TEST_F(FeatureConfigConditionValidatorTest, TestMultipleEvents) {
EventConfig("event1", Comparator(EQUAL, 0), 101u, 0));
config.event_configs.insert(
EventConfig("event2", Comparator(EQUAL, 15u), 101u, 0));
- result = validator_.MeetsConditions(kTestFeatureFoo, config, event_model_,
- availability_model_,
+ result = validator_.MeetsConditions(kFeatureConfigTestFeatureFoo, config,
+ event_model_, availability_model_,
display_lock_controller_, current_day);
EXPECT_FALSE(result.NoErrors());
EXPECT_FALSE(result.preconditions_ok);
@@ -737,8 +769,8 @@ TEST_F(FeatureConfigConditionValidatorTest, TestMultipleEvents) {
EventConfig("event1", Comparator(EQUAL, 30u), 101u, 0));
config.event_configs.insert(
EventConfig("event2", Comparator(EQUAL, 0), 101u, 0));
- result = validator_.MeetsConditions(kTestFeatureFoo, config, event_model_,
- availability_model_,
+ result = validator_.MeetsConditions(kFeatureConfigTestFeatureFoo, config,
+ event_model_, availability_model_,
display_lock_controller_, current_day);
EXPECT_FALSE(result.NoErrors());
EXPECT_FALSE(result.preconditions_ok);
@@ -750,8 +782,8 @@ TEST_F(FeatureConfigConditionValidatorTest, TestMultipleEvents) {
EventConfig("event1", Comparator(EQUAL, 0), 101u, 0));
config.event_configs.insert(
EventConfig("event2", Comparator(EQUAL, 0), 101u, 0));
- result = validator_.MeetsConditions(kTestFeatureFoo, config, event_model_,
- availability_model_,
+ result = validator_.MeetsConditions(kFeatureConfigTestFeatureFoo, config,
+ event_model_, availability_model_,
display_lock_controller_, current_day);
EXPECT_FALSE(result.NoErrors());
EXPECT_FALSE(result.preconditions_ok);
@@ -759,7 +791,7 @@ TEST_F(FeatureConfigConditionValidatorTest, TestMultipleEvents) {
TEST_F(FeatureConfigConditionValidatorTest, TestStaggeredTriggering) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
// Trigger maximum 2 times, and only 1 time last 2 days (today + yesterday).
FeatureConfig config;
@@ -799,7 +831,7 @@ TEST_F(FeatureConfigConditionValidatorTest, TestStaggeredTriggering) {
TEST_F(FeatureConfigConditionValidatorTest, TestMultipleEventsWithSameName) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
// Trigger maximum 2 times, and only 1 time last 2 days (today + yesterday).
FeatureConfig config = GetAcceptingFeatureConfig();
@@ -836,7 +868,7 @@ TEST_F(FeatureConfigConditionValidatorTest, TestMultipleEventsWithSameName) {
TEST_F(FeatureConfigConditionValidatorTest, DisplayLockedStatus) {
base::test::ScopedFeatureList scoped_feature_list;
- scoped_feature_list.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list.InitWithFeatures({kFeatureConfigTestFeatureFoo}, {});
// When the display is locked, the result should be negative.
display_lock_controller_.SetNextIsDisplayLockedResult(true);
diff --git a/chromium/components/feature_engagement/internal/feature_config_event_storage_validator_unittest.cc b/chromium/components/feature_engagement/internal/feature_config_event_storage_validator_unittest.cc
index e34b018c6df..78eb92a2c8f 100644
--- a/chromium/components/feature_engagement/internal/feature_config_event_storage_validator_unittest.cc
+++ b/chromium/components/feature_engagement/internal/feature_config_event_storage_validator_unittest.cc
@@ -19,10 +19,10 @@ namespace feature_engagement {
namespace {
-const base::Feature kTestFeatureFoo{"test_foo",
- base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kTestFeatureBar{"test_bar",
- base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kEventStorageTestFeatureFoo{
+ "test_foo", base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kEventStorageTestFeatureBar{
+ "test_bar", base::FEATURE_DISABLED_BY_DEFAULT};
FeatureConfig kNeverStored;
FeatureConfig kStoredInUsed1Day;
@@ -105,22 +105,23 @@ class FeatureConfigEventStorageValidatorTest : public ::testing::Test {
}
void UseConfig(const FeatureConfig& foo_config) {
- FeatureVector features = {&kTestFeatureFoo};
+ FeatureVector features = {&kEventStorageTestFeatureFoo};
validator_.ClearForTesting();
EditableConfiguration configuration;
- configuration.SetConfiguration(&kTestFeatureFoo, foo_config);
+ configuration.SetConfiguration(&kEventStorageTestFeatureFoo, foo_config);
validator_.InitializeFeatures(features, configuration);
}
void UseConfigs(const FeatureConfig& foo_config,
const FeatureConfig& bar_config) {
- FeatureVector features = {&kTestFeatureFoo, &kTestFeatureBar};
+ FeatureVector features = {&kEventStorageTestFeatureFoo,
+ &kEventStorageTestFeatureBar};
validator_.ClearForTesting();
EditableConfiguration configuration;
- configuration.SetConfiguration(&kTestFeatureFoo, foo_config);
- configuration.SetConfiguration(&kTestFeatureBar, bar_config);
+ configuration.SetConfiguration(&kEventStorageTestFeatureFoo, foo_config);
+ configuration.SetConfiguration(&kEventStorageTestFeatureBar, bar_config);
validator_.InitializeFeatures(features, configuration);
}
@@ -181,7 +182,8 @@ class FeatureConfigEventStorageValidatorTest : public ::testing::Test {
TEST_F(FeatureConfigEventStorageValidatorTest,
ShouldOnlyUseConfigFromEnabledFeatures) {
- scoped_feature_list_.InitWithFeatures({kTestFeatureFoo}, {kTestFeatureBar});
+ scoped_feature_list_.InitWithFeatures({kEventStorageTestFeatureFoo},
+ {kEventStorageTestFeatureBar});
FeatureConfig foo_config = kNeverStored;
foo_config.used = EventConfig("fooevent", Comparator(ANY, 0), 0, 1);
@@ -196,7 +198,7 @@ TEST_F(FeatureConfigEventStorageValidatorTest,
TEST_F(FeatureConfigEventStorageValidatorTest,
ShouldStoreIfSingleConfigHasMinimum1DayStorage) {
- scoped_feature_list_.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list_.InitWithFeatures({kEventStorageTestFeatureFoo}, {});
UseConfig(kNeverStored);
EXPECT_FALSE(validator_.ShouldStore("myevent"));
@@ -215,7 +217,8 @@ TEST_F(FeatureConfigEventStorageValidatorTest,
TEST_F(FeatureConfigEventStorageValidatorTest,
ShouldStoreIfAnyConfigHasMinimum1DayStorage) {
- scoped_feature_list_.InitWithFeatures({kTestFeatureFoo, kTestFeatureBar}, {});
+ scoped_feature_list_.InitWithFeatures(
+ {kEventStorageTestFeatureFoo, kEventStorageTestFeatureBar}, {});
UseConfigs(kNeverStored, kNeverStored);
EXPECT_FALSE(validator_.ShouldStore("myevent"));
@@ -234,7 +237,7 @@ TEST_F(FeatureConfigEventStorageValidatorTest,
TEST_F(FeatureConfigEventStorageValidatorTest,
ShouldKeepIfSingleConfigMeetsEventAge) {
- scoped_feature_list_.InitWithFeatures({kTestFeatureFoo}, {});
+ scoped_feature_list_.InitWithFeatures({kEventStorageTestFeatureFoo}, {});
UseConfig(kNeverStored);
VerifyNeverKeep();
@@ -264,7 +267,8 @@ TEST_F(FeatureConfigEventStorageValidatorTest,
TEST_F(FeatureConfigEventStorageValidatorTest,
ShouldKeepIfAnyConfigMeetsEventAge) {
- scoped_feature_list_.InitWithFeatures({kTestFeatureFoo, kTestFeatureBar}, {});
+ scoped_feature_list_.InitWithFeatures(
+ {kEventStorageTestFeatureFoo, kEventStorageTestFeatureBar}, {});
UseConfigs(kNeverStored, kNeverStored);
VerifyNeverKeep();
diff --git a/chromium/components/feature_engagement/internal/never_availability_model_unittest.cc b/chromium/components/feature_engagement/internal/never_availability_model_unittest.cc
index 099df237f2e..495011f6305 100644
--- a/chromium/components/feature_engagement/internal/never_availability_model_unittest.cc
+++ b/chromium/components/feature_engagement/internal/never_availability_model_unittest.cc
@@ -15,10 +15,10 @@ namespace feature_engagement {
namespace {
-const base::Feature kTestFeatureFoo{"test_foo",
- base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kTestFeatureBar{"test_bar",
- base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kAvailabilityTestFeatureFoo{
+ "test_foo", base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kAvailabilityTestFeatureBar{
+ "test_bar", base::FEATURE_DISABLED_BY_DEFAULT};
class NeverAvailabilityModelTest : public ::testing::Test {
public:
@@ -40,9 +40,9 @@ class NeverAvailabilityModelTest : public ::testing::Test {
TEST_F(NeverAvailabilityModelTest, ShouldNeverHaveData) {
EXPECT_EQ(base::nullopt,
- availability_model_.GetAvailability(kTestFeatureFoo));
+ availability_model_.GetAvailability(kAvailabilityTestFeatureFoo));
EXPECT_EQ(base::nullopt,
- availability_model_.GetAvailability(kTestFeatureBar));
+ availability_model_.GetAvailability(kAvailabilityTestFeatureBar));
availability_model_.Initialize(
base::BindOnce(&NeverAvailabilityModelTest::OnInitializedCallback,
@@ -51,9 +51,9 @@ TEST_F(NeverAvailabilityModelTest, ShouldNeverHaveData) {
base::RunLoop().RunUntilIdle();
EXPECT_EQ(base::nullopt,
- availability_model_.GetAvailability(kTestFeatureFoo));
+ availability_model_.GetAvailability(kAvailabilityTestFeatureFoo));
EXPECT_EQ(base::nullopt,
- availability_model_.GetAvailability(kTestFeatureBar));
+ availability_model_.GetAvailability(kAvailabilityTestFeatureBar));
}
TEST_F(NeverAvailabilityModelTest, ShouldBeReadyAfterInitialization) {
diff --git a/chromium/components/feature_engagement/internal/never_condition_validator_unittest.cc b/chromium/components/feature_engagement/internal/never_condition_validator_unittest.cc
index ecb8e5234a3..7011d2c5e42 100644
--- a/chromium/components/feature_engagement/internal/never_condition_validator_unittest.cc
+++ b/chromium/components/feature_engagement/internal/never_condition_validator_unittest.cc
@@ -18,15 +18,15 @@ namespace feature_engagement {
namespace {
-const base::Feature kTestFeatureFoo{"test_foo",
- base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kTestFeatureBar{"test_bar",
- base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kNeverTestFeatureFoo{"test_foo",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kNeverTestFeatureBar{"test_bar",
+ base::FEATURE_DISABLED_BY_DEFAULT};
// A EventModel that is always postive to show in-product help.
-class TestEventModel : public EventModel {
+class NeverTestEventModel : public EventModel {
public:
- TestEventModel() = default;
+ NeverTestEventModel() = default;
void Initialize(const OnModelInitializationFinished& callback,
uint32_t current_day) override {}
@@ -40,7 +40,7 @@ class TestEventModel : public EventModel {
void IncrementEvent(const std::string& event_name, uint32_t day) override {}
private:
- DISALLOW_COPY_AND_ASSIGN(TestEventModel);
+ DISALLOW_COPY_AND_ASSIGN(NeverTestEventModel);
};
class NeverConditionValidatorTest : public ::testing::Test {
@@ -48,7 +48,7 @@ class NeverConditionValidatorTest : public ::testing::Test {
NeverConditionValidatorTest() = default;
protected:
- TestEventModel event_model_;
+ NeverTestEventModel event_model_;
NeverAvailabilityModel availability_model_;
NoopDisplayLockController display_lock_controller_;
NeverConditionValidator validator_;
@@ -61,12 +61,12 @@ class NeverConditionValidatorTest : public ::testing::Test {
TEST_F(NeverConditionValidatorTest, ShouldNeverMeetConditions) {
EXPECT_FALSE(validator_
- .MeetsConditions(kTestFeatureFoo, FeatureConfig(),
+ .MeetsConditions(kNeverTestFeatureFoo, FeatureConfig(),
event_model_, availability_model_,
display_lock_controller_, 0u)
.NoErrors());
EXPECT_FALSE(validator_
- .MeetsConditions(kTestFeatureBar, FeatureConfig(),
+ .MeetsConditions(kNeverTestFeatureBar, FeatureConfig(),
event_model_, availability_model_,
display_lock_controller_, 0u)
.NoErrors());
diff --git a/chromium/components/feature_engagement/internal/once_condition_validator_unittest.cc b/chromium/components/feature_engagement/internal/once_condition_validator_unittest.cc
index 210b923d058..6baa055b0a9 100644
--- a/chromium/components/feature_engagement/internal/once_condition_validator_unittest.cc
+++ b/chromium/components/feature_engagement/internal/once_condition_validator_unittest.cc
@@ -18,18 +18,18 @@ namespace feature_engagement {
namespace {
-const base::Feature kTestFeatureFoo{"test_foo",
- base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kTestFeatureBar{"test_bar",
- base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kOnceTestFeatureFoo{"test_foo",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kOnceTestFeatureBar{"test_bar",
+ base::FEATURE_DISABLED_BY_DEFAULT};
FeatureConfig kValidFeatureConfig;
FeatureConfig kInvalidFeatureConfig;
// A EventModel that is easily configurable at runtime.
-class TestEventModel : public EventModel {
+class OnceTestEventModel : public EventModel {
public:
- TestEventModel() : ready_(false) { kValidFeatureConfig.valid = true; }
+ OnceTestEventModel() : ready_(false) { kValidFeatureConfig.valid = true; }
void Initialize(const OnModelInitializationFinished& callback,
uint32_t current_day) override {}
@@ -57,7 +57,7 @@ class OnceConditionValidatorTest : public ::testing::Test {
protected:
EditableConfiguration configuration_;
- TestEventModel event_model_;
+ OnceTestEventModel event_model_;
NeverAvailabilityModel availability_model_;
NoopDisplayLockController display_lock_controller_;
OnceConditionValidator validator_;
@@ -71,14 +71,14 @@ class OnceConditionValidatorTest : public ::testing::Test {
TEST_F(OnceConditionValidatorTest, EnabledFeatureShouldTriggerOnce) {
// Only the first call to MeetsConditions() should lead to enlightenment.
EXPECT_TRUE(validator_
- .MeetsConditions(kTestFeatureFoo, kValidFeatureConfig,
+ .MeetsConditions(kOnceTestFeatureFoo, kValidFeatureConfig,
event_model_, availability_model_,
display_lock_controller_, 0u)
.NoErrors());
- validator_.NotifyIsShowing(kTestFeatureFoo, FeatureConfig(), {""});
+ validator_.NotifyIsShowing(kOnceTestFeatureFoo, FeatureConfig(), {""});
ConditionValidator::Result result = validator_.MeetsConditions(
- kTestFeatureFoo, kValidFeatureConfig, event_model_, availability_model_,
- display_lock_controller_, 0u);
+ kOnceTestFeatureFoo, kValidFeatureConfig, event_model_,
+ availability_model_, display_lock_controller_, 0u);
EXPECT_FALSE(result.NoErrors());
EXPECT_FALSE(result.session_rate_ok);
EXPECT_FALSE(result.trigger_ok);
@@ -86,17 +86,17 @@ TEST_F(OnceConditionValidatorTest, EnabledFeatureShouldTriggerOnce) {
TEST_F(OnceConditionValidatorTest,
BothEnabledAndDisabledFeaturesShouldTrigger) {
- // Only the kTestFeatureFoo feature should lead to enlightenment, since
- // kTestFeatureBar is disabled. Ordering disabled feature first to ensure this
- // captures a different behavior than the
+ // Only the kOnceTestFeatureFoo feature should lead to enlightenment, since
+ // kOnceTestFeatureBar is disabled. Ordering disabled feature first to ensure
+ // this captures a different behavior than the
// OnlyOneFeatureShouldTriggerPerSession test below.
EXPECT_TRUE(validator_
- .MeetsConditions(kTestFeatureBar, kValidFeatureConfig,
+ .MeetsConditions(kOnceTestFeatureBar, kValidFeatureConfig,
event_model_, availability_model_,
display_lock_controller_, 0u)
.NoErrors());
EXPECT_TRUE(validator_
- .MeetsConditions(kTestFeatureFoo, kValidFeatureConfig,
+ .MeetsConditions(kOnceTestFeatureFoo, kValidFeatureConfig,
event_model_, availability_model_,
display_lock_controller_, 0u)
.NoErrors());
@@ -105,12 +105,12 @@ TEST_F(OnceConditionValidatorTest,
TEST_F(OnceConditionValidatorTest, StillTriggerWhenAllFeaturesDisabled) {
// No features should get to show enlightenment.
EXPECT_TRUE(validator_
- .MeetsConditions(kTestFeatureFoo, kValidFeatureConfig,
+ .MeetsConditions(kOnceTestFeatureFoo, kValidFeatureConfig,
event_model_, availability_model_,
display_lock_controller_, 0u)
.NoErrors());
EXPECT_TRUE(validator_
- .MeetsConditions(kTestFeatureBar, kValidFeatureConfig,
+ .MeetsConditions(kOnceTestFeatureBar, kValidFeatureConfig,
event_model_, availability_model_,
display_lock_controller_, 0u)
.NoErrors());
@@ -119,30 +119,30 @@ TEST_F(OnceConditionValidatorTest, StillTriggerWhenAllFeaturesDisabled) {
TEST_F(OnceConditionValidatorTest, OnlyTriggerWhenModelIsReady) {
event_model_.SetIsReady(false);
ConditionValidator::Result result = validator_.MeetsConditions(
- kTestFeatureFoo, kValidFeatureConfig, event_model_, availability_model_,
- display_lock_controller_, 0u);
+ kOnceTestFeatureFoo, kValidFeatureConfig, event_model_,
+ availability_model_, display_lock_controller_, 0u);
EXPECT_FALSE(result.NoErrors());
EXPECT_FALSE(result.event_model_ready_ok);
event_model_.SetIsReady(true);
EXPECT_TRUE(validator_
- .MeetsConditions(kTestFeatureFoo, kValidFeatureConfig,
+ .MeetsConditions(kOnceTestFeatureFoo, kValidFeatureConfig,
event_model_, availability_model_,
display_lock_controller_, 0u)
.NoErrors());
}
TEST_F(OnceConditionValidatorTest, OnlyTriggerIfNothingElseIsShowing) {
- validator_.NotifyIsShowing(kTestFeatureBar, FeatureConfig(), {""});
+ validator_.NotifyIsShowing(kOnceTestFeatureBar, FeatureConfig(), {""});
ConditionValidator::Result result = validator_.MeetsConditions(
- kTestFeatureFoo, kValidFeatureConfig, event_model_, availability_model_,
- display_lock_controller_, 0u);
+ kOnceTestFeatureFoo, kValidFeatureConfig, event_model_,
+ availability_model_, display_lock_controller_, 0u);
EXPECT_FALSE(result.NoErrors());
EXPECT_FALSE(result.currently_showing_ok);
- validator_.NotifyDismissed(kTestFeatureBar);
+ validator_.NotifyDismissed(kOnceTestFeatureBar);
EXPECT_TRUE(validator_
- .MeetsConditions(kTestFeatureFoo, kValidFeatureConfig,
+ .MeetsConditions(kOnceTestFeatureFoo, kValidFeatureConfig,
event_model_, availability_model_,
display_lock_controller_, 0u)
.NoErrors());
@@ -150,13 +150,13 @@ TEST_F(OnceConditionValidatorTest, OnlyTriggerIfNothingElseIsShowing) {
TEST_F(OnceConditionValidatorTest, DoNotTriggerForInvalidConfig) {
ConditionValidator::Result result = validator_.MeetsConditions(
- kTestFeatureFoo, kInvalidFeatureConfig, event_model_, availability_model_,
- display_lock_controller_, 0u);
+ kOnceTestFeatureFoo, kInvalidFeatureConfig, event_model_,
+ availability_model_, display_lock_controller_, 0u);
EXPECT_FALSE(result.NoErrors());
EXPECT_FALSE(result.config_ok);
EXPECT_TRUE(validator_
- .MeetsConditions(kTestFeatureFoo, kValidFeatureConfig,
+ .MeetsConditions(kOnceTestFeatureFoo, kValidFeatureConfig,
event_model_, availability_model_,
display_lock_controller_, 0u)
.NoErrors());
diff --git a/chromium/components/feature_engagement/internal/persistent_availability_store_unittest.cc b/chromium/components/feature_engagement/internal/persistent_availability_store_unittest.cc
index 85b21ac8894..9ace4f3ce0d 100644
--- a/chromium/components/feature_engagement/internal/persistent_availability_store_unittest.cc
+++ b/chromium/components/feature_engagement/internal/persistent_availability_store_unittest.cc
@@ -26,14 +26,14 @@
namespace feature_engagement {
namespace {
-const base::Feature kTestFeatureFoo{"test_foo",
- base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kTestFeatureBar{"test_bar",
- base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kTestFeatureQux{"test_qux",
- base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kTestFeatureNop{"test_nop",
- base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kPersistentTestFeatureFoo{
+ "test_foo", base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kPersistentTestFeatureBar{
+ "test_bar", base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kPersistentTestFeatureQux{
+ "test_qux", base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kPersistentTestFeatureNop{
+ "test_nop", base::FEATURE_DISABLED_BY_DEFAULT};
Availability CreateAvailability(const base::Feature& feature, uint32_t day) {
Availability availability;
@@ -173,13 +173,14 @@ TEST_F(PersistentAvailabilityStoreTest, EmptyDBEmptyFeatureFilterUpdateOK) {
}
TEST_F(PersistentAvailabilityStoreTest, AllNewFeatures) {
- scoped_feature_list_.InitWithFeatures({kTestFeatureFoo, kTestFeatureBar},
- {kTestFeatureQux});
+ scoped_feature_list_.InitWithFeatures(
+ {kPersistentTestFeatureFoo, kPersistentTestFeatureBar},
+ {kPersistentTestFeatureQux});
FeatureVector feature_filter;
- feature_filter.push_back(&kTestFeatureFoo); // Enabled. Not in DB.
- feature_filter.push_back(&kTestFeatureBar); // Enabled. Not in DB.
- feature_filter.push_back(&kTestFeatureQux); // Disabled. Not in DB.
+ feature_filter.push_back(&kPersistentTestFeatureFoo); // Enabled. Not in DB.
+ feature_filter.push_back(&kPersistentTestFeatureBar); // Enabled. Not in DB.
+ feature_filter.push_back(&kPersistentTestFeatureQux); // Disabled. Not in DB.
PersistentAvailabilityStore::LoadAndUpdateStore(
storage_dir_, CreateDB(), feature_filter, std::move(load_callback_), 14u);
@@ -197,35 +198,36 @@ TEST_F(PersistentAvailabilityStoreTest, AllNewFeatures) {
ASSERT_EQ(2u, load_results_->size());
ASSERT_EQ(2u, db_availabilities_.size());
- ASSERT_TRUE(load_results_->find(kTestFeatureFoo.name) !=
+ ASSERT_TRUE(load_results_->find(kPersistentTestFeatureFoo.name) !=
load_results_->end());
- EXPECT_EQ(14u, (*load_results_)[kTestFeatureFoo.name]);
- ASSERT_TRUE(db_availabilities_.find(kTestFeatureFoo.name) !=
+ EXPECT_EQ(14u, (*load_results_)[kPersistentTestFeatureFoo.name]);
+ ASSERT_TRUE(db_availabilities_.find(kPersistentTestFeatureFoo.name) !=
db_availabilities_.end());
- EXPECT_EQ(14u, db_availabilities_[kTestFeatureFoo.name].day());
+ EXPECT_EQ(14u, db_availabilities_[kPersistentTestFeatureFoo.name].day());
- ASSERT_TRUE(load_results_->find(kTestFeatureBar.name) !=
+ ASSERT_TRUE(load_results_->find(kPersistentTestFeatureBar.name) !=
load_results_->end());
- EXPECT_EQ(14u, (*load_results_)[kTestFeatureBar.name]);
- ASSERT_TRUE(db_availabilities_.find(kTestFeatureBar.name) !=
+ EXPECT_EQ(14u, (*load_results_)[kPersistentTestFeatureBar.name]);
+ ASSERT_TRUE(db_availabilities_.find(kPersistentTestFeatureBar.name) !=
db_availabilities_.end());
- EXPECT_EQ(14u, db_availabilities_[kTestFeatureBar.name].day());
+ EXPECT_EQ(14u, db_availabilities_[kPersistentTestFeatureBar.name].day());
}
TEST_F(PersistentAvailabilityStoreTest, TestAllFilterCombinations) {
- scoped_feature_list_.InitWithFeatures({kTestFeatureFoo, kTestFeatureBar},
- {kTestFeatureQux, kTestFeatureNop});
+ scoped_feature_list_.InitWithFeatures(
+ {kPersistentTestFeatureFoo, kPersistentTestFeatureBar},
+ {kPersistentTestFeatureQux, kPersistentTestFeatureNop});
FeatureVector feature_filter;
- feature_filter.push_back(&kTestFeatureFoo); // Enabled. Not in DB.
- feature_filter.push_back(&kTestFeatureBar); // Enabled. In DB.
- feature_filter.push_back(&kTestFeatureQux); // Disabled. Not in DB.
- feature_filter.push_back(&kTestFeatureNop); // Disabled. In DB.
+ feature_filter.push_back(&kPersistentTestFeatureFoo); // Enabled. Not in DB.
+ feature_filter.push_back(&kPersistentTestFeatureBar); // Enabled. In DB.
+ feature_filter.push_back(&kPersistentTestFeatureQux); // Disabled. Not in DB.
+ feature_filter.push_back(&kPersistentTestFeatureNop); // Disabled. In DB.
- db_availabilities_[kTestFeatureBar.name] =
- CreateAvailability(kTestFeatureBar, 10u);
- db_availabilities_[kTestFeatureNop.name] =
- CreateAvailability(kTestFeatureNop, 8u);
+ db_availabilities_[kPersistentTestFeatureBar.name] =
+ CreateAvailability(kPersistentTestFeatureBar, 10u);
+ db_availabilities_[kPersistentTestFeatureNop.name] =
+ CreateAvailability(kPersistentTestFeatureNop, 8u);
PersistentAvailabilityStore::LoadAndUpdateStore(
storage_dir_, CreateDB(), feature_filter, std::move(load_callback_), 14u);
@@ -243,35 +245,36 @@ TEST_F(PersistentAvailabilityStoreTest, TestAllFilterCombinations) {
ASSERT_EQ(2u, load_results_->size());
ASSERT_EQ(2u, db_availabilities_.size());
- ASSERT_TRUE(load_results_->find(kTestFeatureFoo.name) !=
+ ASSERT_TRUE(load_results_->find(kPersistentTestFeatureFoo.name) !=
load_results_->end());
- EXPECT_EQ(14u, (*load_results_)[kTestFeatureFoo.name]);
- ASSERT_TRUE(db_availabilities_.find(kTestFeatureFoo.name) !=
+ EXPECT_EQ(14u, (*load_results_)[kPersistentTestFeatureFoo.name]);
+ ASSERT_TRUE(db_availabilities_.find(kPersistentTestFeatureFoo.name) !=
db_availabilities_.end());
- EXPECT_EQ(14u, db_availabilities_[kTestFeatureFoo.name].day());
+ EXPECT_EQ(14u, db_availabilities_[kPersistentTestFeatureFoo.name].day());
- ASSERT_TRUE(load_results_->find(kTestFeatureBar.name) !=
+ ASSERT_TRUE(load_results_->find(kPersistentTestFeatureBar.name) !=
load_results_->end());
- EXPECT_EQ(10u, (*load_results_)[kTestFeatureBar.name]);
- ASSERT_TRUE(db_availabilities_.find(kTestFeatureBar.name) !=
+ EXPECT_EQ(10u, (*load_results_)[kPersistentTestFeatureBar.name]);
+ ASSERT_TRUE(db_availabilities_.find(kPersistentTestFeatureBar.name) !=
db_availabilities_.end());
- EXPECT_EQ(10u, db_availabilities_[kTestFeatureBar.name].day());
+ EXPECT_EQ(10u, db_availabilities_[kPersistentTestFeatureBar.name].day());
}
TEST_F(PersistentAvailabilityStoreTest, TestAllCombinationsEmptyFilter) {
- scoped_feature_list_.InitWithFeatures({kTestFeatureFoo, kTestFeatureBar},
- {kTestFeatureQux, kTestFeatureNop});
+ scoped_feature_list_.InitWithFeatures(
+ {kPersistentTestFeatureFoo, kPersistentTestFeatureBar},
+ {kPersistentTestFeatureQux, kPersistentTestFeatureNop});
// Empty filter, but the following setup:
- // kTestFeatureFoo: Enabled. Not in DB.
- // kTestFeatureBar: Enabled. In DB.
- // kTestFeatureQux: Disabled. Not in DB.
- // kTestFeatureNop: Disabled. In DB.
-
- db_availabilities_[kTestFeatureBar.name] =
- CreateAvailability(kTestFeatureBar, 10u);
- db_availabilities_[kTestFeatureNop.name] =
- CreateAvailability(kTestFeatureNop, 8u);
+ // kPersistentTestFeatureFoo: Enabled. Not in DB.
+ // kPersistentTestFeatureBar: Enabled. In DB.
+ // kPersistentTestFeatureQux: Disabled. Not in DB.
+ // kPersistentTestFeatureNop: Disabled. In DB.
+
+ db_availabilities_[kPersistentTestFeatureBar.name] =
+ CreateAvailability(kPersistentTestFeatureBar, 10u);
+ db_availabilities_[kPersistentTestFeatureNop.name] =
+ CreateAvailability(kPersistentTestFeatureNop, 8u);
PersistentAvailabilityStore::LoadAndUpdateStore(
storage_dir_, CreateDB(), FeatureVector(), std::move(load_callback_),
diff --git a/chromium/components/feature_engagement/internal/persistent_event_store.cc b/chromium/components/feature_engagement/internal/persistent_event_store.cc
index a744ced1af2..0926e365695 100644
--- a/chromium/components/feature_engagement/internal/persistent_event_store.cc
+++ b/chromium/components/feature_engagement/internal/persistent_event_store.cc
@@ -13,7 +13,7 @@ namespace feature_engagement {
namespace {
// Corresponds to a UMA suffix "LevelDBOpenResults" in histograms.xml.
// Please do not change.
-const char kDatabaseUMAName[] = "FeatureEngagementTrackerEventStore";
+const char kDBUMAName[] = "FeatureEngagementTrackerEventStore";
using KeyEventPair = std::pair<std::string, Event>;
using KeyEventList = std::vector<KeyEventPair>;
@@ -37,8 +37,7 @@ PersistentEventStore::~PersistentEventStore() = default;
void PersistentEventStore::Load(const OnLoadedCallback& callback) {
DCHECK(!ready_);
- db_->Init(kDatabaseUMAName, storage_dir_,
- leveldb_proto::CreateSimpleOptions(),
+ db_->Init(kDBUMAName, storage_dir_, leveldb_proto::CreateSimpleOptions(),
base::BindOnce(&PersistentEventStore::OnInitComplete,
weak_ptr_factory_.GetWeakPtr(), callback));
}
diff --git a/chromium/components/feature_engagement/internal/single_invalid_configuration_unittest.cc b/chromium/components/feature_engagement/internal/single_invalid_configuration_unittest.cc
index c8f369ce07d..a9ca38bacfc 100644
--- a/chromium/components/feature_engagement/internal/single_invalid_configuration_unittest.cc
+++ b/chromium/components/feature_engagement/internal/single_invalid_configuration_unittest.cc
@@ -12,10 +12,10 @@ namespace feature_engagement {
namespace {
-const base::Feature kTestFeatureFoo{"test_foo",
- base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kTestFeatureBar{"test_bar",
- base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kSingleTestFeatureFoo{"test_foo",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kSingleTestFeatureBar{"test_bar",
+ base::FEATURE_DISABLED_BY_DEFAULT};
class SingleInvalidConfigurationTest : public ::testing::Test {
public:
@@ -31,10 +31,12 @@ class SingleInvalidConfigurationTest : public ::testing::Test {
} // namespace
TEST_F(SingleInvalidConfigurationTest, AllConfigurationsAreInvalid) {
- FeatureConfig foo_config = configuration_.GetFeatureConfig(kTestFeatureFoo);
+ FeatureConfig foo_config =
+ configuration_.GetFeatureConfig(kSingleTestFeatureFoo);
EXPECT_FALSE(foo_config.valid);
- FeatureConfig bar_config = configuration_.GetFeatureConfig(kTestFeatureBar);
+ FeatureConfig bar_config =
+ configuration_.GetFeatureConfig(kSingleTestFeatureBar);
EXPECT_FALSE(bar_config.valid);
}
diff --git a/chromium/components/feature_engagement/internal/test/BUILD.gn b/chromium/components/feature_engagement/internal/test/BUILD.gn
index 961c1f6066b..5c9e7a1c2be 100644
--- a/chromium/components/feature_engagement/internal/test/BUILD.gn
+++ b/chromium/components/feature_engagement/internal/test/BUILD.gn
@@ -2,7 +2,9 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-source_set("test_support") {
+import("//build/config/jumbo.gni")
+
+jumbo_source_set("test_support") {
testonly = true
visibility = [ "//components/feature_engagement/internal:unit_tests" ]
diff --git a/chromium/components/feature_engagement/internal/tracker_impl_unittest.cc b/chromium/components/feature_engagement/internal/tracker_impl_unittest.cc
index 45482486e02..8cb3398a9f1 100644
--- a/chromium/components/feature_engagement/internal/tracker_impl_unittest.cc
+++ b/chromium/components/feature_engagement/internal/tracker_impl_unittest.cc
@@ -33,14 +33,14 @@
namespace feature_engagement {
namespace {
-const base::Feature kTestFeatureFoo{"test_foo",
- base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kTestFeatureBar{"test_bar",
- base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kTestFeatureBaz{"test_baz",
- base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kTestFeatureQux{"test_qux",
- base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kTrackerTestFeatureFoo{"test_foo",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kTrackerTestFeatureBar{"test_bar",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kTrackerTestFeatureBaz{"test_baz",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kTrackerTestFeatureQux{"test_qux",
+ base::FEATURE_DISABLED_BY_DEFAULT};
void RegisterFeatureConfig(EditableConfiguration* configuration,
const base::Feature& feature,
@@ -79,9 +79,9 @@ class StoringInitializedCallback {
// An InMemoryEventStore that is able to fake successful and unsuccessful
// loading of state.
-class TestInMemoryEventStore : public InMemoryEventStore {
+class TestTrackerInMemoryEventStore : public InMemoryEventStore {
public:
- explicit TestInMemoryEventStore(bool load_should_succeed)
+ explicit TestTrackerInMemoryEventStore(bool load_should_succeed)
: load_should_succeed_(load_should_succeed) {}
void Load(const OnLoadedCallback& callback) override {
@@ -101,7 +101,7 @@ class TestInMemoryEventStore : public InMemoryEventStore {
std::map<std::string, Event> events_;
- DISALLOW_COPY_AND_ASSIGN(TestInMemoryEventStore);
+ DISALLOW_COPY_AND_ASSIGN(TestTrackerInMemoryEventStore);
};
class StoreEverythingEventStorageValidator : public EventStorageValidator {
@@ -135,10 +135,10 @@ class TestTimeProvider : public TimeProvider {
DISALLOW_COPY_AND_ASSIGN(TestTimeProvider);
};
-class TestAvailabilityModel : public AvailabilityModel {
+class TestTrackerAvailabilityModel : public AvailabilityModel {
public:
- TestAvailabilityModel() : ready_(true) {}
- ~TestAvailabilityModel() override = default;
+ TestTrackerAvailabilityModel() : ready_(true) {}
+ ~TestTrackerAvailabilityModel() override = default;
void Initialize(AvailabilityModel::OnInitializedCallback callback,
uint32_t current_day) override {
@@ -158,13 +158,13 @@ class TestAvailabilityModel : public AvailabilityModel {
private:
bool ready_;
- DISALLOW_COPY_AND_ASSIGN(TestAvailabilityModel);
+ DISALLOW_COPY_AND_ASSIGN(TestTrackerAvailabilityModel);
};
-class TestDisplayLockController : public DisplayLockController {
+class TestTrackerDisplayLockController : public DisplayLockController {
public:
- TestDisplayLockController() = default;
- ~TestDisplayLockController() override = default;
+ TestTrackerDisplayLockController() = default;
+ ~TestTrackerDisplayLockController() override = default;
std::unique_ptr<DisplayLockHandle> AcquireDisplayLock() override {
return std::move(next_display_lock_handle_);
@@ -181,7 +181,7 @@ class TestDisplayLockController : public DisplayLockController {
// The next DisplayLockHandle to return.
std::unique_ptr<DisplayLockHandle> next_display_lock_handle_;
- DISALLOW_COPY_AND_ASSIGN(TestDisplayLockController);
+ DISALLOW_COPY_AND_ASSIGN(TestTrackerDisplayLockController);
};
class TrackerImplTest : public ::testing::Test {
@@ -193,28 +193,29 @@ class TrackerImplTest : public ::testing::Test {
std::make_unique<EditableConfiguration>();
configuration_ = configuration.get();
- RegisterFeatureConfig(configuration.get(), kTestFeatureFoo,
+ RegisterFeatureConfig(configuration.get(), kTrackerTestFeatureFoo,
true /* is_valid */, false /* tracking_only */);
- RegisterFeatureConfig(configuration.get(), kTestFeatureBar,
+ RegisterFeatureConfig(configuration.get(), kTrackerTestFeatureBar,
true /* is_valid */, false /* tracking_only */);
- RegisterFeatureConfig(configuration.get(), kTestFeatureBaz,
+ RegisterFeatureConfig(configuration.get(), kTrackerTestFeatureBaz,
true /* is_valid */, true /* tracking_only */);
- RegisterFeatureConfig(configuration.get(), kTestFeatureQux,
+ RegisterFeatureConfig(configuration.get(), kTrackerTestFeatureQux,
false /* is_valid */, false /* tracking_only */);
- std::unique_ptr<TestInMemoryEventStore> event_store = CreateEventStore();
+ std::unique_ptr<TestTrackerInMemoryEventStore> event_store =
+ CreateEventStore();
event_store_ = event_store.get();
auto event_model = std::make_unique<EventModelImpl>(
std::move(event_store),
std::make_unique<StoreEverythingEventStorageValidator>());
- auto availability_model = std::make_unique<TestAvailabilityModel>();
+ auto availability_model = std::make_unique<TestTrackerAvailabilityModel>();
availability_model_ = availability_model.get();
availability_model_->SetIsReady(ShouldAvailabilityStoreBeReady());
auto display_lock_controller =
- std::make_unique<TestDisplayLockController>();
+ std::make_unique<TestTrackerDisplayLockController>();
display_lock_controller_ = display_lock_controller.get();
tracker_.reset(new TrackerImpl(
@@ -407,18 +408,18 @@ class TrackerImplTest : public ::testing::Test {
}
protected:
- virtual std::unique_ptr<TestInMemoryEventStore> CreateEventStore() {
+ virtual std::unique_ptr<TestTrackerInMemoryEventStore> CreateEventStore() {
// Returns a EventStore that will successfully initialize.
- return std::make_unique<TestInMemoryEventStore>(true);
+ return std::make_unique<TestTrackerInMemoryEventStore>(true);
}
virtual bool ShouldAvailabilityStoreBeReady() { return true; }
base::MessageLoop message_loop_;
std::unique_ptr<TrackerImpl> tracker_;
- TestInMemoryEventStore* event_store_;
- TestAvailabilityModel* availability_model_;
- TestDisplayLockController* display_lock_controller_;
+ TestTrackerInMemoryEventStore* event_store_;
+ TestTrackerAvailabilityModel* availability_model_;
+ TestTrackerDisplayLockController* display_lock_controller_;
Configuration* configuration_;
base::HistogramTester histogram_tester_;
@@ -432,9 +433,9 @@ class FailingStoreInitTrackerImplTest : public TrackerImplTest {
FailingStoreInitTrackerImplTest() = default;
protected:
- std::unique_ptr<TestInMemoryEventStore> CreateEventStore() override {
+ std::unique_ptr<TestTrackerInMemoryEventStore> CreateEventStore() override {
// Returns a EventStore that will fail to initialize.
- return std::make_unique<TestInMemoryEventStore>(false);
+ return std::make_unique<TestTrackerInMemoryEventStore>(false);
}
private:
@@ -609,12 +610,12 @@ TEST_F(TrackerImplTest, TestTriggering) {
base::UserActionTester user_action_tester;
// The first time a feature triggers it should be shown.
- EXPECT_TRUE(tracker_->ShouldTriggerHelpUI(kTestFeatureFoo));
- VerifyEventTriggerEvents(kTestFeatureFoo, 1u);
- EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureFoo));
- VerifyEventTriggerEvents(kTestFeatureFoo, 1u);
- EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureQux));
- VerifyEventTriggerEvents(kTestFeatureQux, 0);
+ EXPECT_TRUE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureFoo));
+ VerifyEventTriggerEvents(kTrackerTestFeatureFoo, 1u);
+ EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureFoo));
+ VerifyEventTriggerEvents(kTrackerTestFeatureFoo, 1u);
+ EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureQux));
+ VerifyEventTriggerEvents(kTrackerTestFeatureQux, 0);
VerifyUserActionsTriggerChecks(user_action_tester, 2, 0, 0, 1);
VerifyUserActionsTriggered(user_action_tester, 1, 0, 0, 0);
VerifyUserActionsNotTriggered(user_action_tester, 1, 0, 0, 1);
@@ -625,10 +626,10 @@ TEST_F(TrackerImplTest, TestTriggering) {
// While in-product help is currently showing, no other features should be
// shown.
- EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureBar));
- VerifyEventTriggerEvents(kTestFeatureBar, 0);
- EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureQux));
- VerifyEventTriggerEvents(kTestFeatureQux, 0);
+ EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureBar));
+ VerifyEventTriggerEvents(kTrackerTestFeatureBar, 0);
+ EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureQux));
+ VerifyEventTriggerEvents(kTrackerTestFeatureQux, 0);
VerifyUserActionsTriggerChecks(user_action_tester, 2, 1, 0, 2);
VerifyUserActionsTriggered(user_action_tester, 1, 0, 0, 0);
VerifyUserActionsNotTriggered(user_action_tester, 1, 1, 0, 2);
@@ -638,13 +639,13 @@ TEST_F(TrackerImplTest, TestTriggering) {
// After dismissing the current in-product help, that feature can not be shown
// again, but a different feature should.
- tracker_->Dismissed(kTestFeatureFoo);
- EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureFoo));
- VerifyEventTriggerEvents(kTestFeatureFoo, 1u);
- EXPECT_TRUE(tracker_->ShouldTriggerHelpUI(kTestFeatureBar));
- VerifyEventTriggerEvents(kTestFeatureBar, 1u);
- EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureQux));
- VerifyEventTriggerEvents(kTestFeatureQux, 0);
+ tracker_->Dismissed(kTrackerTestFeatureFoo);
+ EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureFoo));
+ VerifyEventTriggerEvents(kTrackerTestFeatureFoo, 1u);
+ EXPECT_TRUE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureBar));
+ VerifyEventTriggerEvents(kTrackerTestFeatureBar, 1u);
+ EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureQux));
+ VerifyEventTriggerEvents(kTrackerTestFeatureQux, 0);
VerifyUserActionsTriggerChecks(user_action_tester, 3, 2, 0, 3);
VerifyUserActionsTriggered(user_action_tester, 1, 1, 0, 0);
VerifyUserActionsNotTriggered(user_action_tester, 2, 1, 0, 3);
@@ -653,14 +654,14 @@ TEST_F(TrackerImplTest, TestTriggering) {
VerifyHistograms(true, 1, 2, 0, true, 1, 1, 0, false, 0, 0, 0, true, 0, 3, 0);
// After dismissing the second registered feature, no more in-product help
- // should be shown, since kTestFeatureQux is invalid.
- tracker_->Dismissed(kTestFeatureBar);
- EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureFoo));
- VerifyEventTriggerEvents(kTestFeatureFoo, 1u);
- EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureBar));
- VerifyEventTriggerEvents(kTestFeatureBar, 1u);
- EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureQux));
- VerifyEventTriggerEvents(kTestFeatureQux, 0);
+ // should be shown, since kTrackerTestFeatureQux is invalid.
+ tracker_->Dismissed(kTrackerTestFeatureBar);
+ EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureFoo));
+ VerifyEventTriggerEvents(kTrackerTestFeatureFoo, 1u);
+ EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureBar));
+ VerifyEventTriggerEvents(kTrackerTestFeatureBar, 1u);
+ EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureQux));
+ VerifyEventTriggerEvents(kTrackerTestFeatureQux, 0);
VerifyUserActionsTriggerChecks(user_action_tester, 4, 3, 0, 4);
VerifyUserActionsTriggered(user_action_tester, 1, 1, 0, 0);
VerifyUserActionsNotTriggered(user_action_tester, 3, 2, 0, 4);
@@ -677,11 +678,12 @@ TEST_F(TrackerImplTest, TestTrackingOnlyTriggering) {
base::RunLoop().RunUntilIdle();
base::UserActionTester user_action_tester;
- // Tracking only kTestFeatureBaz should never be shown, but should be counted.
- EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureBaz));
- VerifyEventTriggerEvents(kTestFeatureBaz, 1u);
- EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureFoo));
- VerifyEventTriggerEvents(kTestFeatureFoo, 0u);
+ // Tracking only kTrackerTestFeatureBaz should never be shown, but should be
+ // counted.
+ EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureBaz));
+ VerifyEventTriggerEvents(kTrackerTestFeatureBaz, 1u);
+ EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureFoo));
+ VerifyEventTriggerEvents(kTrackerTestFeatureFoo, 0u);
VerifyUserActionsTriggerChecks(user_action_tester, 1, 0, 1, 0);
VerifyUserActionsTriggered(user_action_tester, 0, 0, 0, 0);
VerifyUserActionsNotTriggered(user_action_tester, 1, 0, 0, 0);
@@ -692,8 +694,8 @@ TEST_F(TrackerImplTest, TestTrackingOnlyTriggering) {
// While in-product help is currently showing, even in a tracking only
// setting, no other features should be shown.
- EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureFoo));
- VerifyEventTriggerEvents(kTestFeatureFoo, 0);
+ EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureFoo));
+ VerifyEventTriggerEvents(kTrackerTestFeatureFoo, 0);
VerifyUserActionsTriggerChecks(user_action_tester, 2, 0, 1, 0);
VerifyUserActionsTriggered(user_action_tester, 0, 0, 0, 0);
VerifyUserActionsNotTriggered(user_action_tester, 2, 0, 0, 0);
@@ -704,11 +706,11 @@ TEST_F(TrackerImplTest, TestTrackingOnlyTriggering) {
// After dismissing the current in-product help, that feature can not be shown
// again, but a different feature should.
- tracker_->Dismissed(kTestFeatureBaz);
- EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureBaz));
- VerifyEventTriggerEvents(kTestFeatureBaz, 1u);
- EXPECT_TRUE(tracker_->ShouldTriggerHelpUI(kTestFeatureFoo));
- VerifyEventTriggerEvents(kTestFeatureFoo, 1u);
+ tracker_->Dismissed(kTrackerTestFeatureBaz);
+ EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureBaz));
+ VerifyEventTriggerEvents(kTrackerTestFeatureBaz, 1u);
+ EXPECT_TRUE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureFoo));
+ VerifyEventTriggerEvents(kTrackerTestFeatureFoo, 1u);
VerifyUserActionsTriggerChecks(user_action_tester, 3, 0, 2, 0);
VerifyUserActionsTriggered(user_action_tester, 1, 0, 0, 0);
VerifyUserActionsNotTriggered(user_action_tester, 2, 0, 1, 0);
@@ -727,12 +729,12 @@ TEST_F(TrackerImplTest, TestWouldTriggerInspection) {
base::UserActionTester user_action_tester;
// Initially, both foo and bar would have been shown.
- EXPECT_TRUE(tracker_->WouldTriggerHelpUI(kTestFeatureFoo));
- EXPECT_TRUE(tracker_->WouldTriggerHelpUI(kTestFeatureBar));
- EXPECT_FALSE(tracker_->WouldTriggerHelpUI(kTestFeatureQux));
- VerifyEventTriggerEvents(kTestFeatureFoo, 0u);
- VerifyEventTriggerEvents(kTestFeatureBar, 0u);
- VerifyEventTriggerEvents(kTestFeatureQux, 0u);
+ EXPECT_TRUE(tracker_->WouldTriggerHelpUI(kTrackerTestFeatureFoo));
+ EXPECT_TRUE(tracker_->WouldTriggerHelpUI(kTrackerTestFeatureBar));
+ EXPECT_FALSE(tracker_->WouldTriggerHelpUI(kTrackerTestFeatureQux));
+ VerifyEventTriggerEvents(kTrackerTestFeatureFoo, 0u);
+ VerifyEventTriggerEvents(kTrackerTestFeatureBar, 0u);
+ VerifyEventTriggerEvents(kTrackerTestFeatureQux, 0u);
VerifyUserActionsTriggerChecks(user_action_tester, 0, 0, 0, 0);
VerifyUserActionsTriggered(user_action_tester, 0, 0, 0, 0);
VerifyUserActionsNotTriggered(user_action_tester, 0, 0, 0, 0);
@@ -742,11 +744,11 @@ TEST_F(TrackerImplTest, TestWouldTriggerInspection) {
0);
// While foo shows, nothing else would have been shown.
- EXPECT_TRUE(tracker_->ShouldTriggerHelpUI(kTestFeatureFoo));
- EXPECT_FALSE(tracker_->WouldTriggerHelpUI(kTestFeatureFoo));
- EXPECT_FALSE(tracker_->WouldTriggerHelpUI(kTestFeatureBar));
- EXPECT_FALSE(tracker_->WouldTriggerHelpUI(kTestFeatureQux));
- VerifyEventTriggerEvents(kTestFeatureFoo, 1);
+ EXPECT_TRUE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureFoo));
+ EXPECT_FALSE(tracker_->WouldTriggerHelpUI(kTrackerTestFeatureFoo));
+ EXPECT_FALSE(tracker_->WouldTriggerHelpUI(kTrackerTestFeatureBar));
+ EXPECT_FALSE(tracker_->WouldTriggerHelpUI(kTrackerTestFeatureQux));
+ VerifyEventTriggerEvents(kTrackerTestFeatureFoo, 1);
VerifyUserActionsTriggerChecks(user_action_tester, 1, 0, 0, 0);
VerifyUserActionsTriggered(user_action_tester, 1, 0, 0, 0);
VerifyUserActionsNotTriggered(user_action_tester, 0, 0, 0, 0);
@@ -757,14 +759,14 @@ TEST_F(TrackerImplTest, TestWouldTriggerInspection) {
// After foo has been dismissed, it would not have triggered again, but bar
// would have.
- tracker_->Dismissed(kTestFeatureFoo);
- EXPECT_FALSE(tracker_->WouldTriggerHelpUI(kTestFeatureFoo));
- EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureFoo));
- EXPECT_TRUE(tracker_->WouldTriggerHelpUI(kTestFeatureBar));
- EXPECT_TRUE(tracker_->ShouldTriggerHelpUI(kTestFeatureBar));
- EXPECT_FALSE(tracker_->WouldTriggerHelpUI(kTestFeatureQux));
- VerifyEventTriggerEvents(kTestFeatureFoo, 1);
- VerifyEventTriggerEvents(kTestFeatureBar, 1);
+ tracker_->Dismissed(kTrackerTestFeatureFoo);
+ EXPECT_FALSE(tracker_->WouldTriggerHelpUI(kTrackerTestFeatureFoo));
+ EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureFoo));
+ EXPECT_TRUE(tracker_->WouldTriggerHelpUI(kTrackerTestFeatureBar));
+ EXPECT_TRUE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureBar));
+ EXPECT_FALSE(tracker_->WouldTriggerHelpUI(kTrackerTestFeatureQux));
+ VerifyEventTriggerEvents(kTrackerTestFeatureFoo, 1);
+ VerifyEventTriggerEvents(kTrackerTestFeatureBar, 1);
VerifyUserActionsTriggerChecks(user_action_tester, 2, 1, 0, 0);
VerifyUserActionsTriggered(user_action_tester, 1, 1, 0, 0);
VerifyUserActionsNotTriggered(user_action_tester, 1, 0, 0, 0);
@@ -777,9 +779,9 @@ TEST_F(TrackerImplTest, TestWouldTriggerInspection) {
TEST_F(TrackerImplTest, TestTriggerStateInspection) {
// Before initialization has finished, NOT_READY should always be returned.
EXPECT_EQ(Tracker::TriggerState::NOT_READY,
- tracker_->GetTriggerState(kTestFeatureFoo));
+ tracker_->GetTriggerState(kTrackerTestFeatureFoo));
EXPECT_EQ(Tracker::TriggerState::NOT_READY,
- tracker_->GetTriggerState(kTestFeatureQux));
+ tracker_->GetTriggerState(kTrackerTestFeatureQux));
// Ensure all initialization is finished.
StoringInitializedCallback callback;
@@ -789,37 +791,37 @@ TEST_F(TrackerImplTest, TestTriggerStateInspection) {
base::UserActionTester user_action_tester;
EXPECT_EQ(Tracker::TriggerState::HAS_NOT_BEEN_DISPLAYED,
- tracker_->GetTriggerState(kTestFeatureFoo));
+ tracker_->GetTriggerState(kTrackerTestFeatureFoo));
EXPECT_EQ(Tracker::TriggerState::HAS_NOT_BEEN_DISPLAYED,
- tracker_->GetTriggerState(kTestFeatureBar));
+ tracker_->GetTriggerState(kTrackerTestFeatureBar));
// The first time a feature triggers it should be shown.
- EXPECT_TRUE(tracker_->ShouldTriggerHelpUI(kTestFeatureFoo));
- VerifyEventTriggerEvents(kTestFeatureFoo, 1u);
+ EXPECT_TRUE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureFoo));
+ VerifyEventTriggerEvents(kTrackerTestFeatureFoo, 1u);
EXPECT_EQ(Tracker::TriggerState::HAS_BEEN_DISPLAYED,
- tracker_->GetTriggerState(kTestFeatureFoo));
+ tracker_->GetTriggerState(kTrackerTestFeatureFoo));
// Trying to show again should keep state as displayed.
- EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureFoo));
- VerifyEventTriggerEvents(kTestFeatureFoo, 1u);
+ EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureFoo));
+ VerifyEventTriggerEvents(kTrackerTestFeatureFoo, 1u);
EXPECT_EQ(Tracker::TriggerState::HAS_BEEN_DISPLAYED,
- tracker_->GetTriggerState(kTestFeatureFoo));
+ tracker_->GetTriggerState(kTrackerTestFeatureFoo));
// Other features should also be kept at not having been displayed.
- EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureBar));
- VerifyEventTriggerEvents(kTestFeatureBar, 0);
+ EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureBar));
+ VerifyEventTriggerEvents(kTrackerTestFeatureBar, 0);
EXPECT_EQ(Tracker::TriggerState::HAS_NOT_BEEN_DISPLAYED,
- tracker_->GetTriggerState(kTestFeatureBar));
+ tracker_->GetTriggerState(kTrackerTestFeatureBar));
// Dismiss foo and show qux, which should update TriggerState of bar, and keep
// TriggerState for foo.
- tracker_->Dismissed(kTestFeatureFoo);
- EXPECT_TRUE(tracker_->ShouldTriggerHelpUI(kTestFeatureBar));
- VerifyEventTriggerEvents(kTestFeatureBar, 1);
+ tracker_->Dismissed(kTrackerTestFeatureFoo);
+ EXPECT_TRUE(tracker_->ShouldTriggerHelpUI(kTrackerTestFeatureBar));
+ VerifyEventTriggerEvents(kTrackerTestFeatureBar, 1);
EXPECT_EQ(Tracker::TriggerState::HAS_BEEN_DISPLAYED,
- tracker_->GetTriggerState(kTestFeatureFoo));
+ tracker_->GetTriggerState(kTrackerTestFeatureFoo));
EXPECT_EQ(Tracker::TriggerState::HAS_BEEN_DISPLAYED,
- tracker_->GetTriggerState(kTestFeatureBar));
+ tracker_->GetTriggerState(kTrackerTestFeatureBar));
}
TEST_F(TrackerImplTest, TestNotifyEvent) {
@@ -832,8 +834,8 @@ TEST_F(TrackerImplTest, TestNotifyEvent) {
tracker_->NotifyEvent("foo");
tracker_->NotifyEvent("foo");
tracker_->NotifyEvent("bar");
- tracker_->NotifyEvent(kTestFeatureFoo.name + std::string("_used"));
- tracker_->NotifyEvent(kTestFeatureFoo.name + std::string("_trigger"));
+ tracker_->NotifyEvent(kTrackerTestFeatureFoo.name + std::string("_used"));
+ tracker_->NotifyEvent(kTrackerTestFeatureFoo.name + std::string("_trigger"));
// Used event will record both NotifyEvent and NotifyUsedEvent. Explicitly
// specify the whole user action string here.
diff --git a/chromium/components/feature_engagement/public/BUILD.gn b/chromium/components/feature_engagement/public/BUILD.gn
index ede4df0a652..95861e7346d 100644
--- a/chromium/components/feature_engagement/public/BUILD.gn
+++ b/chromium/components/feature_engagement/public/BUILD.gn
@@ -2,12 +2,14 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//build/config/jumbo.gni")
+
if (is_android) {
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
}
-source_set("public") {
+jumbo_source_set("public") {
sources = [
"event_constants.cc",
"event_constants.h",
@@ -37,7 +39,7 @@ if (is_android) {
deps = [
"//base:base_java",
- "//third_party/android_tools:android_support_annotations_java",
+ "//third_party/android_deps:android_support_annotations_java",
]
srcjar_deps = [ ":public_java_enums_srcjar" ]
diff --git a/chromium/components/feature_engagement/public/android/java/src/org/chromium/components/feature_engagement/EventConstants.java b/chromium/components/feature_engagement/public/android/java/src/org/chromium/components/feature_engagement/EventConstants.java
new file mode 100644
index 00000000000..ccb8f025c8a
--- /dev/null
+++ b/chromium/components/feature_engagement/public/android/java/src/org/chromium/components/feature_engagement/EventConstants.java
@@ -0,0 +1,167 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.components.feature_engagement;
+
+/**
+ * EventConstants contains the String name of all in-product help events.
+ */
+public final class EventConstants {
+ /**
+ * The page load has failed and user has landed on an offline dino page.
+ */
+ public static final String USER_HAS_SEEN_DINO = "user_has_seen_dino";
+
+ /**
+ * The user has started downloading a page.
+ */
+ public static final String DOWNLOAD_PAGE_STARTED = "download_page_started";
+
+ /**
+ * The download has completed successfully.
+ */
+ public static final String DOWNLOAD_COMPLETED = "download_completed";
+
+ /**
+ * The download home was opened by the user (from toolbar menu or notifications).
+ */
+ public static final String DOWNLOAD_HOME_OPENED = "download_home_opened";
+
+ /**
+ * The user triggered pull to refresh. Used to help determine when to show the Chrome Home
+ * in-product help.
+ */
+ public static final String PULL_TO_REFRESH = "pull_to_refresh";
+
+ /** The contextual suggestions button was shown to the user. */
+ public static final String CONTEXTUAL_SUGGESTIONS_BUTTON_SHOWN =
+ "contextual_suggestions_button_shown";
+
+ /**
+ * The contextual suggestions bottom sheet was explicitly dismissed via a tap on its close
+ * button.
+ */
+ public static final String CONTEXTUAL_SUGGESTIONS_DISMISSED =
+ "contextual_suggestions_dismissed";
+
+ /**
+ * The contextual suggestions bottom sheet was opened.
+ */
+ public static final String CONTEXTUAL_SUGGESTIONS_OPENED = "contextual_suggestions_opened";
+
+ /**
+ * A contextual suggestion was clicked, opened in a new tab or downloaded.
+ */
+ public static final String CONTEXTUAL_SUGGESTION_TAKEN = "contextual_suggestion_taken";
+
+ /**
+ * Screenshot is taken with Chrome in the foreground.
+ */
+ public static final String SCREENSHOT_TAKEN_CHROME_IN_FOREGROUND =
+ "screenshot_taken_chrome_in_foreground";
+
+ /**
+ * The data saver preview infobar was shown.
+ */
+ public static final String DATA_SAVER_PREVIEW_INFOBAR_SHOWN = "data_saver_preview_opened";
+
+ /**
+ * Data was saved when page loaded.
+ */
+ public static final String DATA_SAVED_ON_PAGE_LOAD = "data_saved_page_load";
+
+ /**
+ * The overflow menu was opened.
+ */
+ public static final String OVERFLOW_OPENED_WITH_DATA_SAVER_SHOWN =
+ "overflow_opened_data_saver_shown";
+
+ /**
+ * The data saver footer was used (tapped).
+ */
+ public static final String DATA_SAVER_DETAIL_OPENED = "data_saver_overview_opened";
+
+ /**
+ * The previews verbose status view was opened.
+ */
+ public static final String PREVIEWS_VERBOSE_STATUS_OPENED = "previews_verbose_status_opened";
+
+ /**
+ * A page load used a preview.
+ */
+ public static final String PREVIEWS_PAGE_LOADED = "preview_page_load";
+
+ /**
+ * The download button for a media element was displayed.
+ */
+ public static final String MEDIA_DOWNLOAD_BUTTON_DISPLAYED = "media_download_button_displayed";
+
+ /**
+ * Contextual Search panel was opened.
+ */
+ public static final String CONTEXTUAL_SEARCH_PANEL_OPENED = "contextual_search_panel_opened";
+
+ /**
+ * Contextual Search panel was opened after it was triggered by tapping.
+ */
+ public static final String CONTEXTUAL_SEARCH_PANEL_OPENED_AFTER_TAP =
+ "contextual_search_panel_opened_after_tap";
+
+ /**
+ * Contextual Search panel was opened after it was triggered by longpressing.
+ */
+ public static final String CONTEXTUAL_SEARCH_PANEL_OPENED_AFTER_LONGPRESS =
+ "contextual_search_panel_opened_after_longpress";
+
+ /**
+ * Contextual Search panel was opened after receiving entity data.
+ */
+ public static final String CONTEXTUAL_SEARCH_PANEL_OPENED_FOR_ENTITY =
+ "contextual_search_panel_opened_for_entity";
+
+ /**
+ * User performed a web search for a query by choosing the Web Search option on the popup menu.
+ */
+ public static final String WEB_SEARCH_PERFORMED = "web_search_performed";
+
+ /**
+ * Contextual Search showed an entity result for the searched query.
+ */
+ public static final String CONTEXTUAL_SEARCH_ENTITY_RESULT = "contextual_search_entity_result";
+
+ /**
+ * Contextual Search was triggered by a tap.
+ */
+ public static final String CONTEXTUAL_SEARCH_TRIGGERED_BY_TAP =
+ "contextual_search_triggered_by_tap";
+
+ /**
+ * Contextual Search was triggered by longpressing.
+ */
+ public static final String CONTEXTUAL_SEARCH_TRIGGERED_BY_LONGPRESS =
+ "contextual_search_triggered_by_longpress";
+
+ /**
+ * The partner homepage was pressed.
+ */
+ public static final String PARTNER_HOME_PAGE_BUTTON_PRESSED =
+ "partner_home_page_button_pressed";
+
+ /** The user used a button in the bottom toolbar. */
+ public static final String CHROME_DUET_USED_BOTTOM_TOOLBAR = "chrome_duet_used_bottom_toolbar";
+
+ /** The homepage button in the toolbar was clicked. */
+ public static final String HOMEPAGE_BUTTON_CLICKED = "homepage_button_clicked";
+
+ /** The clear tab button in the toolbar was clicked. */
+ public static final String CLEAR_TAB_BUTTON_CLICKED = "clear_tab_button_clicked";
+
+ /** The pinned homepage tile in MV tiles was clicked. */
+ public static final String HOMEPAGE_TILE_CLICKED = "homepage_tile_clicked";
+
+ /**
+ * Do not instantiate.
+ */
+ private EventConstants() {}
+}
diff --git a/chromium/components/feature_engagement/public/android/java/src/org/chromium/components/feature_engagement/FeatureConstants.java b/chromium/components/feature_engagement/public/android/java/src/org/chromium/components/feature_engagement/FeatureConstants.java
new file mode 100644
index 00000000000..35afe27f4ef
--- /dev/null
+++ b/chromium/components/feature_engagement/public/android/java/src/org/chromium/components/feature_engagement/FeatureConstants.java
@@ -0,0 +1,75 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.components.feature_engagement;
+
+/**
+ * FeatureConstants contains the String name of all base::Feature in-product help features declared
+ * in //components/feature_engagement/public/feature_constants.h.
+ */
+public final class FeatureConstants {
+ public static final String DOWNLOAD_PAGE_FEATURE = "IPH_DownloadPage";
+ public static final String DOWNLOAD_PAGE_SCREENSHOT_FEATURE = "IPH_DownloadPageScreenshot";
+ public static final String DOWNLOAD_HOME_FEATURE = "IPH_DownloadHome";
+ public static final String CHROME_DUET_FEATURE = "IPH_ChromeDuet";
+ public static final String CHROME_HOME_EXPAND_FEATURE = "IPH_ChromeHomeExpand";
+ public static final String CHROME_HOME_PULL_TO_REFRESH_FEATURE = "IPH_ChromeHomePullToRefresh";
+ public static final String CONTEXTUAL_SUGGESTIONS_FEATURE = "IPH_ContextualSuggestions";
+ public static final String DATA_SAVER_PREVIEW_FEATURE = "IPH_DataSaverPreview";
+ public static final String DATA_SAVER_DETAIL_FEATURE = "IPH_DataSaverDetail";
+ public static final String NTP_BUTTON_FEATURE = "IPH_NewTabPageButton";
+ public static final String PREVIEWS_OMNIBOX_UI_FEATURE = "IPH_PreviewsOmniboxUI";
+ public static final String HOMEPAGE_TILE_FEATURE = "IPH_HomepageTile";
+
+ public static final String MEDIA_DOWNLOAD_FEATURE = "IPH_MediaDownload";
+
+ /**
+ * An IPH feature that encourages users who search a query from a web page in a new tab, to use
+ * Contextual Search instead.
+ */
+ public static final String CONTEXTUAL_SEARCH_WEB_SEARCH_FEATURE =
+ "IPH_ContextualSearchWebSearch";
+
+ /**
+ * An IPH feature for promoting tap over longpress for activating Contextual Search.
+ */
+ public static final String CONTEXTUAL_SEARCH_PROMOTE_TAP_FEATURE =
+ "IPH_ContextualSearchPromoteTap";
+
+ /**
+ * An IPH feature for encouraging users to open the Contextual Search Panel.
+ */
+ public static final String CONTEXTUAL_SEARCH_PROMOTE_PANEL_OPEN_FEATURE =
+ "IPH_ContextualSearchPromotePanelOpen";
+
+ /**
+ * An IPH feature for encouraging users to opt-in for Contextual Search.
+ */
+ public static final String CONTEXTUAL_SEARCH_OPT_IN_FEATURE = "IPH_ContextualSearchOptIn";
+
+ /**
+ * An IPH feature indicating to users that there are settings for downloads and they are
+ * accessible through Downloads Home.
+ */
+ public static final String DOWNLOAD_SETTINGS_FEATURE = "IPH_DownloadSettings";
+
+ /**
+ * An IPH feature informing the users that even though infobar was closed, downloads are still
+ * continuing in the background.
+ */
+ public static final String DOWNLOAD_INFOBAR_DOWNLOAD_CONTINUING_FEATURE =
+ "IPH_DownloadInfoBarDownloadContinuing";
+
+ /**
+ * An IPH feature that points to the download progress infobar and informs users that downloads
+ * are now faster than before.
+ */
+ public static final String DOWNLOAD_INFOBAR_DOWNLOADS_ARE_FASTER_FEATURE =
+ "IPH_DownloadInfoBarDownloadsAreFaster";
+
+ /**
+ * Do not instantiate.
+ */
+ private FeatureConstants() {}
+}
diff --git a/chromium/components/feature_engagement/public/android/java/src/org/chromium/components/feature_engagement/Tracker.java b/chromium/components/feature_engagement/public/android/java/src/org/chromium/components/feature_engagement/Tracker.java
new file mode 100644
index 00000000000..59ac1c52b5f
--- /dev/null
+++ b/chromium/components/feature_engagement/public/android/java/src/org/chromium/components/feature_engagement/Tracker.java
@@ -0,0 +1,115 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.components.feature_engagement;
+
+import android.support.annotation.CheckResult;
+import android.support.annotation.Nullable;
+
+import org.chromium.base.Callback;
+
+/**
+ * Tracker is the Java representation of a native Tracker object.
+ * It is owned by the native BrowserContext.
+ *
+ * Tracker is the core class for the feature engagement.
+ */
+public interface Tracker {
+ /**
+ * A handle for the display lock. While this is unreleased, no in-product help can be displayed.
+ */
+ interface DisplayLockHandle {
+ /**
+ * This method must be invoked when the lock should be released, and it must be invoked on
+ * the main thread.
+ */
+ void release();
+ }
+
+ /**
+ * Must be called whenever an event happens.
+ */
+ void notifyEvent(String event);
+
+ /**
+ * This function must be called whenever the triggering condition for a specific feature
+ * happens. Returns true iff the display of the in-product help must happen.
+ * If {@code true} is returned, the caller *must* call {@link #dismissed(String)} when display
+ * of feature enlightenment ends.
+ *
+ * @return whether feature enlightenment should be displayed.
+ */
+ @CheckResult
+ boolean shouldTriggerHelpUI(String feature);
+
+ /**
+ * Invoking this is basically the same as being allowed to invoke {@link
+ * #shouldTriggerHelpUI(String)} without requiring to show the in-product help. This function
+ * may be called to inspect if the current state would allow the given {@code feature} to pass
+ * all its conditions and display the feature enlightenment.
+ *
+ * NOTE: It is still required to invoke ShouldTriggerHelpUI(...) if feature enlightenment should
+ * be shown.
+ *
+ * NOTE: It is not guaranteed that invoking {@link #shouldTriggerHelpUI(String)} after this
+ * would yield the same result. The state might change in-between the calls because time has
+ * passed, other events might have been triggered, and other state might have changed.
+ *
+ * @return whether feature enlightenment would be displayed if {@link
+ * #shouldTriggerHelpUI(String)} had been invoked instead.
+ */
+ boolean wouldTriggerHelpUI(String feature);
+
+ /**
+ * This function can be called to query if a particular |feature| meets its particular
+ * precondition for triggering within the bounds of the current feature configuration.
+ * Calling this method requires the {@link Tracker} to already have been initialized.
+ * See {@link #isInitialized()) and {@link #addOnInitializedCallback(Callback<Boolean>)} for how
+ * to ensure the call to this is delayed.
+ * This function can typically be used to ensure that expensive operations for tracking other
+ * state related to in-product help do not happen if in-product help has already been displayed
+ * for the given |feature|.
+ */
+ @TriggerState
+ int getTriggerState(String feature);
+
+ /**
+ * Must be called after display of feature enlightenment finishes for a particular feature.
+ */
+ void dismissed(String feature);
+
+ /**
+ * Acquiring a display lock means that no in-product help can be displayed while it is held. To
+ * release the lock, delete the handle. If in-product help is already displayed while the
+ * display lock is acquired, the lock is still handed out, but it will not dismiss the current
+ * in-product help. However, no new in-product help will be shown until all locks have been
+ * released. It is required to invoke {@link DisplayLockHandle#release()} once the lock should
+ * no longer be held.
+ * The DisplayLockHandle must be released on the main thread.
+ * @return a DisplayLockHandle, or {@code null} if no handle could be retrieved.
+ */
+ @CheckResult
+ @Nullable
+ DisplayLockHandle acquireDisplayLock();
+
+ /**
+ * Returns whether the tracker has been successfully initialized. During startup, this will be
+ * false until the internal models have been loaded at which point it is set to true if the
+ * initialization was successful. The state will never change from initialized to uninitialized.
+ * Callers can invoke AddOnInitializedCallback(...) to be notified when the result of the
+ * initialization is ready.
+ */
+ boolean isInitialized();
+
+ /**
+ * For features that trigger on startup, they can register a callback to ensure that they are
+ * informed when the tracker has finished the initialization. If the tracker has already been
+ * initialized, the callback will still be invoked with the result. The callback is guaranteed
+ * to be invoked exactly one time.
+ *
+ * The |result| parameter indicates whether the initialization was a success and the tracker is
+ * ready to receive calls.
+ */
+ void addOnInitializedCallback(Callback<Boolean> callback);
+}
diff --git a/chromium/components/feature_engagement/public/event_constants.cc b/chromium/components/feature_engagement/public/event_constants.cc
index 3700e129e9c..59e6061d936 100644
--- a/chromium/components/feature_engagement/public/event_constants.cc
+++ b/chromium/components/feature_engagement/public/event_constants.cc
@@ -22,6 +22,7 @@ const char kIncognitoWindowOpened[] = "incognito_window_opened";
const char kIncognitoWindowSessionTimeMet[] =
"incognito_window_session_time_met";
+const char kReopenTabConditionsMet[] = "reopen_tab_conditions_met";
#endif // BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_IOS)
diff --git a/chromium/components/feature_engagement/public/event_constants.h b/chromium/components/feature_engagement/public/event_constants.h
index d45d76a4fa6..45c308203ac 100644
--- a/chromium/components/feature_engagement/public/event_constants.h
+++ b/chromium/components/feature_engagement/public/event_constants.h
@@ -40,6 +40,11 @@ extern const char kIncognitoWindowOpened[];
// IncognitoWindowPromo by accumulating 2 hours of active session time (one-off
// event).
extern const char kIncognitoWindowSessionTimeMet[];
+
+// All conditions for reopen closed tab IPH were met. Since this IPH needs to
+// track user events (opening/closing tabs, focusing the omnibox, etc) on the
+// second level, it must be done manually.
+extern const char kReopenTabConditionsMet[];
#endif // BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_IOS)
diff --git a/chromium/components/feature_engagement/public/feature_constants.cc b/chromium/components/feature_engagement/public/feature_constants.cc
index ec73d007885..5c33fea7d84 100644
--- a/chromium/components/feature_engagement/public/feature_constants.cc
+++ b/chromium/components/feature_engagement/public/feature_constants.cc
@@ -55,6 +55,8 @@ const base::Feature kIPHHomepageTileFeature{"IPH_HomepageTile",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kIPHNewTabPageButtonFeature{
"IPH_NewTabPageButton", base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kIPHPreviewsOmniboxUIFeature{
+ "IPH_PreviewsOmniboxUI", base::FEATURE_DISABLED_BY_DEFAULT};
#endif // defined(OS_ANDROID)
#if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
@@ -64,6 +66,8 @@ const base::Feature kIPHIncognitoWindowFeature{
"IPH_IncognitoWindow", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kIPHNewTabFeature{"IPH_NewTab",
base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kIPHReopenTabFeature{"IPH_ReopenTab",
+ base::FEATURE_DISABLED_BY_DEFAULT};
#endif // BUILDFLAG(ENABLE_DESKTOP_IPH)
#if defined(OS_IOS)
diff --git a/chromium/components/feature_engagement/public/feature_constants.h b/chromium/components/feature_engagement/public/feature_constants.h
index cc493a2bd0d..bce43b7be58 100644
--- a/chromium/components/feature_engagement/public/feature_constants.h
+++ b/chromium/components/feature_engagement/public/feature_constants.h
@@ -41,12 +41,14 @@ extern const base::Feature kIPHDownloadInfoBarDownloadsAreFasterFeature;
extern const base::Feature kIPHHomePageButtonFeature;
extern const base::Feature kIPHHomepageTileFeature;
extern const base::Feature kIPHNewTabPageButtonFeature;
+extern const base::Feature kIPHPreviewsOmniboxUIFeature;
#endif // defined(OS_ANDROID)
#if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
extern const base::Feature kIPHBookmarkFeature;
extern const base::Feature kIPHIncognitoWindowFeature;
extern const base::Feature kIPHNewTabFeature;
+extern const base::Feature kIPHReopenTabFeature;
#endif // BUILDFLAG(ENABLE_DESKTOP_IPH)
#if defined(OS_IOS)
diff --git a/chromium/components/feature_engagement/public/feature_list.cc b/chromium/components/feature_engagement/public/feature_list.cc
index 3b7b27e371e..932a6d91e68 100644
--- a/chromium/components/feature_engagement/public/feature_list.cc
+++ b/chromium/components/feature_engagement/public/feature_list.cc
@@ -36,11 +36,13 @@ const base::Feature* const kAllFeatures[] = {
&kIPHHomePageButtonFeature,
&kIPHHomepageTileFeature,
&kIPHNewTabPageButtonFeature,
+ &kIPHPreviewsOmniboxUIFeature,
#endif // defined(OS_ANDROID)
#if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
&kIPHBookmarkFeature,
&kIPHIncognitoWindowFeature,
&kIPHNewTabFeature,
+ &kIPHReopenTabFeature,
#endif // BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
#if defined(OS_IOS)
&kIPHBottomToolbarTipFeature,
diff --git a/chromium/components/feature_engagement/public/feature_list.h b/chromium/components/feature_engagement/public/feature_list.h
index 67a424620cf..334238c5d89 100644
--- a/chromium/components/feature_engagement/public/feature_list.h
+++ b/chromium/components/feature_engagement/public/feature_list.h
@@ -75,11 +75,13 @@ DEFINE_VARIATION_PARAM(kIPHDownloadInfoBarDownloadsAreFasterFeature,
DEFINE_VARIATION_PARAM(kIPHHomePageButtonFeature, "IPH_HomePageButton");
DEFINE_VARIATION_PARAM(kIPHHomepageTileFeature, "IPH_HomepageTile");
DEFINE_VARIATION_PARAM(kIPHNewTabPageButtonFeature, "IPH_NewTabPageButton");
+DEFINE_VARIATION_PARAM(kIPHPreviewsOmniboxUIFeature, "IPH_PreviewsOmniboxUI");
#endif // defined(OS_ANDROID)
#if BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
DEFINE_VARIATION_PARAM(kIPHBookmarkFeature, "IPH_Bookmark");
DEFINE_VARIATION_PARAM(kIPHIncognitoWindowFeature, "IPH_IncognitoWindow");
DEFINE_VARIATION_PARAM(kIPHNewTabFeature, "IPH_NewTab");
+DEFINE_VARIATION_PARAM(kIPHReopenTabFeature, "IPH_ReopenTab");
#endif // BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
#if defined(OS_IOS)
DEFINE_VARIATION_PARAM(kIPHBottomToolbarTipFeature, "IPH_BottomToolbarTip");
@@ -118,10 +120,12 @@ constexpr flags_ui::FeatureEntry::FeatureVariation
VARIATION_ENTRY(kIPHHomePageButtonFeature),
VARIATION_ENTRY(kIPHHomepageTileFeature),
VARIATION_ENTRY(kIPHNewTabPageButtonFeature),
+ VARIATION_ENTRY(kIPHPreviewsOmniboxUIFeature),
#elif BUILDFLAG(ENABLE_DESKTOP_IN_PRODUCT_HELP)
VARIATION_ENTRY(kIPHBookmarkFeature),
VARIATION_ENTRY(kIPHIncognitoWindowFeature),
VARIATION_ENTRY(kIPHNewTabFeature),
+ VARIATION_ENTRY(kIPHReopenTabFeature),
#elif defined(OS_IOS)
VARIATION_ENTRY(kIPHBottomToolbarTipFeature),
VARIATION_ENTRY(kIPHLongPressToolbarTipFeature),