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

Side by Side Diff: components/storage_monitor/storage_monitor_win_unittest.cc

Issue 120303003: [StorageMonitor] Move gallery name generation to StorageInfo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address vandebo's comments Created 6 years, 9 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 <windows.h> 5 #include <windows.h>
6 #include <dbt.h> 6 #include <dbt.h>
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 "dcim:mount1subdir", L"mount1subdir", 100); 306 "dcim:mount1subdir", L"mount1subdir", 100);
307 volume_mount_watcher_->AddDeviceForTesting( 307 volume_mount_watcher_->AddDeviceForTesting(
308 base::FilePath(FILE_PATH_LITERAL("F:\\mount2")), 308 base::FilePath(FILE_PATH_LITERAL("F:\\mount2")),
309 "dcim:mount2", L"mount2", 100); 309 "dcim:mount2", L"mount2", 100);
310 RunUntilIdle(); 310 RunUntilIdle();
311 EXPECT_EQ(init_storages + 3, monitor_->GetAllAvailableStorages().size()); 311 EXPECT_EQ(init_storages + 3, monitor_->GetAllAvailableStorages().size());
312 312
313 StorageInfo info; 313 StorageInfo info;
314 EXPECT_TRUE(monitor_->GetStorageInfoForPath( 314 EXPECT_TRUE(monitor_->GetStorageInfoForPath(
315 base::FilePath(ASCIIToUTF16("F:\\dir")), &info)); 315 base::FilePath(ASCIIToUTF16("F:\\dir")), &info));
316 EXPECT_EQ(L"", info.name()); 316 EXPECT_EQ(L"F:\\ Drive", info.GetDisplayName(false));
317 EXPECT_EQ(L"F:\\ Drive", info.storage_label());
318 EXPECT_TRUE(monitor_->GetStorageInfoForPath( 317 EXPECT_TRUE(monitor_->GetStorageInfoForPath(
319 base::FilePath(ASCIIToUTF16("F:\\mount1")), &info)); 318 base::FilePath(ASCIIToUTF16("F:\\mount1")), &info));
320 EXPECT_EQ(L"mount1", info.name()); 319 EXPECT_EQ(L"mount1", info.GetDisplayName(false));
321 EXPECT_TRUE(monitor_->GetStorageInfoForPath( 320 EXPECT_TRUE(monitor_->GetStorageInfoForPath(
322 base::FilePath(ASCIIToUTF16("F:\\mount1\\dir")), &info)); 321 base::FilePath(ASCIIToUTF16("F:\\mount1\\dir")), &info));
323 EXPECT_EQ(L"mount1", info.name()); 322 EXPECT_EQ(L"mount1", info.GetDisplayName(false));
324 EXPECT_TRUE(monitor_->GetStorageInfoForPath( 323 EXPECT_TRUE(monitor_->GetStorageInfoForPath(
325 base::FilePath(ASCIIToUTF16("F:\\mount2\\dir")), &info)); 324 base::FilePath(ASCIIToUTF16("F:\\mount2\\dir")), &info));
326 EXPECT_EQ(L"mount2", info.name()); 325 EXPECT_EQ(L"mount2", info.GetDisplayName(false));
327 EXPECT_TRUE(monitor_->GetStorageInfoForPath( 326 EXPECT_TRUE(monitor_->GetStorageInfoForPath(
328 base::FilePath(ASCIIToUTF16("F:\\mount1\\subdir")), &info)); 327 base::FilePath(ASCIIToUTF16("F:\\mount1\\subdir")), &info));
329 EXPECT_EQ(L"mount1subdir", info.name()); 328 EXPECT_EQ(L"mount1subdir", info.GetDisplayName(false));
330 EXPECT_TRUE(monitor_->GetStorageInfoForPath( 329 EXPECT_TRUE(monitor_->GetStorageInfoForPath(
331 base::FilePath(ASCIIToUTF16("F:\\mount1\\subdir\\dir")), &info)); 330 base::FilePath(ASCIIToUTF16("F:\\mount1\\subdir\\dir")), &info));
332 EXPECT_EQ(L"mount1subdir", info.name()); 331 EXPECT_EQ(L"mount1subdir", info.GetDisplayName(false));
333 EXPECT_TRUE(monitor_->GetStorageInfoForPath( 332 EXPECT_TRUE(monitor_->GetStorageInfoForPath(
334 base::FilePath(ASCIIToUTF16("F:\\mount1\\subdir\\dir\\dir")), &info)); 333 base::FilePath(ASCIIToUTF16("F:\\mount1\\subdir\\dir\\dir")), &info));
335 EXPECT_EQ(L"mount1subdir", info.name()); 334 EXPECT_EQ(L"mount1subdir", info.GetDisplayName(false));
336 } 335 }
337 336
338 TEST_F(StorageMonitorWinTest, DevicesAttachedHighBoundary) { 337 TEST_F(StorageMonitorWinTest, DevicesAttachedHighBoundary) {
339 DeviceIndices device_indices; 338 DeviceIndices device_indices;
340 device_indices.push_back(25); 339 device_indices.push_back(25);
341 340
342 DoMassStorageDeviceAttachedTest(device_indices); 341 DoMassStorageDeviceAttachedTest(device_indices);
343 } 342 }
344 343
345 TEST_F(StorageMonitorWinTest, DevicesAttachedLowBoundary) { 344 TEST_F(StorageMonitorWinTest, DevicesAttachedLowBoundary) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 &device_info)); 467 &device_info));
469 468
470 // A connected removable device. 469 // A connected removable device.
471 base::FilePath removable_device(L"F:\\"); 470 base::FilePath removable_device(L"F:\\");
472 EXPECT_TRUE(monitor_->GetStorageInfoForPath(removable_device, &device_info)); 471 EXPECT_TRUE(monitor_->GetStorageInfoForPath(removable_device, &device_info));
473 472
474 StorageInfo info; 473 StorageInfo info;
475 ASSERT_TRUE(volume_mount_watcher_->GetDeviceInfo(removable_device, &info)); 474 ASSERT_TRUE(volume_mount_watcher_->GetDeviceInfo(removable_device, &info));
476 EXPECT_TRUE(StorageInfo::IsRemovableDevice(info.device_id())); 475 EXPECT_TRUE(StorageInfo::IsRemovableDevice(info.device_id()));
477 EXPECT_EQ(info.device_id(), device_info.device_id()); 476 EXPECT_EQ(info.device_id(), device_info.device_id());
478 EXPECT_EQ(info.name(), device_info.name()); 477 EXPECT_EQ(info.GetDisplayName(false), device_info.GetDisplayName(false));
479 EXPECT_EQ(info.location(), device_info.location()); 478 EXPECT_EQ(info.location(), device_info.location());
480 EXPECT_EQ(1000000, info.total_size_in_bytes()); 479 EXPECT_EQ(1000000, info.total_size_in_bytes());
481 480
482 // A fixed device. 481 // A fixed device.
483 base::FilePath fixed_device(L"N:\\"); 482 base::FilePath fixed_device(L"N:\\");
484 EXPECT_TRUE(monitor_->GetStorageInfoForPath(fixed_device, &device_info)); 483 EXPECT_TRUE(monitor_->GetStorageInfoForPath(fixed_device, &device_info));
485 484
486 ASSERT_TRUE(volume_mount_watcher_->GetDeviceInfo( 485 ASSERT_TRUE(volume_mount_watcher_->GetDeviceInfo(
487 fixed_device, &info)); 486 fixed_device, &info));
488 EXPECT_FALSE(StorageInfo::IsRemovableDevice(info.device_id())); 487 EXPECT_FALSE(StorageInfo::IsRemovableDevice(info.device_id()));
489 EXPECT_EQ(info.device_id(), device_info.device_id()); 488 EXPECT_EQ(info.device_id(), device_info.device_id());
490 EXPECT_EQ(info.name(), device_info.name()); 489 EXPECT_EQ(info.GetDisplayName(false), device_info.GetDisplayName(false));
491 EXPECT_EQ(info.location(), device_info.location()); 490 EXPECT_EQ(info.location(), device_info.location());
492 } 491 }
493 492
494 // Test to verify basic MTP storage attach and detach notifications. 493 // Test to verify basic MTP storage attach and detach notifications.
495 TEST_F(StorageMonitorWinTest, MTPDeviceBasicAttachDetach) { 494 TEST_F(StorageMonitorWinTest, MTPDeviceBasicAttachDetach) {
496 DoMTPDeviceTest(TestPortableDeviceWatcherWin::kMTPDeviceWithValidInfo, true); 495 DoMTPDeviceTest(TestPortableDeviceWatcherWin::kMTPDeviceWithValidInfo, true);
497 DoMTPDeviceTest(TestPortableDeviceWatcherWin::kMTPDeviceWithValidInfo, false); 496 DoMTPDeviceTest(TestPortableDeviceWatcherWin::kMTPDeviceWithValidInfo, false);
498 } 497 }
499 498
500 // When a MTP storage device with invalid storage label and id is 499 // When a MTP storage device with invalid storage label and id is
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 TestPortableDeviceWatcherWin::kMTPDeviceWithValidInfo); 540 TestPortableDeviceWatcherWin::kMTPDeviceWithValidInfo);
542 EXPECT_EQ(expected, pnp_device_id); 541 EXPECT_EQ(expected, pnp_device_id);
543 EXPECT_EQ(it->object_persistent_id, 542 EXPECT_EQ(it->object_persistent_id,
544 TestPortableDeviceWatcherWin::GetMTPStorageUniqueId( 543 TestPortableDeviceWatcherWin::GetMTPStorageUniqueId(
545 pnp_device_id, storage_object_id)); 544 pnp_device_id, storage_object_id));
546 } 545 }
547 DoMTPDeviceTest(TestPortableDeviceWatcherWin::kMTPDeviceWithValidInfo, false); 546 DoMTPDeviceTest(TestPortableDeviceWatcherWin::kMTPDeviceWithValidInfo, false);
548 } 547 }
549 548
550 } // namespace storage_monitor 549 } // namespace storage_monitor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698