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

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

Issue 11490010: [Media Galleries] Introduce a new type for Mac Image Capture. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix include Created 8 years 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/media_storage_util_unittest.cc
diff --git a/chrome/browser/system_monitor/media_storage_util_unittest.cc b/chrome/browser/system_monitor/media_storage_util_unittest.cc
index 175cb781cfaf37bded4fcec05b823e55f8535b15..de61f11a57c09ea43c8e2e16ecb2d0c121c96a03 100644
--- a/chrome/browser/system_monitor/media_storage_util_unittest.cc
+++ b/chrome/browser/system_monitor/media_storage_util_unittest.cc
@@ -4,7 +4,13 @@
#include <string>
+#include "base/message_loop.h"
+#include "base/synchronization/waitable_event.h"
+#include "base/system_monitor/system_monitor.h"
+#include "base/utf_string_conversions.h"
#include "chrome/browser/system_monitor/media_storage_util.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chrome {
@@ -37,4 +43,54 @@ TEST_F(MediaStorageUtilTest, CrackMtpDeviceId) {
ASSERT_EQ(MediaStorageUtil::MTP_OR_PTP, type);
}
+TEST_F(MediaStorageUtilTest, TestImageCaptureDeviceId) {
+ MediaStorageUtil::Type type;
+ std::string id;
+ EXPECT_TRUE(MediaStorageUtil::CrackDeviceId("ic:xyz", &type, &id));
Lei Zhang 2012/12/10 23:21:53 nit: replace "ic:xyz" with a constant. It's used a
Greg Billock 2012/12/11 00:11:22 Done.
Greg Billock 2012/12/11 00:11:22 Done.
+ EXPECT_EQ(MediaStorageUtil::MAC_IMAGE_CAPTURE, type);
+ EXPECT_EQ("xyz", id);
+}
+
+TEST_F(MediaStorageUtilTest, CanCreateFileSystemForImageCapture) {
+ EXPECT_TRUE(MediaStorageUtil::CanCreateFileSystem("ic:xyz", FilePath()));
+}
+
+void SignalEvent(base::WaitableEvent* event) {
+ event->Signal();
+}
+
+TEST_F(MediaStorageUtilTest, DetectDeviceFiltered) {
+ MessageLoop loop;
+#if defined(OS_MACOSX)
+ // This needs to happen before SystemMonitor's ctor.
+ base::SystemMonitor::AllocateSystemIOPorts();
+#endif
+ // Installs global. Required MessageLoop.
+ // On Mac, requires AllocateSystemIOPorts.
+ base::SystemMonitor monitor;
+
+ content::TestBrowserThread file_thread(content::BrowserThread::FILE, &loop);
+
+ MediaStorageUtil::DeviceIdSet devices;
+ devices.insert("ic:xyz");
+
+ base::WaitableEvent event(true, false);
+ MediaStorageUtil::FilterAttachedDevices(&devices,
+ base::Bind(&SignalEvent, &event));
+ loop.RunUntilIdle();
+ event.Wait();
+ EXPECT_FALSE(devices.find("ic:xyz") != devices.end());
+
+ base::SystemMonitor::Get()->ProcessRemovableStorageAttached(
+ "ic:xyz", ASCIIToUTF16("name"), "/location");
Lei Zhang 2012/12/10 23:21:53 |location| needs to be FILE_PATH_LITERAL("/locatio
Greg Billock 2012/12/11 00:11:22 Good catch. Done. On 2012/12/10 23:21:53, Lei Zhan
+ devices.insert("ic:xyz");
+ event.Reset();
+ MediaStorageUtil::FilterAttachedDevices(&devices,
+ base::Bind(&SignalEvent, &event));
+ loop.RunUntilIdle();
+ event.Wait();
+
+ EXPECT_TRUE(devices.find("ic:xyz") != devices.end());
+}
+
} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698