Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // RemovableDeviceNotificationsLinux unit tests. | 5 // RemovableDeviceNotificationsLinux unit tests. |
| 6 | 6 |
| 7 #include "chrome/browser/system_monitor/removable_device_notifications_linux.h" | 7 #include "chrome/browser/system_monitor/removable_device_notifications_linux.h" |
| 8 | 8 |
| 9 #include <mntent.h> | 9 #include <mntent.h> |
| 10 #include <stdio.h> | 10 #include <stdio.h> |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/file_util.h" | 14 #include "base/file_util.h" |
| 15 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
| 19 #include "base/system_monitor/system_monitor.h" | |
| 20 #include "base/test/mock_devices_changed_observer.h" | |
| 21 #include "base/utf_string_conversions.h" | 19 #include "base/utf_string_conversions.h" |
| 22 #include "chrome/browser/system_monitor/media_device_notifications_utils.h" | 20 #include "chrome/browser/system_monitor/media_device_notifications_utils.h" |
| 23 #include "chrome/browser/system_monitor/media_storage_util.h" | 21 #include "chrome/browser/system_monitor/media_storage_util.h" |
| 24 #include "chrome/browser/system_monitor/removable_device_constants.h" | 22 #include "chrome/browser/system_monitor/removable_device_constants.h" |
| 25 #include "content/public/test/test_browser_thread.h" | 23 #include "content/public/test/test_browser_thread.h" |
| 24 #include "testing/gmock/include/gmock/gmock.h" | |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 27 | 26 |
| 28 namespace chrome { | 27 namespace chrome { |
| 29 | 28 |
| 30 namespace { | 29 namespace { |
| 31 | 30 |
| 32 using testing::_; | 31 using testing::_; |
| 33 | 32 |
| 34 const char kValidFS[] = "vfat"; | 33 const char kValidFS[] = "vfat"; |
| 35 const char kInvalidFS[] = "invalidfs"; | 34 const char kInvalidFS[] = "invalidfs"; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 virtual void OnFilePathChanged(const FilePath& path, bool error) OVERRIDE { | 153 virtual void OnFilePathChanged(const FilePath& path, bool error) OVERRIDE { |
| 155 RemovableDeviceNotificationsLinux::OnFilePathChanged(path, error); | 154 RemovableDeviceNotificationsLinux::OnFilePathChanged(path, error); |
| 156 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 155 message_loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 157 } | 156 } |
| 158 | 157 |
| 159 MessageLoop* message_loop_; | 158 MessageLoop* message_loop_; |
| 160 | 159 |
| 161 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsLinuxTestWrapper); | 160 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsLinuxTestWrapper); |
| 162 }; | 161 }; |
| 163 | 162 |
| 163 class MockStorageObserver | |
| 164 : public RemovableStorageNotifications::RemovableStorageObserver { | |
| 165 public: | |
| 166 MockStorageObserver() {} | |
| 167 ~MockStorageObserver() {} | |
| 168 | |
| 169 MOCK_METHOD3(OnRemovableStorageAttached, | |
| 170 void(const std::string& id, | |
| 171 const string16& name, | |
| 172 const FilePath::StringType& location)); | |
| 173 MOCK_METHOD1(OnRemovableStorageDetached, void(const std::string& id)); | |
| 174 }; | |
| 175 | |
| 164 class RemovableDeviceNotificationLinuxTest : public testing::Test { | 176 class RemovableDeviceNotificationLinuxTest : public testing::Test { |
| 165 public: | 177 public: |
| 166 struct MtabTestData { | 178 struct MtabTestData { |
| 167 MtabTestData(const std::string& mount_device, | 179 MtabTestData(const std::string& mount_device, |
| 168 const std::string& mount_point, | 180 const std::string& mount_point, |
| 169 const std::string& mount_type) | 181 const std::string& mount_type) |
| 170 : mount_device(mount_device), | 182 : mount_device(mount_device), |
| 171 mount_point(mount_point), | 183 mount_point(mount_point), |
| 172 mount_type(mount_type) { | 184 mount_type(mount_type) { |
| 173 } | 185 } |
| 174 | 186 |
| 175 const std::string mount_device; | 187 const std::string mount_device; |
| 176 const std::string mount_point; | 188 const std::string mount_point; |
| 177 const std::string mount_type; | 189 const std::string mount_type; |
| 178 }; | 190 }; |
| 179 | 191 |
| 180 RemovableDeviceNotificationLinuxTest() | 192 RemovableDeviceNotificationLinuxTest() |
| 181 : message_loop_(MessageLoop::TYPE_IO), | 193 : message_loop_(MessageLoop::TYPE_IO), |
| 182 file_thread_(content::BrowserThread::FILE, &message_loop_) { | 194 file_thread_(content::BrowserThread::FILE, &message_loop_) { |
| 183 } | 195 } |
| 184 virtual ~RemovableDeviceNotificationLinuxTest() {} | 196 virtual ~RemovableDeviceNotificationLinuxTest() {} |
| 185 | 197 |
| 186 protected: | 198 protected: |
| 187 virtual void SetUp() OVERRIDE { | 199 virtual void SetUp() OVERRIDE { |
| 188 mock_devices_changed_observer_.reset(new base::MockDevicesChangedObserver); | |
| 189 system_monitor_.AddDevicesChangedObserver( | |
| 190 mock_devices_changed_observer_.get()); | |
| 191 | |
| 192 // Create and set up a temp dir with files for the test. | 200 // Create and set up a temp dir with files for the test. |
| 193 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); | 201 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); |
| 194 FilePath test_dir = scoped_temp_dir_.path().AppendASCII("test_etc"); | 202 FilePath test_dir = scoped_temp_dir_.path().AppendASCII("test_etc"); |
| 195 ASSERT_TRUE(file_util::CreateDirectory(test_dir)); | 203 ASSERT_TRUE(file_util::CreateDirectory(test_dir)); |
| 196 mtab_file_ = test_dir.AppendASCII("test_mtab"); | 204 mtab_file_ = test_dir.AppendASCII("test_mtab"); |
| 197 MtabTestData initial_test_data[] = { | 205 MtabTestData initial_test_data[] = { |
| 198 MtabTestData("dummydevice", "dummydir", kInvalidFS), | 206 MtabTestData("dummydevice", "dummydir", kInvalidFS), |
| 199 }; | 207 }; |
| 200 WriteToMtab(initial_test_data, | 208 WriteToMtab(initial_test_data, |
| 201 arraysize(initial_test_data), | 209 arraysize(initial_test_data), |
| 202 true /* overwrite */); | 210 true /* overwrite */); |
| 203 | 211 |
| 204 // Initialize the test subject. | 212 // Initialize the test subject. |
| 205 notifications_ = new RemovableDeviceNotificationsLinuxTestWrapper( | 213 notifications_ = new RemovableDeviceNotificationsLinuxTestWrapper( |
| 206 mtab_file_, &message_loop_); | 214 mtab_file_, &message_loop_); |
| 207 notifications_->Init(); | 215 notifications_->Init(); |
| 208 message_loop_.RunUntilIdle(); | 216 message_loop_.RunUntilIdle(); |
| 217 | |
|
vandebo (ex-Chrome)
2013/01/04 21:06:03
Why move this below the implementation set up? Th
Greg Billock
2013/01/07 21:55:18
I don't recall doing this deliberately. Perhaps a
| |
| 218 mock_storage_observer_.reset(new MockStorageObserver); | |
| 219 notifications_->AddRemovableStorageObserver( | |
| 220 mock_storage_observer_.get()); | |
| 209 } | 221 } |
| 210 | 222 |
| 211 virtual void TearDown() OVERRIDE { | 223 virtual void TearDown() OVERRIDE { |
| 212 message_loop_.RunUntilIdle(); | 224 message_loop_.RunUntilIdle(); |
| 225 notifications_->RemoveRemovableStorageObserver( | |
| 226 mock_storage_observer_.get()); | |
| 213 notifications_ = NULL; | 227 notifications_ = NULL; |
| 214 system_monitor_.RemoveDevicesChangedObserver( | |
| 215 mock_devices_changed_observer_.get()); | |
| 216 } | 228 } |
| 217 | 229 |
| 218 // Append mtab entries from the |data| array of size |data_size| to the mtab | 230 // Append mtab entries from the |data| array of size |data_size| to the mtab |
| 219 // file, and run the message loop. | 231 // file, and run the message loop. |
| 220 void AppendToMtabAndRunLoop(const MtabTestData* data, size_t data_size) { | 232 void AppendToMtabAndRunLoop(const MtabTestData* data, size_t data_size) { |
| 221 WriteToMtab(data, data_size, false /* do not overwrite */); | 233 WriteToMtab(data, data_size, false /* do not overwrite */); |
| 222 message_loop_.Run(); | 234 message_loop_.Run(); |
| 223 } | 235 } |
| 224 | 236 |
| 225 // Overwrite the mtab file with mtab entries from the |data| array of size | 237 // Overwrite the mtab file with mtab entries from the |data| array of size |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 249 FilePath CreateMountPointWithoutDCIMDir(const std::string& dir) { | 261 FilePath CreateMountPointWithoutDCIMDir(const std::string& dir) { |
| 250 return CreateMountPoint(dir, false /* do not create DCIM dir */); | 262 return CreateMountPoint(dir, false /* do not create DCIM dir */); |
| 251 } | 263 } |
| 252 | 264 |
| 253 void RemoveDCIMDirFromMountPoint(const std::string& dir) { | 265 void RemoveDCIMDirFromMountPoint(const std::string& dir) { |
| 254 FilePath dcim = | 266 FilePath dcim = |
| 255 scoped_temp_dir_.path().AppendASCII(dir).Append(kDCIMDirectoryName); | 267 scoped_temp_dir_.path().AppendASCII(dir).Append(kDCIMDirectoryName); |
| 256 file_util::Delete(dcim, false); | 268 file_util::Delete(dcim, false); |
| 257 } | 269 } |
| 258 | 270 |
| 259 base::MockDevicesChangedObserver& observer() { | 271 MockStorageObserver& observer() { |
| 260 return *mock_devices_changed_observer_; | 272 return *mock_storage_observer_; |
| 261 } | 273 } |
| 262 | 274 |
| 263 RemovableDeviceNotificationsLinux* notifier() { | 275 RemovableDeviceNotificationsLinux* notifier() { |
| 264 return notifications_.get(); | 276 return notifications_.get(); |
| 265 } | 277 } |
| 266 | 278 |
| 267 private: | 279 private: |
| 268 // Create a directory named |dir| relative to the test directory. | 280 // Create a directory named |dir| relative to the test directory. |
| 269 // Set |with_dcim_dir| to true if the created directory will have a "DCIM" | 281 // Set |with_dcim_dir| to true if the created directory will have a "DCIM" |
| 270 // subdirectory. | 282 // subdirectory. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 entry.mnt_type = const_cast<char*>(data[i].mount_type.c_str()); | 323 entry.mnt_type = const_cast<char*>(data[i].mount_type.c_str()); |
| 312 ASSERT_EQ(0, addmntent(file, &entry)); | 324 ASSERT_EQ(0, addmntent(file, &entry)); |
| 313 } | 325 } |
| 314 ASSERT_EQ(1, endmntent(file)); | 326 ASSERT_EQ(1, endmntent(file)); |
| 315 } | 327 } |
| 316 | 328 |
| 317 // The message loop and file thread to run tests on. | 329 // The message loop and file thread to run tests on. |
| 318 MessageLoop message_loop_; | 330 MessageLoop message_loop_; |
| 319 content::TestBrowserThread file_thread_; | 331 content::TestBrowserThread file_thread_; |
| 320 | 332 |
| 321 // SystemMonitor and DevicesChangedObserver to hook together to test. | 333 scoped_ptr<MockStorageObserver> mock_storage_observer_; |
| 322 base::SystemMonitor system_monitor_; | |
| 323 scoped_ptr<base::MockDevicesChangedObserver> mock_devices_changed_observer_; | |
| 324 | 334 |
| 325 // Temporary directory for created test data. | 335 // Temporary directory for created test data. |
| 326 base::ScopedTempDir scoped_temp_dir_; | 336 base::ScopedTempDir scoped_temp_dir_; |
| 327 // Path to the test mtab file. | 337 // Path to the test mtab file. |
| 328 FilePath mtab_file_; | 338 FilePath mtab_file_; |
| 329 | 339 |
| 330 scoped_refptr<RemovableDeviceNotificationsLinuxTestWrapper> notifications_; | 340 scoped_refptr<RemovableDeviceNotificationsLinuxTestWrapper> notifications_; |
| 331 | 341 |
| 332 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationLinuxTest); | 342 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationLinuxTest); |
| 333 }; | 343 }; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 WriteEmptyMtabAndRunLoop(); | 416 WriteEmptyMtabAndRunLoop(); |
| 407 } | 417 } |
| 408 | 418 |
| 409 // More complicated test case with multiple devices on multiple mount points. | 419 // More complicated test case with multiple devices on multiple mount points. |
| 410 TEST_F(RemovableDeviceNotificationLinuxTest, SwapMountPoints) { | 420 TEST_F(RemovableDeviceNotificationLinuxTest, SwapMountPoints) { |
| 411 FilePath test_path_a = CreateMountPointWithDCIMDir(kMountPointA); | 421 FilePath test_path_a = CreateMountPointWithDCIMDir(kMountPointA); |
| 412 FilePath test_path_b = CreateMountPointWithDCIMDir(kMountPointB); | 422 FilePath test_path_b = CreateMountPointWithDCIMDir(kMountPointB); |
| 413 ASSERT_FALSE(test_path_a.empty()); | 423 ASSERT_FALSE(test_path_a.empty()); |
| 414 ASSERT_FALSE(test_path_b.empty()); | 424 ASSERT_FALSE(test_path_b.empty()); |
| 415 | 425 |
| 416 // Attach two devices. (*'d mounts are those SystemMonitor knows about.) | 426 // Attach two devices. |
| 427 // (*'d mounts are those RemovableStorageNotifications knows about.) | |
| 417 // kDeviceDCIM1 -> kMountPointA * | 428 // kDeviceDCIM1 -> kMountPointA * |
| 418 // kDeviceDCIM2 -> kMountPointB * | 429 // kDeviceDCIM2 -> kMountPointB * |
| 419 MtabTestData test_data1[] = { | 430 MtabTestData test_data1[] = { |
| 420 MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS), | 431 MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS), |
| 421 MtabTestData(kDeviceDCIM2, test_path_b.value(), kValidFS), | 432 MtabTestData(kDeviceDCIM2, test_path_b.value(), kValidFS), |
| 422 }; | 433 }; |
| 423 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(2); | 434 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(2); |
| 424 EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); | 435 EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
| 425 AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); | 436 AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); |
| 426 | 437 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 442 WriteEmptyMtabAndRunLoop(); | 453 WriteEmptyMtabAndRunLoop(); |
| 443 } | 454 } |
| 444 | 455 |
| 445 // More complicated test case with multiple devices on multiple mount points. | 456 // More complicated test case with multiple devices on multiple mount points. |
| 446 TEST_F(RemovableDeviceNotificationLinuxTest, MultiDevicesMultiMountPoints) { | 457 TEST_F(RemovableDeviceNotificationLinuxTest, MultiDevicesMultiMountPoints) { |
| 447 FilePath test_path_a = CreateMountPointWithDCIMDir(kMountPointA); | 458 FilePath test_path_a = CreateMountPointWithDCIMDir(kMountPointA); |
| 448 FilePath test_path_b = CreateMountPointWithDCIMDir(kMountPointB); | 459 FilePath test_path_b = CreateMountPointWithDCIMDir(kMountPointB); |
| 449 ASSERT_FALSE(test_path_a.empty()); | 460 ASSERT_FALSE(test_path_a.empty()); |
| 450 ASSERT_FALSE(test_path_b.empty()); | 461 ASSERT_FALSE(test_path_b.empty()); |
| 451 | 462 |
| 452 // Attach two devices. (*'d mounts are those SystemMonitor knows about.) | 463 // Attach two devices. |
| 464 // (*'d mounts are those RemovableStorageNotifications knows about.) | |
| 453 // kDeviceDCIM1 -> kMountPointA * | 465 // kDeviceDCIM1 -> kMountPointA * |
| 454 // kDeviceDCIM2 -> kMountPointB * | 466 // kDeviceDCIM2 -> kMountPointB * |
| 455 MtabTestData test_data1[] = { | 467 MtabTestData test_data1[] = { |
| 456 MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS), | 468 MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS), |
| 457 MtabTestData(kDeviceDCIM2, test_path_b.value(), kValidFS), | 469 MtabTestData(kDeviceDCIM2, test_path_b.value(), kValidFS), |
| 458 }; | 470 }; |
| 459 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(2); | 471 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(2); |
| 460 EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); | 472 EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
| 461 AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); | 473 AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); |
| 462 | 474 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 509 WriteEmptyMtabAndRunLoop(); | 521 WriteEmptyMtabAndRunLoop(); |
| 510 } | 522 } |
| 511 | 523 |
| 512 TEST_F(RemovableDeviceNotificationLinuxTest, | 524 TEST_F(RemovableDeviceNotificationLinuxTest, |
| 513 MultipleMountPointsWithNonDCIMDevices) { | 525 MultipleMountPointsWithNonDCIMDevices) { |
| 514 FilePath test_path_a = CreateMountPointWithDCIMDir(kMountPointA); | 526 FilePath test_path_a = CreateMountPointWithDCIMDir(kMountPointA); |
| 515 FilePath test_path_b = CreateMountPointWithDCIMDir(kMountPointB); | 527 FilePath test_path_b = CreateMountPointWithDCIMDir(kMountPointB); |
| 516 ASSERT_FALSE(test_path_a.empty()); | 528 ASSERT_FALSE(test_path_a.empty()); |
| 517 ASSERT_FALSE(test_path_b.empty()); | 529 ASSERT_FALSE(test_path_b.empty()); |
| 518 | 530 |
| 519 // Attach to one first. (*'d mounts are those SystemMonitor knows about.) | 531 // Attach to one first. |
| 532 // (*'d mounts are those RemovableStorageNotifications knows about.) | |
| 520 // kDeviceDCIM1 -> kMountPointA * | 533 // kDeviceDCIM1 -> kMountPointA * |
| 521 MtabTestData test_data1[] = { | 534 MtabTestData test_data1[] = { |
| 522 MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS), | 535 MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS), |
| 523 }; | 536 }; |
| 524 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(1); | 537 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(1); |
| 525 EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); | 538 EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
| 526 AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); | 539 AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); |
| 527 | 540 |
| 528 // Attach |kDeviceDCIM1| to |kMountPointB|. | 541 // Attach |kDeviceDCIM1| to |kMountPointB|. |
| 529 // kDeviceDCIM1 -> kMountPointA * | 542 // kDeviceDCIM1 -> kMountPointA * |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 } | 609 } |
| 597 | 610 |
| 598 TEST_F(RemovableDeviceNotificationLinuxTest, DeviceLookUp) { | 611 TEST_F(RemovableDeviceNotificationLinuxTest, DeviceLookUp) { |
| 599 FilePath test_path_a = CreateMountPointWithDCIMDir(kMountPointA); | 612 FilePath test_path_a = CreateMountPointWithDCIMDir(kMountPointA); |
| 600 FilePath test_path_b = CreateMountPointWithoutDCIMDir(kMountPointB); | 613 FilePath test_path_b = CreateMountPointWithoutDCIMDir(kMountPointB); |
| 601 FilePath test_path_c = CreateMountPointWithoutDCIMDir(kMountPointC); | 614 FilePath test_path_c = CreateMountPointWithoutDCIMDir(kMountPointC); |
| 602 ASSERT_FALSE(test_path_a.empty()); | 615 ASSERT_FALSE(test_path_a.empty()); |
| 603 ASSERT_FALSE(test_path_b.empty()); | 616 ASSERT_FALSE(test_path_b.empty()); |
| 604 ASSERT_FALSE(test_path_c.empty()); | 617 ASSERT_FALSE(test_path_c.empty()); |
| 605 | 618 |
| 606 // Attach to one first. (*'d mounts are those SystemMonitor knows about.) | 619 // Attach to one first. |
| 620 // (*'d mounts are those RemovableStorageNotifications knows about.) | |
| 607 // kDeviceDCIM1 -> kMountPointA * | 621 // kDeviceDCIM1 -> kMountPointA * |
| 608 // kDeviceNoDCIM -> kMountPointB * | 622 // kDeviceNoDCIM -> kMountPointB * |
| 609 // kDeviceFixed -> kMountPointC | 623 // kDeviceFixed -> kMountPointC |
| 610 MtabTestData test_data1[] = { | 624 MtabTestData test_data1[] = { |
| 611 MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS), | 625 MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS), |
| 612 MtabTestData(kDeviceNoDCIM, test_path_b.value(), kValidFS), | 626 MtabTestData(kDeviceNoDCIM, test_path_b.value(), kValidFS), |
| 613 MtabTestData(kDeviceFixed, test_path_c.value(), kValidFS), | 627 MtabTestData(kDeviceFixed, test_path_c.value(), kValidFS), |
| 614 }; | 628 }; |
| 615 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(2); | 629 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(2); |
| 616 EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); | 630 EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
| 617 AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); | 631 AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); |
| 618 | 632 |
| 619 base::SystemMonitor::RemovableStorageInfo device_info; | 633 RemovableStorageNotifications::RemovableStorageInfo device_info; |
| 620 EXPECT_TRUE(notifier()->GetDeviceInfoForPath(test_path_a, &device_info)); | 634 EXPECT_TRUE(notifier()->GetDeviceInfoForPath(test_path_a, &device_info)); |
| 621 EXPECT_EQ(GetDeviceId(kDeviceDCIM1), device_info.device_id); | 635 EXPECT_EQ(GetDeviceId(kDeviceDCIM1), device_info.device_id); |
| 622 EXPECT_EQ(test_path_a.value(), device_info.location); | 636 EXPECT_EQ(test_path_a.value(), device_info.location); |
| 623 EXPECT_EQ(GetDeviceName(kDeviceDCIM1), device_info.name); | 637 EXPECT_EQ(GetDeviceName(kDeviceDCIM1), device_info.name); |
| 624 | 638 |
| 625 EXPECT_TRUE(notifier()->GetDeviceInfoForPath(test_path_b, &device_info)); | 639 EXPECT_TRUE(notifier()->GetDeviceInfoForPath(test_path_b, &device_info)); |
| 626 EXPECT_EQ(GetDeviceId(kDeviceNoDCIM), device_info.device_id); | 640 EXPECT_EQ(GetDeviceId(kDeviceNoDCIM), device_info.device_id); |
| 627 EXPECT_EQ(test_path_b.value(), device_info.location); | 641 EXPECT_EQ(test_path_b.value(), device_info.location); |
| 628 EXPECT_EQ(GetDeviceName(kDeviceNoDCIM), device_info.name); | 642 EXPECT_EQ(GetDeviceName(kDeviceNoDCIM), device_info.name); |
| 629 | 643 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 684 notifier()->GetStorageSize(test_path_a.value())); | 698 notifier()->GetStorageSize(test_path_a.value())); |
| 685 EXPECT_EQ(GetDevicePartitionSize(kDeviceNoDCIM), | 699 EXPECT_EQ(GetDevicePartitionSize(kDeviceNoDCIM), |
| 686 notifier()->GetStorageSize(test_path_b.value())); | 700 notifier()->GetStorageSize(test_path_b.value())); |
| 687 EXPECT_EQ(GetDevicePartitionSize(kInvalidPath), | 701 EXPECT_EQ(GetDevicePartitionSize(kInvalidPath), |
| 688 notifier()->GetStorageSize(kInvalidPath)); | 702 notifier()->GetStorageSize(kInvalidPath)); |
| 689 } | 703 } |
| 690 | 704 |
| 691 } // namespace | 705 } // namespace |
| 692 | 706 |
| 693 } // namespace chrome | 707 } // namespace chrome |
| OLD | NEW |