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

Side by Side Diff: components/browser_sync/profile_sync_service_unittest.cc

Issue 2504433002: [Sync] Return nullptr for OpenTabsUIDelegate when PROXY_TABS is disabled. (Closed)
Patch Set: Gave test case an appropriate name. Created 4 years, 1 month 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
« no previous file with comments | « components/browser_sync/profile_sync_service.cc ('k') | components/sync/driver/sync_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser_sync/profile_sync_service.h" 5 #include "components/browser_sync/profile_sync_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 21 matching lines...) Expand all
32 #include "components/sync/driver/sync_driver_switches.h" 32 #include "components/sync/driver/sync_driver_switches.h"
33 #include "components/sync/driver/sync_service_observer.h" 33 #include "components/sync/driver/sync_service_observer.h"
34 #include "components/sync/driver/sync_util.h" 34 #include "components/sync/driver/sync_util.h"
35 #include "components/sync_preferences/testing_pref_service_syncable.h" 35 #include "components/sync_preferences/testing_pref_service_syncable.h"
36 #include "components/version_info/version_info_values.h" 36 #include "components/version_info/version_info_values.h"
37 #include "google_apis/gaia/gaia_constants.h" 37 #include "google_apis/gaia/gaia_constants.h"
38 #include "testing/gmock/include/gmock/gmock.h" 38 #include "testing/gmock/include/gmock/gmock.h"
39 #include "testing/gtest/include/gtest/gtest.h" 39 #include "testing/gtest/include/gtest/gtest.h"
40 #include "ui/base/l10n/l10n_util.h" 40 #include "ui/base/l10n/l10n_util.h"
41 41
42 using syncer::DataTypeController;
42 using syncer::SyncBackendHostMock; 43 using syncer::SyncBackendHostMock;
44 using syncer::SyncMergeResult;
43 using testing::Return; 45 using testing::Return;
44 46
45 namespace browser_sync { 47 namespace browser_sync {
46 48
47 namespace { 49 namespace {
48 50
49 const char kGaiaId[] = "12345"; 51 const char kGaiaId[] = "12345";
50 const char kEmail[] = "test_user@gmail.com"; 52 const char kEmail[] = "test_user@gmail.com";
51 53
52 class FakeDataTypeManager : public syncer::DataTypeManager { 54 class FakeDataTypeManager : public syncer::DataTypeManager {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 syncer::SyncManager::ClearServerDataCallback* captured_callback, 194 syncer::SyncManager::ClearServerDataCallback* captured_callback,
193 const syncer::SyncManager::ClearServerDataCallback& callback) { 195 const syncer::SyncManager::ClearServerDataCallback& callback) {
194 *captured_callback = callback; 196 *captured_callback = callback;
195 } 197 }
196 198
197 ACTION_P(ReturnNewMockHostCaptureClearServerData, captured_callback) { 199 ACTION_P(ReturnNewMockHostCaptureClearServerData, captured_callback) {
198 return new SyncBackendHostCaptureClearServerData(base::Bind( 200 return new SyncBackendHostCaptureClearServerData(base::Bind(
199 &OnClearServerDataCalled, base::Unretained(captured_callback))); 201 &OnClearServerDataCalled, base::Unretained(captured_callback)));
200 } 202 }
201 203
204 void DoNothing(DataTypeController::ConfigureResult ignored1,
205 const SyncMergeResult& ignored2,
206 const SyncMergeResult& ignored3) {}
207
202 // A test harness that uses a real ProfileSyncService and in most cases a 208 // A test harness that uses a real ProfileSyncService and in most cases a
203 // MockSyncBackendHost. 209 // MockSyncBackendHost.
204 // 210 //
205 // This is useful if we want to test the ProfileSyncService and don't care about 211 // This is useful if we want to test the ProfileSyncService and don't care about
206 // testing the SyncBackendHost. 212 // testing the SyncBackendHost.
207 class ProfileSyncServiceTest : public ::testing::Test { 213 class ProfileSyncServiceTest : public ::testing::Test {
208 protected: 214 protected:
209 ProfileSyncServiceTest() : component_factory_(nullptr) {} 215 ProfileSyncServiceTest() : component_factory_(nullptr) {}
210 ~ProfileSyncServiceTest() override {} 216 ~ProfileSyncServiceTest() override {}
211 217
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
945 // Regression test for crbug/555434. The issue is that check for sessions DTC in 951 // Regression test for crbug/555434. The issue is that check for sessions DTC in
946 // OnSessionRestoreComplete was creating map entry with nullptr which later was 952 // OnSessionRestoreComplete was creating map entry with nullptr which later was
947 // dereferenced in OnSyncCycleCompleted. The fix is to use find() to check if 953 // dereferenced in OnSyncCycleCompleted. The fix is to use find() to check if
948 // entry for sessions exists in map. 954 // entry for sessions exists in map.
949 TEST_F(ProfileSyncServiceTest, ValidPointersInDTCMap) { 955 TEST_F(ProfileSyncServiceTest, ValidPointersInDTCMap) {
950 CreateService(ProfileSyncService::AUTO_START); 956 CreateService(ProfileSyncService::AUTO_START);
951 service()->OnSessionRestoreComplete(); 957 service()->OnSessionRestoreComplete();
952 service()->OnSyncCycleCompleted(); 958 service()->OnSyncCycleCompleted();
953 } 959 }
954 960
961 // The OpenTabsUIDelegate should only be accessable when PROXY_TABS is enabled.
962 TEST_F(ProfileSyncServiceTest, GetOpenTabsUIDelegate) {
963 CreateService(ProfileSyncService::AUTO_START);
964 InitializeForNthSync();
965 EXPECT_EQ(nullptr, service()->GetOpenTabsUIDelegate());
966
967 auto controller =
968 base::MakeUnique<syncer::FakeDataTypeController>(syncer::PROXY_TABS);
969 // Progress the controller to RUNNING first, which is how the service
970 // determines whether a type is enabled.
971 controller->StartAssociating(base::Bind(&DoNothing));
972 controller->FinishStart(DataTypeController::OK_FIRST_RUN);
973 service()->RegisterDataTypeController(std::move(controller));
974 EXPECT_NE(nullptr, service()->GetOpenTabsUIDelegate());
975 }
976
955 } // namespace 977 } // namespace
956 } // namespace browser_sync 978 } // namespace browser_sync
OLDNEW
« no previous file with comments | « components/browser_sync/profile_sync_service.cc ('k') | components/sync/driver/sync_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698