| 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/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" |
| 11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "sql/connection.h" | 15 #include "sql/connection.h" |
| 16 #include "sql/statement.h" | 16 #include "sql/statement.h" |
| 17 #include "sync/base/sync_export.h" | 17 #include "sync/base/sync_export.h" |
| 18 #include "sync/internal_api/public/base/node_ordinal.h" | 18 #include "sync/internal_api/public/base/node_ordinal.h" |
| 19 #include "sync/protocol/bookmark_specifics.pb.h" | 19 #include "sync/protocol/bookmark_specifics.pb.h" |
| 20 #include "sync/protocol/sync.pb.h" | 20 #include "sync/protocol/sync.pb.h" |
| 21 #include "sync/syncable/directory.h" |
| 21 #include "sync/syncable/directory_backing_store.h" | 22 #include "sync/syncable/directory_backing_store.h" |
| 22 #include "sync/syncable/on_disk_directory_backing_store.h" | 23 #include "sync/syncable/on_disk_directory_backing_store.h" |
| 23 #include "sync/syncable/syncable-inl.h" | 24 #include "sync/syncable/syncable-inl.h" |
| 24 #include "sync/test/test_directory_backing_store.h" | 25 #include "sync/test/test_directory_backing_store.h" |
| 25 #include "sync/util/time.h" | 26 #include "sync/util/time.h" |
| 26 #include "testing/gtest/include/gtest/gtest-param-test.h" | 27 #include "testing/gtest/include/gtest/gtest-param-test.h" |
| 27 | 28 |
| 28 namespace syncer { | 29 namespace syncer { |
| 29 namespace syncable { | 30 namespace syncable { |
| 30 | 31 |
| (...skipping 3915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3946 TEST_F(DirectoryBackingStoreTest, GenerateCacheGUID) { | 3947 TEST_F(DirectoryBackingStoreTest, GenerateCacheGUID) { |
| 3947 const std::string& guid1 = TestDirectoryBackingStore::GenerateCacheGUID(); | 3948 const std::string& guid1 = TestDirectoryBackingStore::GenerateCacheGUID(); |
| 3948 const std::string& guid2 = TestDirectoryBackingStore::GenerateCacheGUID(); | 3949 const std::string& guid2 = TestDirectoryBackingStore::GenerateCacheGUID(); |
| 3949 EXPECT_EQ(24U, guid1.size()); | 3950 EXPECT_EQ(24U, guid1.size()); |
| 3950 EXPECT_EQ(24U, guid2.size()); | 3951 EXPECT_EQ(24U, guid2.size()); |
| 3951 // In theory this test can fail, but it won't before the universe | 3952 // In theory this test can fail, but it won't before the universe |
| 3952 // dies of heat death. | 3953 // dies of heat death. |
| 3953 EXPECT_NE(guid1, guid2); | 3954 EXPECT_NE(guid1, guid2); |
| 3954 } | 3955 } |
| 3955 | 3956 |
| 3957 TEST_F(DirectoryBackingStoreTest, IncreaseDatabasePageSizeFrom4KTo32K) { |
| 3958 sql::Connection connection; |
| 3959 ASSERT_TRUE(connection.Open(GetDatabasePath())); |
| 3960 |
| 3961 SetUpCurrentDatabaseAndCheckVersion(&connection); |
| 3962 scoped_ptr<TestDirectoryBackingStore> dbs( |
| 3963 new TestDirectoryBackingStore(GetUsername(), &connection)); |
| 3964 Directory::MetahandlesMap handles_map; |
| 3965 JournalIndex delete_journals; |
| 3966 Directory::KernelLoadInfo kernel_load_info; |
| 3967 STLValueDeleter<Directory::MetahandlesMap> index_deleter(&handles_map); |
| 3968 |
| 3969 DirOpenResult open_result = |
| 3970 dbs->Load(&handles_map, &delete_journals, &kernel_load_info); |
| 3971 EXPECT_EQ(open_result, OPENED); |
| 3972 |
| 3973 // Check if update is successful. |
| 3974 int pageSize = 0; |
| 3975 dbs->GetDatabasePageSize(&pageSize); |
| 3976 EXPECT_EQ(1024, pageSize); |
| 3977 dbs->db_->set_page_size(32768); |
| 3978 dbs->IncreasePageSizeTo32K(); |
| 3979 pageSize = 0; |
| 3980 dbs->GetDatabasePageSize(&pageSize); |
| 3981 EXPECT_EQ(32768, pageSize); |
| 3982 |
| 3983 // Snapshot and save. |
| 3984 Directory::SaveChangesSnapshot snapshot; |
| 3985 dbs->SaveChanges(snapshot); |
| 3986 |
| 3987 // Load the directory again. |
| 3988 dbs.reset(new TestDirectoryBackingStore(GetUsername(), &connection)); |
| 3989 pageSize = 0; |
| 3990 dbs->GetDatabasePageSize(&pageSize); |
| 3991 EXPECT_EQ(32768, pageSize); |
| 3992 open_result = dbs->Load(&handles_map, &delete_journals, &kernel_load_info); |
| 3993 EXPECT_EQ(open_result, OPENED); |
| 3994 } |
| 3995 |
| 3956 } // namespace syncable | 3996 } // namespace syncable |
| 3957 } // namespace syncer | 3997 } // namespace syncer |
| OLD | NEW |