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

Side by Side Diff: chrome/browser/storage_monitor/storage_monitor_linux_unittest.cc

Issue 100573002: Move directory creation functions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // StorageMonitorLinux unit tests. 5 // StorageMonitorLinux unit tests.
6 6
7 #include "chrome/browser/storage_monitor/storage_monitor_linux.h" 7 #include "chrome/browser/storage_monitor/storage_monitor_linux.h"
8 8
9 #include <mntent.h> 9 #include <mntent.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 StorageMonitorLinuxTest() 159 StorageMonitorLinuxTest()
160 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {} 160 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {}
161 virtual ~StorageMonitorLinuxTest() {} 161 virtual ~StorageMonitorLinuxTest() {}
162 162
163 protected: 163 protected:
164 virtual void SetUp() OVERRIDE { 164 virtual void SetUp() OVERRIDE {
165 // Create and set up a temp dir with files for the test. 165 // Create and set up a temp dir with files for the test.
166 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); 166 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir());
167 base::FilePath test_dir = scoped_temp_dir_.path().AppendASCII("test_etc"); 167 base::FilePath test_dir = scoped_temp_dir_.path().AppendASCII("test_etc");
168 ASSERT_TRUE(file_util::CreateDirectory(test_dir)); 168 ASSERT_TRUE(base::CreateDirectory(test_dir));
169 mtab_file_ = test_dir.AppendASCII("test_mtab"); 169 mtab_file_ = test_dir.AppendASCII("test_mtab");
170 MtabTestData initial_test_data[] = { 170 MtabTestData initial_test_data[] = {
171 MtabTestData("dummydevice", "dummydir", kInvalidFS), 171 MtabTestData("dummydevice", "dummydir", kInvalidFS),
172 }; 172 };
173 WriteToMtab(initial_test_data, 173 WriteToMtab(initial_test_data,
174 arraysize(initial_test_data), 174 arraysize(initial_test_data),
175 true /* overwrite */); 175 true /* overwrite */);
176 176
177 TestStorageMonitor::RemoveSingleton(); 177 TestStorageMonitor::RemoveSingleton();
178 monitor_ = new TestStorageMonitorLinux(mtab_file_); 178 monitor_ = new TestStorageMonitorLinux(mtab_file_);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // Set |with_dcim_dir| to true if the created directory will have a "DCIM" 259 // Set |with_dcim_dir| to true if the created directory will have a "DCIM"
260 // subdirectory. 260 // subdirectory.
261 // Returns the full path to the created directory on success, or an empty 261 // Returns the full path to the created directory on success, or an empty
262 // path on failure. 262 // path on failure.
263 base::FilePath CreateMountPoint(const std::string& dir, bool with_dcim_dir) { 263 base::FilePath CreateMountPoint(const std::string& dir, bool with_dcim_dir) {
264 base::FilePath return_path(scoped_temp_dir_.path()); 264 base::FilePath return_path(scoped_temp_dir_.path());
265 return_path = return_path.AppendASCII(dir); 265 return_path = return_path.AppendASCII(dir);
266 base::FilePath path(return_path); 266 base::FilePath path(return_path);
267 if (with_dcim_dir) 267 if (with_dcim_dir)
268 path = path.Append(kDCIMDirectoryName); 268 path = path.Append(kDCIMDirectoryName);
269 if (!file_util::CreateDirectory(path)) 269 if (!base::CreateDirectory(path))
270 return base::FilePath(); 270 return base::FilePath();
271 return return_path; 271 return return_path;
272 } 272 }
273 273
274 // Write the test mtab data to |mtab_file_|. 274 // Write the test mtab data to |mtab_file_|.
275 // |data| is an array of mtab entries. 275 // |data| is an array of mtab entries.
276 // |data_size| is the array size of |data|. 276 // |data_size| is the array size of |data|.
277 // |overwrite| specifies whether to overwrite |mtab_file_|. 277 // |overwrite| specifies whether to overwrite |mtab_file_|.
278 void WriteToMtab(const MtabTestData* data, 278 void WriteToMtab(const MtabTestData* data,
279 size_t data_size, 279 size_t data_size,
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 679
680 EXPECT_EQ(GetDevicePartitionSize(kDeviceDCIM1), 680 EXPECT_EQ(GetDevicePartitionSize(kDeviceDCIM1),
681 GetStorageSize(test_path_a)); 681 GetStorageSize(test_path_a));
682 EXPECT_EQ(GetDevicePartitionSize(kDeviceNoDCIM), 682 EXPECT_EQ(GetDevicePartitionSize(kDeviceNoDCIM),
683 GetStorageSize(test_path_b)); 683 GetStorageSize(test_path_b));
684 EXPECT_EQ(GetDevicePartitionSize(kInvalidPath), 684 EXPECT_EQ(GetDevicePartitionSize(kInvalidPath),
685 GetStorageSize(base::FilePath(kInvalidPath))); 685 GetStorageSize(base::FilePath(kInvalidPath)));
686 } 686 }
687 687
688 } // namespace 688 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698