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

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

Issue 2877243002: Support IPH NotifyEvent calls before Initialize (Closed)
Patch Set: Fixed build.gn Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/feature_engagement_tracker/internal/feature_engagement_trac ker_impl.h" 5 #include "components/feature_engagement_tracker/internal/feature_engagement_trac ker_impl.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "components/feature_engagement_tracker/internal/editable_configuration. h" 14 #include "components/feature_engagement_tracker/internal/editable_configuration. h"
15 #include "components/feature_engagement_tracker/internal/in_memory_store.h" 15 #include "components/feature_engagement_tracker/internal/in_memory_store.h"
16 #include "components/feature_engagement_tracker/internal/model_impl.h"
16 #include "components/feature_engagement_tracker/internal/never_storage_validator .h" 17 #include "components/feature_engagement_tracker/internal/never_storage_validator .h"
17 #include "components/feature_engagement_tracker/internal/once_condition_validato r.h" 18 #include "components/feature_engagement_tracker/internal/once_condition_validato r.h"
18 #include "components/feature_engagement_tracker/internal/time_provider.h" 19 #include "components/feature_engagement_tracker/internal/time_provider.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 namespace feature_engagement_tracker { 22 namespace feature_engagement_tracker {
22 23
23 namespace { 24 namespace {
24 const base::Feature kTestFeatureFoo{"test_foo", 25 const base::Feature kTestFeatureFoo{"test_foo",
25 base::FEATURE_DISABLED_BY_DEFAULT}; 26 base::FEATURE_DISABLED_BY_DEFAULT};
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 FeatureEngagementTrackerImplTest() = default; 97 FeatureEngagementTrackerImplTest() = default;
97 98
98 void SetUp() override { 99 void SetUp() override {
99 std::unique_ptr<EditableConfiguration> configuration = 100 std::unique_ptr<EditableConfiguration> configuration =
100 base::MakeUnique<EditableConfiguration>(); 101 base::MakeUnique<EditableConfiguration>();
101 102
102 RegisterFeatureConfig(configuration.get(), kTestFeatureFoo, true); 103 RegisterFeatureConfig(configuration.get(), kTestFeatureFoo, true);
103 RegisterFeatureConfig(configuration.get(), kTestFeatureBar, true); 104 RegisterFeatureConfig(configuration.get(), kTestFeatureBar, true);
104 RegisterFeatureConfig(configuration.get(), kTestFeatureQux, false); 105 RegisterFeatureConfig(configuration.get(), kTestFeatureQux, false);
105 106
107 auto model = base::MakeUnique<ModelImpl>(
108 CreateStore(), base::MakeUnique<NeverStorageValidator>());
109
106 tracker_.reset(new FeatureEngagementTrackerImpl( 110 tracker_.reset(new FeatureEngagementTrackerImpl(
107 CreateStore(), std::move(configuration), 111 std::move(model), std::move(configuration),
108 base::MakeUnique<OnceConditionValidator>(), 112 base::MakeUnique<OnceConditionValidator>(),
109 base::MakeUnique<NeverStorageValidator>(),
110 base::MakeUnique<TestTimeProvider>())); 113 base::MakeUnique<TestTimeProvider>()));
111 } 114 }
112 115
113 protected: 116 protected:
114 virtual std::unique_ptr<Store> CreateStore() { 117 virtual std::unique_ptr<Store> CreateStore() {
115 // Returns a Store that will successfully initialize. 118 // Returns a Store that will successfully initialize.
116 return base::MakeUnique<TestInMemoryStore>(true); 119 return base::MakeUnique<TestInMemoryStore>(true);
117 } 120 }
118 121
119 base::MessageLoop message_loop_; 122 base::MessageLoop message_loop_;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 297
295 // After dismissing the second registered feature, no more in-product help 298 // After dismissing the second registered feature, no more in-product help
296 // should be shown, since kTestFeatureQux is invalid. 299 // should be shown, since kTestFeatureQux is invalid.
297 tracker_->Dismissed(kTestFeatureBar); 300 tracker_->Dismissed(kTestFeatureBar);
298 EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureFoo)); 301 EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureFoo));
299 EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureBar)); 302 EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureBar));
300 EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureQux)); 303 EXPECT_FALSE(tracker_->ShouldTriggerHelpUI(kTestFeatureQux));
301 } 304 }
302 305
303 } // namespace feature_engagement_tracker 306 } // namespace feature_engagement_tracker
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698