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_cache_metadata.h" | 5 #include "chrome/browser/chromeos/drive/file_cache_metadata.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "chrome/browser/chromeos/drive/drive.pb.h" | 9 #include "chrome/browser/chromeos/drive/drive.pb.h" |
10 #include "chrome/browser/chromeos/drive/file_system_util.h" | 10 #include "chrome/browser/chromeos/drive/file_system_util.h" |
11 #include "chrome/browser/chromeos/drive/test_util.h" | 11 #include "chrome/browser/chromeos/drive/test_util.h" |
12 #include "chrome/browser/google_apis/test_util.h" | 12 #include "chrome/browser/google_apis/test_util.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace drive { | 15 namespace drive { |
16 namespace internal { | 16 namespace internal { |
17 | 17 |
18 class FileCacheMetadataTest : public testing::Test { | 18 class FileCacheMetadataTest : public testing::Test { |
19 public: | 19 public: |
20 FileCacheMetadataTest() {} | |
21 | |
22 virtual void SetUp() OVERRIDE { | 20 virtual void SetUp() OVERRIDE { |
23 // Create cache directories. | 21 // Create cache directories. |
24 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 22 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
25 metadata_.reset(new FileCacheMetadata(NULL)); | 23 metadata_.reset(new FileCacheMetadata(NULL)); |
26 } | 24 } |
27 | 25 |
28 virtual void TearDown() OVERRIDE { | |
29 metadata_.reset(); | |
30 } | |
31 | |
32 protected: | 26 protected: |
33 base::ScopedTempDir temp_dir_; | 27 base::ScopedTempDir temp_dir_; |
34 scoped_ptr<FileCacheMetadata> metadata_; | 28 scoped_ptr<FileCacheMetadata> metadata_; |
35 }; | 29 }; |
36 | 30 |
37 // Test all the methods of FileCacheMetadata except for | 31 // Test all the methods of FileCacheMetadata except for |
38 // RemoveTemporaryFiles. | 32 // RemoveTemporaryFiles. |
39 TEST_F(FileCacheMetadataTest, CacheTest) { | 33 TEST_F(FileCacheMetadataTest, CacheTest) { |
40 ASSERT_EQ(FileCacheMetadata::INITIALIZE_CREATED, | 34 ASSERT_EQ(FileCacheMetadata::INITIALIZE_CREATED, |
41 metadata_->Initialize(temp_dir_.path().AppendASCII("test.db"))); | 35 metadata_->Initialize(temp_dir_.path().AppendASCII("test.db"))); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // Try to open a nonexistent path. | 118 // Try to open a nonexistent path. |
125 base::FilePath non_existent_path(FILE_PATH_LITERAL( | 119 base::FilePath non_existent_path(FILE_PATH_LITERAL( |
126 "/somewhere/nonexistent/test.db")); | 120 "/somewhere/nonexistent/test.db")); |
127 metadata_.reset(new FileCacheMetadata(NULL)); | 121 metadata_.reset(new FileCacheMetadata(NULL)); |
128 EXPECT_EQ(FileCacheMetadata::INITIALIZE_FAILED, | 122 EXPECT_EQ(FileCacheMetadata::INITIALIZE_FAILED, |
129 metadata_->Initialize(non_existent_path)); | 123 metadata_->Initialize(non_existent_path)); |
130 } | 124 } |
131 | 125 |
132 } // namespace internal | 126 } // namespace internal |
133 } // namespace drive | 127 } // namespace drive |
OLD | NEW |