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

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

Issue 11359217: Move scoped_temp_dir from base to base/files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « sync/syncable/directory_backing_store_unittest.cc ('k') | sync/tools/sync_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <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/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/files/scoped_temp_dir.h"
11 #include "base/location.h" 12 #include "base/location.h"
12 #include "base/logging.h" 13 #include "base/logging.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop.h" 15 #include "base/message_loop.h"
15 #include "base/scoped_temp_dir.h"
16 #include "base/stringprintf.h" 16 #include "base/stringprintf.h"
17 #include "base/synchronization/condition_variable.h" 17 #include "base/synchronization/condition_variable.h"
18 #include "base/test/values_test_util.h" 18 #include "base/test/values_test_util.h"
19 #include "base/threading/platform_thread.h" 19 #include "base/threading/platform_thread.h"
20 #include "base/values.h" 20 #include "base/values.h"
21 #include "sync/internal_api/public/base/node_ordinal.h" 21 #include "sync/internal_api/public/base/node_ordinal.h"
22 #include "sync/protocol/bookmark_specifics.pb.h" 22 #include "sync/protocol/bookmark_specifics.pb.h"
23 #include "sync/syncable/directory_backing_store.h" 23 #include "sync/syncable/directory_backing_store.h"
24 #include "sync/syncable/directory_change_delegate.h" 24 #include "sync/syncable/directory_change_delegate.h"
25 #include "sync/syncable/in_memory_directory_backing_store.h" 25 #include "sync/syncable/in_memory_directory_backing_store.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 virtual void SetUp() { 91 virtual void SetUp() {
92 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 92 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
93 db_path_ = temp_dir_.path().Append( 93 db_path_ = temp_dir_.path().Append(
94 FILE_PATH_LITERAL("SyncableTest.sqlite3")); 94 FILE_PATH_LITERAL("SyncableTest.sqlite3"));
95 } 95 }
96 96
97 virtual void TearDown() { 97 virtual void TearDown() {
98 } 98 }
99 protected: 99 protected:
100 MessageLoop message_loop_; 100 MessageLoop message_loop_;
101 ScopedTempDir temp_dir_; 101 base::ScopedTempDir temp_dir_;
102 NullDirectoryChangeDelegate delegate_; 102 NullDirectoryChangeDelegate delegate_;
103 FakeEncryptor encryptor_; 103 FakeEncryptor encryptor_;
104 TestUnrecoverableErrorHandler handler_; 104 TestUnrecoverableErrorHandler handler_;
105 FilePath db_path_; 105 FilePath db_path_;
106 }; 106 };
107 107
108 const char SyncableGeneralTest::kIndexTestName[] = "IndexTest"; 108 const char SyncableGeneralTest::kIndexTestName[] = "IndexTest";
109 109
110 TEST_F(SyncableGeneralTest, General) { 110 TEST_F(SyncableGeneralTest, General) {
111 Directory dir(new InMemoryDirectoryBackingStore("SimpleTest"), 111 Directory dir(new InMemoryDirectoryBackingStore("SimpleTest"),
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 TestBackingStore* backing_store) 1476 TestBackingStore* backing_store)
1477 : Directory(backing_store, handler, NULL, NULL, NULL), 1477 : Directory(backing_store, handler, NULL, NULL, NULL),
1478 backing_store_(backing_store) { 1478 backing_store_(backing_store) {
1479 } 1479 }
1480 1480
1481 TestDirectory::~TestDirectory() { } 1481 TestDirectory::~TestDirectory() { }
1482 1482
1483 TEST(OnDiskSyncableDirectory, FailInitialWrite) { 1483 TEST(OnDiskSyncableDirectory, FailInitialWrite) {
1484 FakeEncryptor encryptor; 1484 FakeEncryptor encryptor;
1485 TestUnrecoverableErrorHandler handler; 1485 TestUnrecoverableErrorHandler handler;
1486 ScopedTempDir temp_dir; 1486 base::ScopedTempDir temp_dir;
1487 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 1487 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
1488 FilePath file_path = temp_dir.path().Append( 1488 FilePath file_path = temp_dir.path().Append(
1489 FILE_PATH_LITERAL("Test.sqlite3")); 1489 FILE_PATH_LITERAL("Test.sqlite3"));
1490 std::string name = "user@x.com"; 1490 std::string name = "user@x.com";
1491 NullDirectoryChangeDelegate delegate; 1491 NullDirectoryChangeDelegate delegate;
1492 1492
1493 scoped_ptr<TestDirectory> test_dir( 1493 scoped_ptr<TestDirectory> test_dir(
1494 TestDirectory::Create(&encryptor, &handler, name, file_path)); 1494 TestDirectory::Create(&encryptor, &handler, name, file_path));
1495 1495
1496 test_dir->StartFailingSaveChanges(); 1496 test_dir->StartFailingSaveChanges();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 void SaveAndReloadDir() { 1532 void SaveAndReloadDir() {
1533 dir_->SaveChanges(); 1533 dir_->SaveChanges();
1534 CreateDirectory(); 1534 CreateDirectory();
1535 } 1535 }
1536 1536
1537 void StartFailingSaveChanges() { 1537 void StartFailingSaveChanges() {
1538 test_directory_->StartFailingSaveChanges(); 1538 test_directory_->StartFailingSaveChanges();
1539 } 1539 }
1540 1540
1541 TestDirectory *test_directory_; // mirrors scoped_ptr<Directory> dir_ 1541 TestDirectory *test_directory_; // mirrors scoped_ptr<Directory> dir_
1542 ScopedTempDir temp_dir_; 1542 base::ScopedTempDir temp_dir_;
1543 FilePath file_path_; 1543 FilePath file_path_;
1544 }; 1544 };
1545 1545
1546 TEST_F(OnDiskSyncableDirectoryTest, TestPurgeEntriesWithTypeIn) { 1546 TEST_F(OnDiskSyncableDirectoryTest, TestPurgeEntriesWithTypeIn) {
1547 sync_pb::EntitySpecifics bookmark_specs; 1547 sync_pb::EntitySpecifics bookmark_specs;
1548 sync_pb::EntitySpecifics autofill_specs; 1548 sync_pb::EntitySpecifics autofill_specs;
1549 sync_pb::EntitySpecifics preference_specs; 1549 sync_pb::EntitySpecifics preference_specs;
1550 AddDefaultFieldValue(BOOKMARKS, &bookmark_specs); 1550 AddDefaultFieldValue(BOOKMARKS, &bookmark_specs);
1551 AddDefaultFieldValue(PREFERENCES, &preference_specs); 1551 AddDefaultFieldValue(PREFERENCES, &preference_specs);
1552 AddDefaultFieldValue(AUTOFILL, &autofill_specs); 1552 AddDefaultFieldValue(AUTOFILL, &autofill_specs);
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
1935 class SyncableDirectoryManagement : public testing::Test { 1935 class SyncableDirectoryManagement : public testing::Test {
1936 public: 1936 public:
1937 virtual void SetUp() { 1937 virtual void SetUp() {
1938 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 1938 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
1939 } 1939 }
1940 1940
1941 virtual void TearDown() { 1941 virtual void TearDown() {
1942 } 1942 }
1943 protected: 1943 protected:
1944 MessageLoop message_loop_; 1944 MessageLoop message_loop_;
1945 ScopedTempDir temp_dir_; 1945 base::ScopedTempDir temp_dir_;
1946 FakeEncryptor encryptor_; 1946 FakeEncryptor encryptor_;
1947 TestUnrecoverableErrorHandler handler_; 1947 TestUnrecoverableErrorHandler handler_;
1948 NullDirectoryChangeDelegate delegate_; 1948 NullDirectoryChangeDelegate delegate_;
1949 }; 1949 };
1950 1950
1951 TEST_F(SyncableDirectoryManagement, TestFileRelease) { 1951 TEST_F(SyncableDirectoryManagement, TestFileRelease) {
1952 FilePath path = temp_dir_.path().Append( 1952 FilePath path = temp_dir_.path().Append(
1953 Directory::kSyncDatabaseFilename); 1953 Directory::kSyncDatabaseFilename);
1954 1954
1955 syncable::Directory dir(new OnDiskDirectoryBackingStore("ScopeTest", path), 1955 syncable::Directory dir(new OnDiskDirectoryBackingStore("ScopeTest", path),
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 } 2004 }
2005 } 2005 }
2006 } 2006 }
2007 } 2007 }
2008 2008
2009 DISALLOW_COPY_AND_ASSIGN(StressTransactionsDelegate); 2009 DISALLOW_COPY_AND_ASSIGN(StressTransactionsDelegate);
2010 }; 2010 };
2011 2011
2012 TEST(SyncableDirectory, StressTransactions) { 2012 TEST(SyncableDirectory, StressTransactions) {
2013 MessageLoop message_loop; 2013 MessageLoop message_loop;
2014 ScopedTempDir temp_dir; 2014 base::ScopedTempDir temp_dir;
2015 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); 2015 ASSERT_TRUE(temp_dir.CreateUniqueTempDir());
2016 FakeEncryptor encryptor; 2016 FakeEncryptor encryptor;
2017 TestUnrecoverableErrorHandler handler; 2017 TestUnrecoverableErrorHandler handler;
2018 NullDirectoryChangeDelegate delegate; 2018 NullDirectoryChangeDelegate delegate;
2019 std::string dirname = "stress"; 2019 std::string dirname = "stress";
2020 Directory dir(new InMemoryDirectoryBackingStore(dirname), 2020 Directory dir(new InMemoryDirectoryBackingStore(dirname),
2021 &handler, 2021 &handler,
2022 NULL, 2022 NULL,
2023 NULL, 2023 NULL,
2024 NULL); 2024 NULL);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2136 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true)); 2136 EXPECT_TRUE(CreateWithDefaultTag(factory_.NewServerId(), true));
2137 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true)); 2137 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), true));
2138 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false)); 2138 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewServerId(), false));
2139 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false)); 2139 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), false));
2140 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true)); 2140 EXPECT_FALSE(CreateWithDefaultTag(factory_.NewLocalId(), true));
2141 } 2141 }
2142 2142
2143 } // namespace 2143 } // namespace
2144 } // namespace syncable 2144 } // namespace syncable
2145 } // namespace syncer 2145 } // namespace syncer
OLDNEW
« no previous file with comments | « sync/syncable/directory_backing_store_unittest.cc ('k') | sync/tools/sync_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698