| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <string.h> | 5 #include <string.h> |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 watcher_callback, | 309 watcher_callback, |
| 310 base::Bind( | 310 base::Bind( |
| 311 [](base::RunLoop* run_loop, base::File::Error error) { | 311 [](base::RunLoop* run_loop, base::File::Error error) { |
| 312 EXPECT_EQ(base::File::FILE_OK, error); | 312 EXPECT_EQ(base::File::FILE_OK, error); |
| 313 run_loop->Quit(); | 313 run_loop->Quit(); |
| 314 }, | 314 }, |
| 315 &run_loop)); | 315 &run_loop)); |
| 316 run_loop.Run(); | 316 run_loop.Run(); |
| 317 } | 317 } |
| 318 | 318 |
| 319 // Even if AddWatcher() returns, the watch may not have started. In order to |
| 320 // make installation finish we run the message loop until idle. This depends |
| 321 // on the behavior of FakeFileSystemInstance. |
| 322 // |
| 323 // TODO(crbug.com/698624): Remove the hack to make AddWatcher() return |
| 324 // immediately. |
| 325 base::RunLoop().RunUntilIdle(); |
| 326 |
| 319 EXPECT_EQ(0, num_called); | 327 EXPECT_EQ(0, num_called); |
| 320 fake_file_system_.TriggerWatchers(kAuthority, kDirSpec.document_id, | 328 fake_file_system_.TriggerWatchers(kAuthority, kDirSpec.document_id, |
| 321 storage::WatcherManager::CHANGED); | 329 storage::WatcherManager::CHANGED); |
| 322 base::RunLoop().RunUntilIdle(); | 330 base::RunLoop().RunUntilIdle(); |
| 323 EXPECT_EQ(1, num_called); | 331 EXPECT_EQ(1, num_called); |
| 324 | 332 |
| 325 { | 333 { |
| 326 base::RunLoop run_loop; | 334 base::RunLoop run_loop; |
| 327 root_->RemoveWatcher( | 335 root_->RemoveWatcher( |
| 328 base::FilePath(FILE_PATH_LITERAL("dir")), | 336 base::FilePath(FILE_PATH_LITERAL("dir")), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 351 watcher_callback, | 359 watcher_callback, |
| 352 base::Bind( | 360 base::Bind( |
| 353 [](base::RunLoop* run_loop, base::File::Error error) { | 361 [](base::RunLoop* run_loop, base::File::Error error) { |
| 354 EXPECT_EQ(base::File::FILE_OK, error); | 362 EXPECT_EQ(base::File::FILE_OK, error); |
| 355 run_loop->Quit(); | 363 run_loop->Quit(); |
| 356 }, | 364 }, |
| 357 &run_loop)); | 365 &run_loop)); |
| 358 run_loop.Run(); | 366 run_loop.Run(); |
| 359 } | 367 } |
| 360 | 368 |
| 369 // Even if AddWatcher() returns, the watch may not have started. In order to |
| 370 // make installation finish we run the message loop until idle. This depends |
| 371 // on the behavior of FakeFileSystemInstance. |
| 372 // |
| 373 // TODO(crbug.com/698624): Remove the hack to make AddWatcher() return |
| 374 // immediately. |
| 375 base::RunLoop().RunUntilIdle(); |
| 376 |
| 361 EXPECT_EQ(0, num_called); | 377 EXPECT_EQ(0, num_called); |
| 362 fake_file_system_.TriggerWatchers(kAuthority, kDirSpec.document_id, | 378 fake_file_system_.TriggerWatchers(kAuthority, kDirSpec.document_id, |
| 363 storage::WatcherManager::DELETED); | 379 storage::WatcherManager::DELETED); |
| 364 base::RunLoop().RunUntilIdle(); | 380 base::RunLoop().RunUntilIdle(); |
| 365 EXPECT_EQ(1, num_called); | 381 EXPECT_EQ(1, num_called); |
| 366 | 382 |
| 367 // Even if the watched file was deleted, the watcher is still alive and we | 383 // Even if the watched file was deleted, the watcher is still alive and we |
| 368 // should clean it up. | 384 // should clean it up. |
| 369 { | 385 { |
| 370 base::RunLoop run_loop; | 386 base::RunLoop run_loop; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 [](base::RunLoop* run_loop, const GURL& url) { | 446 [](base::RunLoop* run_loop, const GURL& url) { |
| 431 EXPECT_EQ(GURL("content://org.chromium.test/document/dup3-id"), | 447 EXPECT_EQ(GURL("content://org.chromium.test/document/dup3-id"), |
| 432 url); | 448 url); |
| 433 run_loop->Quit(); | 449 run_loop->Quit(); |
| 434 }, | 450 }, |
| 435 &run_loop)); | 451 &run_loop)); |
| 436 run_loop.Run(); | 452 run_loop.Run(); |
| 437 } | 453 } |
| 438 | 454 |
| 439 } // namespace arc | 455 } // namespace arc |
| OLD | NEW |