Commit 4272e58f authored by gbillock@chromium.org's avatar gbillock@chromium.org

[MediaGalleries] Add temp dir adjustment in windows unit test.

This accounts for test environments that may have the TMP directory
on drives that aren't C:.

R=vandebo@chromium.org,ajwong@chromium.org
BUG=None

Review URL: https://chromiumcodereview.appspot.com/15767005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203086 0039d316-1c4b-4281-b951-d872f2087c98
parent a6ef1834
......@@ -151,7 +151,7 @@ void StorageMonitorWinTest::DoMassStorageDeviceAttachedTest(
volume_broadcast.dbcv_unitmask = 0x0;
volume_broadcast.dbcv_flags = 0x0;
int expect_attach_calls = 0;
int expect_attach_calls = observer_.attach_calls();
for (DeviceIndices::const_iterator it = device_indices.begin();
it != device_indices.end(); ++it) {
volume_broadcast.dbcv_unitmask |= 0x1 << *it;
......@@ -291,6 +291,7 @@ TEST_F(StorageMonitorWinTest, DevicesAttached) {
TEST_F(StorageMonitorWinTest, PathMountDevices) {
PreAttachDevices();
int init_storages = monitor_->GetAttachedStorage().size();
volume_mount_watcher_->AddDeviceForTesting(
base::FilePath(FILE_PATH_LITERAL("F:\\mount1")),
......@@ -302,7 +303,7 @@ TEST_F(StorageMonitorWinTest, PathMountDevices) {
base::FilePath(FILE_PATH_LITERAL("F:\\mount2")),
"dcim:mount2", L"mount2", 100);
RunUntilIdle();
EXPECT_EQ(9, monitor_->GetAttachedStorage().size());
EXPECT_EQ(init_storages + 3, monitor_->GetAttachedStorage().size());
StorageInfo info;
EXPECT_TRUE(monitor_->GetStorageInfoForPath(
......
......@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/files/file_path.h"
#include "base/files/scoped_temp_dir.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/storage_monitor/storage_info.h"
......@@ -16,9 +17,25 @@ namespace test {
namespace {
base::FilePath GetTempRoot() {
base::ScopedTempDir temp_dir;
temp_dir.CreateUniqueTempDir();
base::FilePath temp_root = temp_dir.path();
while (temp_root.DirName() != temp_root)
temp_root = temp_root.DirName();
return temp_root;
}
std::vector<base::FilePath> FakeGetSingleAttachedDevice() {
std::vector<base::FilePath> result;
result.push_back(VolumeMountWatcherWin::DriveNumberToFilePath(2)); // C
// Make sure we are adding the drive on which ScopedTempDir will make
// test directories.
base::FilePath temp_root = GetTempRoot();
if (temp_root != VolumeMountWatcherWin::DriveNumberToFilePath(2))
result.push_back(temp_root);
return result;
}
......@@ -51,7 +68,8 @@ bool GetMassStorageDeviceDetails(const base::FilePath& device_path,
StorageInfo::Type type = StorageInfo::FIXED_MASS_STORAGE;
if (path.value() != ASCIIToUTF16("N:\\") &&
path.value() != ASCIIToUTF16("C:\\")) {
path.value() != ASCIIToUTF16("C:\\") &&
path.value() != GetTempRoot().value()) {
type = StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM;
}
std::string unique_id =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment