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 <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/threading/sequenced_worker_pool.h" | 11 #include "base/threading/sequenced_worker_pool.h" |
12 #include "chrome/browser/chromeos/gdata/drive.pb.h" | 12 #include "chrome/browser/chromeos/gdata/drive.pb.h" |
13 #include "chrome/browser/chromeos/gdata/drive_cache.h" | 13 #include "chrome/browser/chromeos/gdata/drive_cache.h" |
14 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" | 14 #include "chrome/browser/chromeos/gdata/drive_file_system.h" |
15 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" | 15 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" |
16 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 16 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
17 #include "chrome/browser/chromeos/gdata/mock_drive_cache_observer.h" | 17 #include "chrome/browser/chromeos/gdata/mock_drive_cache_observer.h" |
18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
19 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
20 #include "content/public/test/test_browser_thread.h" | 20 #include "content/public/test/test_browser_thread.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 | 23 |
24 using ::testing::AtLeast; | 24 using ::testing::AtLeast; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 ASSERT_TRUE(file_util::CreateDirectory( | 177 ASSERT_TRUE(file_util::CreateDirectory( |
178 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_PERSISTENT))); | 178 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_PERSISTENT))); |
179 ASSERT_TRUE(file_util::CreateDirectory( | 179 ASSERT_TRUE(file_util::CreateDirectory( |
180 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_TMP))); | 180 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_TMP))); |
181 ASSERT_TRUE(file_util::CreateDirectory( | 181 ASSERT_TRUE(file_util::CreateDirectory( |
182 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_PINNED))); | 182 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_PINNED))); |
183 ASSERT_TRUE(file_util::CreateDirectory( | 183 ASSERT_TRUE(file_util::CreateDirectory( |
184 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_OUTGOING))); | 184 cache_->GetCacheDirectoryPath(DriveCache::CACHE_TYPE_OUTGOING))); |
185 | 185 |
186 // Dump some files into cache dirs so that | 186 // Dump some files into cache dirs so that |
187 // GDataFileSystem::InitializeCacheOnBlockingPool would scan through them | 187 // DriveFileSystem::InitializeCacheOnBlockingPool would scan through them |
188 // and populate cache map accordingly. | 188 // and populate cache map accordingly. |
189 | 189 |
190 // Copy files from data dir to cache dir to act as cached files. | 190 // Copy files from data dir to cache dir to act as cached files. |
191 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(initial_cache_resources); ++i) { | 191 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(initial_cache_resources); ++i) { |
192 const struct InitialCacheResource& resource = initial_cache_resources[i]; | 192 const struct InitialCacheResource& resource = initial_cache_resources[i]; |
193 // Determine gdata cache file absolute path according to cache state. | 193 // Determine gdata cache file absolute path according to cache state. |
194 FilePath dest_path = cache_->GetCacheFilePath( | 194 FilePath dest_path = cache_->GetCacheFilePath( |
195 resource.resource_id, | 195 resource.resource_id, |
196 resource.md5, | 196 resource.md5, |
197 test_util::ToCacheEntry(resource.cache_state).is_pinned() || | 197 test_util::ToCacheEntry(resource.cache_state).is_pinned() || |
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 test_util::TEST_CACHE_STATE_NONE, | 1558 test_util::TEST_CACHE_STATE_NONE, |
1559 DriveCache::CACHE_TYPE_TMP); | 1559 DriveCache::CACHE_TYPE_TMP); |
1560 EXPECT_EQ(1, num_callback_invocations_); | 1560 EXPECT_EQ(1, num_callback_invocations_); |
1561 | 1561 |
1562 // Verify that there's no files added. | 1562 // Verify that there's no files added. |
1563 EXPECT_EQ(0U, CountCacheFiles(resource_id, md5)); | 1563 EXPECT_EQ(0U, CountCacheFiles(resource_id, md5)); |
1564 } | 1564 } |
1565 | 1565 |
1566 | 1566 |
1567 } // namespace gdata | 1567 } // namespace gdata |
OLD | NEW |