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 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/extensions/extension_system.h" | 24 #include "chrome/browser/extensions/extension_system.h" |
25 #include "chrome/browser/extensions/test_extension_system.h" | 25 #include "chrome/browser/extensions/test_extension_system.h" |
26 #include "chrome/browser/media_galleries/media_file_system_context.h" | 26 #include "chrome/browser/media_galleries/media_file_system_context.h" |
27 #include "chrome/browser/media_galleries/media_file_system_registry.h" | 27 #include "chrome/browser/media_galleries/media_file_system_registry.h" |
28 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h" | 28 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h" |
29 #include "chrome/browser/media_galleries/media_galleries_test_util.h" | 29 #include "chrome/browser/media_galleries/media_galleries_test_util.h" |
30 #include "chrome/browser/storage_monitor/media_storage_util.h" | 30 #include "chrome/browser/storage_monitor/media_storage_util.h" |
31 #include "chrome/browser/storage_monitor/removable_device_constants.h" | 31 #include "chrome/browser/storage_monitor/removable_device_constants.h" |
32 #include "chrome/browser/storage_monitor/storage_monitor.h" | 32 #include "chrome/browser/storage_monitor/storage_monitor.h" |
33 #include "chrome/browser/storage_monitor/test_storage_monitor.h" | 33 #include "chrome/browser/storage_monitor/test_storage_monitor.h" |
| 34 #include "chrome/common/extensions/background_info.h" |
34 #include "chrome/common/extensions/extension.h" | 35 #include "chrome/common/extensions/extension.h" |
| 36 #include "chrome/common/extensions/manifest_handler.h" |
35 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 37 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
36 #include "chrome/test/base/testing_browser_process.h" | 38 #include "chrome/test/base/testing_browser_process.h" |
37 #include "chrome/test/base/testing_profile.h" | 39 #include "chrome/test/base/testing_profile.h" |
38 #include "content/public/browser/render_process_host.h" | 40 #include "content/public/browser/render_process_host.h" |
39 #include "content/public/browser/render_process_host_factory.h" | 41 #include "content/public/browser/render_process_host_factory.h" |
40 #include "content/public/browser/render_view_host.h" | 42 #include "content/public/browser/render_view_host.h" |
41 #include "content/public/browser/web_contents.h" | 43 #include "content/public/browser/web_contents.h" |
42 #include "content/public/test/mock_render_process_host.h" | 44 #include "content/public/test/mock_render_process_host.h" |
43 #include "content/public/test/test_browser_thread.h" | 45 #include "content/public/test/test_browser_thread.h" |
44 #include "content/public/test/web_contents_tester.h" | 46 #include "content/public/test/web_contents_tester.h" |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 window_->Init(); | 784 window_->Init(); |
783 #endif | 785 #endif |
784 | 786 |
785 ChromeRenderViewHostTestHarness::SetUp(); | 787 ChromeRenderViewHostTestHarness::SetUp(); |
786 DeleteContents(); | 788 DeleteContents(); |
787 SetRenderProcessHostFactory(&rph_factory_); | 789 SetRenderProcessHostFactory(&rph_factory_); |
788 | 790 |
789 TestMediaStorageUtil::SetTestingMode(); | 791 TestMediaStorageUtil::SetTestingMode(); |
790 test_file_system_context_ = new TestMediaFileSystemContext( | 792 test_file_system_context_ = new TestMediaFileSystemContext( |
791 g_browser_process->media_file_system_registry()); | 793 g_browser_process->media_file_system_registry()); |
| 794 (new extensions::BackgroundManifestHandler)->Register(); |
792 | 795 |
793 ASSERT_TRUE(galleries_dir_.CreateUniqueTempDir()); | 796 ASSERT_TRUE(galleries_dir_.CreateUniqueTempDir()); |
794 empty_dir_ = galleries_dir_.path().AppendASCII("empty"); | 797 empty_dir_ = galleries_dir_.path().AppendASCII("empty"); |
795 ASSERT_TRUE(file_util::CreateDirectory(empty_dir_)); | 798 ASSERT_TRUE(file_util::CreateDirectory(empty_dir_)); |
796 dcim_dir_ = galleries_dir_.path().AppendASCII("with_dcim"); | 799 dcim_dir_ = galleries_dir_.path().AppendASCII("with_dcim"); |
797 ASSERT_TRUE(file_util::CreateDirectory(dcim_dir_)); | 800 ASSERT_TRUE(file_util::CreateDirectory(dcim_dir_)); |
798 ASSERT_TRUE(file_util::CreateDirectory(dcim_dir_.Append(kDCIMDirectoryName))); | 801 ASSERT_TRUE(file_util::CreateDirectory(dcim_dir_.Append(kDCIMDirectoryName))); |
799 } | 802 } |
800 | 803 |
801 void MediaFileSystemRegistryTest::TearDown() { | 804 void MediaFileSystemRegistryTest::TearDown() { |
802 profile_states_.clear(); | 805 profile_states_.clear(); |
803 ChromeRenderViewHostTestHarness::TearDown(); | 806 ChromeRenderViewHostTestHarness::TearDown(); |
804 MediaFileSystemRegistry* registry = | 807 MediaFileSystemRegistry* registry = |
805 g_browser_process->media_file_system_registry(); | 808 g_browser_process->media_file_system_registry(); |
806 EXPECT_EQ(0U, registry->GetExtensionGalleriesHostCountForTests()); | 809 EXPECT_EQ(0U, registry->GetExtensionGalleriesHostCountForTests()); |
807 BrowserThread::GetBlockingPool()->FlushForTesting(); | 810 BrowserThread::GetBlockingPool()->FlushForTesting(); |
808 MessageLoop::current()->RunUntilIdle(); | 811 MessageLoop::current()->RunUntilIdle(); |
| 812 extensions::ManifestHandler::ClearRegistryForTesting(); |
809 } | 813 } |
810 | 814 |
811 /////////// | 815 /////////// |
812 // Tests // | 816 // Tests // |
813 /////////// | 817 /////////// |
814 | 818 |
815 TEST_F(MediaFileSystemRegistryTest, Basic) { | 819 TEST_F(MediaFileSystemRegistryTest, Basic) { |
816 CreateProfileState(1); | 820 CreateProfileState(1); |
817 AssertAllAutoAddedGalleries(); | 821 AssertAllAutoAddedGalleries(); |
818 | 822 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 pref_info_with_relpath.device_id = device_id; | 1019 pref_info_with_relpath.device_id = device_id; |
1016 EXPECT_EQ(dcim_dir().Append(pref_info_with_relpath.path).value(), | 1020 EXPECT_EQ(dcim_dir().Append(pref_info_with_relpath.path).value(), |
1017 pref_info_with_relpath.AbsolutePath().value()); | 1021 pref_info_with_relpath.AbsolutePath().value()); |
1018 | 1022 |
1019 DetachDevice(device_id); | 1023 DetachDevice(device_id); |
1020 EXPECT_TRUE(pref_info.AbsolutePath().empty()); | 1024 EXPECT_TRUE(pref_info.AbsolutePath().empty()); |
1021 EXPECT_TRUE(pref_info_with_relpath.AbsolutePath().empty()); | 1025 EXPECT_TRUE(pref_info_with_relpath.AbsolutePath().empty()); |
1022 } | 1026 } |
1023 | 1027 |
1024 } // namespace chrome | 1028 } // namespace chrome |
OLD | NEW |