OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 public: | 34 public: |
35 virtual void SetUp() { | 35 virtual void SetUp() { |
36 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 36 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
37 } | 37 } |
38 | 38 |
39 protected: | 39 protected: |
40 std::string GetUsername() { | 40 std::string GetUsername() { |
41 return "nick@chromium.org"; | 41 return "nick@chromium.org"; |
42 } | 42 } |
43 | 43 |
44 FilePath GetDatabasePath() { | 44 base::FilePath GetDatabasePath() { |
45 return temp_dir_.path().Append(Directory::kSyncDatabaseFilename); | 45 return temp_dir_.path().Append(Directory::kSyncDatabaseFilename); |
46 } | 46 } |
47 | 47 |
48 static bool LoadAndIgnoreReturnedData(DirectoryBackingStore *dbs) { | 48 static bool LoadAndIgnoreReturnedData(DirectoryBackingStore *dbs) { |
49 MetahandlesIndex metas; | 49 MetahandlesIndex metas; |
50 JournalIndex delete_journals;; | 50 JournalIndex delete_journals;; |
51 STLElementDeleter<MetahandlesIndex> index_deleter(&metas); | 51 STLElementDeleter<MetahandlesIndex> index_deleter(&metas); |
52 Directory::KernelLoadInfo kernel_load_info; | 52 Directory::KernelLoadInfo kernel_load_info; |
53 return dbs->Load(&metas, &delete_journals, &kernel_load_info) == OPENED; | 53 return dbs->Load(&metas, &delete_journals, &kernel_load_info) == OPENED; |
54 } | 54 } |
(...skipping 3126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3181 TestDirectoryBackingStore::ModelIdToModelTypeEnum(model_id.data(), | 3181 TestDirectoryBackingStore::ModelIdToModelTypeEnum(model_id.data(), |
3182 model_id.size())); | 3182 model_id.size())); |
3183 } | 3183 } |
3184 } | 3184 } |
3185 | 3185 |
3186 namespace { | 3186 namespace { |
3187 | 3187 |
3188 class OnDiskDirectoryBackingStoreForTest : public OnDiskDirectoryBackingStore { | 3188 class OnDiskDirectoryBackingStoreForTest : public OnDiskDirectoryBackingStore { |
3189 public: | 3189 public: |
3190 OnDiskDirectoryBackingStoreForTest(const std::string& dir_name, | 3190 OnDiskDirectoryBackingStoreForTest(const std::string& dir_name, |
3191 const FilePath& backing_filepath); | 3191 const base::FilePath& backing_filepath); |
3192 virtual ~OnDiskDirectoryBackingStoreForTest(); | 3192 virtual ~OnDiskDirectoryBackingStoreForTest(); |
3193 bool DidFailFirstOpenAttempt(); | 3193 bool DidFailFirstOpenAttempt(); |
3194 | 3194 |
3195 protected: | 3195 protected: |
3196 virtual void ReportFirstTryOpenFailure() OVERRIDE; | 3196 virtual void ReportFirstTryOpenFailure() OVERRIDE; |
3197 | 3197 |
3198 private: | 3198 private: |
3199 bool first_open_failed_; | 3199 bool first_open_failed_; |
3200 }; | 3200 }; |
3201 | 3201 |
3202 OnDiskDirectoryBackingStoreForTest::OnDiskDirectoryBackingStoreForTest( | 3202 OnDiskDirectoryBackingStoreForTest::OnDiskDirectoryBackingStoreForTest( |
3203 const std::string& dir_name, | 3203 const std::string& dir_name, |
3204 const FilePath& backing_filepath) : | 3204 const base::FilePath& backing_filepath) : |
3205 OnDiskDirectoryBackingStore(dir_name, backing_filepath), | 3205 OnDiskDirectoryBackingStore(dir_name, backing_filepath), |
3206 first_open_failed_(false) { } | 3206 first_open_failed_(false) { } |
3207 | 3207 |
3208 OnDiskDirectoryBackingStoreForTest::~OnDiskDirectoryBackingStoreForTest() { } | 3208 OnDiskDirectoryBackingStoreForTest::~OnDiskDirectoryBackingStoreForTest() { } |
3209 | 3209 |
3210 void OnDiskDirectoryBackingStoreForTest::ReportFirstTryOpenFailure() { | 3210 void OnDiskDirectoryBackingStoreForTest::ReportFirstTryOpenFailure() { |
3211 // Do nothing, just like we would in release-mode. In debug mode, we DCHECK. | 3211 // Do nothing, just like we would in release-mode. In debug mode, we DCHECK. |
3212 first_open_failed_ = true; | 3212 first_open_failed_ = true; |
3213 } | 3213 } |
3214 | 3214 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3303 const std::string& guid2 = TestDirectoryBackingStore::GenerateCacheGUID(); | 3303 const std::string& guid2 = TestDirectoryBackingStore::GenerateCacheGUID(); |
3304 EXPECT_EQ(24U, guid1.size()); | 3304 EXPECT_EQ(24U, guid1.size()); |
3305 EXPECT_EQ(24U, guid2.size()); | 3305 EXPECT_EQ(24U, guid2.size()); |
3306 // In theory this test can fail, but it won't before the universe | 3306 // In theory this test can fail, but it won't before the universe |
3307 // dies of heat death. | 3307 // dies of heat death. |
3308 EXPECT_NE(guid1, guid2); | 3308 EXPECT_NE(guid1, guid2); |
3309 } | 3309 } |
3310 | 3310 |
3311 } // namespace syncable | 3311 } // namespace syncable |
3312 } // namespace syncer | 3312 } // namespace syncer |
OLD | NEW |