| 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace | 102 } // namespace |
| 103 | 103 |
| 104 class LocalFileSyncServiceTest | 104 class LocalFileSyncServiceTest |
| 105 : public testing::Test, | 105 : public testing::Test, |
| 106 public LocalFileSyncService::Observer { | 106 public LocalFileSyncService::Observer { |
| 107 protected: | 107 protected: |
| 108 LocalFileSyncServiceTest() : num_changes_(0) {} | 108 LocalFileSyncServiceTest() : num_changes_(0) {} |
| 109 | 109 |
| 110 ~LocalFileSyncServiceTest() {} | 110 virtual ~LocalFileSyncServiceTest() {} |
| 111 | 111 |
| 112 virtual void SetUp() OVERRIDE { | 112 virtual void SetUp() OVERRIDE { |
| 113 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 113 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 114 | 114 |
| 115 thread_helper_.SetUp(); | 115 thread_helper_.SetUp(); |
| 116 | 116 |
| 117 file_system_.reset(new fileapi::CannedSyncableFileSystem( | 117 file_system_.reset(new fileapi::CannedSyncableFileSystem( |
| 118 GURL(kOrigin), kServiceName, | 118 GURL(kOrigin), kServiceName, |
| 119 thread_helper_.io_task_runner(), | 119 thread_helper_.io_task_runner(), |
| 120 thread_helper_.file_task_runner())); | 120 thread_helper_.file_task_runner())); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 140 | 140 |
| 141 virtual void TearDown() OVERRIDE { | 141 virtual void TearDown() OVERRIDE { |
| 142 local_service_->Shutdown(); | 142 local_service_->Shutdown(); |
| 143 file_system_->TearDown(); | 143 file_system_->TearDown(); |
| 144 fileapi::RevokeSyncableFileSystem(kServiceName); | 144 fileapi::RevokeSyncableFileSystem(kServiceName); |
| 145 | 145 |
| 146 thread_helper_.TearDown(); | 146 thread_helper_.TearDown(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 // LocalChangeObserver overrides. | 149 // LocalChangeObserver overrides. |
| 150 virtual void OnLocalChangeAvailable(int64 num_changes) { | 150 virtual void OnLocalChangeAvailable(int64 num_changes) OVERRIDE { |
| 151 num_changes_ = num_changes; | 151 num_changes_ = num_changes; |
| 152 } | 152 } |
| 153 | 153 |
| 154 void PrepareForProcessRemoteChange( | 154 void PrepareForProcessRemoteChange( |
| 155 const FileSystemURL& url, | 155 const FileSystemURL& url, |
| 156 const tracked_objects::Location& where, | 156 const tracked_objects::Location& where, |
| 157 SyncStatusCode expected_status, | 157 SyncStatusCode expected_status, |
| 158 const SyncFileMetadata& expected_metadata) { | 158 const SyncFileMetadata& expected_metadata) { |
| 159 base::RunLoop run_loop; | 159 base::RunLoop run_loop; |
| 160 local_service_->PrepareForProcessRemoteChange( | 160 local_service_->PrepareForProcessRemoteChange( |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 } | 565 } |
| 566 | 566 |
| 567 // TODO(kinuko): Add tests for multiple file changes and multiple | 567 // TODO(kinuko): Add tests for multiple file changes and multiple |
| 568 // FileSystemContexts. | 568 // FileSystemContexts. |
| 569 | 569 |
| 570 // Unit test for OriginChangeMap --------------------------------------------- | 570 // Unit test for OriginChangeMap --------------------------------------------- |
| 571 | 571 |
| 572 class OriginChangeMapTest : public testing::Test { | 572 class OriginChangeMapTest : public testing::Test { |
| 573 protected: | 573 protected: |
| 574 OriginChangeMapTest() {} | 574 OriginChangeMapTest() {} |
| 575 ~OriginChangeMapTest() {} | 575 virtual ~OriginChangeMapTest() {} |
| 576 | 576 |
| 577 bool NextOriginToProcess(GURL* origin) { | 577 bool NextOriginToProcess(GURL* origin) { |
| 578 return map_.NextOriginToProcess(origin); | 578 return map_.NextOriginToProcess(origin); |
| 579 } | 579 } |
| 580 | 580 |
| 581 int64 GetTotalChangeCount() const { | 581 int64 GetTotalChangeCount() const { |
| 582 return map_.GetTotalChangeCount(); | 582 return map_.GetTotalChangeCount(); |
| 583 } | 583 } |
| 584 | 584 |
| 585 void SetOriginChangeCount(const GURL& origin, int64 changes) { | 585 void SetOriginChangeCount(const GURL& origin, int64 changes) { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 all_origins.insert(kOrigin2); | 707 all_origins.insert(kOrigin2); |
| 708 all_origins.insert(kOrigin3); | 708 all_origins.insert(kOrigin3); |
| 709 while (!all_origins.empty()) { | 709 while (!all_origins.empty()) { |
| 710 ASSERT_TRUE(NextOriginToProcess(&origin)); | 710 ASSERT_TRUE(NextOriginToProcess(&origin)); |
| 711 ASSERT_TRUE(ContainsKey(all_origins, origin)); | 711 ASSERT_TRUE(ContainsKey(all_origins, origin)); |
| 712 all_origins.erase(origin); | 712 all_origins.erase(origin); |
| 713 } | 713 } |
| 714 } | 714 } |
| 715 | 715 |
| 716 } // namespace sync_file_system | 716 } // namespace sync_file_system |
| OLD | NEW |