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 |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h" | 14 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_root.h" |
15 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h" | 15 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h" |
16 #include "chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner.h
" | 16 #include "chrome/browser/chromeos/arc/fileapi/arc_file_system_operation_runner.h
" |
17 #include "components/arc/arc_bridge_service.h" | 17 #include "components/arc/arc_bridge_service.h" |
18 #include "components/arc/arc_service_manager.h" | 18 #include "components/arc/arc_service_manager.h" |
19 #include "components/arc/common/file_system.mojom.h" | 19 #include "components/arc/common/file_system.mojom.h" |
20 #include "components/arc/test/fake_file_system_instance.h" | 20 #include "components/arc/test/fake_file_system_instance.h" |
21 #include "content/public/test/test_browser_thread_bundle.h" | 21 #include "content/public/test/test_browser_thread_bundle.h" |
| 22 #include "storage/browser/fileapi/watcher_manager.h" |
22 #include "storage/common/fileapi/directory_entry.h" | 23 #include "storage/common/fileapi/directory_entry.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
24 #include "url/gurl.h" | 25 #include "url/gurl.h" |
25 | 26 |
26 using ChangeType = arc::ArcDocumentsProviderRoot::ChangeType; | 27 using ChangeType = arc::ArcDocumentsProviderRoot::ChangeType; |
27 using storage::DirectoryEntry; | 28 using storage::DirectoryEntry; |
28 using Document = arc::FakeFileSystemInstance::Document; | 29 using Document = arc::FakeFileSystemInstance::Document; |
29 using EntryList = storage::AsyncFileUtil::EntryList; | 30 using EntryList = storage::AsyncFileUtil::EntryList; |
30 | 31 |
31 namespace arc { | 32 namespace arc { |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 [](base::RunLoop* run_loop, base::File::Error error) { | 311 [](base::RunLoop* run_loop, base::File::Error error) { |
311 EXPECT_EQ(base::File::FILE_OK, error); | 312 EXPECT_EQ(base::File::FILE_OK, error); |
312 run_loop->Quit(); | 313 run_loop->Quit(); |
313 }, | 314 }, |
314 &run_loop)); | 315 &run_loop)); |
315 run_loop.Run(); | 316 run_loop.Run(); |
316 } | 317 } |
317 | 318 |
318 EXPECT_EQ(0, num_called); | 319 EXPECT_EQ(0, num_called); |
319 fake_file_system_.TriggerWatchers(kAuthority, kDirSpec.document_id, | 320 fake_file_system_.TriggerWatchers(kAuthority, kDirSpec.document_id, |
320 mojom::ChangeType::CHANGED); | 321 storage::WatcherManager::CHANGED); |
321 base::RunLoop().RunUntilIdle(); | 322 base::RunLoop().RunUntilIdle(); |
322 EXPECT_EQ(1, num_called); | 323 EXPECT_EQ(1, num_called); |
323 | 324 |
324 { | 325 { |
325 base::RunLoop run_loop; | 326 base::RunLoop run_loop; |
326 root_->RemoveWatcher( | 327 root_->RemoveWatcher( |
327 base::FilePath(FILE_PATH_LITERAL("dir")), | 328 base::FilePath(FILE_PATH_LITERAL("dir")), |
328 base::Bind( | 329 base::Bind( |
329 [](base::RunLoop* run_loop, base::File::Error error) { | 330 [](base::RunLoop* run_loop, base::File::Error error) { |
330 EXPECT_EQ(base::File::FILE_OK, error); | 331 EXPECT_EQ(base::File::FILE_OK, error); |
(...skipping 21 matching lines...) Expand all Loading... |
352 [](base::RunLoop* run_loop, base::File::Error error) { | 353 [](base::RunLoop* run_loop, base::File::Error error) { |
353 EXPECT_EQ(base::File::FILE_OK, error); | 354 EXPECT_EQ(base::File::FILE_OK, error); |
354 run_loop->Quit(); | 355 run_loop->Quit(); |
355 }, | 356 }, |
356 &run_loop)); | 357 &run_loop)); |
357 run_loop.Run(); | 358 run_loop.Run(); |
358 } | 359 } |
359 | 360 |
360 EXPECT_EQ(0, num_called); | 361 EXPECT_EQ(0, num_called); |
361 fake_file_system_.TriggerWatchers(kAuthority, kDirSpec.document_id, | 362 fake_file_system_.TriggerWatchers(kAuthority, kDirSpec.document_id, |
362 mojom::ChangeType::DELETED); | 363 storage::WatcherManager::DELETED); |
363 base::RunLoop().RunUntilIdle(); | 364 base::RunLoop().RunUntilIdle(); |
364 EXPECT_EQ(1, num_called); | 365 EXPECT_EQ(1, num_called); |
365 | 366 |
366 // Even if the watched file was deleted, the watcher is still alive and we | 367 // Even if the watched file was deleted, the watcher is still alive and we |
367 // should clean it up. | 368 // should clean it up. |
368 { | 369 { |
369 base::RunLoop run_loop; | 370 base::RunLoop run_loop; |
370 root_->RemoveWatcher( | 371 root_->RemoveWatcher( |
371 base::FilePath(FILE_PATH_LITERAL("dir")), | 372 base::FilePath(FILE_PATH_LITERAL("dir")), |
372 base::Bind( | 373 base::Bind( |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 [](base::RunLoop* run_loop, const GURL& url) { | 430 [](base::RunLoop* run_loop, const GURL& url) { |
430 EXPECT_EQ(GURL("content://org.chromium.test/document/dup3-id"), | 431 EXPECT_EQ(GURL("content://org.chromium.test/document/dup3-id"), |
431 url); | 432 url); |
432 run_loop->Quit(); | 433 run_loop->Quit(); |
433 }, | 434 }, |
434 &run_loop)); | 435 &run_loop)); |
435 run_loop.Run(); | 436 run_loop.Run(); |
436 } | 437 } |
437 | 438 |
438 } // namespace arc | 439 } // namespace arc |
OLD | NEW |