OLD | NEW |
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 #include "chrome/browser/chromeos/drive/file_system.h" | 5 #include "chrome/browser/chromeos/drive/file_system.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 (*counter)++; | 52 (*counter)++; |
53 if (*counter >= expected_counter) | 53 if (*counter >= expected_counter) |
54 quit.Run(); | 54 quit.Run(); |
55 } | 55 } |
56 | 56 |
57 // This class is used to record directory changes and examine them later. | 57 // This class is used to record directory changes and examine them later. |
58 class MockDirectoryChangeObserver : public FileSystemObserver { | 58 class MockDirectoryChangeObserver : public FileSystemObserver { |
59 public: | 59 public: |
60 MockDirectoryChangeObserver() {} | 60 MockDirectoryChangeObserver() {} |
61 virtual ~MockDirectoryChangeObserver() {} | 61 ~MockDirectoryChangeObserver() override {} |
62 | 62 |
63 // FileSystemObserver overrides. | 63 // FileSystemObserver overrides. |
64 virtual void OnDirectoryChanged( | 64 void OnDirectoryChanged(const base::FilePath& directory_path) override { |
65 const base::FilePath& directory_path) override { | |
66 changed_directories_.push_back(directory_path); | 65 changed_directories_.push_back(directory_path); |
67 } | 66 } |
68 | 67 |
69 virtual void OnFileChanged(const FileChange& new_file_change) override { | 68 void OnFileChanged(const FileChange& new_file_change) override { |
70 changed_files_.Apply(new_file_change); | 69 changed_files_.Apply(new_file_change); |
71 } | 70 } |
72 | 71 |
73 const std::vector<base::FilePath>& changed_directories() const { | 72 const std::vector<base::FilePath>& changed_directories() const { |
74 return changed_directories_; | 73 return changed_directories_; |
75 } | 74 } |
76 | 75 |
77 const FileChange& changed_files() const { return changed_files_; } | 76 const FileChange& changed_files() const { return changed_files_; } |
78 | 77 |
79 private: | 78 private: |
80 std::vector<base::FilePath> changed_directories_; | 79 std::vector<base::FilePath> changed_directories_; |
81 FileChange changed_files_; | 80 FileChange changed_files_; |
82 DISALLOW_COPY_AND_ASSIGN(MockDirectoryChangeObserver); | 81 DISALLOW_COPY_AND_ASSIGN(MockDirectoryChangeObserver); |
83 }; | 82 }; |
84 | 83 |
85 } // namespace | 84 } // namespace |
86 | 85 |
87 class FileSystemTest : public testing::Test { | 86 class FileSystemTest : public testing::Test { |
88 protected: | 87 protected: |
89 virtual void SetUp() override { | 88 void SetUp() override { |
90 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 89 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
91 pref_service_.reset(new TestingPrefServiceSimple); | 90 pref_service_.reset(new TestingPrefServiceSimple); |
92 test_util::RegisterDrivePrefs(pref_service_->registry()); | 91 test_util::RegisterDrivePrefs(pref_service_->registry()); |
93 | 92 |
94 logger_.reset(new EventLogger); | 93 logger_.reset(new EventLogger); |
95 fake_drive_service_.reset(new FakeDriveService); | 94 fake_drive_service_.reset(new FakeDriveService); |
96 test_util::SetUpTestEntries(fake_drive_service_.get()); | 95 test_util::SetUpTestEntries(fake_drive_service_.get()); |
97 | 96 |
98 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter); | 97 fake_free_disk_space_getter_.reset(new FakeFreeDiskSpaceGetter); |
99 | 98 |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 kEmbedOrigin, | 965 kEmbedOrigin, |
967 google_apis::test_util::CreateCopyResultCallback(&error, &share_url)); | 966 google_apis::test_util::CreateCopyResultCallback(&error, &share_url)); |
968 content::RunAllBlockingPoolTasksUntilIdle(); | 967 content::RunAllBlockingPoolTasksUntilIdle(); |
969 | 968 |
970 // Verify the share url to the sharing dialog. | 969 // Verify the share url to the sharing dialog. |
971 EXPECT_EQ(FILE_ERROR_OK, error); | 970 EXPECT_EQ(FILE_ERROR_OK, error); |
972 EXPECT_TRUE(share_url.is_valid()); | 971 EXPECT_TRUE(share_url.is_valid()); |
973 } | 972 } |
974 | 973 |
975 } // namespace drive | 974 } // namespace drive |
OLD | NEW |