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

Unified Diff: chrome/browser/system_monitor/removable_device_notifications_chromeos_unittest.cc

Issue 11363236: Revert 167606 - [Media Gallery][ChromeOS] Improve device media gallery names. (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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/system_monitor/removable_device_notifications_chromeos_unittest.cc
===================================================================
--- chrome/browser/system_monitor/removable_device_notifications_chromeos_unittest.cc (revision 167608)
+++ chrome/browser/system_monitor/removable_device_notifications_chromeos_unittest.cc (working copy)
@@ -28,36 +28,19 @@
using disks::DiskMountManager;
using testing::_;
-const char kDeviceNameWithManufacturerDetails[] = "110 KB (CompanyA, Z101)";
const char kDevice1[] = "/dev/d1";
-const char kDevice1Name[] = "d1";
-const char kDevice1NameWithSizeInfo[] = "110 KB d1";
const char kDevice2[] = "/dev/disk/d2";
+const char kDevice1Name[] = "d1";
const char kDevice2Name[] = "d2";
-const char kDevice2NameWithSizeInfo[] = "19.8 GB d2";
-const char kEmptyDeviceLabel[] = "";
const char kMountPointA[] = "mnt_a";
const char kMountPointB[] = "mnt_b";
-const char kSDCardDeviceName1[] = "8.6 MB Amy_SD";
-const char kSDCardDeviceName2[] = "8.6 MB SD Card";
-const char kSDCardMountPoint1[] = "/media/removable/Amy_SD";
-const char kSDCardMountPoint2[] = "/media/removable/SD Card";
-const char kProductName[] = "Z101";
-const char kUniqueId1[] = "FFFF-FFFF";
-const char kUniqueId2[] = "FFFF-FF0F";
-const char kVendorName[] = "CompanyA";
-uint64 kDevice1SizeInBytes = 113048;
-uint64 kDevice2SizeInBytes = 21231209600;
-uint64 kSDCardSizeInBytes = 9000000;
-
std::string GetDCIMDeviceId(const std::string& unique_id) {
return chrome::MediaStorageUtil::MakeDeviceId(
chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM,
chrome::kFSUniqueIdPrefix + unique_id);
}
-// Wrapper class to test RemovableDeviceNotificationsCros.
class RemovableDeviceNotificationsCrosTest : public testing::Test {
public:
RemovableDeviceNotificationsCrosTest()
@@ -67,7 +50,7 @@
virtual ~RemovableDeviceNotificationsCrosTest() {}
protected:
- virtual void SetUp() OVERRIDE {
+ virtual void SetUp() {
ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir());
file_thread_.Start();
@@ -84,7 +67,7 @@
notifications_ = new RemovableDeviceNotificationsCros();
}
- virtual void TearDown() OVERRIDE {
+ virtual void TearDown() {
notifications_ = NULL;
disk_mount_manager_mock_ = NULL;
DiskMountManager::Shutdown();
@@ -100,15 +83,10 @@
void MountDevice(MountError error_code,
const DiskMountManager::MountPointInfo& mount_info,
const std::string& unique_id,
- const std::string& device_label,
- const std::string& vendor_name,
- const std::string& product_name,
- DeviceType device_type,
- uint64 device_size_in_bytes) {
+ const std::string& device_label) {
if (error_code == MOUNT_ERROR_NONE) {
disk_mount_manager_mock_->CreateDiskEntryForMountDevice(
- mount_info, unique_id, device_label, vendor_name, product_name,
- device_type, device_size_in_bytes);
+ mount_info, unique_id, device_label);
}
notifications_->MountCompleted(disks::DiskMountManager::MOUNTING,
error_code,
@@ -128,10 +106,6 @@
WaitForFileThread();
}
- uint64 GetDeviceStorageSize(const std::string& device_location) {
- return notifications_->GetStorageSize(device_location);
- }
-
// Create a directory named |dir| relative to the test directory.
// Set |with_dcim_dir| to true if the created directory will have a "DCIM"
// subdirectory.
@@ -149,12 +123,14 @@
}
static void PostQuitToUIThread() {
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
+ BrowserThread::PostTask(BrowserThread::UI,
+ FROM_HERE,
MessageLoop::QuitClosure());
}
static void WaitForFileThread() {
- BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
+ BrowserThread::PostTask(BrowserThread::FILE,
+ FROM_HERE,
base::Bind(&PostQuitToUIThread));
MessageLoop::current()->Run();
}
@@ -188,16 +164,16 @@
mount_path1.value(),
MOUNT_TYPE_DEVICE,
disks::MOUNT_CONDITION_NONE);
+ const std::string kUniqueId0 = "FFFF-FFFF";
EXPECT_CALL(observer(),
- OnRemovableStorageAttached(GetDCIMDeviceId(kUniqueId1),
- ASCIIToUTF16(kDevice1NameWithSizeInfo),
+ OnRemovableStorageAttached(GetDCIMDeviceId(kUniqueId0),
+ ASCIIToUTF16(kDevice1Name),
mount_path1.value()))
.InSequence(mock_sequence);
- MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kDevice1Name,
- kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
+ MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId0, kDevice1Name);
EXPECT_CALL(observer(),
- OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId1)))
+ OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId0)))
.InSequence(mock_sequence);
UnmountDevice(MOUNT_ERROR_NONE, mount_info);
@@ -207,16 +183,17 @@
mount_path2.value(),
MOUNT_TYPE_DEVICE,
disks::MOUNT_CONDITION_NONE);
+ const std::string kUniqueId1 = "FFF0-FFF0";
+
EXPECT_CALL(observer(),
- OnRemovableStorageAttached(GetDCIMDeviceId(kUniqueId2),
- ASCIIToUTF16(kDevice2NameWithSizeInfo),
+ OnRemovableStorageAttached(GetDCIMDeviceId(kUniqueId1),
+ ASCIIToUTF16(kDevice2Name),
mount_path2.value()))
.InSequence(mock_sequence);
- MountDevice(MOUNT_ERROR_NONE, mount_info2, kUniqueId2, kDevice2Name,
- kVendorName, kProductName, DEVICE_TYPE_USB, kDevice2SizeInBytes);
+ MountDevice(MOUNT_ERROR_NONE, mount_info2, kUniqueId1, kDevice2Name);
EXPECT_CALL(observer(),
- OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId2)))
+ OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId1)))
.InSequence(mock_sequence);
UnmountDevice(MOUNT_ERROR_NONE, mount_info2);
}
@@ -235,11 +212,9 @@
chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM,
chrome::kFSUniqueIdPrefix + kUniqueId);
EXPECT_CALL(observer(),
- OnRemovableStorageAttached(device_id,
- ASCIIToUTF16(kDevice1NameWithSizeInfo),
+ OnRemovableStorageAttached(device_id, ASCIIToUTF16(kDevice1Name),
mount_path.value())).Times(1);
- MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name,
- kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
+ MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name);
}
// Non device mounts and mount errors are ignored.
@@ -255,109 +230,20 @@
MOUNT_TYPE_DEVICE,
disks::MOUNT_CONDITION_NONE);
EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0);
- MountDevice(MOUNT_ERROR_UNKNOWN, mount_info, kUniqueId, kDevice1Name,
- kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
+ MountDevice(MOUNT_ERROR_UNKNOWN, mount_info, kUniqueId, kDevice1Name);
// Not a device
mount_info.mount_type = MOUNT_TYPE_ARCHIVE;
EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0);
- MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name,
- kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
+ MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name);
// Unsupported file system.
mount_info.mount_type = MOUNT_TYPE_DEVICE;
mount_info.mount_condition = disks::MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM;
EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0);
- MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name,
- kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
+ MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name);
}
-TEST_F(RemovableDeviceNotificationsCrosTest, SDCardAttachDetach) {
- testing::Sequence mock_sequence;
- FilePath mount_path1 = CreateMountPoint(kSDCardMountPoint1, true);
- ASSERT_FALSE(mount_path1.empty());
- DiskMountManager::MountPointInfo mount_info1(kSDCardDeviceName1,
- mount_path1.value(),
- MOUNT_TYPE_DEVICE,
- disks::MOUNT_CONDITION_NONE);
- EXPECT_CALL(observer(),
- OnRemovableStorageAttached(GetDCIMDeviceId(kUniqueId2),
- ASCIIToUTF16(kSDCardDeviceName1),
- mount_path1.value()))
- .InSequence(mock_sequence);
- MountDevice(MOUNT_ERROR_NONE, mount_info1, kUniqueId2, kSDCardDeviceName1,
- kVendorName, kProductName, DEVICE_TYPE_SD, kSDCardSizeInBytes);
-
- EXPECT_CALL(observer(),
- OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId2)))
- .InSequence(mock_sequence);
- UnmountDevice(MOUNT_ERROR_NONE, mount_info1);
-
- FilePath mount_path2 = CreateMountPoint(kSDCardMountPoint2, true);
- ASSERT_FALSE(mount_path2.empty());
- DiskMountManager::MountPointInfo mount_info2(kSDCardDeviceName2,
- mount_path2.value(),
- MOUNT_TYPE_DEVICE,
- disks::MOUNT_CONDITION_NONE);
- EXPECT_CALL(observer(),
- OnRemovableStorageAttached(GetDCIMDeviceId(kUniqueId2),
- ASCIIToUTF16(kSDCardDeviceName2),
- mount_path2.value()))
- .InSequence(mock_sequence);
- MountDevice(MOUNT_ERROR_NONE, mount_info2, kUniqueId2, kSDCardDeviceName2,
- kVendorName, kProductName, DEVICE_TYPE_SD, kSDCardSizeInBytes);
-
- EXPECT_CALL(observer(),
- OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId2)))
- .InSequence(mock_sequence);
- UnmountDevice(MOUNT_ERROR_NONE, mount_info2);
-}
-
-TEST_F(RemovableDeviceNotificationsCrosTest, AttachDeviceWithEmptyLabel) {
- testing::Sequence mock_sequence;
- FilePath mount_path1 = CreateMountPoint(kMountPointA, true);
- ASSERT_FALSE(mount_path1.empty());
- DiskMountManager::MountPointInfo mount_info(kEmptyDeviceLabel,
- mount_path1.value(),
- MOUNT_TYPE_DEVICE,
- disks::MOUNT_CONDITION_NONE);
- EXPECT_CALL(observer(), OnRemovableStorageAttached(
- GetDCIMDeviceId(kUniqueId1),
- ASCIIToUTF16(kDeviceNameWithManufacturerDetails),
- mount_path1.value()))
- .InSequence(mock_sequence);
- MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kEmptyDeviceLabel,
- kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
-
- EXPECT_CALL(observer(),
- OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId1)))
- .InSequence(mock_sequence);
- UnmountDevice(MOUNT_ERROR_NONE, mount_info);
-}
-
-TEST_F(RemovableDeviceNotificationsCrosTest, GetStorageSize) {
- testing::Sequence mock_sequence;
- FilePath mount_path1 = CreateMountPoint(kMountPointA, true);
- ASSERT_FALSE(mount_path1.empty());
- DiskMountManager::MountPointInfo mount_info(kEmptyDeviceLabel,
- mount_path1.value(),
- MOUNT_TYPE_DEVICE,
- disks::MOUNT_CONDITION_NONE);
- EXPECT_CALL(observer(), OnRemovableStorageAttached(
- GetDCIMDeviceId(kUniqueId1),
- ASCIIToUTF16(kDeviceNameWithManufacturerDetails),
- mount_path1.value()))
- .InSequence(mock_sequence);
- MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kEmptyDeviceLabel,
- kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
-
- EXPECT_EQ(kDevice1SizeInBytes, GetDeviceStorageSize(mount_path1.value()));
- EXPECT_CALL(observer(),
- OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId1)))
- .InSequence(mock_sequence);
- UnmountDevice(MOUNT_ERROR_NONE, mount_info);
-}
-
} // namespace
} // namespace chrome
« no previous file with comments | « chrome/browser/system_monitor/removable_device_notifications_chromeos.cc ('k') | chromeos/disks/mock_disk_mount_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698