OLD | NEW |
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 <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/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 102 |
103 class LocalFileSyncServiceTest | 103 class LocalFileSyncServiceTest |
104 : public testing::Test, | 104 : public testing::Test, |
105 public LocalFileSyncService::Observer { | 105 public LocalFileSyncService::Observer { |
106 protected: | 106 protected: |
107 LocalFileSyncServiceTest() | 107 LocalFileSyncServiceTest() |
108 : thread_bundle_(content::TestBrowserThreadBundle::REAL_FILE_THREAD | | 108 : thread_bundle_(content::TestBrowserThreadBundle::REAL_FILE_THREAD | |
109 content::TestBrowserThreadBundle::REAL_IO_THREAD), | 109 content::TestBrowserThreadBundle::REAL_IO_THREAD), |
110 num_changes_(0) {} | 110 num_changes_(0) {} |
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 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); | 114 in_memory_env_.reset(leveldb::NewMemEnv(leveldb::Env::Default())); |
115 | 115 |
116 file_system_.reset(new CannedSyncableFileSystem( | 116 file_system_.reset(new CannedSyncableFileSystem( |
117 GURL(kOrigin), | 117 GURL(kOrigin), |
118 in_memory_env_.get(), | 118 in_memory_env_.get(), |
119 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 119 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
120 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); | 120 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); |
121 | 121 |
122 local_service_ = LocalFileSyncService::CreateForTesting( | 122 local_service_ = LocalFileSyncService::CreateForTesting( |
123 &profile_, in_memory_env_.get()); | 123 &profile_, in_memory_env_.get()); |
124 | 124 |
125 file_system_->SetUp(CannedSyncableFileSystem::QUOTA_ENABLED); | 125 file_system_->SetUp(CannedSyncableFileSystem::QUOTA_ENABLED); |
126 | 126 |
127 base::RunLoop run_loop; | 127 base::RunLoop run_loop; |
128 SyncStatusCode status = SYNC_STATUS_UNKNOWN; | 128 SyncStatusCode status = SYNC_STATUS_UNKNOWN; |
129 local_service_->MaybeInitializeFileSystemContext( | 129 local_service_->MaybeInitializeFileSystemContext( |
130 GURL(kOrigin), file_system_->file_system_context(), | 130 GURL(kOrigin), file_system_->file_system_context(), |
131 AssignAndQuitCallback(&run_loop, &status)); | 131 AssignAndQuitCallback(&run_loop, &status)); |
132 run_loop.Run(); | 132 run_loop.Run(); |
133 | 133 |
134 local_service_->AddChangeObserver(this); | 134 local_service_->AddChangeObserver(this); |
135 | 135 |
136 EXPECT_EQ(base::File::FILE_OK, file_system_->OpenFileSystem()); | 136 EXPECT_EQ(base::File::FILE_OK, file_system_->OpenFileSystem()); |
137 | 137 |
138 file_system_->backend()->sync_context()-> | 138 file_system_->backend()->sync_context()-> |
139 set_mock_notify_changes_duration_in_sec(0); | 139 set_mock_notify_changes_duration_in_sec(0); |
140 } | 140 } |
141 | 141 |
142 virtual void TearDown() OVERRIDE { | 142 virtual void TearDown() override { |
143 local_service_->Shutdown(); | 143 local_service_->Shutdown(); |
144 file_system_->TearDown(); | 144 file_system_->TearDown(); |
145 RevokeSyncableFileSystem(); | 145 RevokeSyncableFileSystem(); |
146 content::RunAllPendingInMessageLoop(BrowserThread::FILE); | 146 content::RunAllPendingInMessageLoop(BrowserThread::FILE); |
147 content::RunAllPendingInMessageLoop(BrowserThread::IO); | 147 content::RunAllPendingInMessageLoop(BrowserThread::IO); |
148 } | 148 } |
149 | 149 |
150 // LocalChangeObserver overrides. | 150 // LocalChangeObserver overrides. |
151 virtual void OnLocalChangeAvailable(int64 num_changes) OVERRIDE { | 151 virtual void OnLocalChangeAvailable(int64 num_changes) override { |
152 num_changes_ = num_changes; | 152 num_changes_ = num_changes; |
153 } | 153 } |
154 | 154 |
155 void PrepareForProcessRemoteChange( | 155 void PrepareForProcessRemoteChange( |
156 const FileSystemURL& url, | 156 const FileSystemURL& url, |
157 const tracked_objects::Location& where, | 157 const tracked_objects::Location& where, |
158 SyncStatusCode expected_status, | 158 SyncStatusCode expected_status, |
159 const SyncFileMetadata& expected_metadata) { | 159 const SyncFileMetadata& expected_metadata) { |
160 base::RunLoop run_loop; | 160 base::RunLoop run_loop; |
161 local_service_->PrepareForProcessRemoteChange( | 161 local_service_->PrepareForProcessRemoteChange( |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 all_origins.insert(kOrigin2); | 726 all_origins.insert(kOrigin2); |
727 all_origins.insert(kOrigin3); | 727 all_origins.insert(kOrigin3); |
728 while (!all_origins.empty()) { | 728 while (!all_origins.empty()) { |
729 ASSERT_TRUE(NextOriginToProcess(&origin)); | 729 ASSERT_TRUE(NextOriginToProcess(&origin)); |
730 ASSERT_TRUE(ContainsKey(all_origins, origin)); | 730 ASSERT_TRUE(ContainsKey(all_origins, origin)); |
731 all_origins.erase(origin); | 731 all_origins.erase(origin); |
732 } | 732 } |
733 } | 733 } |
734 | 734 |
735 } // namespace sync_file_system | 735 } // namespace sync_file_system |
OLD | NEW |