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

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

Issue 2909283003: [Sync] Split UserEventService into interface and impl, add fake impl, add unit tests. (Closed)
Patch Set: Added a NoOp service to handle OffTheRecord. 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
Index: components/sync/user_events/user_event_service_impl_unittest.cc
diff --git a/components/sync/user_events/user_event_service_unittest.cc b/components/sync/user_events/user_event_service_impl_unittest.cc
similarity index 80%
rename from components/sync/user_events/user_event_service_unittest.cc
rename to components/sync/user_events/user_event_service_impl_unittest.cc
index f7862e6f1c0c40af2d42e010ef521935f53d015e..d6f4279f284ee4846c8b93b9a608db05954d5ff4 100644
--- a/components/sync/user_events/user_event_service_unittest.cc
+++ b/components/sync/user_events/user_event_service_impl_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/sync/user_events/user_event_service.h"
+#include "components/sync/user_events/user_event_service_impl.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop.h"
@@ -39,9 +39,9 @@ class TestSyncService : public FakeSyncService {
ModelTypeSet preferred_data_types_;
};
-class UserEventServiceTest : public testing::Test {
+class UserEventServiceImplTest : public testing::Test {
protected:
- UserEventServiceTest() {
+ UserEventServiceImplTest() {
scoped_feature_list_ = base::MakeUnique<base::test::ScopedFeatureList>();
scoped_feature_list_->InitAndEnableFeature(switches::kSyncUserEvents);
}
@@ -65,51 +65,51 @@ class UserEventServiceTest : public testing::Test {
base::MessageLoop message_loop_;
};
-TEST_F(UserEventServiceTest, ShouldNotRecordNoSync) {
- UserEventService service(nullptr, MakeBridge());
+TEST_F(UserEventServiceImplTest, ShouldNotRecordNoSync) {
+ UserEventServiceImpl service(nullptr, MakeBridge());
service.RecordUserEvent(base::MakeUnique<UserEventSpecifics>());
EXPECT_EQ(0u, processor().put_multimap().size());
}
-TEST_F(UserEventServiceTest, ShouldNotRecordFeatureIsDisabled) {
+TEST_F(UserEventServiceImplTest, ShouldNotRecordFeatureIsDisabled) {
DisableUserEvents();
TestSyncService sync_service(false, ModelTypeSet(HISTORY_DELETE_DIRECTIVES));
- UserEventService service(&sync_service, MakeBridge());
+ UserEventServiceImpl service(&sync_service, MakeBridge());
service.RecordUserEvent(base::MakeUnique<UserEventSpecifics>());
EXPECT_EQ(0u, processor().put_multimap().size());
}
-TEST_F(UserEventServiceTest, ShouldNotRecordNoHistory) {
+TEST_F(UserEventServiceImplTest, ShouldNotRecordNoHistory) {
TestSyncService sync_service(true, ModelTypeSet());
- UserEventService service(&sync_service, MakeBridge());
+ UserEventServiceImpl service(&sync_service, MakeBridge());
service.RecordUserEvent(base::MakeUnique<UserEventSpecifics>());
EXPECT_EQ(0u, processor().put_multimap().size());
}
-TEST_F(UserEventServiceTest, ShouldNotRecordEngineOff) {
+TEST_F(UserEventServiceImplTest, ShouldNotRecordEngineOff) {
TestSyncService sync_service(false, ModelTypeSet(HISTORY_DELETE_DIRECTIVES));
- UserEventService service(&sync_service, MakeBridge());
+ UserEventServiceImpl service(&sync_service, MakeBridge());
service.RecordUserEvent(base::MakeUnique<UserEventSpecifics>());
EXPECT_EQ(0u, processor().put_multimap().size());
}
-TEST_F(UserEventServiceTest, ShouldRecord) {
+TEST_F(UserEventServiceImplTest, ShouldRecord) {
TestSyncService sync_service(true, ModelTypeSet(HISTORY_DELETE_DIRECTIVES));
- UserEventService service(&sync_service, MakeBridge());
+ UserEventServiceImpl service(&sync_service, MakeBridge());
service.RecordUserEvent(base::MakeUnique<UserEventSpecifics>());
EXPECT_EQ(1u, processor().put_multimap().size());
}
-TEST_F(UserEventServiceTest, SessionIdIsDifferent) {
+TEST_F(UserEventServiceImplTest, SessionIdIsDifferent) {
TestSyncService sync_service(true, ModelTypeSet(HISTORY_DELETE_DIRECTIVES));
- UserEventService service1(&sync_service, MakeBridge());
+ UserEventServiceImpl service1(&sync_service, MakeBridge());
service1.RecordUserEvent(base::MakeUnique<UserEventSpecifics>());
ASSERT_EQ(1u, processor().put_multimap().size());
auto put1 = processor().put_multimap().begin();
int64_t session_id1 = put1->second->specifics.user_event().session_id();
- UserEventService service2(&sync_service, MakeBridge());
+ UserEventServiceImpl service2(&sync_service, MakeBridge());
service2.RecordUserEvent(base::MakeUnique<UserEventSpecifics>());
// The object processor() points to has changed to be |service2|'s processor.
ASSERT_EQ(1u, processor().put_multimap().size());
« no previous file with comments | « components/sync/user_events/user_event_service_impl.cc ('k') | components/sync/user_events/user_event_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698