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

Side by Side Diff: chrome/browser/system_monitor/removable_device_notifications_mac_unittest.mm

Issue 10948019: Remove use of weakptr for RemovableDeviceNotificationsMac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 #include "chrome/browser/system_monitor/removable_device_notifications_mac.h" 5 #include "chrome/browser/system_monitor/removable_device_notifications_mac.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 virtual void SetUp() OVERRIDE { 50 virtual void SetUp() OVERRIDE {
51 base::SystemMonitor::AllocateSystemIOPorts(); 51 base::SystemMonitor::AllocateSystemIOPorts();
52 system_monitor_.reset(new base::SystemMonitor()); 52 system_monitor_.reset(new base::SystemMonitor());
53 53
54 mock_devices_changed_observer_.reset(new base::MockDevicesChangedObserver); 54 mock_devices_changed_observer_.reset(new base::MockDevicesChangedObserver);
55 system_monitor_->AddDevicesChangedObserver( 55 system_monitor_->AddDevicesChangedObserver(
56 mock_devices_changed_observer_.get()); 56 mock_devices_changed_observer_.get());
57 57
58 notifications_.reset(new RemovableDeviceNotificationsMac); 58 notifications_ = new RemovableDeviceNotificationsMac;
59 59
60 unique_id_ = "test_id"; 60 unique_id_ = "test_id";
61 display_name_ = ASCIIToUTF16("Test Display Name"); 61 display_name_ = ASCIIToUTF16("Test Display Name");
62 mount_point_ = FilePath("/unused_test_directory"); 62 mount_point_ = FilePath("/unused_test_directory");
63 device_id_ = MediaStorageUtil::MakeDeviceId( 63 device_id_ = MediaStorageUtil::MakeDeviceId(
64 MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM, unique_id_); 64 MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM, unique_id_);
65 disk_info_ = CreateDiskInfoMac(unique_id_, display_name_, mount_point_); 65 disk_info_ = CreateDiskInfoMac(unique_id_, display_name_, mount_point_);
66 } 66 }
67 67
68 protected: 68 protected:
69 // The message loop and file thread to run tests on. 69 // The message loop and file thread to run tests on.
70 MessageLoop message_loop_; 70 MessageLoop message_loop_;
71 content::TestBrowserThread file_thread_; 71 content::TestBrowserThread file_thread_;
72 72
73 // SystemMonitor and DevicesChangedObserver to hook together to test. 73 // SystemMonitor and DevicesChangedObserver to hook together to test.
74 scoped_ptr<base::SystemMonitor> system_monitor_; 74 scoped_ptr<base::SystemMonitor> system_monitor_;
75 scoped_ptr<base::MockDevicesChangedObserver> mock_devices_changed_observer_; 75 scoped_ptr<base::MockDevicesChangedObserver> mock_devices_changed_observer_;
76 76
77 // Information about the disk. 77 // Information about the disk.
78 std::string unique_id_; 78 std::string unique_id_;
79 string16 display_name_; 79 string16 display_name_;
80 FilePath mount_point_; 80 FilePath mount_point_;
81 std::string device_id_; 81 std::string device_id_;
82 DiskInfoMac disk_info_; 82 DiskInfoMac disk_info_;
83 83
84 scoped_ptr<RemovableDeviceNotificationsMac> notifications_; 84 scoped_refptr<RemovableDeviceNotificationsMac> notifications_;
85 }; 85 };
86 86
87 TEST_F(RemovableDeviceNotificationsMacTest, AddRemove) { 87 TEST_F(RemovableDeviceNotificationsMacTest, AddRemove) {
88 { 88 {
89 EXPECT_CALL(*mock_devices_changed_observer_, 89 EXPECT_CALL(*mock_devices_changed_observer_,
90 OnRemovableStorageAttached(device_id_, 90 OnRemovableStorageAttached(device_id_,
91 display_name_, 91 display_name_,
92 mount_point_.value())); 92 mount_point_.value()));
93 notifications_->UpdateDisk( 93 notifications_->UpdateDisk(
94 disk_info_, RemovableDeviceNotificationsMac::UPDATE_DEVICE_ADDED); 94 disk_info_, RemovableDeviceNotificationsMac::UPDATE_DEVICE_ADDED);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 mount_point_.AppendASCII("foo"), &info)); 168 mount_point_.AppendASCII("foo"), &info));
169 EXPECT_EQ(info.device_id, device_id_); 169 EXPECT_EQ(info.device_id, device_id_);
170 EXPECT_EQ(info.name, display_name_); 170 EXPECT_EQ(info.name, display_name_);
171 EXPECT_EQ(info.location, mount_point_.value()); 171 EXPECT_EQ(info.location, mount_point_.value());
172 172
173 EXPECT_FALSE(notifications_->GetDeviceInfoForPath( 173 EXPECT_FALSE(notifications_->GetDeviceInfoForPath(
174 FilePath("/non/matching/path"), &info)); 174 FilePath("/non/matching/path"), &info));
175 } 175 }
176 176
177 } // namespace chrome 177 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698