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 // MediaFileSystemRegistry unit tests. | 5 // MediaFileSystemRegistry unit tests. |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 const std::vector<MediaFileSystemInfo>& all_extension_galleries) { | 504 const std::vector<MediaFileSystemInfo>& all_extension_galleries) { |
505 content::RenderViewHost* rvh = single_web_contents_->GetRenderViewHost(); | 505 content::RenderViewHost* rvh = single_web_contents_->GetRenderViewHost(); |
506 MediaFileSystemRegistry* registry = | 506 MediaFileSystemRegistry* registry = |
507 g_browser_process->media_file_system_registry(); | 507 g_browser_process->media_file_system_registry(); |
508 | 508 |
509 // No Media Galleries permissions. | 509 // No Media Galleries permissions. |
510 std::vector<MediaFileSystemInfo> empty_expectation; | 510 std::vector<MediaFileSystemInfo> empty_expectation; |
511 registry->GetMediaFileSystemsForExtension( | 511 registry->GetMediaFileSystemsForExtension( |
512 rvh, no_permissions_extension_.get(), | 512 rvh, no_permissions_extension_.get(), |
513 base::Bind(&ProfileState::CompareResults, base::Unretained(this), | 513 base::Bind(&ProfileState::CompareResults, base::Unretained(this), |
514 StringPrintf("%s (no permission)", test.c_str()), | 514 base::StringPrintf("%s (no permission)", test.c_str()), |
515 base::ConstRef(empty_expectation))); | 515 base::ConstRef(empty_expectation))); |
516 MessageLoop::current()->RunUntilIdle(); | 516 MessageLoop::current()->RunUntilIdle(); |
517 EXPECT_EQ(1, GetAndClearComparisonCount()); | 517 EXPECT_EQ(1, GetAndClearComparisonCount()); |
518 | 518 |
519 // Read permission only. | 519 // Read permission only. |
520 registry->GetMediaFileSystemsForExtension( | 520 registry->GetMediaFileSystemsForExtension( |
521 rvh, regular_permission_extension_.get(), | 521 rvh, regular_permission_extension_.get(), |
522 base::Bind(&ProfileState::CompareResults, base::Unretained(this), | 522 base::Bind(&ProfileState::CompareResults, base::Unretained(this), |
523 StringPrintf("%s (regular permission)", test.c_str()), | 523 base::StringPrintf("%s (regular permission)", test.c_str()), |
524 base::ConstRef(regular_extension_galleries))); | 524 base::ConstRef(regular_extension_galleries))); |
525 MessageLoop::current()->RunUntilIdle(); | 525 MessageLoop::current()->RunUntilIdle(); |
526 EXPECT_EQ(1, GetAndClearComparisonCount()); | 526 EXPECT_EQ(1, GetAndClearComparisonCount()); |
527 | 527 |
528 // All galleries permission. | 528 // All galleries permission. |
529 registry->GetMediaFileSystemsForExtension( | 529 registry->GetMediaFileSystemsForExtension( |
530 rvh, all_permission_extension_.get(), | 530 rvh, all_permission_extension_.get(), |
531 base::Bind(&ProfileState::CompareResults, base::Unretained(this), | 531 base::Bind(&ProfileState::CompareResults, base::Unretained(this), |
532 StringPrintf("%s (all permission)", test.c_str()), | 532 base::StringPrintf("%s (all permission)", test.c_str()), |
533 base::ConstRef(all_extension_galleries))); | 533 base::ConstRef(all_extension_galleries))); |
534 MessageLoop::current()->RunUntilIdle(); | 534 MessageLoop::current()->RunUntilIdle(); |
535 EXPECT_EQ(1, GetAndClearComparisonCount()); | 535 EXPECT_EQ(1, GetAndClearComparisonCount()); |
536 } | 536 } |
537 | 537 |
538 FSInfoMap ProfileState::GetGalleriesInfo(extensions::Extension* extension) { | 538 FSInfoMap ProfileState::GetGalleriesInfo(extensions::Extension* extension) { |
539 content::RenderViewHost* rvh = single_web_contents_->GetRenderViewHost(); | 539 content::RenderViewHost* rvh = single_web_contents_->GetRenderViewHost(); |
540 FSInfoMap results; | 540 FSInfoMap results; |
541 MediaFileSystemRegistry* registry = | 541 MediaFileSystemRegistry* registry = |
542 g_browser_process->media_file_system_registry(); | 542 g_browser_process->media_file_system_registry(); |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 pref_info_with_relpath.device_id = device_id; | 983 pref_info_with_relpath.device_id = device_id; |
984 EXPECT_EQ(dcim_dir().Append(pref_info_with_relpath.path).value(), | 984 EXPECT_EQ(dcim_dir().Append(pref_info_with_relpath.path).value(), |
985 pref_info_with_relpath.AbsolutePath().value()); | 985 pref_info_with_relpath.AbsolutePath().value()); |
986 | 986 |
987 DetachDevice(device_id); | 987 DetachDevice(device_id); |
988 EXPECT_TRUE(pref_info.AbsolutePath().empty()); | 988 EXPECT_TRUE(pref_info.AbsolutePath().empty()); |
989 EXPECT_TRUE(pref_info_with_relpath.AbsolutePath().empty()); | 989 EXPECT_TRUE(pref_info_with_relpath.AbsolutePath().empty()); |
990 } | 990 } |
991 | 991 |
992 } // namespace chrome | 992 } // namespace chrome |
OLD | NEW |