| 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/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include "testing/gtest/include/gtest/gtest.h" | 49 #include "testing/gtest/include/gtest/gtest.h" |
| 50 | 50 |
| 51 #if defined(OS_CHROMEOS) | 51 #if defined(OS_CHROMEOS) |
| 52 #include "chrome/browser/chromeos/login/user_manager.h" | 52 #include "chrome/browser/chromeos/login/user_manager.h" |
| 53 #include "chrome/browser/chromeos/settings/cros_settings.h" | 53 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 54 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 54 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 55 #endif | 55 #endif |
| 56 | 56 |
| 57 using content::BrowserThread; | 57 using content::BrowserThread; |
| 58 | 58 |
| 59 namespace chrome { | |
| 60 | |
| 61 // Not anonymous so it can be friends with MediaFileSystemRegistry. | 59 // Not anonymous so it can be friends with MediaFileSystemRegistry. |
| 62 class TestMediaFileSystemContext : public MediaFileSystemContext { | 60 class TestMediaFileSystemContext : public MediaFileSystemContext { |
| 63 public: | 61 public: |
| 64 struct FSInfo { | 62 struct FSInfo { |
| 65 FSInfo() {} | 63 FSInfo() {} |
| 66 FSInfo(const std::string& device_id, const base::FilePath& path, | 64 FSInfo(const std::string& device_id, const base::FilePath& path, |
| 67 const std::string& fsid); | 65 const std::string& fsid); |
| 68 | 66 |
| 69 bool operator<(const FSInfo& other) const; | 67 bool operator<(const FSInfo& other) const; |
| 70 | 68 |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 it != registry->extension_hosts_map_.end(); | 736 it != registry->extension_hosts_map_.end(); |
| 739 ++it) { | 737 ++it) { |
| 740 extension_galleries_host_count += it->second.size(); | 738 extension_galleries_host_count += it->second.size(); |
| 741 } | 739 } |
| 742 return extension_galleries_host_count; | 740 return extension_galleries_host_count; |
| 743 } | 741 } |
| 744 | 742 |
| 745 | 743 |
| 746 void MediaFileSystemRegistryTest::SetUp() { | 744 void MediaFileSystemRegistryTest::SetUp() { |
| 747 ChromeRenderViewHostTestHarness::SetUp(); | 745 ChromeRenderViewHostTestHarness::SetUp(); |
| 748 ASSERT_TRUE(test::TestStorageMonitor::CreateAndInstall()); | 746 ASSERT_TRUE(TestStorageMonitor::CreateAndInstall()); |
| 749 | 747 |
| 750 DeleteContents(); | 748 DeleteContents(); |
| 751 SetRenderProcessHostFactory(&rph_factory_); | 749 SetRenderProcessHostFactory(&rph_factory_); |
| 752 | 750 |
| 753 test_file_system_context_ = new TestMediaFileSystemContext( | 751 test_file_system_context_ = new TestMediaFileSystemContext( |
| 754 g_browser_process->media_file_system_registry()); | 752 g_browser_process->media_file_system_registry()); |
| 755 | 753 |
| 756 #if defined(OS_CHROMEOS) | 754 #if defined(OS_CHROMEOS) |
| 757 test_user_manager_.reset(new chromeos::ScopedTestUserManager()); | 755 test_user_manager_.reset(new chromeos::ScopedTestUserManager()); |
| 758 #endif | 756 #endif |
| 759 | 757 |
| 760 ASSERT_TRUE(galleries_dir_.CreateUniqueTempDir()); | 758 ASSERT_TRUE(galleries_dir_.CreateUniqueTempDir()); |
| 761 empty_dir_ = galleries_dir_.path().AppendASCII("empty"); | 759 empty_dir_ = galleries_dir_.path().AppendASCII("empty"); |
| 762 ASSERT_TRUE(file_util::CreateDirectory(empty_dir_)); | 760 ASSERT_TRUE(file_util::CreateDirectory(empty_dir_)); |
| 763 dcim_dir_ = galleries_dir_.path().AppendASCII("with_dcim"); | 761 dcim_dir_ = galleries_dir_.path().AppendASCII("with_dcim"); |
| 764 ASSERT_TRUE(file_util::CreateDirectory(dcim_dir_)); | 762 ASSERT_TRUE(file_util::CreateDirectory(dcim_dir_)); |
| 765 ASSERT_TRUE(file_util::CreateDirectory(dcim_dir_.Append(kDCIMDirectoryName))); | 763 ASSERT_TRUE(file_util::CreateDirectory(dcim_dir_.Append(kDCIMDirectoryName))); |
| 766 } | 764 } |
| 767 | 765 |
| 768 void MediaFileSystemRegistryTest::TearDown() { | 766 void MediaFileSystemRegistryTest::TearDown() { |
| 769 profile_states_.clear(); | 767 profile_states_.clear(); |
| 770 MediaFileSystemRegistry* registry = | 768 MediaFileSystemRegistry* registry = |
| 771 g_browser_process->media_file_system_registry(); | 769 g_browser_process->media_file_system_registry(); |
| 772 EXPECT_EQ(0U, GetExtensionGalleriesHostCount(registry)); | 770 EXPECT_EQ(0U, GetExtensionGalleriesHostCount(registry)); |
| 773 test::TestStorageMonitor::RemoveSingleton(); | 771 TestStorageMonitor::RemoveSingleton(); |
| 774 #if defined(OS_CHROMEOS) | 772 #if defined(OS_CHROMEOS) |
| 775 test_user_manager_.reset(); | 773 test_user_manager_.reset(); |
| 776 #endif | 774 #endif |
| 777 | 775 |
| 778 ChromeRenderViewHostTestHarness::TearDown(); | 776 ChromeRenderViewHostTestHarness::TearDown(); |
| 779 } | 777 } |
| 780 | 778 |
| 781 /////////// | 779 /////////// |
| 782 // Tests // | 780 // Tests // |
| 783 /////////// | 781 /////////// |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_PICTURES, &path)); | 1021 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_PICTURES, &path)); |
| 1024 profile_state->AddNameForAllCompare(path.BaseName().LossyDisplayName()); | 1022 profile_state->AddNameForAllCompare(path.BaseName().LossyDisplayName()); |
| 1025 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_VIDEOS, &path)); | 1023 ASSERT_TRUE(PathService::Get(chrome::DIR_USER_VIDEOS, &path)); |
| 1026 profile_state->AddNameForAllCompare(path.BaseName().LossyDisplayName()); | 1024 profile_state->AddNameForAllCompare(path.BaseName().LossyDisplayName()); |
| 1027 | 1025 |
| 1028 profile_state->CheckGalleries("names-dir", one_expectation, auto_galleries); | 1026 profile_state->CheckGalleries("names-dir", one_expectation, auto_galleries); |
| 1029 } else { | 1027 } else { |
| 1030 profile_state->CheckGalleries("names", one_expectation, one_expectation); | 1028 profile_state->CheckGalleries("names", one_expectation, one_expectation); |
| 1031 } | 1029 } |
| 1032 } | 1030 } |
| 1033 | |
| 1034 } // namespace chrome | |
| OLD | NEW |