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

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

Issue 2919933002: Revert of ChromeOS: Per-user time zone: refactor tests first. (Closed)
Patch Set: Created 3 years, 6 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
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 "chrome/browser/media_galleries/media_file_system_registry.h" 7 #include "chrome/browser/media_galleries/media_file_system_registry.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "content/public/browser/render_process_host_factory.h" 45 #include "content/public/browser/render_process_host_factory.h"
46 #include "content/public/browser/web_contents.h" 46 #include "content/public/browser/web_contents.h"
47 #include "content/public/test/mock_render_process_host.h" 47 #include "content/public/test/mock_render_process_host.h"
48 #include "content/public/test/test_browser_thread.h" 48 #include "content/public/test/test_browser_thread.h"
49 #include "content/public/test/web_contents_tester.h" 49 #include "content/public/test/web_contents_tester.h"
50 #include "extensions/browser/extension_system.h" 50 #include "extensions/browser/extension_system.h"
51 #include "extensions/common/extension.h" 51 #include "extensions/common/extension.h"
52 #include "testing/gtest/include/gtest/gtest.h" 52 #include "testing/gtest/include/gtest/gtest.h"
53 53
54 #if defined(OS_CHROMEOS) 54 #if defined(OS_CHROMEOS)
55 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h"
55 #include "chrome/browser/chromeos/settings/cros_settings.h" 56 #include "chrome/browser/chromeos/settings/cros_settings.h"
56 #include "chrome/browser/chromeos/settings/device_settings_service.h" 57 #include "chrome/browser/chromeos/settings/device_settings_service.h"
57 #endif 58 #endif
58 59
59 using content::BrowserThread; 60 using content::BrowserThread;
60 using storage_monitor::StorageInfo; 61 using storage_monitor::StorageInfo;
61 using storage_monitor::StorageMonitor; 62 using storage_monitor::StorageMonitor;
62 using storage_monitor::TestStorageMonitor; 63 using storage_monitor::TestStorageMonitor;
63 64
64 // Not anonymous so it can be friends with MediaFileSystemRegistry. 65 // Not anonymous so it can be friends with MediaFileSystemRegistry.
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 base::FilePath dcim_dir_; 372 base::FilePath dcim_dir_;
372 373
373 // MediaFileSystemRegistry owns this. 374 // MediaFileSystemRegistry owns this.
374 TestMediaFileSystemContext* test_file_system_context_; 375 TestMediaFileSystemContext* test_file_system_context_;
375 376
376 // Needed for extension service & friends to work. 377 // Needed for extension service & friends to work.
377 378
378 #if defined(OS_CHROMEOS) 379 #if defined(OS_CHROMEOS)
379 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; 380 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_;
380 chromeos::ScopedTestCrosSettings test_cros_settings_; 381 chromeos::ScopedTestCrosSettings test_cros_settings_;
382 std::unique_ptr<chromeos::ScopedTestUserManager> test_user_manager_;
381 #endif 383 #endif
382 384
383 MockProfileSharedRenderProcessHostFactory rph_factory_; 385 MockProfileSharedRenderProcessHostFactory rph_factory_;
384 386
385 std::vector<std::unique_ptr<ProfileState>> profile_states_; 387 std::vector<std::unique_ptr<ProfileState>> profile_states_;
386 388
387 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistryTest); 389 DISALLOW_COPY_AND_ASSIGN(MediaFileSystemRegistryTest);
388 }; 390 };
389 391
390 namespace { 392 namespace {
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 void MediaFileSystemRegistryTest::SetUp() { 770 void MediaFileSystemRegistryTest::SetUp() {
769 ChromeRenderViewHostTestHarness::SetUp(); 771 ChromeRenderViewHostTestHarness::SetUp();
770 ASSERT_TRUE(TestStorageMonitor::CreateAndInstall()); 772 ASSERT_TRUE(TestStorageMonitor::CreateAndInstall());
771 773
772 DeleteContents(); 774 DeleteContents();
773 SetRenderProcessHostFactory(&rph_factory_); 775 SetRenderProcessHostFactory(&rph_factory_);
774 776
775 test_file_system_context_ = new TestMediaFileSystemContext( 777 test_file_system_context_ = new TestMediaFileSystemContext(
776 g_browser_process->media_file_system_registry()); 778 g_browser_process->media_file_system_registry());
777 779
780 #if defined(OS_CHROMEOS)
781 test_user_manager_.reset(new chromeos::ScopedTestUserManager());
782 #endif
783
778 ASSERT_TRUE(galleries_dir_.CreateUniqueTempDir()); 784 ASSERT_TRUE(galleries_dir_.CreateUniqueTempDir());
779 empty_dir_ = galleries_dir_.GetPath().AppendASCII("empty"); 785 empty_dir_ = galleries_dir_.GetPath().AppendASCII("empty");
780 ASSERT_TRUE(base::CreateDirectory(empty_dir_)); 786 ASSERT_TRUE(base::CreateDirectory(empty_dir_));
781 dcim_dir_ = galleries_dir_.GetPath().AppendASCII("with_dcim"); 787 dcim_dir_ = galleries_dir_.GetPath().AppendASCII("with_dcim");
782 ASSERT_TRUE(base::CreateDirectory(dcim_dir_)); 788 ASSERT_TRUE(base::CreateDirectory(dcim_dir_));
783 ASSERT_TRUE(base::CreateDirectory( 789 ASSERT_TRUE(base::CreateDirectory(
784 dcim_dir_.Append(storage_monitor::kDCIMDirectoryName))); 790 dcim_dir_.Append(storage_monitor::kDCIMDirectoryName)));
785 } 791 }
786 792
787 void MediaFileSystemRegistryTest::TearDown() { 793 void MediaFileSystemRegistryTest::TearDown() {
788 profile_states_.clear(); 794 profile_states_.clear();
789 MediaFileSystemRegistry* registry = 795 MediaFileSystemRegistry* registry =
790 g_browser_process->media_file_system_registry(); 796 g_browser_process->media_file_system_registry();
791 EXPECT_EQ(0U, GetExtensionGalleriesHostCount(registry)); 797 EXPECT_EQ(0U, GetExtensionGalleriesHostCount(registry));
792 798
799 #if defined(OS_CHROMEOS)
800 test_user_manager_.reset();
801 #endif
802
793 // The TestingProfile must be destroyed before the TestingBrowserProcess 803 // The TestingProfile must be destroyed before the TestingBrowserProcess
794 // because it uses it in its destructor. 804 // because it uses it in its destructor.
795 ChromeRenderViewHostTestHarness::TearDown(); 805 ChromeRenderViewHostTestHarness::TearDown();
796 806
797 // The MediaFileSystemRegistry owned by the TestingBrowserProcess must be 807 // The MediaFileSystemRegistry owned by the TestingBrowserProcess must be
798 // destroyed before the StorageMonitor because it calls 808 // destroyed before the StorageMonitor because it calls
799 // StorageMonitor::RemoveObserver() in its destructor. 809 // StorageMonitor::RemoveObserver() in its destructor.
800 TestingBrowserProcess::DeleteInstance(); 810 TestingBrowserProcess::DeleteInstance();
801 811
802 TestStorageMonitor::Destroy(); 812 TestStorageMonitor::Destroy();
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 fs_info.begin()->second.fsid).empty()); 1085 fs_info.begin()->second.fsid).empty());
1076 1086
1077 // Revoke permission and ensure that the file system is revoked. 1087 // Revoke permission and ensure that the file system is revoked.
1078 SetGalleryPermission(profile_state, 1088 SetGalleryPermission(profile_state,
1079 profile_state->regular_permission_extension(), 1089 profile_state->regular_permission_extension(),
1080 device_id, 1090 device_id,
1081 false /*has access*/); 1091 false /*has access*/);
1082 EXPECT_TRUE(test_file_system_context()->GetRegisteredPath( 1092 EXPECT_TRUE(test_file_system_context()->GetRegisteredPath(
1083 fs_info.begin()->second.fsid).empty()); 1093 fs_info.begin()->second.fsid).empty());
1084 } 1094 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698