OLD | NEW |
---|---|
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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/signin/signin_manager.h" | 9 #include "chrome/browser/signin/signin_manager.h" |
10 #include "chrome/browser/signin/signin_manager_factory.h" | 10 #include "chrome/browser/signin/signin_manager_factory.h" |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 args1, reply_handler.AsWeakHandle()); | 309 args1, reply_handler.AsWeakHandle()); |
310 } | 310 } |
311 | 311 |
312 IssueTestTokens(); | 312 IssueTestTokens(); |
313 | 313 |
314 // This forces the sync thread to process the message and reply. | 314 // This forces the sync thread to process the message and reply. |
315 service_.reset(); | 315 service_.reset(); |
316 ui_loop_.RunAllPending(); | 316 ui_loop_.RunAllPending(); |
317 } | 317 } |
318 | 318 |
319 // Make sure that things still work if sync is not enabled, but some old sync | |
320 // databases are lingering in the "Sync Data" folder. | |
321 TEST_F(ProfileSyncServiceTest, TestStartupWithOldSyncData) { | |
Nicolas Zea
2012/09/13 00:45:55
why was this removed?
rlarocque
2012/09/14 01:03:07
It looks like I was a bit too hasty with this test
| |
322 const char* nonsense1 = "reginald"; | |
323 const char* nonsense2 = "beartato"; | |
324 const char* nonsense3 = "harrison"; | |
325 FilePath temp_directory = profile_->GetPath().AppendASCII("Sync Data"); | |
326 FilePath sync_file1 = | |
327 temp_directory.AppendASCII("BookmarkSyncSettings.sqlite3"); | |
328 FilePath sync_file2 = temp_directory.AppendASCII("SyncData.sqlite3"); | |
329 FilePath sync_file3 = temp_directory.AppendASCII("nonsense_file"); | |
330 ASSERT_TRUE(file_util::CreateDirectory(temp_directory)); | |
331 ASSERT_NE(-1, | |
332 file_util::WriteFile(sync_file1, nonsense1, strlen(nonsense1))); | |
333 ASSERT_NE(-1, | |
334 file_util::WriteFile(sync_file2, nonsense2, strlen(nonsense2))); | |
335 ASSERT_NE(-1, | |
336 file_util::WriteFile(sync_file3, nonsense3, strlen(nonsense3))); | |
337 | |
338 StartSyncServiceAndSetInitialSyncEnded(false, false, true, false, | |
339 syncer::STORAGE_ON_DISK); | |
340 EXPECT_FALSE(service_->HasSyncSetupCompleted()); | |
341 EXPECT_FALSE(service_->sync_initialized()); | |
342 | |
343 // Since we're doing synchronous initialization, backend should be | |
344 // initialized by this call. | |
345 IssueTestTokens(); | |
346 | |
347 // Stop the service so we can read the new Sync Data files that were | |
348 // created. | |
349 service_.reset(); | |
350 | |
351 // This file should have been deleted when the whole directory was nuked. | |
352 ASSERT_FALSE(file_util::PathExists(sync_file3)); | |
353 ASSERT_FALSE(file_util::PathExists(sync_file1)); | |
354 | |
355 // This will still exist, but the text should have changed. | |
356 ASSERT_TRUE(file_util::PathExists(sync_file2)); | |
357 std::string file2text; | |
358 ASSERT_TRUE(file_util::ReadFileToString(sync_file2, &file2text)); | |
359 ASSERT_NE(file2text.compare(nonsense2), 0); | |
360 } | |
361 | |
362 // Simulates a scenario where a database is corrupted and it is impossible to | 319 // Simulates a scenario where a database is corrupted and it is impossible to |
363 // recreate it. This test is useful mainly when it is run under valgrind. Its | 320 // recreate it. This test is useful mainly when it is run under valgrind. Its |
364 // expectations are not very interesting. | 321 // expectations are not very interesting. |
365 TEST_F(ProfileSyncServiceTest, FailToOpenDatabase) { | 322 TEST_F(ProfileSyncServiceTest, FailToOpenDatabase) { |
366 StartSyncServiceAndSetInitialSyncEnded(false, true, true, true, | 323 StartSyncServiceAndSetInitialSyncEnded(false, true, true, true, |
367 syncer::STORAGE_INVALID); | 324 syncer::STORAGE_INVALID); |
368 | 325 |
369 // The backend is not ready. Ensure the PSS knows this. | 326 // The backend is not ready. Ensure the PSS knows this. |
370 EXPECT_FALSE(service_->sync_initialized()); | 327 EXPECT_FALSE(service_->sync_initialized()); |
371 } | 328 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
442 EXPECT_THAT(states, Eq(handler.GetLastNotificationIdStateMap())); | 399 EXPECT_THAT(states, Eq(handler.GetLastNotificationIdStateMap())); |
443 EXPECT_EQ(syncer::REMOTE_NOTIFICATION, handler.GetLastNotificationSource()); | 400 EXPECT_EQ(syncer::REMOTE_NOTIFICATION, handler.GetLastNotificationSource()); |
444 | 401 |
445 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); | 402 backend->EmitOnNotificationsDisabled(syncer::TRANSIENT_NOTIFICATION_ERROR); |
446 EXPECT_EQ(syncer::TRANSIENT_NOTIFICATION_ERROR, | 403 EXPECT_EQ(syncer::TRANSIENT_NOTIFICATION_ERROR, |
447 handler.GetNotificationsDisabledReason()); | 404 handler.GetNotificationsDisabledReason()); |
448 } | 405 } |
449 | 406 |
450 } // namespace | 407 } // namespace |
451 } // namespace browser_sync | 408 } // namespace browser_sync |
OLD | NEW |