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

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

Issue 10520010: Not for review: Support sync init with missing or corrupt store (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Documentation Created 8 years, 6 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 | Annotate | Revision Log
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 "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 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 TEST_F(DirectoryBackingStoreTest, ModelTypeIds) { 2077 TEST_F(DirectoryBackingStoreTest, ModelTypeIds) {
2078 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { 2078 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
2079 std::string model_id = 2079 std::string model_id =
2080 TestDirectoryBackingStore::ModelTypeEnumToModelId(ModelTypeFromInt(i)); 2080 TestDirectoryBackingStore::ModelTypeEnumToModelId(ModelTypeFromInt(i));
2081 EXPECT_EQ(i, 2081 EXPECT_EQ(i,
2082 TestDirectoryBackingStore::ModelIdToModelTypeEnum(model_id.data(), 2082 TestDirectoryBackingStore::ModelIdToModelTypeEnum(model_id.data(),
2083 model_id.size())); 2083 model_id.size()));
2084 } 2084 }
2085 } 2085 }
2086 2086
2087 // TODO(109668): This had to be disabled because the latest API will
2088 // intentionally crash when a database is this badly corrupted.
2089 TEST_F(DirectoryBackingStoreTest, DISABLED_Corruption) {
rlarocque 2012/06/04 20:07:09 I've given up on testing this. I simply can't fin
2090 {
2091 scoped_ptr<OnDiskDirectoryBackingStore> dbs(
2092 new OnDiskDirectoryBackingStore(GetUsername(), GetDatabasePath()));
2093 EXPECT_TRUE(LoadAndIgnoreReturnedData(dbs.get()));
2094 }
2095 std::string bad_data("BAD DATA");
2096 EXPECT_TRUE(file_util::WriteFile(GetDatabasePath(), bad_data.data(),
2097 bad_data.size()));
2098 {
2099 scoped_ptr<OnDiskDirectoryBackingStore> dbs(
2100 new OnDiskDirectoryBackingStore(GetUsername(), GetDatabasePath()));
2101
2102 EXPECT_FALSE(LoadAndIgnoreReturnedData(dbs.get()));
2103 }
2104 }
2105
2106 TEST_F(DirectoryBackingStoreTest, DeleteEntries) { 2087 TEST_F(DirectoryBackingStoreTest, DeleteEntries) {
2107 sql::Connection connection; 2088 sql::Connection connection;
2108 ASSERT_TRUE(connection.OpenInMemory()); 2089 ASSERT_TRUE(connection.OpenInMemory());
2109 2090
2110 SetUpCurrentDatabaseAndCheckVersion(&connection); 2091 SetUpCurrentDatabaseAndCheckVersion(&connection);
2111 scoped_ptr<TestDirectoryBackingStore> dbs( 2092 scoped_ptr<TestDirectoryBackingStore> dbs(
2112 new TestDirectoryBackingStore(GetUsername(), &connection)); 2093 new TestDirectoryBackingStore(GetUsername(), &connection));
2113 MetahandlesIndex index; 2094 MetahandlesIndex index;
2114 Directory::KernelLoadInfo kernel_load_info; 2095 Directory::KernelLoadInfo kernel_load_info;
2115 STLElementDeleter<MetahandlesIndex> index_deleter(&index); 2096 STLElementDeleter<MetahandlesIndex> index_deleter(&index);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2153 const std::string& guid1 = TestDirectoryBackingStore::GenerateCacheGUID(); 2134 const std::string& guid1 = TestDirectoryBackingStore::GenerateCacheGUID();
2154 const std::string& guid2 = TestDirectoryBackingStore::GenerateCacheGUID(); 2135 const std::string& guid2 = TestDirectoryBackingStore::GenerateCacheGUID();
2155 EXPECT_EQ(24U, guid1.size()); 2136 EXPECT_EQ(24U, guid1.size());
2156 EXPECT_EQ(24U, guid2.size()); 2137 EXPECT_EQ(24U, guid2.size());
2157 // In theory this test can fail, but it won't before the universe 2138 // In theory this test can fail, but it won't before the universe
2158 // dies of heat death. 2139 // dies of heat death.
2159 EXPECT_NE(guid1, guid2); 2140 EXPECT_NE(guid1, guid2);
2160 } 2141 }
2161 2142
2162 } // namespace syncable 2143 } // namespace syncable
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698