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

Side by Side Diff: components/storage_monitor/storage_monitor_linux_unittest.cc

Issue 1884743002: Convert a few components from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: lint Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/storage_monitor/storage_monitor_linux.h" 7 #include "components/storage_monitor/storage_monitor_linux.h"
8 8
9 #include <mntent.h> 9 #include <mntent.h>
10 #include <stddef.h> 10 #include <stddef.h>
11 #include <stdint.h> 11 #include <stdint.h>
12 #include <stdio.h> 12 #include <stdio.h>
13 13
14 #include <memory>
14 #include <string> 15 #include <string>
15 16
16 #include "base/files/file_util.h" 17 #include "base/files/file_util.h"
17 #include "base/files/scoped_temp_dir.h" 18 #include "base/files/scoped_temp_dir.h"
18 #include "base/logging.h" 19 #include "base/logging.h"
19 #include "base/macros.h" 20 #include "base/macros.h"
20 #include "base/memory/scoped_ptr.h"
21 #include "base/run_loop.h" 21 #include "base/run_loop.h"
22 #include "base/strings/utf_string_conversions.h" 22 #include "base/strings/utf_string_conversions.h"
23 #include "base/thread_task_runner_handle.h" 23 #include "base/thread_task_runner_handle.h"
24 #include "components/storage_monitor/mock_removable_storage_observer.h" 24 #include "components/storage_monitor/mock_removable_storage_observer.h"
25 #include "components/storage_monitor/removable_device_constants.h" 25 #include "components/storage_monitor/removable_device_constants.h"
26 #include "components/storage_monitor/storage_info.h" 26 #include "components/storage_monitor/storage_info.h"
27 #include "components/storage_monitor/storage_monitor.h" 27 #include "components/storage_monitor/storage_monitor.h"
28 #include "components/storage_monitor/test_media_transfer_protocol_manager_linux. h" 28 #include "components/storage_monitor/test_media_transfer_protocol_manager_linux. h"
29 #include "components/storage_monitor/test_storage_monitor.h" 29 #include "components/storage_monitor/test_storage_monitor.h"
30 #include "content/public/test/test_browser_thread_bundle.h" 30 #include "content/public/test/test_browser_thread_bundle.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM, 65 StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM,
66 8773 }, 66 8773 },
67 { kDeviceDCIM3, "VendorModelSerial:::WEM319X792", 67 { kDeviceDCIM3, "VendorModelSerial:::WEM319X792",
68 StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM, 22837 }, 68 StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM, 22837 },
69 { kDeviceNoDCIM, "UUID:ABCD-1234", 69 { kDeviceNoDCIM, "UUID:ABCD-1234",
70 StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM, 512 }, 70 StorageInfo::REMOVABLE_MASS_STORAGE_NO_DCIM, 512 },
71 { kDeviceFixed, "UUID:743A-2349", 71 { kDeviceFixed, "UUID:743A-2349",
72 StorageInfo::FIXED_MASS_STORAGE, 17282 }, 72 StorageInfo::FIXED_MASS_STORAGE, 17282 },
73 }; 73 };
74 74
75 scoped_ptr<StorageInfo> GetDeviceInfo(const base::FilePath& device_path, 75 std::unique_ptr<StorageInfo> GetDeviceInfo(const base::FilePath& device_path,
76 const base::FilePath& mount_point) { 76 const base::FilePath& mount_point) {
77 bool device_found = false; 77 bool device_found = false;
78 size_t i = 0; 78 size_t i = 0;
79 for (; i < arraysize(kTestDeviceData); i++) { 79 for (; i < arraysize(kTestDeviceData); i++) {
80 if (device_path.value() == kTestDeviceData[i].device_path) { 80 if (device_path.value() == kTestDeviceData[i].device_path) {
81 device_found = true; 81 device_found = true;
82 break; 82 break;
83 } 83 }
84 } 84 }
85 85
86 scoped_ptr<StorageInfo> storage_info; 86 std::unique_ptr<StorageInfo> storage_info;
87 if (!device_found) { 87 if (!device_found) {
88 NOTREACHED(); 88 NOTREACHED();
89 return storage_info; 89 return storage_info;
90 } 90 }
91 91
92 StorageInfo::Type type = kTestDeviceData[i].type; 92 StorageInfo::Type type = kTestDeviceData[i].type;
93 storage_info.reset(new StorageInfo( 93 storage_info.reset(new StorageInfo(
94 StorageInfo::MakeDeviceId(type, kTestDeviceData[i].unique_id), 94 StorageInfo::MakeDeviceId(type, kTestDeviceData[i].unique_id),
95 mount_point.value(), 95 mount_point.value(),
96 base::ASCIIToUTF16("volume label"), 96 base::ASCIIToUTF16("volume label"),
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 entry.mnt_fsname = const_cast<char*>(data[i].mount_device.c_str()); 297 entry.mnt_fsname = const_cast<char*>(data[i].mount_device.c_str());
298 entry.mnt_dir = const_cast<char*>(data[i].mount_point.c_str()); 298 entry.mnt_dir = const_cast<char*>(data[i].mount_point.c_str());
299 entry.mnt_type = const_cast<char*>(data[i].mount_type.c_str()); 299 entry.mnt_type = const_cast<char*>(data[i].mount_type.c_str());
300 ASSERT_EQ(0, addmntent(file, &entry)); 300 ASSERT_EQ(0, addmntent(file, &entry));
301 } 301 }
302 ASSERT_EQ(1, endmntent(file)); 302 ASSERT_EQ(1, endmntent(file));
303 } 303 }
304 304
305 content::TestBrowserThreadBundle thread_bundle_; 305 content::TestBrowserThreadBundle thread_bundle_;
306 306
307 scoped_ptr<MockRemovableStorageObserver> mock_storage_observer_; 307 std::unique_ptr<MockRemovableStorageObserver> mock_storage_observer_;
308 308
309 // Temporary directory for created test data. 309 // Temporary directory for created test data.
310 base::ScopedTempDir scoped_temp_dir_; 310 base::ScopedTempDir scoped_temp_dir_;
311 // Path to the test mtab file. 311 // Path to the test mtab file.
312 base::FilePath mtab_file_; 312 base::FilePath mtab_file_;
313 313
314 scoped_ptr<TestStorageMonitorLinux> monitor_; 314 std::unique_ptr<TestStorageMonitorLinux> monitor_;
315 315
316 DISALLOW_COPY_AND_ASSIGN(StorageMonitorLinuxTest); 316 DISALLOW_COPY_AND_ASSIGN(StorageMonitorLinuxTest);
317 }; 317 };
318 318
319 // Simple test case where we attach and detach a media device. 319 // Simple test case where we attach and detach a media device.
320 // http://crbug.com/526252 flaky 320 // http://crbug.com/526252 flaky
321 TEST_F(StorageMonitorLinuxTest, DISABLED_BasicAttachDetach) { 321 TEST_F(StorageMonitorLinuxTest, DISABLED_BasicAttachDetach) {
322 base::FilePath test_path = CreateMountPointWithDCIMDir(kMountPointA); 322 base::FilePath test_path = CreateMountPointWithDCIMDir(kMountPointA);
323 ASSERT_FALSE(test_path.empty()); 323 ASSERT_FALSE(test_path.empty());
324 MtabTestData test_data[] = { 324 MtabTestData test_data[] = {
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 GetStorageSize(test_path_a)); 680 GetStorageSize(test_path_a));
681 EXPECT_EQ(GetDevicePartitionSize(kDeviceNoDCIM), 681 EXPECT_EQ(GetDevicePartitionSize(kDeviceNoDCIM),
682 GetStorageSize(test_path_b)); 682 GetStorageSize(test_path_b));
683 EXPECT_EQ(GetDevicePartitionSize(kInvalidPath), 683 EXPECT_EQ(GetDevicePartitionSize(kInvalidPath),
684 GetStorageSize(base::FilePath(kInvalidPath))); 684 GetStorageSize(base::FilePath(kInvalidPath)));
685 } 685 }
686 686
687 } // namespace 687 } // namespace
688 688
689 } // namespace storage_monitor 689 } // namespace storage_monitor
OLDNEW
« no previous file with comments | « components/storage_monitor/storage_monitor_linux.cc ('k') | components/storage_monitor/storage_monitor_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698