| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 test_dir->StartFailingSaveChanges(); | 139 test_dir->StartFailingSaveChanges(); |
| 140 ASSERT_EQ(FAILED_INITIAL_WRITE, test_dir->Open(name, &delegate, | 140 ASSERT_EQ(FAILED_INITIAL_WRITE, test_dir->Open(name, &delegate, |
| 141 NullTransactionObserver())); | 141 NullTransactionObserver())); |
| 142 } | 142 } |
| 143 | 143 |
| 144 // A variant of SyncableDirectoryTest that uses a real sqlite database. | 144 // A variant of SyncableDirectoryTest that uses a real sqlite database. |
| 145 class OnDiskSyncableDirectoryTest : public SyncableDirectoryTest { | 145 class OnDiskSyncableDirectoryTest : public SyncableDirectoryTest { |
| 146 protected: | 146 protected: |
| 147 // SetUp() is called before each test case is run. | 147 // SetUp() is called before each test case is run. |
| 148 // The sqlite3 DB is deleted before each test is run. | 148 // The sqlite3 DB is deleted before each test is run. |
| 149 virtual void SetUp() { | 149 void SetUp() override { |
| 150 SyncableDirectoryTest::SetUp(); | 150 SyncableDirectoryTest::SetUp(); |
| 151 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 151 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 152 file_path_ = temp_dir_.path().Append( | 152 file_path_ = temp_dir_.path().Append( |
| 153 FILE_PATH_LITERAL("Test.sqlite3")); | 153 FILE_PATH_LITERAL("Test.sqlite3")); |
| 154 base::DeleteFile(file_path_, true); | 154 base::DeleteFile(file_path_, true); |
| 155 CreateDirectory(); | 155 CreateDirectory(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 virtual void TearDown() { | 158 void TearDown() override { |
| 159 // This also closes file handles. | 159 // This also closes file handles. |
| 160 dir()->SaveChanges(); | 160 dir()->SaveChanges(); |
| 161 dir().reset(); | 161 dir().reset(); |
| 162 base::DeleteFile(file_path_, true); | 162 base::DeleteFile(file_path_, true); |
| 163 SyncableDirectoryTest::TearDown(); | 163 SyncableDirectoryTest::TearDown(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 // Creates a new directory. Deletes the old directory, if it exists. | 166 // Creates a new directory. Deletes the old directory, if it exists. |
| 167 void CreateDirectory() { | 167 void CreateDirectory() { |
| 168 test_directory_ = TestDirectory::Create( | 168 test_directory_ = TestDirectory::Create( |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 | 538 |
| 539 ModelTypeSet set(BOOKMARKS); | 539 ModelTypeSet set(BOOKMARKS); |
| 540 dir()->PurgeEntriesWithTypeIn(set, ModelTypeSet(), ModelTypeSet()); | 540 dir()->PurgeEntriesWithTypeIn(set, ModelTypeSet(), ModelTypeSet()); |
| 541 EXPECT_TRUE(IsInMetahandlesToPurge(handle1)); | 541 EXPECT_TRUE(IsInMetahandlesToPurge(handle1)); |
| 542 ASSERT_FALSE(dir()->SaveChanges()); | 542 ASSERT_FALSE(dir()->SaveChanges()); |
| 543 EXPECT_TRUE(IsInMetahandlesToPurge(handle1)); | 543 EXPECT_TRUE(IsInMetahandlesToPurge(handle1)); |
| 544 } | 544 } |
| 545 | 545 |
| 546 class SyncableDirectoryManagement : public testing::Test { | 546 class SyncableDirectoryManagement : public testing::Test { |
| 547 public: | 547 public: |
| 548 virtual void SetUp() { | 548 void SetUp() override { ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); } |
| 549 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | |
| 550 } | |
| 551 | 549 |
| 552 virtual void TearDown() { | 550 void TearDown() override {} |
| 553 } | 551 |
| 554 protected: | 552 protected: |
| 555 base::MessageLoop message_loop_; | 553 base::MessageLoop message_loop_; |
| 556 base::ScopedTempDir temp_dir_; | 554 base::ScopedTempDir temp_dir_; |
| 557 FakeEncryptor encryptor_; | 555 FakeEncryptor encryptor_; |
| 558 TestUnrecoverableErrorHandler handler_; | 556 TestUnrecoverableErrorHandler handler_; |
| 559 NullDirectoryChangeDelegate delegate_; | 557 NullDirectoryChangeDelegate delegate_; |
| 560 }; | 558 }; |
| 561 | 559 |
| 562 TEST_F(SyncableDirectoryManagement, TestFileRelease) { | 560 TEST_F(SyncableDirectoryManagement, TestFileRelease) { |
| 563 base::FilePath path = | 561 base::FilePath path = |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 TEST_F(SyncableClientTagTest, TestClientTagIndexDuplicateServer) { | 665 TEST_F(SyncableClientTagTest, TestClientTagIndexDuplicateServer) { |
| 668 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); | 666 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); |
| 669 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); | 667 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); |
| 670 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); | 668 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); |
| 671 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); | 669 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); |
| 672 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); | 670 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); |
| 673 } | 671 } |
| 674 | 672 |
| 675 } // namespace syncable | 673 } // namespace syncable |
| 676 } // namespace syncer | 674 } // namespace syncer |
| OLD | NEW |