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

Side by Side Diff: chrome/browser/media_galleries/mac/mtp_device_delegate_impl_mac_unittest.mm

Issue 2056443002: Manual refactor to enum-based WaitableEvent for remaining mac/ios files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@d_1_explicit_bools
Patch Set: Created 4 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
« no previous file with comments | « no previous file | components/cronet/ios/cronet_environment.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #import <Foundation/Foundation.h> 5 #import <Foundation/Foundation.h>
6 #import <ImageCaptureCore/ImageCaptureCore.h> 6 #import <ImageCaptureCore/ImageCaptureCore.h>
7 7
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 void OnDownload(base::WaitableEvent* event, 228 void OnDownload(base::WaitableEvent* event,
229 const base::File::Info& file_info, 229 const base::File::Info& file_info,
230 const base::FilePath& local_path) { 230 const base::FilePath& local_path) {
231 error_ = base::File::FILE_OK; 231 error_ = base::File::FILE_OK;
232 event->Signal(); 232 event->Signal();
233 } 233 }
234 234
235 base::File::Error GetFileInfo(const base::FilePath& path, 235 base::File::Error GetFileInfo(const base::FilePath& path,
236 base::File::Info* info) { 236 base::File::Info* info) {
237 base::WaitableEvent wait(true, false); 237 base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::MANUAL,
238 base::WaitableEvent::InitialState::NOT_SIGNALED);
238 delegate_->GetFileInfo( 239 delegate_->GetFileInfo(
239 path, 240 path,
240 base::Bind(&MTPDeviceDelegateImplMacTest::OnFileInfo, 241 base::Bind(&MTPDeviceDelegateImplMacTest::OnFileInfo,
241 base::Unretained(this), 242 base::Unretained(this),
242 &wait), 243 &wait),
243 base::Bind(&MTPDeviceDelegateImplMacTest::OnError, 244 base::Bind(&MTPDeviceDelegateImplMacTest::OnError,
244 base::Unretained(this), 245 base::Unretained(this),
245 &wait)); 246 &wait));
246 base::RunLoop loop; 247 base::RunLoop loop;
247 loop.RunUntilIdle(); 248 loop.RunUntilIdle();
248 EXPECT_TRUE(wait.IsSignaled()); 249 EXPECT_TRUE(wait.IsSignaled());
249 *info = info_; 250 *info = info_;
250 return error_; 251 return error_;
251 } 252 }
252 253
253 base::File::Error ReadDir(const base::FilePath& path) { 254 base::File::Error ReadDir(const base::FilePath& path) {
254 base::WaitableEvent wait(true, false); 255 base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::MANUAL,
256 base::WaitableEvent::InitialState::NOT_SIGNALED);
255 delegate_->ReadDirectory( 257 delegate_->ReadDirectory(
256 path, 258 path,
257 base::Bind(&MTPDeviceDelegateImplMacTest::OnReadDir, 259 base::Bind(&MTPDeviceDelegateImplMacTest::OnReadDir,
258 base::Unretained(this), 260 base::Unretained(this),
259 &wait), 261 &wait),
260 base::Bind(&MTPDeviceDelegateImplMacTest::OnError, 262 base::Bind(&MTPDeviceDelegateImplMacTest::OnError,
261 base::Unretained(this), 263 base::Unretained(this),
262 &wait)); 264 &wait));
263 base::RunLoop loop; 265 base::RunLoop loop;
264 loop.RunUntilIdle(); 266 loop.RunUntilIdle();
265 wait.Wait(); 267 wait.Wait();
266 return error_; 268 return error_;
267 } 269 }
268 270
269 base::File::Error DownloadFile( 271 base::File::Error DownloadFile(
270 const base::FilePath& path, 272 const base::FilePath& path,
271 const base::FilePath& local_path) { 273 const base::FilePath& local_path) {
272 base::WaitableEvent wait(true, false); 274 base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::MANUAL,
275 base::WaitableEvent::InitialState::NOT_SIGNALED);
273 delegate_->CreateSnapshotFile( 276 delegate_->CreateSnapshotFile(
274 path, local_path, 277 path, local_path,
275 base::Bind(&MTPDeviceDelegateImplMacTest::OnDownload, 278 base::Bind(&MTPDeviceDelegateImplMacTest::OnDownload,
276 base::Unretained(this), 279 base::Unretained(this),
277 &wait), 280 &wait),
278 base::Bind(&MTPDeviceDelegateImplMacTest::OnError, 281 base::Bind(&MTPDeviceDelegateImplMacTest::OnError,
279 base::Unretained(this), 282 base::Unretained(this),
280 &wait)); 283 &wait));
281 base::RunLoop loop; 284 base::RunLoop loop;
282 loop.RunUntilIdle(); 285 loop.RunUntilIdle();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 base::Time time1 = base::Time::Now(); 332 base::Time time1 = base::Time::Now();
330 base::File::Info info1; 333 base::File::Info info1;
331 info1.size = 1; 334 info1.size = 1;
332 info1.is_directory = false; 335 info1.is_directory = false;
333 info1.is_symbolic_link = false; 336 info1.is_symbolic_link = false;
334 info1.last_modified = time1; 337 info1.last_modified = time1;
335 info1.last_accessed = time1; 338 info1.last_accessed = time1;
336 info1.creation_time = time1; 339 info1.creation_time = time1;
337 delegate_->ItemAdded("name1", info1); 340 delegate_->ItemAdded("name1", info1);
338 341
339 base::WaitableEvent wait(true, false); 342 base::WaitableEvent wait(base::WaitableEvent::ResetPolicy::MANUAL,
343 base::WaitableEvent::InitialState::NOT_SIGNALED);
340 344
341 delegate_->ReadDirectory( 345 delegate_->ReadDirectory(
342 base::FilePath(kDevicePath), 346 base::FilePath(kDevicePath),
343 base::Bind(&MTPDeviceDelegateImplMacTest::OnReadDir, 347 base::Bind(&MTPDeviceDelegateImplMacTest::OnReadDir,
344 base::Unretained(this), 348 base::Unretained(this),
345 &wait), 349 &wait),
346 base::Bind(&MTPDeviceDelegateImplMacTest::OnError, 350 base::Bind(&MTPDeviceDelegateImplMacTest::OnError,
347 base::Unretained(this), 351 base::Unretained(this),
348 &wait)); 352 &wait));
349 353
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 temp_dir_.path().Append("target"))); 548 temp_dir_.path().Append("target")));
545 549
546 EXPECT_EQ(base::File::FILE_OK, 550 EXPECT_EQ(base::File::FILE_OK,
547 DownloadFile(base::FilePath("/ic:id/filename"), 551 DownloadFile(base::FilePath("/ic:id/filename"),
548 temp_dir_.path().Append("target"))); 552 temp_dir_.path().Append("target")));
549 std::string contents; 553 std::string contents;
550 EXPECT_TRUE(base::ReadFileToString(temp_dir_.path().Append("target"), 554 EXPECT_TRUE(base::ReadFileToString(temp_dir_.path().Append("target"),
551 &contents)); 555 &contents));
552 EXPECT_EQ(kTestFileContents, contents); 556 EXPECT_EQ(kTestFileContents, contents);
553 } 557 }
OLDNEW
« no previous file with comments | « no previous file | components/cronet/ios/cronet_environment.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698