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

Side by Side Diff: chrome/browser/sync_file_system/local/local_file_sync_context_unittest.cc

Issue 145693005: [FileAPI] Replace default leveldb::Env with leveldb::MemEnv in tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/sync_file_system/local/local_file_sync_context.h" 5 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/platform_file.h" 14 #include "base/platform_file.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" 16 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h"
17 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" 17 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h"
18 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" 18 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h"
19 #include "chrome/browser/sync_file_system/sync_file_metadata.h" 19 #include "chrome/browser/sync_file_system/sync_file_metadata.h"
20 #include "chrome/browser/sync_file_system/sync_status_code.h" 20 #include "chrome/browser/sync_file_system/sync_status_code.h"
21 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" 21 #include "chrome/browser/sync_file_system/syncable_file_system_util.h"
22 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
23 #include "content/public/test/mock_blob_url_request_context.h" 23 #include "content/public/test/mock_blob_url_request_context.h"
24 #include "content/public/test/test_browser_thread_bundle.h" 24 #include "content/public/test/test_browser_thread_bundle.h"
25 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
26 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h"
27 #include "third_party/leveldatabase/src/include/leveldb/env.h"
26 #include "webkit/browser/fileapi/file_system_context.h" 28 #include "webkit/browser/fileapi/file_system_context.h"
27 #include "webkit/browser/fileapi/file_system_operation_runner.h" 29 #include "webkit/browser/fileapi/file_system_operation_runner.h"
28 #include "webkit/browser/fileapi/isolated_context.h" 30 #include "webkit/browser/fileapi/isolated_context.h"
29 #include "webkit/common/blob/scoped_file.h" 31 #include "webkit/common/blob/scoped_file.h"
30 32
31 #define FPL FILE_PATH_LITERAL 33 #define FPL FILE_PATH_LITERAL
32 34
33 using content::BrowserThread; 35 using content::BrowserThread;
34 using fileapi::FileSystemContext; 36 using fileapi::FileSystemContext;
35 using fileapi::FileSystemURL; 37 using fileapi::FileSystemURL;
(...skipping 19 matching lines...) Expand all
55 content::TestBrowserThreadBundle::REAL_FILE_THREAD | 57 content::TestBrowserThreadBundle::REAL_FILE_THREAD |
56 content::TestBrowserThreadBundle::REAL_IO_THREAD), 58 content::TestBrowserThreadBundle::REAL_IO_THREAD),
57 status_(SYNC_FILE_ERROR_FAILED), 59 status_(SYNC_FILE_ERROR_FAILED),
58 file_error_(base::File::FILE_ERROR_FAILED), 60 file_error_(base::File::FILE_ERROR_FAILED),
59 async_modify_finished_(false), 61 async_modify_finished_(false),
60 has_inflight_prepare_for_sync_(false) {} 62 has_inflight_prepare_for_sync_(false) {}
61 63
62 virtual void SetUp() OVERRIDE { 64 virtual void SetUp() OVERRIDE {
63 RegisterSyncableFileSystem(); 65 RegisterSyncableFileSystem();
64 ASSERT_TRUE(dir_.CreateUniqueTempDir()); 66 ASSERT_TRUE(dir_.CreateUniqueTempDir());
67 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default()));
65 68
66 ui_task_runner_ = base::MessageLoop::current()->message_loop_proxy(); 69 ui_task_runner_ = base::MessageLoop::current()->message_loop_proxy();
67 io_task_runner_ = BrowserThread::GetMessageLoopProxyForThread( 70 io_task_runner_ = BrowserThread::GetMessageLoopProxyForThread(
68 BrowserThread::IO); 71 BrowserThread::IO);
69 file_task_runner_ = BrowserThread::GetMessageLoopProxyForThread( 72 file_task_runner_ = BrowserThread::GetMessageLoopProxyForThread(
70 BrowserThread::IO); 73 BrowserThread::IO);
71 } 74 }
72 75
73 virtual void TearDown() OVERRIDE { 76 virtual void TearDown() OVERRIDE {
74 RevokeSyncableFileSystem(); 77 RevokeSyncableFileSystem();
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 sync_context_->FinalizeExclusiveSync( 224 sync_context_->FinalizeExclusiveSync(
222 file_system_context, url, 225 file_system_context, url,
223 status == SYNC_STATUS_OK /* clear_local_changes */, 226 status == SYNC_STATUS_OK /* clear_local_changes */,
224 base::Bind(&base::DoNothing)); 227 base::Bind(&base::DoNothing));
225 } 228 }
226 } 229 }
227 230
228 void PrepareForSync_Basic(LocalFileSyncContext::SyncMode sync_mode, 231 void PrepareForSync_Basic(LocalFileSyncContext::SyncMode sync_mode,
229 SyncStatusCode simulate_sync_finish_status) { 232 SyncStatusCode simulate_sync_finish_status) {
230 CannedSyncableFileSystem file_system(GURL(kOrigin1), 233 CannedSyncableFileSystem file_system(GURL(kOrigin1),
234 in_memory_env_.get(),
231 io_task_runner_.get(), 235 io_task_runner_.get(),
232 file_task_runner_.get()); 236 file_task_runner_.get());
233 file_system.SetUp(); 237 file_system.SetUp();
234 sync_context_ = new LocalFileSyncContext( 238 sync_context_ = new LocalFileSyncContext(
235 dir_.path(), ui_task_runner_.get(), io_task_runner_.get()); 239 dir_.path(), in_memory_env_.get(),
240 ui_task_runner_.get(), io_task_runner_.get());
236 ASSERT_EQ(SYNC_STATUS_OK, 241 ASSERT_EQ(SYNC_STATUS_OK,
237 file_system.MaybeInitializeFileSystemContext( 242 file_system.MaybeInitializeFileSystemContext(
238 sync_context_.get())); 243 sync_context_.get()));
239 ASSERT_EQ(base::File::FILE_OK, file_system.OpenFileSystem()); 244 ASSERT_EQ(base::File::FILE_OK, file_system.OpenFileSystem());
240 245
241 const FileSystemURL kFile(file_system.URL("file")); 246 const FileSystemURL kFile(file_system.URL("file"));
242 EXPECT_EQ(base::File::FILE_OK, file_system.CreateFile(kFile)); 247 EXPECT_EQ(base::File::FILE_OK, file_system.CreateFile(kFile));
243 248
244 SyncFileMetadata metadata; 249 SyncFileMetadata metadata;
245 FileChangeList changes; 250 FileChangeList changes;
(...skipping 25 matching lines...) Expand all
271 276
272 sync_context_->ShutdownOnUIThread(); 277 sync_context_->ShutdownOnUIThread();
273 sync_context_ = NULL; 278 sync_context_ = NULL;
274 279
275 file_system.TearDown(); 280 file_system.TearDown();
276 } 281 }
277 282
278 void PrepareForSync_WriteDuringSync( 283 void PrepareForSync_WriteDuringSync(
279 LocalFileSyncContext::SyncMode sync_mode) { 284 LocalFileSyncContext::SyncMode sync_mode) {
280 CannedSyncableFileSystem file_system(GURL(kOrigin1), 285 CannedSyncableFileSystem file_system(GURL(kOrigin1),
286 in_memory_env_.get(),
281 io_task_runner_.get(), 287 io_task_runner_.get(),
282 file_task_runner_.get()); 288 file_task_runner_.get());
283 file_system.SetUp(); 289 file_system.SetUp();
284 sync_context_ = new LocalFileSyncContext( 290 sync_context_ = new LocalFileSyncContext(
285 dir_.path(), ui_task_runner_.get(), io_task_runner_.get()); 291 dir_.path(), in_memory_env_.get(),
292 ui_task_runner_.get(), io_task_runner_.get());
286 ASSERT_EQ(SYNC_STATUS_OK, 293 ASSERT_EQ(SYNC_STATUS_OK,
287 file_system.MaybeInitializeFileSystemContext( 294 file_system.MaybeInitializeFileSystemContext(
288 sync_context_.get())); 295 sync_context_.get()));
289 ASSERT_EQ(base::File::FILE_OK, file_system.OpenFileSystem()); 296 ASSERT_EQ(base::File::FILE_OK, file_system.OpenFileSystem());
290 297
291 const FileSystemURL kFile(file_system.URL("file")); 298 const FileSystemURL kFile(file_system.URL("file"));
292 EXPECT_EQ(base::File::FILE_OK, file_system.CreateFile(kFile)); 299 EXPECT_EQ(base::File::FILE_OK, file_system.CreateFile(kFile));
293 300
294 SyncFileMetadata metadata; 301 SyncFileMetadata metadata;
295 FileChangeList changes; 302 FileChangeList changes;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 341
335 sync_context_->ShutdownOnUIThread(); 342 sync_context_->ShutdownOnUIThread();
336 sync_context_ = NULL; 343 sync_context_ = NULL;
337 344
338 file_system.TearDown(); 345 file_system.TearDown();
339 } 346 }
340 347
341 ScopedEnableSyncFSDirectoryOperation enable_directory_operation_; 348 ScopedEnableSyncFSDirectoryOperation enable_directory_operation_;
342 349
343 base::ScopedTempDir dir_; 350 base::ScopedTempDir dir_;
351 scoped_ptr<leveldb::Env> in_memory_env_;
344 352
345 // These need to remain until the very end. 353 // These need to remain until the very end.
346 content::TestBrowserThreadBundle thread_bundle_; 354 content::TestBrowserThreadBundle thread_bundle_;
347 355
348 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; 356 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
349 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 357 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
350 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; 358 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
351 359
352 scoped_refptr<LocalFileSyncContext> sync_context_; 360 scoped_refptr<LocalFileSyncContext> sync_context_;
353 361
354 SyncStatusCode status_; 362 SyncStatusCode status_;
355 base::File::Error file_error_; 363 base::File::Error file_error_;
356 bool async_modify_finished_; 364 bool async_modify_finished_;
357 bool has_inflight_prepare_for_sync_; 365 bool has_inflight_prepare_for_sync_;
358 }; 366 };
359 367
360 TEST_F(LocalFileSyncContextTest, ConstructAndDestruct) { 368 TEST_F(LocalFileSyncContextTest, ConstructAndDestruct) {
361 sync_context_ = 369 sync_context_ =
362 new LocalFileSyncContext( 370 new LocalFileSyncContext(
363 dir_.path(), ui_task_runner_.get(), io_task_runner_.get()); 371 dir_.path(), in_memory_env_.get(),
372 ui_task_runner_.get(), io_task_runner_.get());
364 sync_context_->ShutdownOnUIThread(); 373 sync_context_->ShutdownOnUIThread();
365 } 374 }
366 375
367 TEST_F(LocalFileSyncContextTest, InitializeFileSystemContext) { 376 TEST_F(LocalFileSyncContextTest, InitializeFileSystemContext) {
368 CannedSyncableFileSystem file_system(GURL(kOrigin1), 377 CannedSyncableFileSystem file_system(GURL(kOrigin1),
378 in_memory_env_.get(),
369 io_task_runner_.get(), 379 io_task_runner_.get(),
370 file_task_runner_.get()); 380 file_task_runner_.get());
371 file_system.SetUp(); 381 file_system.SetUp();
372 382
373 sync_context_ = new LocalFileSyncContext( 383 sync_context_ = new LocalFileSyncContext(
374 dir_.path(), ui_task_runner_.get(), io_task_runner_.get()); 384 dir_.path(), in_memory_env_.get(),
385 ui_task_runner_.get(), io_task_runner_.get());
375 386
376 // Initializes file_system using |sync_context_|. 387 // Initializes file_system using |sync_context_|.
377 EXPECT_EQ(SYNC_STATUS_OK, 388 EXPECT_EQ(SYNC_STATUS_OK,
378 file_system.MaybeInitializeFileSystemContext(sync_context_.get())); 389 file_system.MaybeInitializeFileSystemContext(sync_context_.get()));
379 390
380 // Make sure everything's set up for file_system to be able to handle 391 // Make sure everything's set up for file_system to be able to handle
381 // syncable file system operations. 392 // syncable file system operations.
382 EXPECT_TRUE(file_system.backend()->sync_context() != NULL); 393 EXPECT_TRUE(file_system.backend()->sync_context() != NULL);
383 EXPECT_TRUE(file_system.backend()->change_tracker() != NULL); 394 EXPECT_TRUE(file_system.backend()->change_tracker() != NULL);
384 EXPECT_EQ(sync_context_.get(), file_system.backend()->sync_context()); 395 EXPECT_EQ(sync_context_.get(), file_system.backend()->sync_context());
(...skipping 15 matching lines...) Expand all
400 ASSERT_EQ(1U, urls.size()); 411 ASSERT_EQ(1U, urls.size());
401 EXPECT_TRUE(ContainsKey(urls, kURL)); 412 EXPECT_TRUE(ContainsKey(urls, kURL));
402 413
403 // Finishing the test. 414 // Finishing the test.
404 sync_context_->ShutdownOnUIThread(); 415 sync_context_->ShutdownOnUIThread();
405 file_system.TearDown(); 416 file_system.TearDown();
406 } 417 }
407 418
408 TEST_F(LocalFileSyncContextTest, MultipleFileSystemContexts) { 419 TEST_F(LocalFileSyncContextTest, MultipleFileSystemContexts) {
409 CannedSyncableFileSystem file_system1(GURL(kOrigin1), 420 CannedSyncableFileSystem file_system1(GURL(kOrigin1),
421 in_memory_env_.get(),
410 io_task_runner_.get(), 422 io_task_runner_.get(),
411 file_task_runner_.get()); 423 file_task_runner_.get());
412 CannedSyncableFileSystem file_system2(GURL(kOrigin2), 424 CannedSyncableFileSystem file_system2(GURL(kOrigin2),
425 in_memory_env_.get(),
413 io_task_runner_.get(), 426 io_task_runner_.get(),
414 file_task_runner_.get()); 427 file_task_runner_.get());
415 file_system1.SetUp(); 428 file_system1.SetUp();
416 file_system2.SetUp(); 429 file_system2.SetUp();
417 430
418 sync_context_ = new LocalFileSyncContext( 431 sync_context_ = new LocalFileSyncContext(
419 dir_.path(), ui_task_runner_.get(), io_task_runner_.get()); 432 dir_.path(), in_memory_env_.get(),
433 ui_task_runner_.get(), io_task_runner_.get());
420 434
421 // Initializes file_system1 and file_system2. 435 // Initializes file_system1 and file_system2.
422 EXPECT_EQ(SYNC_STATUS_OK, 436 EXPECT_EQ(SYNC_STATUS_OK,
423 file_system1.MaybeInitializeFileSystemContext(sync_context_.get())); 437 file_system1.MaybeInitializeFileSystemContext(sync_context_.get()));
424 EXPECT_EQ(SYNC_STATUS_OK, 438 EXPECT_EQ(SYNC_STATUS_OK,
425 file_system2.MaybeInitializeFileSystemContext(sync_context_.get())); 439 file_system2.MaybeInitializeFileSystemContext(sync_context_.get()));
426 440
427 EXPECT_EQ(base::File::FILE_OK, file_system1.OpenFileSystem()); 441 EXPECT_EQ(base::File::FILE_OK, file_system1.OpenFileSystem());
428 EXPECT_EQ(base::File::FILE_OK, file_system2.OpenFileSystem()); 442 EXPECT_EQ(base::File::FILE_OK, file_system2.OpenFileSystem());
429 443
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 TEST_F(LocalFileSyncContextTest, PrepareSync_WriteDuringSync_Snapshot) { 530 TEST_F(LocalFileSyncContextTest, PrepareSync_WriteDuringSync_Snapshot) {
517 PrepareForSync_WriteDuringSync(LocalFileSyncContext::SYNC_SNAPSHOT); 531 PrepareForSync_WriteDuringSync(LocalFileSyncContext::SYNC_SNAPSHOT);
518 } 532 }
519 533
520 // LocalFileSyncContextTest.PrepareSyncWhileWriting is flaky on android. 534 // LocalFileSyncContextTest.PrepareSyncWhileWriting is flaky on android.
521 // http://crbug.com/239793 535 // http://crbug.com/239793
522 // It is also flaky on the TSAN v2 bots, and hangs other bots. 536 // It is also flaky on the TSAN v2 bots, and hangs other bots.
523 // http://crbug.com/305905. 537 // http://crbug.com/305905.
524 TEST_F(LocalFileSyncContextTest, DISABLED_PrepareSyncWhileWriting) { 538 TEST_F(LocalFileSyncContextTest, DISABLED_PrepareSyncWhileWriting) {
525 CannedSyncableFileSystem file_system(GURL(kOrigin1), 539 CannedSyncableFileSystem file_system(GURL(kOrigin1),
540 in_memory_env_.get(),
526 io_task_runner_.get(), 541 io_task_runner_.get(),
527 file_task_runner_.get()); 542 file_task_runner_.get());
528 file_system.SetUp(); 543 file_system.SetUp();
529 sync_context_ = new LocalFileSyncContext( 544 sync_context_ = new LocalFileSyncContext(
530 dir_.path(), ui_task_runner_.get(), io_task_runner_.get()); 545 dir_.path(), in_memory_env_.get(),
546 ui_task_runner_.get(), io_task_runner_.get());
531 EXPECT_EQ(SYNC_STATUS_OK, 547 EXPECT_EQ(SYNC_STATUS_OK,
532 file_system.MaybeInitializeFileSystemContext(sync_context_.get())); 548 file_system.MaybeInitializeFileSystemContext(sync_context_.get()));
533 549
534 EXPECT_EQ(base::File::FILE_OK, file_system.OpenFileSystem()); 550 EXPECT_EQ(base::File::FILE_OK, file_system.OpenFileSystem());
535 551
536 const FileSystemURL kURL1(file_system.URL("foo")); 552 const FileSystemURL kURL1(file_system.URL("foo"));
537 553
538 // Creates a file in file_system. 554 // Creates a file in file_system.
539 EXPECT_EQ(base::File::FILE_OK, file_system.CreateFile(kURL1)); 555 EXPECT_EQ(base::File::FILE_OK, file_system.CreateFile(kURL1));
540 556
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 EXPECT_EQ(SYNC_FILE_TYPE_FILE, metadata.file_type); 593 EXPECT_EQ(SYNC_FILE_TYPE_FILE, metadata.file_type);
578 EXPECT_EQ(1, metadata.size); 594 EXPECT_EQ(1, metadata.size);
579 595
580 sync_context_->ShutdownOnUIThread(); 596 sync_context_->ShutdownOnUIThread();
581 sync_context_ = NULL; 597 sync_context_ = NULL;
582 file_system.TearDown(); 598 file_system.TearDown();
583 } 599 }
584 600
585 TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForDeletion) { 601 TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForDeletion) {
586 CannedSyncableFileSystem file_system(GURL(kOrigin1), 602 CannedSyncableFileSystem file_system(GURL(kOrigin1),
603 in_memory_env_.get(),
587 io_task_runner_.get(), 604 io_task_runner_.get(),
588 file_task_runner_.get()); 605 file_task_runner_.get());
589 file_system.SetUp(); 606 file_system.SetUp();
590 607
591 sync_context_ = new LocalFileSyncContext( 608 sync_context_ = new LocalFileSyncContext(
592 dir_.path(), ui_task_runner_.get(), io_task_runner_.get()); 609 dir_.path(), in_memory_env_.get(),
610 ui_task_runner_.get(), io_task_runner_.get());
593 ASSERT_EQ(SYNC_STATUS_OK, 611 ASSERT_EQ(SYNC_STATUS_OK,
594 file_system.MaybeInitializeFileSystemContext(sync_context_.get())); 612 file_system.MaybeInitializeFileSystemContext(sync_context_.get()));
595 ASSERT_EQ(base::File::FILE_OK, file_system.OpenFileSystem()); 613 ASSERT_EQ(base::File::FILE_OK, file_system.OpenFileSystem());
596 614
597 // Record the initial usage (likely 0). 615 // Record the initial usage (likely 0).
598 int64 initial_usage = -1; 616 int64 initial_usage = -1;
599 int64 quota = -1; 617 int64 quota = -1;
600 EXPECT_EQ(quota::kQuotaStatusOk, 618 EXPECT_EQ(quota::kQuotaStatusOk,
601 file_system.GetUsageAndQuota(&initial_usage, &quota)); 619 file_system.GetUsageAndQuota(&initial_usage, &quota));
602 620
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 file_system.GetUsageAndQuota(&new_usage, &quota)); 681 file_system.GetUsageAndQuota(&new_usage, &quota));
664 EXPECT_EQ(new_usage, initial_usage); 682 EXPECT_EQ(new_usage, initial_usage);
665 683
666 sync_context_->ShutdownOnUIThread(); 684 sync_context_->ShutdownOnUIThread();
667 sync_context_ = NULL; 685 sync_context_ = NULL;
668 file_system.TearDown(); 686 file_system.TearDown();
669 } 687 }
670 688
671 TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForDeletion_ForRoot) { 689 TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForDeletion_ForRoot) {
672 CannedSyncableFileSystem file_system(GURL(kOrigin1), 690 CannedSyncableFileSystem file_system(GURL(kOrigin1),
691 in_memory_env_.get(),
673 io_task_runner_.get(), 692 io_task_runner_.get(),
674 file_task_runner_.get()); 693 file_task_runner_.get());
675 file_system.SetUp(); 694 file_system.SetUp();
676 695
677 sync_context_ = new LocalFileSyncContext( 696 sync_context_ = new LocalFileSyncContext(
678 dir_.path(), ui_task_runner_.get(), io_task_runner_.get()); 697 dir_.path(), in_memory_env_.get(),
698 ui_task_runner_.get(), io_task_runner_.get());
679 ASSERT_EQ(SYNC_STATUS_OK, 699 ASSERT_EQ(SYNC_STATUS_OK,
680 file_system.MaybeInitializeFileSystemContext(sync_context_.get())); 700 file_system.MaybeInitializeFileSystemContext(sync_context_.get()));
681 ASSERT_EQ(base::File::FILE_OK, file_system.OpenFileSystem()); 701 ASSERT_EQ(base::File::FILE_OK, file_system.OpenFileSystem());
682 702
683 // Record the initial usage (likely 0). 703 // Record the initial usage (likely 0).
684 int64 initial_usage = -1; 704 int64 initial_usage = -1;
685 int64 quota = -1; 705 int64 quota = -1;
686 EXPECT_EQ(quota::kQuotaStatusOk, 706 EXPECT_EQ(quota::kQuotaStatusOk,
687 file_system.GetUsageAndQuota(&initial_usage, &quota)); 707 file_system.GetUsageAndQuota(&initial_usage, &quota));
688 708
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 sync_context_->ShutdownOnUIThread(); 751 sync_context_->ShutdownOnUIThread();
732 sync_context_ = NULL; 752 sync_context_ = NULL;
733 file_system.TearDown(); 753 file_system.TearDown();
734 } 754 }
735 755
736 TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForAddOrUpdate) { 756 TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForAddOrUpdate) {
737 base::ScopedTempDir temp_dir; 757 base::ScopedTempDir temp_dir;
738 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 758 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
739 759
740 CannedSyncableFileSystem file_system(GURL(kOrigin1), 760 CannedSyncableFileSystem file_system(GURL(kOrigin1),
761 in_memory_env_.get(),
741 io_task_runner_.get(), 762 io_task_runner_.get(),
742 file_task_runner_.get()); 763 file_task_runner_.get());
743 file_system.SetUp(); 764 file_system.SetUp();
744 765
745 sync_context_ = new LocalFileSyncContext( 766 sync_context_ = new LocalFileSyncContext(
746 dir_.path(), ui_task_runner_.get(), io_task_runner_.get()); 767 dir_.path(), in_memory_env_.get(),
768 ui_task_runner_.get(), io_task_runner_.get());
747 ASSERT_EQ(SYNC_STATUS_OK, 769 ASSERT_EQ(SYNC_STATUS_OK,
748 file_system.MaybeInitializeFileSystemContext(sync_context_.get())); 770 file_system.MaybeInitializeFileSystemContext(sync_context_.get()));
749 ASSERT_EQ(base::File::FILE_OK, file_system.OpenFileSystem()); 771 ASSERT_EQ(base::File::FILE_OK, file_system.OpenFileSystem());
750 772
751 const FileSystemURL kFile1(file_system.URL("file1")); 773 const FileSystemURL kFile1(file_system.URL("file1"));
752 const FileSystemURL kFile2(file_system.URL("file2")); 774 const FileSystemURL kFile2(file_system.URL("file2"));
753 const FileSystemURL kDir(file_system.URL("dir")); 775 const FileSystemURL kDir(file_system.URL("dir"));
754 776
755 const char kTestFileData0[] = "0123456789"; 777 const char kTestFileData0[] = "0123456789";
756 const char kTestFileData1[] = "Lorem ipsum!"; 778 const char kTestFileData1[] = "Lorem ipsum!";
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 902
881 sync_context_->ShutdownOnUIThread(); 903 sync_context_->ShutdownOnUIThread();
882 file_system.TearDown(); 904 file_system.TearDown();
883 } 905 }
884 906
885 TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForAddOrUpdate_NoParent) { 907 TEST_F(LocalFileSyncContextTest, ApplyRemoteChangeForAddOrUpdate_NoParent) {
886 base::ScopedTempDir temp_dir; 908 base::ScopedTempDir temp_dir;
887 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 909 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
888 910
889 CannedSyncableFileSystem file_system(GURL(kOrigin1), 911 CannedSyncableFileSystem file_system(GURL(kOrigin1),
912 in_memory_env_.get(),
890 io_task_runner_.get(), 913 io_task_runner_.get(),
891 file_task_runner_.get()); 914 file_task_runner_.get());
892 file_system.SetUp(); 915 file_system.SetUp();
893 916
894 sync_context_ = new LocalFileSyncContext( 917 sync_context_ = new LocalFileSyncContext(
895 dir_.path(), ui_task_runner_.get(), io_task_runner_.get()); 918 dir_.path(), in_memory_env_.get(),
919 ui_task_runner_.get(), io_task_runner_.get());
896 ASSERT_EQ(SYNC_STATUS_OK, 920 ASSERT_EQ(SYNC_STATUS_OK,
897 file_system.MaybeInitializeFileSystemContext(sync_context_.get())); 921 file_system.MaybeInitializeFileSystemContext(sync_context_.get()));
898 ASSERT_EQ(base::File::FILE_OK, file_system.OpenFileSystem()); 922 ASSERT_EQ(base::File::FILE_OK, file_system.OpenFileSystem());
899 923
900 const char kTestFileData[] = "Lorem ipsum!"; 924 const char kTestFileData[] = "Lorem ipsum!";
901 const FileSystemURL kDir(file_system.URL("dir")); 925 const FileSystemURL kDir(file_system.URL("dir"));
902 const FileSystemURL kFile(file_system.URL("dir/file")); 926 const FileSystemURL kFile(file_system.URL("dir/file"));
903 927
904 // Either kDir or kFile not exist yet. 928 // Either kDir or kFile not exist yet.
905 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, file_system.FileExists(kDir)); 929 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, file_system.FileExists(kDir));
(...skipping 23 matching lines...) Expand all
929 953
930 // Make sure kDir and kFile are created by ApplyRemoteChange. 954 // Make sure kDir and kFile are created by ApplyRemoteChange.
931 EXPECT_EQ(base::File::FILE_OK, file_system.FileExists(kFile)); 955 EXPECT_EQ(base::File::FILE_OK, file_system.FileExists(kFile));
932 EXPECT_EQ(base::File::FILE_OK, file_system.DirectoryExists(kDir)); 956 EXPECT_EQ(base::File::FILE_OK, file_system.DirectoryExists(kDir));
933 957
934 sync_context_->ShutdownOnUIThread(); 958 sync_context_->ShutdownOnUIThread();
935 file_system.TearDown(); 959 file_system.TearDown();
936 } 960 }
937 961
938 } // namespace sync_file_system 962 } // namespace sync_file_system
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698