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

Unified Diff: base/system_monitor/system_monitor_unittest.cc

Issue 10780023: Change base::SystemMonitor's media device functions to take a type and string16 instead of a FilePa… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix win Created 8 years, 5 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: base/system_monitor/system_monitor_unittest.cc
===================================================================
--- base/system_monitor/system_monitor_unittest.cc (revision 146883)
+++ base/system_monitor/system_monitor_unittest.cc (working copy)
@@ -7,6 +7,7 @@
#include "base/file_path.h"
#include "base/message_loop.h"
#include "base/test/mock_devices_changed_observer.h"
+#include "base/utf_string_conversions.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -108,6 +109,7 @@
TEST_F(SystemMonitorTest, DeviceChangeNotifications) {
const int kObservers = 5;
+ const char kDeviceName[] = "media device";
testing::Sequence mock_sequencer[kObservers];
MockDevicesChangedObserver observers[kObservers];
@@ -117,8 +119,11 @@
EXPECT_CALL(observers[index], OnDevicesChanged())
.Times(3)
.InSequence(mock_sequencer[index]);
- EXPECT_CALL(observers[index], OnMediaDeviceAttached(1, "media device",
- testing::_))
+ EXPECT_CALL(observers[index],
+ OnMediaDeviceAttached(1,
+ kDeviceName,
+ base::SystemMonitor::TYPE_PATH,
+ testing::_))
.InSequence(mock_sequencer[index]);
EXPECT_CALL(observers[index], OnMediaDeviceDetached(1))
.InSequence(mock_sequencer[index]);
@@ -134,7 +139,10 @@
message_loop_.RunAllPending();
system_monitor_->ProcessMediaDeviceAttached(
- 1, "media device", FilePath(FILE_PATH_LITERAL("path")));
+ 1,
+ kDeviceName,
+ base::SystemMonitor::TYPE_PATH,
+ FILE_PATH_LITERAL("path"));
message_loop_.RunAllPending();
system_monitor_->ProcessMediaDeviceDetached(1);
@@ -151,33 +159,38 @@
TEST_F(SystemMonitorTest, GetAttachedMediaDevicesAttachDetach) {
const SystemMonitor::DeviceIdType kDeviceId1 = 42;
const char kDeviceName1[] = "test";
- const FilePath kDevicePath1(FILE_PATH_LITERAL("/testfoo"));
+ const string16 kDevicePath1(ASCIIToUTF16("/testfoo"));
system_monitor_->ProcessMediaDeviceAttached(kDeviceId1,
- kDeviceName1,
- kDevicePath1);
+ kDeviceName1,
+ base::SystemMonitor::TYPE_PATH,
+ kDevicePath1);
message_loop_.RunAllPending();
std::vector<SystemMonitor::MediaDeviceInfo> devices =
system_monitor_->GetAttachedMediaDevices();
ASSERT_EQ(1U, devices.size());
EXPECT_EQ(kDeviceId1, devices[0].a);
EXPECT_EQ(kDeviceName1, devices[0].b);
- EXPECT_EQ(kDevicePath1, devices[0].c);
+ EXPECT_EQ(base::SystemMonitor::TYPE_PATH, devices[0].c);
+ EXPECT_EQ(kDevicePath1, devices[0].d);
const SystemMonitor::DeviceIdType kDeviceId2 = 44;
const char kDeviceName2[] = "test2";
- const FilePath kDevicePath2(FILE_PATH_LITERAL("/testbar"));
+ const string16 kDevicePath2(ASCIIToUTF16("/testbar"));
system_monitor_->ProcessMediaDeviceAttached(kDeviceId2,
- kDeviceName2,
- kDevicePath2);
+ kDeviceName2,
+ base::SystemMonitor::TYPE_PATH,
+ kDevicePath2);
message_loop_.RunAllPending();
devices = system_monitor_->GetAttachedMediaDevices();
ASSERT_EQ(2U, devices.size());
EXPECT_EQ(kDeviceId1, devices[0].a);
EXPECT_EQ(kDeviceName1, devices[0].b);
- EXPECT_EQ(kDevicePath1, devices[0].c);
+ EXPECT_EQ(base::SystemMonitor::TYPE_PATH, devices[0].c);
+ EXPECT_EQ(kDevicePath1, devices[0].d);
EXPECT_EQ(kDeviceId2, devices[1].a);
EXPECT_EQ(kDeviceName2, devices[1].b);
- EXPECT_EQ(kDevicePath2, devices[1].c);
+ EXPECT_EQ(base::SystemMonitor::TYPE_PATH, devices[1].c);
+ EXPECT_EQ(kDevicePath2, devices[1].d);
system_monitor_->ProcessMediaDeviceDetached(kDeviceId1);
message_loop_.RunAllPending();
@@ -185,7 +198,8 @@
ASSERT_EQ(1U, devices.size());
EXPECT_EQ(kDeviceId2, devices[0].a);
EXPECT_EQ(kDeviceName2, devices[0].b);
- EXPECT_EQ(kDevicePath2, devices[0].c);
+ EXPECT_EQ(base::SystemMonitor::TYPE_PATH, devices[0].c);
+ EXPECT_EQ(kDevicePath2, devices[0].d);
system_monitor_->ProcessMediaDeviceDetached(kDeviceId2);
message_loop_.RunAllPending();

Powered by Google App Engine
This is Rietveld 408576698