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

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: 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..160fe4e293be585af783c5405f1ec69b31c724fe 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"
@@ -69,6 +70,11 @@ bool GetDeviceInfo(const std::string& dev_path,
return true;
}
+std::string GetDCIMDeviceId(std::string unique_id) {
+ return chrome::MediaStorageUtil::MakeDeviceId(
+ chrome::MediaStorageUtil::USB_MASS_STORAGE_WITH_DCIM, unique_id);
+}
+
class MediaDeviceNotificationsLinuxTestWrapper
: public MediaDeviceNotificationsLinux {
public:
@@ -267,15 +273,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 +295,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 +310,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 +329,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 +341,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 +365,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 +378,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 +390,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 +403,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 +437,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 +455,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