OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chrome/browser/chromeos/file_manager/file_manager_browsertest_base.h" | 5 #include "chrome/browser/chromeos/file_manager/file_manager_browsertest_base.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 | 10 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 } | 177 } |
178 | 178 |
179 // Test volume. | 179 // Test volume. |
180 class TestVolume { | 180 class TestVolume { |
181 protected: | 181 protected: |
182 explicit TestVolume(const std::string& name) : name_(name) {} | 182 explicit TestVolume(const std::string& name) : name_(name) {} |
183 virtual ~TestVolume() {} | 183 virtual ~TestVolume() {} |
184 | 184 |
185 bool CreateRootDirectory(const Profile* profile) { | 185 bool CreateRootDirectory(const Profile* profile) { |
186 const base::FilePath path = profile->GetPath().Append(name_); | 186 const base::FilePath path = profile->GetPath().Append(name_); |
187 return root_.path() == path || root_.Set(path); | 187 // Ensure that |path| is taken by |root_|. Cannot use |root_.GetPath()| to |
vabr (Chromium)
2016/09/07 15:55:06
I'm aware that this is a bit hacky.
I was tempted
| |
188 // check if it already is so, because GetPath checks that the current path | |
189 // is not empty. | |
190 base::FilePath current_root_path = root_.Take(); | |
191 if (!current_root_path.empty() && current_root_path != path) { | |
192 CHECK(root_.Set(current_root_path)); | |
193 return false; | |
194 } | |
195 return root_.Set(path); | |
188 } | 196 } |
189 | 197 |
190 const std::string& name() { return name_; } | 198 const std::string& name() { return name_; } |
191 const base::FilePath root_path() { return root_.path(); } | 199 const base::FilePath root_path() { return root_.GetPath(); } |
192 | 200 |
193 private: | 201 private: |
194 std::string name_; | 202 std::string name_; |
195 base::ScopedTempDir root_; | 203 base::ScopedTempDir root_; |
196 }; | 204 }; |
197 | 205 |
198 // Listener to obtain the test relative messages synchronously. | 206 // Listener to obtain the test relative messages synchronously. |
199 class FileManagerTestListener : public content::NotificationObserver { | 207 class FileManagerTestListener : public content::NotificationObserver { |
200 public: | 208 public: |
201 struct Message { | 209 struct Message { |
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
730 } | 738 } |
731 | 739 |
732 drive::DriveIntegrationService* | 740 drive::DriveIntegrationService* |
733 FileManagerBrowserTestBase::CreateDriveIntegrationService(Profile* profile) { | 741 FileManagerBrowserTestBase::CreateDriveIntegrationService(Profile* profile) { |
734 drive_volumes_[profile->GetOriginalProfile()].reset(new DriveTestVolume()); | 742 drive_volumes_[profile->GetOriginalProfile()].reset(new DriveTestVolume()); |
735 return drive_volumes_[profile->GetOriginalProfile()] | 743 return drive_volumes_[profile->GetOriginalProfile()] |
736 ->CreateDriveIntegrationService(profile); | 744 ->CreateDriveIntegrationService(profile); |
737 } | 745 } |
738 | 746 |
739 } // namespace file_manager | 747 } // namespace file_manager |
OLD | NEW |