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

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

Issue 2654303002: Always call StorageMonitor::RemoveObserver in ~MediaFileSystemRegistry. (Closed)
Patch Set: add include Created 3 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chrome/browser/media_galleries/gallery_watch_manager.h" 5 #include "chrome/browser/media_galleries/gallery_watch_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/test/scoped_path_override.h" 16 #include "base/test/scoped_path_override.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "chrome/browser/extensions/test_extension_system.h" 18 #include "chrome/browser/extensions/test_extension_system.h"
19 #include "chrome/browser/media_galleries/gallery_watch_manager_observer.h" 19 #include "chrome/browser/media_galleries/gallery_watch_manager_observer.h"
20 #include "chrome/browser/media_galleries/media_galleries_preferences.h" 20 #include "chrome/browser/media_galleries/media_galleries_preferences.h"
21 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h" 21 #include "chrome/browser/media_galleries/media_galleries_preferences_factory.h"
22 #include "chrome/browser/media_galleries/media_galleries_test_util.h" 22 #include "chrome/browser/media_galleries/media_galleries_test_util.h"
23 #include "chrome/test/base/testing_browser_process.h"
23 #include "chrome/test/base/testing_profile.h" 24 #include "chrome/test/base/testing_profile.h"
24 #include "components/storage_monitor/test_storage_monitor.h" 25 #include "components/storage_monitor/test_storage_monitor.h"
25 #include "content/public/test/test_browser_thread_bundle.h" 26 #include "content/public/test/test_browser_thread_bundle.h"
26 #include "extensions/browser/extension_system.h" 27 #include "extensions/browser/extension_system.h"
27 #include "extensions/common/extension.h" 28 #include "extensions/common/extension.h"
28 #include "extensions/common/permissions/media_galleries_permission.h" 29 #include "extensions/common/permissions/media_galleries_permission.h"
29 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
30 31
31 #if defined(OS_CHROMEOS) 32 #if defined(OS_CHROMEOS)
32 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h" 33 #include "chrome/browser/chromeos/login/users/scoped_test_user_manager.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 89
89 manager_.reset(new GalleryWatchManager); 90 manager_.reset(new GalleryWatchManager);
90 manager_->AddObserver(profile_.get(), this); 91 manager_->AddObserver(profile_.get(), this);
91 } 92 }
92 93
93 void TearDown() override { 94 void TearDown() override {
94 if (profile_) { 95 if (profile_) {
95 manager_->RemoveObserver(profile_.get()); 96 manager_->RemoveObserver(profile_.get());
96 } 97 }
97 manager_.reset(); 98 manager_.reset();
99
100 // The TestingProfile must be destroyed before the TestingBrowserProcess
101 // because it uses it in its destructor.
102 ShutdownProfile();
103
104 // The MediaFileSystemRegistry owned by the TestingBrowserProcess must be
105 // destroyed before the StorageMonitor because it calls
106 // StorageMonitor::RemoveObserver() in its destructor.
107 TestingBrowserProcess::DeleteInstance();
108
98 storage_monitor::TestStorageMonitor::Destroy(); 109 storage_monitor::TestStorageMonitor::Destroy();
99 } 110 }
100 111
101 protected: 112 protected:
102 // Create the specified path, and add it to preferences as a gallery. 113 // Create the specified path, and add it to preferences as a gallery.
103 MediaGalleryPrefId AddGallery(const base::FilePath& path) { 114 MediaGalleryPrefId AddGallery(const base::FilePath& path) {
104 MediaGalleryPrefInfo gallery_info; 115 MediaGalleryPrefInfo gallery_info;
105 EXPECT_FALSE(gallery_prefs_->LookUpGalleryByPath(path, &gallery_info)); 116 EXPECT_FALSE(gallery_prefs_->LookUpGalleryByPath(path, &gallery_info));
106 MediaGalleryPrefId id = 117 MediaGalleryPrefId id =
107 gallery_prefs_->AddGallery(gallery_info.device_id, 118 gallery_prefs_->AddGallery(gallery_info.device_id,
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 ShutdownProfile(); 410 ShutdownProfile();
400 411
401 // Trigger a removable storage event that should be ignored now that the 412 // Trigger a removable storage event that should be ignored now that the
402 // profile has been destroyed to catch regressions. crbug.com/467627 413 // profile has been destroyed to catch regressions. crbug.com/467627
403 base::RunLoop run_loop; 414 base::RunLoop run_loop;
404 storage_monitor()->receiver()->ProcessDetach(storage_info.device_id()); 415 storage_monitor()->receiver()->ProcessDetach(storage_info.device_id());
405 run_loop.RunUntilIdle(); 416 run_loop.RunUntilIdle();
406 } 417 }
407 418
408 } // namespace component_updater 419 } // namespace component_updater
OLDNEW
« no previous file with comments | « chrome/browser/media_galleries/gallery_watch_manager.cc ('k') | chrome/browser/media_galleries/media_file_system_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698