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

Unified Diff: components/sync/user_events/user_event_service_unittest.cc

Issue 2869633003: [Sync] Hook UserEvents into sync. (Closed)
Patch Set: Rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/sync/user_events/user_event_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/user_events/user_event_service_unittest.cc
diff --git a/components/sync/user_events/user_event_service_unittest.cc b/components/sync/user_events/user_event_service_unittest.cc
index 83e968a25e2f8dd6dca16807b3a2a0a18b703c27..f7862e6f1c0c40af2d42e010ef521935f53d015e 100644
--- a/components/sync/user_events/user_event_service_unittest.cc
+++ b/components/sync/user_events/user_event_service_unittest.cc
@@ -6,8 +6,10 @@
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
+#include "base/test/scoped_feature_list.h"
#include "components/sync/base/model_type.h"
#include "components/sync/driver/fake_sync_service.h"
+#include "components/sync/driver/sync_driver_switches.h"
#include "components/sync/model/model_type_store_test_util.h"
#include "components/sync/model/recording_model_type_change_processor.h"
#include "components/sync/protocol/sync.pb.h"
@@ -39,6 +41,11 @@ class TestSyncService : public FakeSyncService {
class UserEventServiceTest : public testing::Test {
protected:
+ UserEventServiceTest() {
+ scoped_feature_list_ = base::MakeUnique<base::test::ScopedFeatureList>();
+ scoped_feature_list_->InitAndEnableFeature(switches::kSyncUserEvents);
+ }
+
std::unique_ptr<UserEventSyncBridge> MakeBridge() {
return base::MakeUnique<UserEventSyncBridge>(
ModelTypeStoreTestUtil::FactoryForInMemoryStoreForTest(),
@@ -47,7 +54,13 @@ class UserEventServiceTest : public testing::Test {
const RecordingModelTypeChangeProcessor& processor() { return *processor_; }
+ void DisableUserEvents() {
+ scoped_feature_list_ = base::MakeUnique<base::test::ScopedFeatureList>();
+ scoped_feature_list_->Init();
+ }
+
private:
+ std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_;
RecordingModelTypeChangeProcessor* processor_;
base::MessageLoop message_loop_;
};
@@ -58,6 +71,14 @@ TEST_F(UserEventServiceTest, ShouldNotRecordNoSync) {
EXPECT_EQ(0u, processor().put_multimap().size());
}
+TEST_F(UserEventServiceTest, ShouldNotRecordFeatureIsDisabled) {
+ DisableUserEvents();
+ TestSyncService sync_service(false, ModelTypeSet(HISTORY_DELETE_DIRECTIVES));
+ UserEventService service(&sync_service, MakeBridge());
+ service.RecordUserEvent(base::MakeUnique<UserEventSpecifics>());
+ EXPECT_EQ(0u, processor().put_multimap().size());
+}
+
TEST_F(UserEventServiceTest, ShouldNotRecordNoHistory) {
TestSyncService sync_service(true, ModelTypeSet());
UserEventService service(&sync_service, MakeBridge());
« no previous file with comments | « components/sync/user_events/user_event_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698