Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(959)

Side by Side Diff: components/sync/syncable/syncable_unittest.cc

Issue 2317023003: sync and signin: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Just rebased Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 #else 125 #else
126 #define MAYBE_FailInitialWrite FailInitialWrite 126 #define MAYBE_FailInitialWrite FailInitialWrite
127 #endif 127 #endif
128 TEST(OnDiskSyncableDirectory, MAYBE_FailInitialWrite) { 128 TEST(OnDiskSyncableDirectory, MAYBE_FailInitialWrite) {
129 base::MessageLoop message_loop; 129 base::MessageLoop message_loop;
130 FakeEncryptor encryptor; 130 FakeEncryptor encryptor;
131 TestUnrecoverableErrorHandler handler; 131 TestUnrecoverableErrorHandler handler;
132 base::ScopedTempDir temp_dir; 132 base::ScopedTempDir temp_dir;
133 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 133 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
134 base::FilePath file_path = 134 base::FilePath file_path =
135 temp_dir.path().Append(FILE_PATH_LITERAL("Test.sqlite3")); 135 temp_dir.GetPath().Append(FILE_PATH_LITERAL("Test.sqlite3"));
136 std::string name = "user@x.com"; 136 std::string name = "user@x.com";
137 NullDirectoryChangeDelegate delegate; 137 NullDirectoryChangeDelegate delegate;
138 138
139 std::unique_ptr<TestDirectory> test_dir(TestDirectory::Create( 139 std::unique_ptr<TestDirectory> test_dir(TestDirectory::Create(
140 &encryptor, MakeWeakHandle(handler.GetWeakPtr()), name, file_path)); 140 &encryptor, MakeWeakHandle(handler.GetWeakPtr()), name, file_path));
141 141
142 test_dir->StartFailingSaveChanges(); 142 test_dir->StartFailingSaveChanges();
143 ASSERT_EQ(FAILED_INITIAL_WRITE, 143 ASSERT_EQ(FAILED_INITIAL_WRITE,
144 test_dir->Open(name, &delegate, NullTransactionObserver())); 144 test_dir->Open(name, &delegate, NullTransactionObserver()));
145 } 145 }
146 146
147 // A variant of SyncableDirectoryTest that uses a real sqlite database. 147 // A variant of SyncableDirectoryTest that uses a real sqlite database.
148 class OnDiskSyncableDirectoryTest : public SyncableDirectoryTest { 148 class OnDiskSyncableDirectoryTest : public SyncableDirectoryTest {
149 protected: 149 protected:
150 // SetUp() is called before each test case is run. 150 // SetUp() is called before each test case is run.
151 // The sqlite3 DB is deleted before each test is run. 151 // The sqlite3 DB is deleted before each test is run.
152 void SetUp() override { 152 void SetUp() override {
153 SyncableDirectoryTest::SetUp(); 153 SyncableDirectoryTest::SetUp();
154 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 154 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
155 file_path_ = temp_dir_.path().Append(FILE_PATH_LITERAL("Test.sqlite3")); 155 file_path_ = temp_dir_.GetPath().Append(FILE_PATH_LITERAL("Test.sqlite3"));
156 base::DeleteFile(file_path_, false); 156 base::DeleteFile(file_path_, false);
157 CreateDirectory(); 157 CreateDirectory();
158 } 158 }
159 159
160 void TearDown() override { 160 void TearDown() override {
161 // This also closes file handles. 161 // This also closes file handles.
162 dir()->SaveChanges(); 162 dir()->SaveChanges();
163 dir().reset(); 163 dir().reset();
164 base::DeleteFile(file_path_, false); 164 base::DeleteFile(file_path_, false);
165 SyncableDirectoryTest::TearDown(); 165 SyncableDirectoryTest::TearDown();
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 protected: 544 protected:
545 base::MessageLoop message_loop_; 545 base::MessageLoop message_loop_;
546 base::ScopedTempDir temp_dir_; 546 base::ScopedTempDir temp_dir_;
547 FakeEncryptor encryptor_; 547 FakeEncryptor encryptor_;
548 TestUnrecoverableErrorHandler handler_; 548 TestUnrecoverableErrorHandler handler_;
549 NullDirectoryChangeDelegate delegate_; 549 NullDirectoryChangeDelegate delegate_;
550 }; 550 };
551 551
552 TEST_F(SyncableDirectoryManagement, TestFileRelease) { 552 TEST_F(SyncableDirectoryManagement, TestFileRelease) {
553 base::FilePath path = 553 base::FilePath path =
554 temp_dir_.path().Append(Directory::kSyncDatabaseFilename); 554 temp_dir_.GetPath().Append(Directory::kSyncDatabaseFilename);
555 555
556 { 556 {
557 Directory dir(new OnDiskDirectoryBackingStore("ScopeTest", path), 557 Directory dir(new OnDiskDirectoryBackingStore("ScopeTest", path),
558 MakeWeakHandle(handler_.GetWeakPtr()), base::Closure(), NULL, 558 MakeWeakHandle(handler_.GetWeakPtr()), base::Closure(), NULL,
559 NULL); 559 NULL);
560 DirOpenResult result = 560 DirOpenResult result =
561 dir.Open("ScopeTest", &delegate_, NullTransactionObserver()); 561 dir.Open("ScopeTest", &delegate_, NullTransactionObserver());
562 ASSERT_EQ(result, OPENED); 562 ASSERT_EQ(result, OPENED);
563 } 563 }
564 564
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 TEST_F(SyncableClientTagTest, TestClientTagIndexDuplicateServer) { 655 TEST_F(SyncableClientTagTest, TestClientTagIndexDuplicateServer) {
656 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); 656 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true));
657 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); 657 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true));
658 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); 658 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false));
659 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); 659 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false));
660 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); 660 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true));
661 } 661 }
662 662
663 } // namespace syncable 663 } // namespace syncable
664 } // namespace syncer 664 } // namespace syncer
OLDNEW
« no previous file with comments | « components/sync/syncable/directory_backing_store_unittest.cc ('k') | components/sync/tools/sync_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698