Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Side by Side Diff: chrome/browser/media_galleries/media_file_system_registry_unittest.cc

Issue 14694010: Consolidate manifest handler registration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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"
35 #include "chrome/common/extensions/extension.h" 34 #include "chrome/common/extensions/extension.h"
36 #include "chrome/common/extensions/incognito_handler.h"
37 #include "chrome/common/extensions/manifest_handler.h"
38 #include "chrome/common/extensions/permissions/chrome_api_permissions.h"
39 #include "chrome/common/extensions/permissions/scoped_testing_permissions_info.h "
40 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 35 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
41 #include "chrome/test/base/testing_browser_process.h" 36 #include "chrome/test/base/testing_browser_process.h"
42 #include "chrome/test/base/testing_profile.h" 37 #include "chrome/test/base/testing_profile.h"
43 #include "content/public/browser/render_process_host.h" 38 #include "content/public/browser/render_process_host.h"
44 #include "content/public/browser/render_process_host_factory.h" 39 #include "content/public/browser/render_process_host_factory.h"
45 #include "content/public/browser/render_view_host.h" 40 #include "content/public/browser/render_view_host.h"
46 #include "content/public/browser/web_contents.h" 41 #include "content/public/browser/web_contents.h"
47 #include "content/public/test/mock_render_process_host.h" 42 #include "content/public/test/mock_render_process_host.h"
48 #include "content/public/test/test_browser_thread.h" 43 #include "content/public/test/test_browser_thread.h"
49 #include "content/public/test/web_contents_tester.h" 44 #include "content/public/test/web_contents_tester.h"
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 base::FilePath empty_dir_; 368 base::FilePath empty_dir_;
374 // A directory in |galleries_dir_| with a DCIM directory in it. 369 // A directory in |galleries_dir_| with a DCIM directory in it.
375 base::FilePath dcim_dir_; 370 base::FilePath dcim_dir_;
376 371
377 // MediaFileSystemRegistry owns this. 372 // MediaFileSystemRegistry owns this.
378 TestMediaFileSystemContext* test_file_system_context_; 373 TestMediaFileSystemContext* test_file_system_context_;
379 374
380 // Needed for extension service & friends to work. 375 // Needed for extension service & friends to work.
381 content::TestBrowserThread ui_thread_; 376 content::TestBrowserThread ui_thread_;
382 content::TestBrowserThread file_thread_; 377 content::TestBrowserThread file_thread_;
383 extensions::ScopedTestingPermissionsInfo permissions_info_;
384 378
385 #if defined OS_CHROMEOS 379 #if defined OS_CHROMEOS
386 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 380 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
387 chromeos::ScopedTestCrosSettings test_cros_settings_; 381 chromeos::ScopedTestCrosSettings test_cros_settings_;
388 chromeos::ScopedTestUserManager test_user_manager_; 382 chromeos::ScopedTestUserManager test_user_manager_;
389 #endif 383 #endif
390 384
391 // TODO(gbillock): Eliminate windows-specific code from this test. 385 // TODO(gbillock): Eliminate windows-specific code from this test.
392 #if defined(OS_WIN) 386 #if defined(OS_WIN)
393 scoped_ptr<test::TestStorageMonitorWin> monitor_; 387 scoped_ptr<test::TestStorageMonitorWin> monitor_;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 } 576 }
583 577
584 } // namespace 578 } // namespace
585 579
586 ///////////////////////////////// 580 /////////////////////////////////
587 // MediaFileSystemRegistryTest // 581 // MediaFileSystemRegistryTest //
588 ///////////////////////////////// 582 /////////////////////////////////
589 583
590 MediaFileSystemRegistryTest::MediaFileSystemRegistryTest() 584 MediaFileSystemRegistryTest::MediaFileSystemRegistryTest()
591 : ui_thread_(content::BrowserThread::UI, MessageLoop::current()), 585 : ui_thread_(content::BrowserThread::UI, MessageLoop::current()),
592 file_thread_(content::BrowserThread::FILE, MessageLoop::current()), 586 file_thread_(content::BrowserThread::FILE, MessageLoop::current()) {
593 permissions_info_(extensions::ChromeAPIPermissions()) {
594 } 587 }
595 588
596 void MediaFileSystemRegistryTest::CreateProfileState(size_t profile_count) { 589 void MediaFileSystemRegistryTest::CreateProfileState(size_t profile_count) {
597 for (size_t i = 0; i < profile_count; ++i) { 590 for (size_t i = 0; i < profile_count; ++i) {
598 ProfileState* state = new ProfileState(&rph_factory_); 591 ProfileState* state = new ProfileState(&rph_factory_);
599 profile_states_.push_back(state); 592 profile_states_.push_back(state);
600 } 593 }
601 } 594 }
602 595
603 ProfileState* MediaFileSystemRegistryTest::GetProfileState(size_t i) { 596 ProfileState* MediaFileSystemRegistryTest::GetProfileState(size_t i) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 mount_watcher->FlushWorkerPoolForTesting(); 741 mount_watcher->FlushWorkerPoolForTesting();
749 base::RunLoop().RunUntilIdle(); 742 base::RunLoop().RunUntilIdle();
750 #endif 743 #endif
751 744
752 ChromeRenderViewHostTestHarness::SetUp(); 745 ChromeRenderViewHostTestHarness::SetUp();
753 DeleteContents(); 746 DeleteContents();
754 SetRenderProcessHostFactory(&rph_factory_); 747 SetRenderProcessHostFactory(&rph_factory_);
755 748
756 test_file_system_context_ = new TestMediaFileSystemContext( 749 test_file_system_context_ = new TestMediaFileSystemContext(
757 g_browser_process->media_file_system_registry()); 750 g_browser_process->media_file_system_registry());
758 (new extensions::BackgroundManifestHandler)->Register();
759 (new extensions::IncognitoHandler)->Register();
760 751
761 ASSERT_TRUE(galleries_dir_.CreateUniqueTempDir()); 752 ASSERT_TRUE(galleries_dir_.CreateUniqueTempDir());
762 empty_dir_ = galleries_dir_.path().AppendASCII("empty"); 753 empty_dir_ = galleries_dir_.path().AppendASCII("empty");
763 ASSERT_TRUE(file_util::CreateDirectory(empty_dir_)); 754 ASSERT_TRUE(file_util::CreateDirectory(empty_dir_));
764 dcim_dir_ = galleries_dir_.path().AppendASCII("with_dcim"); 755 dcim_dir_ = galleries_dir_.path().AppendASCII("with_dcim");
765 ASSERT_TRUE(file_util::CreateDirectory(dcim_dir_)); 756 ASSERT_TRUE(file_util::CreateDirectory(dcim_dir_));
766 ASSERT_TRUE(file_util::CreateDirectory(dcim_dir_.Append(kDCIMDirectoryName))); 757 ASSERT_TRUE(file_util::CreateDirectory(dcim_dir_.Append(kDCIMDirectoryName)));
767 } 758 }
768 759
769 void MediaFileSystemRegistryTest::TearDown() { 760 void MediaFileSystemRegistryTest::TearDown() {
770 profile_states_.clear(); 761 profile_states_.clear();
771 ChromeRenderViewHostTestHarness::TearDown(); 762 ChromeRenderViewHostTestHarness::TearDown();
772 MediaFileSystemRegistry* registry = 763 MediaFileSystemRegistry* registry =
773 g_browser_process->media_file_system_registry(); 764 g_browser_process->media_file_system_registry();
774 EXPECT_EQ(0U, registry->GetExtensionGalleriesHostCountForTests()); 765 EXPECT_EQ(0U, registry->GetExtensionGalleriesHostCountForTests());
775 BrowserThread::GetBlockingPool()->FlushForTesting(); 766 BrowserThread::GetBlockingPool()->FlushForTesting();
776 MessageLoop::current()->RunUntilIdle(); 767 MessageLoop::current()->RunUntilIdle();
777 extensions::ManifestHandler::ClearRegistryForTesting();
778 } 768 }
779 769
780 /////////// 770 ///////////
781 // Tests // 771 // Tests //
782 /////////// 772 ///////////
783 773
784 TEST_F(MediaFileSystemRegistryTest, Basic) { 774 TEST_F(MediaFileSystemRegistryTest, Basic) {
785 CreateProfileState(1); 775 CreateProfileState(1);
786 AssertAllAutoAddedGalleries(); 776 AssertAllAutoAddedGalleries();
787 777
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 pref_info_with_relpath.device_id = device_id; 976 pref_info_with_relpath.device_id = device_id;
987 EXPECT_EQ(dcim_dir().Append(pref_info_with_relpath.path).value(), 977 EXPECT_EQ(dcim_dir().Append(pref_info_with_relpath.path).value(),
988 pref_info_with_relpath.AbsolutePath().value()); 978 pref_info_with_relpath.AbsolutePath().value());
989 979
990 DetachDevice(device_id); 980 DetachDevice(device_id);
991 EXPECT_TRUE(pref_info.AbsolutePath().empty()); 981 EXPECT_TRUE(pref_info.AbsolutePath().empty());
992 EXPECT_TRUE(pref_info_with_relpath.AbsolutePath().empty()); 982 EXPECT_TRUE(pref_info_with_relpath.AbsolutePath().empty());
993 } 983 }
994 984
995 } // namespace chrome 985 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698