| 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/gdata/gdata_cache_metadata.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_cache_metadata.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/scoped_temp_dir.h" | 8 #include "base/scoped_temp_dir.h" |
| 9 #include "chrome/browser/chromeos/gdata/gdata.pb.h" | 9 #include "chrome/browser/chromeos/gdata/gdata.pb.h" |
| 10 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" | 10 #include "chrome/browser/chromeos/gdata/gdata_test_util.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 pinned_directory_ = cache_paths_[GDataCache::CACHE_TYPE_PINNED]; | 28 pinned_directory_ = cache_paths_[GDataCache::CACHE_TYPE_PINNED]; |
| 29 outgoing_directory_ = cache_paths_[GDataCache::CACHE_TYPE_OUTGOING]; | 29 outgoing_directory_ = cache_paths_[GDataCache::CACHE_TYPE_OUTGOING]; |
| 30 } | 30 } |
| 31 | 31 |
| 32 virtual void TearDown() OVERRIDE { | 32 virtual void TearDown() OVERRIDE { |
| 33 metadata_.reset(); | 33 metadata_.reset(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 // Sets up the GDataCacheMetadata object. | 36 // Sets up the GDataCacheMetadata object. |
| 37 void SetUpCacheMetadata() { | 37 void SetUpCacheMetadata() { |
| 38 metadata_ = GDataCacheMetadata::CreateGDataCacheMetadata(NULL).Pass(); | 38 metadata_ = |
| 39 GDataCacheMetadata::CreateGDataCacheMetadata(NULL, false).Pass(); |
| 39 metadata_->Initialize(cache_paths_); | 40 metadata_->Initialize(cache_paths_); |
| 40 } | 41 } |
| 41 | 42 |
| 42 // Sets up the cache directories with various files, including stale | 43 // Sets up the cache directories with various files, including stale |
| 43 // symbolic links etc. Should be called before SetUpCacheMetadata(). | 44 // symbolic links etc. Should be called before SetUpCacheMetadata(). |
| 44 void SetUpCacheWithVariousFiles() { | 45 void SetUpCacheWithVariousFiles() { |
| 45 // Create some files in persistent directory. | 46 // Create some files in persistent directory. |
| 46 // | 47 // |
| 47 CreateFile(persistent_directory_.AppendASCII("id_foo.md5foo")); | 48 CreateFile(persistent_directory_.AppendASCII("id_foo.md5foo")); |
| 48 CreateFile(persistent_directory_.AppendASCII("id_bar.local")); | 49 CreateFile(persistent_directory_.AppendASCII("id_bar.local")); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 metadata_->RemoveTemporaryFiles(); | 383 metadata_->RemoveTemporaryFiles(); |
| 383 // resource 1 and 4 should be gone, as these are temporary. | 384 // resource 1 and 4 should be gone, as these are temporary. |
| 384 GDataCacheEntry cache_entry; | 385 GDataCacheEntry cache_entry; |
| 385 EXPECT_FALSE(metadata_->GetCacheEntry("<resource_id_1>", "", &cache_entry)); | 386 EXPECT_FALSE(metadata_->GetCacheEntry("<resource_id_1>", "", &cache_entry)); |
| 386 EXPECT_TRUE(metadata_->GetCacheEntry("<resource_id_2>", "", &cache_entry)); | 387 EXPECT_TRUE(metadata_->GetCacheEntry("<resource_id_2>", "", &cache_entry)); |
| 387 EXPECT_TRUE(metadata_->GetCacheEntry("<resource_id_3>", "", &cache_entry)); | 388 EXPECT_TRUE(metadata_->GetCacheEntry("<resource_id_3>", "", &cache_entry)); |
| 388 EXPECT_FALSE(metadata_->GetCacheEntry("<resource_id_4>", "", &cache_entry)); | 389 EXPECT_FALSE(metadata_->GetCacheEntry("<resource_id_4>", "", &cache_entry)); |
| 389 } | 390 } |
| 390 | 391 |
| 391 } // namespace gdata | 392 } // namespace gdata |
| OLD | NEW |