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

Unified Diff: chrome/browser/media_gallery/media_device_notifications_linux_unittest.cc

Issue 10829384: SystemMonitor: Pull device type into the device id (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: typo Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media_gallery/media_device_notifications_linux_unittest.cc
diff --git a/chrome/browser/media_gallery/media_device_notifications_linux_unittest.cc b/chrome/browser/media_gallery/media_device_notifications_linux_unittest.cc
index a8caa2835ef40332281da798cd2d50052c2d9000..c2370ad0745ad3f432fad8aad632bbb485f9b9e0 100644
--- a/chrome/browser/media_gallery/media_device_notifications_linux_unittest.cc
+++ b/chrome/browser/media_gallery/media_device_notifications_linux_unittest.cc
@@ -19,6 +19,7 @@
#include "base/system_monitor/system_monitor.h"
#include "base/test/mock_devices_changed_observer.h"
#include "base/utf_string_conversions.h"
+#include "chrome/browser/media_gallery/media_storage_util.h"
#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -48,18 +49,22 @@ const char kDeviceLabel3[] = "TEST_USB_MODEL_3";
const char kMountPointA[] = "mnt_a";
const char kMountPointB[] = "mnt_b";
-bool GetDeviceInfo(const std::string& dev_path,
- std::string* id,
+std::string GetDCIMDeviceId(std::string unique_id) {
kmadhusu 2012/08/20 17:13:50 "const std::string&"
+ return chrome::MediaStorageUtil::MakeDeviceId(
+ chrome::MediaStorageUtil::USB_MASS_STORAGE_WITH_DCIM, unique_id);
+}
+
+bool GetDeviceInfo(const std::string& dev_path, std::string* id,
string16* name) {
std::string device_name;
if (dev_path == kDevice1) {
- *id = std::string(kDeviceId1);
+ *id = GetDCIMDeviceId(kDeviceId1);
device_name = kDeviceLabel1;
} else if (dev_path == kDevice2) {
- *id = std::string(kDeviceId2);
+ *id = GetDCIMDeviceId(kDeviceId2);
device_name = kDeviceLabel2;
} else if (dev_path == kDevice3) {
- *id = std::string(kDeviceId3);
+ *id = GetDCIMDeviceId(kDeviceId3);
device_name = kDeviceLabel3;
} else {
return false;
@@ -267,15 +272,14 @@ TEST_F(MediaDeviceNotificationsLinuxTest, BasicAttachDetach) {
};
// Only |kDevice2| should be attached, since |kDevice1| has a bad path.
EXPECT_CALL(observer(),
- OnMediaDeviceAttached(kDeviceId2,
+ OnMediaDeviceAttached(GetDCIMDeviceId(kDeviceId2),
ASCIIToUTF16(kDeviceLabel2),
- base::SystemMonitor::TYPE_PATH,
test_path.value()))
.InSequence(mock_sequence);
AppendToMtabAndRunLoop(test_data, arraysize(test_data));
// |kDevice2| should be detached here.
- EXPECT_CALL(observer(), OnMediaDeviceDetached(kDeviceId2))
+ EXPECT_CALL(observer(), OnMediaDeviceDetached(GetDCIMDeviceId(kDeviceId2)))
.InSequence(mock_sequence);
WriteEmptyMtabAndRunLoop();
}
@@ -290,9 +294,8 @@ TEST_F(MediaDeviceNotificationsLinuxTest, DCIM) {
};
// |kDevice1| should be attached as expected.
EXPECT_CALL(observer(),
- OnMediaDeviceAttached(kDeviceId1,
+ OnMediaDeviceAttached(GetDCIMDeviceId(kDeviceId1),
ASCIIToUTF16(kDeviceLabel1),
- base::SystemMonitor::TYPE_PATH,
test_path_a.value()))
.InSequence(mock_sequence);
AppendToMtabAndRunLoop(test_data1, arraysize(test_data1));
@@ -306,7 +309,7 @@ TEST_F(MediaDeviceNotificationsLinuxTest, DCIM) {
AppendToMtabAndRunLoop(test_data2, arraysize(test_data2));
// |kDevice1| should be detached as expected.
- EXPECT_CALL(observer(), OnMediaDeviceDetached(kDeviceId1))
+ EXPECT_CALL(observer(), OnMediaDeviceDetached(GetDCIMDeviceId(kDeviceId1)))
.InSequence(mock_sequence);
WriteEmptyMtabAndRunLoop();
}
@@ -325,7 +328,7 @@ TEST_F(MediaDeviceNotificationsLinuxTest, SwapMountPoints) {
MtabTestData(kDevice1, test_path_a.value(), kValidFS),
MtabTestData(kDevice2, test_path_b.value(), kValidFS),
};
- EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(2);
+ EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(2);
EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(0);
AppendToMtabAndRunLoop(test_data1, arraysize(test_data1));
@@ -337,12 +340,12 @@ TEST_F(MediaDeviceNotificationsLinuxTest, SwapMountPoints) {
MtabTestData(kDevice1, test_path_b.value(), kValidFS),
MtabTestData(kDevice2, test_path_a.value(), kValidFS),
};
- EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(2);
+ EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(2);
EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(2);
OverwriteMtabAndRunLoop(test_data2, arraysize(test_data2));
// Detach all devices.
- EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(0);
+ EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(0);
EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(2);
WriteEmptyMtabAndRunLoop();
}
@@ -361,7 +364,7 @@ TEST_F(MediaDeviceNotificationsLinuxTest, MultiDevicesMultiMountPoints) {
MtabTestData(kDevice1, test_path_a.value(), kValidFS),
MtabTestData(kDevice2, test_path_b.value(), kValidFS),
};
- EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(2);
+ EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(2);
EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(0);
AppendToMtabAndRunLoop(test_data1, arraysize(test_data1));
@@ -374,7 +377,7 @@ TEST_F(MediaDeviceNotificationsLinuxTest, MultiDevicesMultiMountPoints) {
MtabTestData test_data2[] = {
MtabTestData(kDevice1, test_path_b.value(), kValidFS),
};
- EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(1);
+ EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(1);
EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(2);
AppendToMtabAndRunLoop(test_data2, arraysize(test_data2));
@@ -386,7 +389,7 @@ TEST_F(MediaDeviceNotificationsLinuxTest, MultiDevicesMultiMountPoints) {
MtabTestData test_data3[] = {
MtabTestData(kDevice2, test_path_a.value(), kValidFS),
};
- EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(1);
+ EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(1);
EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(0);
AppendToMtabAndRunLoop(test_data3, arraysize(test_data3));
@@ -399,19 +402,19 @@ TEST_F(MediaDeviceNotificationsLinuxTest, MultiDevicesMultiMountPoints) {
MtabTestData(kDevice2, test_path_b.value(), kValidFS),
MtabTestData(kDevice1, test_path_b.value(), kValidFS),
};
- EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(0);
+ EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(0);
EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(1);
OverwriteMtabAndRunLoop(test_data4, arraysize(test_data4));
// Detach |kDevice1| from |kMountPointB|.
// kDevice1 -> kMountPointA
// kDevice2 -> kMountPointB
- EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(2);
+ EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(2);
EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(1);
OverwriteMtabAndRunLoop(test_data1, arraysize(test_data1));
// Detach all devices.
- EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(0);
+ EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(0);
EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(2);
WriteEmptyMtabAndRunLoop();
}
@@ -433,9 +436,8 @@ TEST_F(MediaDeviceNotificationsLinuxTest, MultiDevicesOneMountPoint) {
MtabTestData(kDevice1, test_path_b.value(), kValidFS),
};
EXPECT_CALL(observer(),
- OnMediaDeviceAttached(kDeviceId1,
+ OnMediaDeviceAttached(GetDCIMDeviceId(kDeviceId1),
ASCIIToUTF16(kDeviceLabel1),
- base::SystemMonitor::TYPE_PATH,
test_path_b.value()))
.Times(1);
EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(0);
@@ -452,18 +454,19 @@ TEST_F(MediaDeviceNotificationsLinuxTest, MultiDevicesOneMountPoint) {
MtabTestData test_data2[] = {
MtabTestData(kDevice3, test_path_b.value(), kValidFS),
};
- EXPECT_CALL(observer(), OnMediaDeviceDetached(kDeviceId1)).Times(1);
+ EXPECT_CALL(observer(), OnMediaDeviceDetached(GetDCIMDeviceId(kDeviceId1)))
+ .Times(1);
EXPECT_CALL(observer(),
- OnMediaDeviceAttached(kDeviceId3,
+ OnMediaDeviceAttached(GetDCIMDeviceId(kDeviceId3),
ASCIIToUTF16(kDeviceLabel3),
- base::SystemMonitor::TYPE_PATH,
test_path_b.value()))
.Times(1);
AppendToMtabAndRunLoop(test_data2, arraysize(test_data2));
// Detach all devices.
- EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(0);
- EXPECT_CALL(observer(), OnMediaDeviceDetached(kDeviceId3)).Times(1);
+ EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(0);
+ EXPECT_CALL(observer(), OnMediaDeviceDetached(GetDCIMDeviceId(kDeviceId3)))
+ .Times(1);
WriteEmptyMtabAndRunLoop();
}

Powered by Google App Engine
This is Rietveld 408576698