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

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

Issue 11413050: chrome/browser: Update calls from RunAllPending() to RunUntilIdle(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 }; 91 };
92 92
93 TEST_F(RemovableDeviceNotificationsMacTest, AddRemove) { 93 TEST_F(RemovableDeviceNotificationsMacTest, AddRemove) {
94 { 94 {
95 EXPECT_CALL(*mock_devices_changed_observer_, 95 EXPECT_CALL(*mock_devices_changed_observer_,
96 OnRemovableStorageAttached(device_id_, 96 OnRemovableStorageAttached(device_id_,
97 display_name_, 97 display_name_,
98 mount_point_.value())); 98 mount_point_.value()));
99 notifications_->UpdateDisk( 99 notifications_->UpdateDisk(
100 disk_info_, RemovableDeviceNotificationsMac::UPDATE_DEVICE_ADDED); 100 disk_info_, RemovableDeviceNotificationsMac::UPDATE_DEVICE_ADDED);
101 message_loop_.RunAllPending(); 101 message_loop_.RunUntilIdle();
102 } 102 }
103 103
104 { 104 {
105 EXPECT_CALL(*mock_devices_changed_observer_, 105 EXPECT_CALL(*mock_devices_changed_observer_,
106 OnRemovableStorageDetached(device_id_)); 106 OnRemovableStorageDetached(device_id_));
107 notifications_->UpdateDisk( 107 notifications_->UpdateDisk(
108 disk_info_, RemovableDeviceNotificationsMac::UPDATE_DEVICE_REMOVED); 108 disk_info_, RemovableDeviceNotificationsMac::UPDATE_DEVICE_REMOVED);
109 message_loop_.RunAllPending(); 109 message_loop_.RunUntilIdle();
110 } 110 }
111 } 111 }
112 112
113 TEST_F(RemovableDeviceNotificationsMacTest, UpdateVolumeName) { 113 TEST_F(RemovableDeviceNotificationsMacTest, UpdateVolumeName) {
114 { 114 {
115 EXPECT_CALL(*mock_devices_changed_observer_, 115 EXPECT_CALL(*mock_devices_changed_observer_,
116 OnRemovableStorageAttached(device_id_, 116 OnRemovableStorageAttached(device_id_,
117 display_name_, 117 display_name_,
118 mount_point_.value())); 118 mount_point_.value()));
119 notifications_->UpdateDisk( 119 notifications_->UpdateDisk(
120 disk_info_, RemovableDeviceNotificationsMac::UPDATE_DEVICE_ADDED); 120 disk_info_, RemovableDeviceNotificationsMac::UPDATE_DEVICE_ADDED);
121 message_loop_.RunAllPending(); 121 message_loop_.RunUntilIdle();
122 } 122 }
123 123
124 { 124 {
125 string16 new_display_name(ASCIIToUTF16("Test Display Name")); 125 string16 new_display_name(ASCIIToUTF16("Test Display Name"));
126 DiskInfoMac info2 = CreateDiskInfoMac( 126 DiskInfoMac info2 = CreateDiskInfoMac(
127 unique_id_, "", new_display_name, mount_point_); 127 unique_id_, "", new_display_name, mount_point_);
128 EXPECT_CALL(*mock_devices_changed_observer_, 128 EXPECT_CALL(*mock_devices_changed_observer_,
129 OnRemovableStorageDetached(device_id_)); 129 OnRemovableStorageDetached(device_id_));
130 EXPECT_CALL(*mock_devices_changed_observer_, 130 EXPECT_CALL(*mock_devices_changed_observer_,
131 OnRemovableStorageAttached(device_id_, 131 OnRemovableStorageAttached(device_id_,
132 new_display_name, 132 new_display_name,
133 mount_point_.value())); 133 mount_point_.value()));
134 notifications_->UpdateDisk( 134 notifications_->UpdateDisk(
135 info2, RemovableDeviceNotificationsMac::UPDATE_DEVICE_CHANGED); 135 info2, RemovableDeviceNotificationsMac::UPDATE_DEVICE_CHANGED);
136 message_loop_.RunAllPending(); 136 message_loop_.RunUntilIdle();
137 } 137 }
138 } 138 }
139 139
140 TEST_F(RemovableDeviceNotificationsMacTest, DCIM) { 140 TEST_F(RemovableDeviceNotificationsMacTest, DCIM) {
141 base::ScopedTempDir temp_dir; 141 base::ScopedTempDir temp_dir;
142 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 142 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
143 file_util::CreateDirectory(temp_dir.path().Append(kDCIMDirectoryName)); 143 file_util::CreateDirectory(temp_dir.path().Append(kDCIMDirectoryName));
144 144
145 FilePath mount_point = temp_dir.path(); 145 FilePath mount_point = temp_dir.path();
146 DiskInfoMac info = CreateDiskInfoMac( 146 DiskInfoMac info = CreateDiskInfoMac(
147 unique_id_, "", display_name_, mount_point); 147 unique_id_, "", display_name_, mount_point);
148 std::string device_id = MediaStorageUtil::MakeDeviceId( 148 std::string device_id = MediaStorageUtil::MakeDeviceId(
149 MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM, unique_id_); 149 MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM, unique_id_);
150 150
151 { 151 {
152 EXPECT_CALL(*mock_devices_changed_observer_, 152 EXPECT_CALL(*mock_devices_changed_observer_,
153 OnRemovableStorageAttached(device_id, 153 OnRemovableStorageAttached(device_id,
154 display_name_, 154 display_name_,
155 mount_point.value())); 155 mount_point.value()));
156 notifications_->UpdateDisk( 156 notifications_->UpdateDisk(
157 info, RemovableDeviceNotificationsMac::UPDATE_DEVICE_ADDED); 157 info, RemovableDeviceNotificationsMac::UPDATE_DEVICE_ADDED);
158 message_loop_.RunAllPending(); 158 message_loop_.RunUntilIdle();
159 } 159 }
160 } 160 }
161 161
162 TEST_F(RemovableDeviceNotificationsMacTest, GetDeviceInfo) { 162 TEST_F(RemovableDeviceNotificationsMacTest, GetDeviceInfo) {
163 { 163 {
164 EXPECT_CALL(*mock_devices_changed_observer_, 164 EXPECT_CALL(*mock_devices_changed_observer_,
165 OnRemovableStorageAttached(device_id_, 165 OnRemovableStorageAttached(device_id_,
166 display_name_, 166 display_name_,
167 mount_point_.value())); 167 mount_point_.value()));
168 notifications_->UpdateDisk( 168 notifications_->UpdateDisk(
169 disk_info_, RemovableDeviceNotificationsMac::UPDATE_DEVICE_ADDED); 169 disk_info_, RemovableDeviceNotificationsMac::UPDATE_DEVICE_ADDED);
170 message_loop_.RunAllPending(); 170 message_loop_.RunUntilIdle();
171 } 171 }
172 172
173 base::SystemMonitor::RemovableStorageInfo info; 173 base::SystemMonitor::RemovableStorageInfo info;
174 EXPECT_TRUE(notifications_->GetDeviceInfoForPath( 174 EXPECT_TRUE(notifications_->GetDeviceInfoForPath(
175 mount_point_.AppendASCII("foo"), &info)); 175 mount_point_.AppendASCII("foo"), &info));
176 EXPECT_EQ(info.device_id, device_id_); 176 EXPECT_EQ(info.device_id, device_id_);
177 EXPECT_EQ(info.name, display_name_); 177 EXPECT_EQ(info.name, display_name_);
178 EXPECT_EQ(info.location, mount_point_.value()); 178 EXPECT_EQ(info.location, mount_point_.value());
179 179
180 EXPECT_FALSE(notifications_->GetDeviceInfoForPath( 180 EXPECT_FALSE(notifications_->GetDeviceInfoForPath(
181 FilePath("/non/matching/path"), &info)); 181 FilePath("/non/matching/path"), &info));
182 } 182 }
183 183
184 // Test that mounting a DMG doesn't send a notification. 184 // Test that mounting a DMG doesn't send a notification.
185 TEST_F(RemovableDeviceNotificationsMacTest, DMG) { 185 TEST_F(RemovableDeviceNotificationsMacTest, DMG) {
186 EXPECT_CALL(*mock_devices_changed_observer_, 186 EXPECT_CALL(*mock_devices_changed_observer_,
187 OnRemovableStorageAttached(testing::_, 187 OnRemovableStorageAttached(testing::_,
188 testing::_, 188 testing::_,
189 testing::_)).Times(0); 189 testing::_)).Times(0);
190 DiskInfoMac info = CreateDiskInfoMac( 190 DiskInfoMac info = CreateDiskInfoMac(
191 unique_id_, "Disk Image", display_name_, mount_point_); 191 unique_id_, "Disk Image", display_name_, mount_point_);
192 notifications_->UpdateDisk( 192 notifications_->UpdateDisk(
193 info, RemovableDeviceNotificationsMac::UPDATE_DEVICE_ADDED); 193 info, RemovableDeviceNotificationsMac::UPDATE_DEVICE_ADDED);
194 message_loop_.RunAllPending(); 194 message_loop_.RunUntilIdle();
195 } 195 }
196 196
197 } // namespace chrome 197 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698