| Index: chrome/browser/extensions/api/image_writer_private/removable_storage_provider_mac_unittest.cc
|
| diff --git a/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_mac_unittest.cc b/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_mac_unittest.cc
|
| index 728d7bd0a6e24498f63bd3be4544803e5c45d621..fb75d0d05a8df2699ac538f9914ac0068e3fee77 100644
|
| --- a/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_mac_unittest.cc
|
| +++ b/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_mac_unittest.cc
|
| @@ -2,15 +2,13 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include <IOKit/storage/IOStorageProtocolCharacteristics.h>
|
| -
|
| #include "base/bind.h"
|
| #include "base/message_loop/message_loop_proxy.h"
|
| #include "base/run_loop.h"
|
| -#include "base/strings/sys_string_conversions.h"
|
| #include "base/threading/thread.h"
|
| #include "chrome/browser/extensions/api/image_writer_private/removable_storage_provider_mac.h"
|
| #include "chrome/browser/extensions/api/image_writer_private/test_utils.h"
|
| +#include "chrome/common/extensions/image_writer_test_util_mac.h"
|
| #include "content/public/test/test_browser_thread_bundle.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -35,11 +33,6 @@ class RemovableStorageProviderMacPeer {
|
| void ProcessDisk(base::ScopedCFTypeRef<CFDictionaryRef> dict) {
|
| peer_->ProcessDisk(dict);
|
| }
|
| - // runs |DiskIsValidTarget| on the |DAWrapper|.
|
| - static bool DiskIsValidTarget(CFDictionaryRef dict) {
|
| - return RemovableStorageProviderMac::DiskIsValidTarget(dict);
|
| - }
|
| -
|
| private:
|
| RemovableStorageProviderMac* peer_;
|
| };
|
| @@ -129,13 +122,19 @@ class RemovableStorageProviderMacUnitTest : public testing::Test {
|
| "Fixed Vendor",
|
| "Fixed Model",
|
| (int64)1 << 40,
|
| - DriveType::FIXED);
|
| + image_writer::DriveType::FIXED);
|
| cd_drive_ = CreateDiskDictionary(
|
| - "disk1", "CD Vendor", "CD Model", 0, DriveType::CD);
|
| - usb_stick_ = CreateDiskDictionary(
|
| - "disk2", "USB Vendor", "USB Model", (int64)1 << 32, DriveType::USB);
|
| - sd_card_ = CreateDiskDictionary(
|
| - "disk3", "SD Vendor", "SD Model", (int64)1 << 33, DriveType::SD);
|
| + "disk1", "CD Vendor", "CD Model", 0, image_writer::DriveType::CD);
|
| + usb_stick_ = CreateDiskDictionary("disk2",
|
| + "USB Vendor",
|
| + "USB Model",
|
| + (int64)1 << 32,
|
| + image_writer::DriveType::USB);
|
| + sd_card_ = CreateDiskDictionary("disk3",
|
| + "SD Vendor",
|
| + "SD Model",
|
| + (int64)1 << 33,
|
| + image_writer::DriveType::SD);
|
| }
|
|
|
| virtual void TearDown() OVERRIDE {}
|
| @@ -168,118 +167,11 @@ class RemovableStorageProviderMacUnitTest : public testing::Test {
|
| base::ScopedCFTypeRef<CFDictionaryRef> cd_drive_;
|
|
|
| private:
|
| - // The different types of disks we want to configure.
|
| - typedef enum DriveType {
|
| - FIXED,
|
| - USB,
|
| - SD,
|
| - CD,
|
| - } DriveType;
|
| -
|
| - // Creates a disk-description dictionary.
|
| - base::ScopedCFTypeRef<CFDictionaryRef> CreateDiskDictionary(
|
| - const std::string& bsd_name,
|
| - const std::string& vendor,
|
| - const std::string& model,
|
| - int64 capacity,
|
| - DriveType type) {
|
| - base::ScopedCFTypeRef<CFMutableDictionaryRef> dict(
|
| - CFDictionaryCreateMutable(kCFAllocatorDefault,
|
| - 0,
|
| - &kCFTypeDictionaryKeyCallBacks,
|
| - &kCFTypeDictionaryValueCallBacks));
|
| -
|
| - CFDictionaryAddValue(dict,
|
| - kDADiskDescriptionMediaBSDNameKey,
|
| - base::SysUTF8ToCFStringRef(bsd_name));
|
| - CFDictionaryAddValue(dict,
|
| - kDADiskDescriptionDeviceVendorKey,
|
| - base::SysUTF8ToCFStringRef(vendor));
|
| - CFDictionaryAddValue(dict,
|
| - kDADiskDescriptionDeviceModelKey,
|
| - base::SysUTF8ToCFStringRef(model));
|
| - CFDictionaryAddValue(dict, kDADiskDescriptionMediaWholeKey, kCFBooleanTrue);
|
| - CFDictionaryAddValue(
|
| - dict,
|
| - kDADiskDescriptionMediaSizeKey,
|
| - CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &capacity));
|
| -
|
| - if (type == DriveType::FIXED) {
|
| - CFDictionaryAddValue(dict,
|
| - kDADiskDescriptionDeviceProtocolKey,
|
| - CFSTR(kIOPropertyPhysicalInterconnectTypeSerialATA));
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionDeviceInternalKey, kCFBooleanTrue);
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionMediaEjectableKey, kCFBooleanFalse);
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionMediaRemovableKey, kCFBooleanFalse);
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionMediaKindKey, CFSTR("IOMedia"));
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionDevicePathKey, CFSTR("Fixed Device Path"));
|
| - } else if (type == DriveType::USB) {
|
| - CFDictionaryAddValue(dict,
|
| - kDADiskDescriptionDeviceProtocolKey,
|
| - CFSTR(kIOPropertyPhysicalInterconnectTypeUSB));
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionDeviceInternalKey, kCFBooleanFalse);
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionMediaEjectableKey, kCFBooleanTrue);
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionMediaRemovableKey, kCFBooleanTrue);
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionMediaKindKey, CFSTR("IOMedia"));
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionDevicePathKey, CFSTR("USB Device Path"));
|
| - } else if (type == DriveType::CD) {
|
| - CFDictionaryAddValue(dict,
|
| - kDADiskDescriptionDeviceProtocolKey,
|
| - CFSTR(kIOPropertyPhysicalInterconnectTypeSerialATA));
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionDeviceInternalKey, kCFBooleanFalse);
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionMediaEjectableKey, kCFBooleanTrue);
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionMediaRemovableKey, kCFBooleanTrue);
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionMediaKindKey, CFSTR("IOCDMedia"));
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionDevicePathKey, CFSTR("CD Device Path"));
|
| - } else if (type == DriveType::SD) {
|
| - CFDictionaryAddValue(dict,
|
| - kDADiskDescriptionDeviceProtocolKey,
|
| - CFSTR(kIOPropertyPhysicalInterconnectTypeUSB));
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionDeviceInternalKey, kCFBooleanTrue);
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionMediaEjectableKey, kCFBooleanTrue);
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionMediaRemovableKey, kCFBooleanTrue);
|
| - CFDictionaryAddValue(
|
| - dict, kDADiskDescriptionMediaKindKey, CFSTR("IOMedia"));
|
| - CFDictionaryAddValue(dict,
|
| - kDADiskDescriptionDevicePathKey,
|
| - CFSTR("SD Device Path e.g. AppleUSBCardReader"));
|
| - }
|
| -
|
| - return base::ScopedCFTypeRef<CFDictionaryRef>(dict,
|
| - base::scoped_policy::RETAIN);
|
| - }
|
| -
|
| content::TestBrowserThreadBundle thread_bundle_;
|
| };
|
|
|
| } // namespace
|
|
|
| -// Tests DiskIsValidTarget.
|
| -TEST_F(RemovableStorageProviderMacUnitTest, DiskIsValidTarget) {
|
| - ASSERT_FALSE(RemovableStorageProviderMacPeer::DiskIsValidTarget(fixed_disk_));
|
| - ASSERT_FALSE(RemovableStorageProviderMacPeer::DiskIsValidTarget(cd_drive_));
|
| - ASSERT_TRUE(RemovableStorageProviderMacPeer::DiskIsValidTarget(usb_stick_));
|
| - ASSERT_TRUE(RemovableStorageProviderMacPeer::DiskIsValidTarget(sd_card_));
|
| -}
|
| -
|
| // Tests ProcessDisk and AddDisk.
|
| TEST_F(RemovableStorageProviderMacUnitTest, ProcessDisks) {
|
| RemovableStorageProviderMac storage_provider;
|
|
|