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

Side by Side Diff: chrome/browser/sync_file_system/sync_file_system_service_unittest.cc

Issue 16109008: Cleanup: Deprecate DriveFileSyncService::kServiceName (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | Annotate | Revision Log
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 <vector> 5 #include <vector>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 22 matching lines...) Expand all
33 using ::testing::InvokeWithoutArgs; 33 using ::testing::InvokeWithoutArgs;
34 using ::testing::Return; 34 using ::testing::Return;
35 using ::testing::StrictMock; 35 using ::testing::StrictMock;
36 using ::testing::_; 36 using ::testing::_;
37 37
38 namespace sync_file_system { 38 namespace sync_file_system {
39 39
40 namespace { 40 namespace {
41 41
42 const char kOrigin[] = "http://example.com"; 42 const char kOrigin[] = "http://example.com";
43 const char kServiceName[] = "test";
44 43
45 template <typename R> struct AssignTrait { 44 template <typename R> struct AssignTrait {
46 typedef const R& ArgumentType; 45 typedef const R& ArgumentType;
47 }; 46 };
48 47
49 template <> struct AssignTrait<SyncFileStatus> { 48 template <> struct AssignTrait<SyncFileStatus> {
50 typedef SyncFileStatus ArgumentType; 49 typedef SyncFileStatus ArgumentType;
51 }; 50 };
52 51
53 template <typename R> 52 template <typename R>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 112
114 class SyncFileSystemServiceTest : public testing::Test { 113 class SyncFileSystemServiceTest : public testing::Test {
115 protected: 114 protected:
116 SyncFileSystemServiceTest() {} 115 SyncFileSystemServiceTest() {}
117 virtual ~SyncFileSystemServiceTest() {} 116 virtual ~SyncFileSystemServiceTest() {}
118 117
119 virtual void SetUp() OVERRIDE { 118 virtual void SetUp() OVERRIDE {
120 thread_helper_.SetUp(); 119 thread_helper_.SetUp();
121 120
122 file_system_.reset(new CannedSyncableFileSystem( 121 file_system_.reset(new CannedSyncableFileSystem(
123 GURL(kOrigin), kServiceName, 122 GURL(kOrigin),
124 thread_helper_.io_task_runner(), 123 thread_helper_.io_task_runner(),
125 thread_helper_.file_task_runner())); 124 thread_helper_.file_task_runner()));
126 125
127 local_service_ = new LocalFileSyncService(&profile_); 126 local_service_ = new LocalFileSyncService(&profile_);
128 remote_service_ = new StrictMock<MockRemoteFileSyncService>; 127 remote_service_ = new StrictMock<MockRemoteFileSyncService>;
129 sync_service_.reset(new SyncFileSystemService(&profile_)); 128 sync_service_.reset(new SyncFileSystemService(&profile_));
130 129
131 EXPECT_CALL(*mock_remote_service(), 130 EXPECT_CALL(*mock_remote_service(),
132 AddServiceObserver(sync_service_.get())).Times(1); 131 AddServiceObserver(sync_service_.get())).Times(1);
133 EXPECT_CALL(*mock_remote_service(), 132 EXPECT_CALL(*mock_remote_service(),
(...skipping 12 matching lines...) Expand all
146 EXPECT_CALL(*mock_remote_service(), SetSyncEnabled(false)).Times(1); 145 EXPECT_CALL(*mock_remote_service(), SetSyncEnabled(false)).Times(1);
147 sync_service_->SetSyncEnabledForTesting(false); 146 sync_service_->SetSyncEnabledForTesting(false);
148 147
149 file_system_->SetUp(); 148 file_system_->SetUp();
150 } 149 }
151 150
152 virtual void TearDown() OVERRIDE { 151 virtual void TearDown() OVERRIDE {
153 sync_service_->Shutdown(); 152 sync_service_->Shutdown();
154 153
155 file_system_->TearDown(); 154 file_system_->TearDown();
156 RevokeSyncableFileSystem(kServiceName); 155 RevokeSyncableFileSystem();
157 thread_helper_.TearDown(); 156 thread_helper_.TearDown();
158 } 157 }
159 158
160 void InitializeApp() { 159 void InitializeApp() {
161 base::RunLoop run_loop; 160 base::RunLoop run_loop;
162 SyncStatusCode status = SYNC_STATUS_UNKNOWN; 161 SyncStatusCode status = SYNC_STATUS_UNKNOWN;
163 162
164 EXPECT_CALL(*mock_remote_service(), 163 EXPECT_CALL(*mock_remote_service(),
165 RegisterOriginForTrackingChanges(GURL(kOrigin), _)).Times(1); 164 RegisterOriginForTrackingChanges(GURL(kOrigin), _)).Times(1);
166 165
167 sync_service_->InitializeForApp( 166 sync_service_->InitializeForApp(
168 file_system_->file_system_context(), 167 file_system_->file_system_context(),
169 kServiceName, GURL(kOrigin), 168 GURL(kOrigin),
170 AssignAndQuitCallback(&run_loop, &status)); 169 AssignAndQuitCallback(&run_loop, &status));
171 run_loop.Run(); 170 run_loop.Run();
172 171
173 EXPECT_EQ(SYNC_STATUS_OK, status); 172 EXPECT_EQ(SYNC_STATUS_OK, status);
174 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->OpenFileSystem()); 173 EXPECT_EQ(base::PLATFORM_FILE_OK, file_system_->OpenFileSystem());
175 } 174 }
176 175
177 // Calls InitializeForApp after setting up the mock remote service to 176 // Calls InitializeForApp after setting up the mock remote service to
178 // perform following when RegisterOriginForTrackingChanges is called: 177 // perform following when RegisterOriginForTrackingChanges is called:
179 // 1. Notify RemoteFileSyncService's observers of |state_to_notify| 178 // 1. Notify RemoteFileSyncService's observers of |state_to_notify|
(...skipping 22 matching lines...) Expand all
202 status_to_return)); 201 status_to_return));
203 202
204 std::vector<SyncServiceState> actual_states; 203 std::vector<SyncServiceState> actual_states;
205 EXPECT_CALL(event_observer, OnSyncStateUpdated(GURL(), _, _)) 204 EXPECT_CALL(event_observer, OnSyncStateUpdated(GURL(), _, _))
206 .WillRepeatedly(RecordState(&actual_states)); 205 .WillRepeatedly(RecordState(&actual_states));
207 206
208 SyncStatusCode actual_status = SYNC_STATUS_UNKNOWN; 207 SyncStatusCode actual_status = SYNC_STATUS_UNKNOWN;
209 base::RunLoop run_loop; 208 base::RunLoop run_loop;
210 sync_service_->InitializeForApp( 209 sync_service_->InitializeForApp(
211 file_system_->file_system_context(), 210 file_system_->file_system_context(),
212 kServiceName, GURL(kOrigin), 211 GURL(kOrigin),
213 AssignAndQuitCallback(&run_loop, &actual_status)); 212 AssignAndQuitCallback(&run_loop, &actual_status));
214 run_loop.Run(); 213 run_loop.Run();
215 214
216 EXPECT_EQ(expected_status, actual_status); 215 EXPECT_EQ(expected_status, actual_status);
217 ASSERT_EQ(expected_states.size(), actual_states.size()); 216 ASSERT_EQ(expected_states.size(), actual_states.size());
218 for (size_t i = 0; i < actual_states.size(); ++i) 217 for (size_t i = 0; i < actual_states.size(); ++i)
219 EXPECT_EQ(expected_states[i], actual_states[i]); 218 EXPECT_EQ(expected_states[i], actual_states[i]);
220 } 219 }
221 220
222 FileSystemURL URL(const std::string& path) const { 221 FileSystemURL URL(const std::string& path) const {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 base::Bind(&AssignValueAndQuit<SyncFileStatus>, 483 base::Bind(&AssignValueAndQuit<SyncFileStatus>,
485 &run_loop, &status, &sync_file_status)); 484 &run_loop, &status, &sync_file_status));
486 run_loop.Run(); 485 run_loop.Run();
487 486
488 EXPECT_EQ(SYNC_STATUS_OK, status); 487 EXPECT_EQ(SYNC_STATUS_OK, status);
489 EXPECT_EQ(SYNC_FILE_STATUS_CONFLICTING, sync_file_status); 488 EXPECT_EQ(SYNC_FILE_STATUS_CONFLICTING, sync_file_status);
490 } 489 }
491 } 490 }
492 491
493 } // namespace sync_file_system 492 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698