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

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

Issue 684513002: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 1 month 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 <stdio.h> 10 #include <stdio.h>
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 119 }
120 120
121 class TestStorageMonitorLinux : public StorageMonitorLinux { 121 class TestStorageMonitorLinux : public StorageMonitorLinux {
122 public: 122 public:
123 explicit TestStorageMonitorLinux(const base::FilePath& path) 123 explicit TestStorageMonitorLinux(const base::FilePath& path)
124 : StorageMonitorLinux(path) { 124 : StorageMonitorLinux(path) {
125 SetMediaTransferProtocolManagerForTest( 125 SetMediaTransferProtocolManagerForTest(
126 new TestMediaTransferProtocolManagerLinux()); 126 new TestMediaTransferProtocolManagerLinux());
127 SetGetDeviceInfoCallbackForTest(base::Bind(&GetDeviceInfo)); 127 SetGetDeviceInfoCallbackForTest(base::Bind(&GetDeviceInfo));
128 } 128 }
129 virtual ~TestStorageMonitorLinux() {} 129 ~TestStorageMonitorLinux() override {}
130 130
131 private: 131 private:
132 virtual void UpdateMtab( 132 void UpdateMtab(
133 const MtabWatcherLinux::MountPointDeviceMap& new_mtab) override { 133 const MtabWatcherLinux::MountPointDeviceMap& new_mtab) override {
134 StorageMonitorLinux::UpdateMtab(new_mtab); 134 StorageMonitorLinux::UpdateMtab(new_mtab);
135 base::MessageLoopProxy::current()->PostTask( 135 base::MessageLoopProxy::current()->PostTask(
136 FROM_HERE, base::MessageLoop::QuitClosure()); 136 FROM_HERE, base::MessageLoop::QuitClosure());
137 } 137 }
138 138
139 DISALLOW_COPY_AND_ASSIGN(TestStorageMonitorLinux); 139 DISALLOW_COPY_AND_ASSIGN(TestStorageMonitorLinux);
140 }; 140 };
141 141
142 class StorageMonitorLinuxTest : public testing::Test { 142 class StorageMonitorLinuxTest : public testing::Test {
143 public: 143 public:
144 struct MtabTestData { 144 struct MtabTestData {
145 MtabTestData(const std::string& mount_device, 145 MtabTestData(const std::string& mount_device,
146 const std::string& mount_point, 146 const std::string& mount_point,
147 const std::string& mount_type) 147 const std::string& mount_type)
148 : mount_device(mount_device), 148 : mount_device(mount_device),
149 mount_point(mount_point), 149 mount_point(mount_point),
150 mount_type(mount_type) { 150 mount_type(mount_type) {
151 } 151 }
152 152
153 const std::string mount_device; 153 const std::string mount_device;
154 const std::string mount_point; 154 const std::string mount_point;
155 const std::string mount_type; 155 const std::string mount_type;
156 }; 156 };
157 157
158 StorageMonitorLinuxTest() 158 StorageMonitorLinuxTest()
159 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {} 159 : thread_bundle_(content::TestBrowserThreadBundle::IO_MAINLOOP) {}
160 virtual ~StorageMonitorLinuxTest() {} 160 ~StorageMonitorLinuxTest() override {}
161 161
162 protected: 162 protected:
163 virtual void SetUp() override { 163 void SetUp() override {
164 // Create and set up a temp dir with files for the test. 164 // Create and set up a temp dir with files for the test.
165 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); 165 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir());
166 base::FilePath test_dir = scoped_temp_dir_.path().AppendASCII("test_etc"); 166 base::FilePath test_dir = scoped_temp_dir_.path().AppendASCII("test_etc");
167 ASSERT_TRUE(base::CreateDirectory(test_dir)); 167 ASSERT_TRUE(base::CreateDirectory(test_dir));
168 mtab_file_ = test_dir.AppendASCII("test_mtab"); 168 mtab_file_ = test_dir.AppendASCII("test_mtab");
169 MtabTestData initial_test_data[] = { 169 MtabTestData initial_test_data[] = {
170 MtabTestData("dummydevice", "dummydir", kInvalidFS), 170 MtabTestData("dummydevice", "dummydir", kInvalidFS),
171 }; 171 };
172 WriteToMtab(initial_test_data, 172 WriteToMtab(initial_test_data,
173 arraysize(initial_test_data), 173 arraysize(initial_test_data),
174 true /* overwrite */); 174 true /* overwrite */);
175 175
176 monitor_.reset(new TestStorageMonitorLinux(mtab_file_)); 176 monitor_.reset(new TestStorageMonitorLinux(mtab_file_));
177 177
178 mock_storage_observer_.reset(new MockRemovableStorageObserver); 178 mock_storage_observer_.reset(new MockRemovableStorageObserver);
179 monitor_->AddObserver(mock_storage_observer_.get()); 179 monitor_->AddObserver(mock_storage_observer_.get());
180 180
181 monitor_->Init(); 181 monitor_->Init();
182 base::RunLoop().RunUntilIdle(); 182 base::RunLoop().RunUntilIdle();
183 } 183 }
184 184
185 virtual void TearDown() override { 185 void TearDown() override {
186 base::RunLoop().RunUntilIdle(); 186 base::RunLoop().RunUntilIdle();
187 monitor_->RemoveObserver(mock_storage_observer_.get()); 187 monitor_->RemoveObserver(mock_storage_observer_.get());
188 base::RunLoop().RunUntilIdle(); 188 base::RunLoop().RunUntilIdle();
189 189
190 // Linux storage monitor must be destroyed on the UI thread, so do it here. 190 // Linux storage monitor must be destroyed on the UI thread, so do it here.
191 monitor_.reset(); 191 monitor_.reset();
192 } 192 }
193 193
194 // Append mtab entries from the |data| array of size |data_size| to the mtab 194 // Append mtab entries from the |data| array of size |data_size| to the mtab
195 // file, and run the message loop. 195 // file, and run the message loop.
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
668 GetStorageSize(test_path_a)); 668 GetStorageSize(test_path_a));
669 EXPECT_EQ(GetDevicePartitionSize(kDeviceNoDCIM), 669 EXPECT_EQ(GetDevicePartitionSize(kDeviceNoDCIM),
670 GetStorageSize(test_path_b)); 670 GetStorageSize(test_path_b));
671 EXPECT_EQ(GetDevicePartitionSize(kInvalidPath), 671 EXPECT_EQ(GetDevicePartitionSize(kInvalidPath),
672 GetStorageSize(base::FilePath(kInvalidPath))); 672 GetStorageSize(base::FilePath(kInvalidPath)));
673 } 673 }
674 674
675 } // namespace 675 } // namespace
676 676
677 } // namespace storage_monitor 677 } // namespace storage_monitor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698