OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/drive/resource_metadata_storage.h" | 5 #include "components/drive/resource_metadata_storage.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 25 matching lines...) Expand all Loading... | |
36 } | 36 } |
37 | 37 |
38 // Overwrites |storage_|'s version. | 38 // Overwrites |storage_|'s version. |
39 void SetDBVersion(int version) { | 39 void SetDBVersion(int version) { |
40 ResourceMetadataHeader header; | 40 ResourceMetadataHeader header; |
41 ASSERT_EQ(FILE_ERROR_OK, storage_->GetHeader(&header)); | 41 ASSERT_EQ(FILE_ERROR_OK, storage_->GetHeader(&header)); |
42 header.set_version(version); | 42 header.set_version(version); |
43 EXPECT_EQ(FILE_ERROR_OK, storage_->PutHeader(header)); | 43 EXPECT_EQ(FILE_ERROR_OK, storage_->PutHeader(header)); |
44 } | 44 } |
45 | 45 |
46 // Overwrites |storage_|'s starred_property_initialized. | |
47 void SetStarredPropertyInitialized(bool value) { | |
48 ResourceMetadataHeader header; | |
49 ASSERT_EQ(FILE_ERROR_OK, storage_->GetHeader(&header)); | |
50 header.set_starred_property_initialized(value); | |
51 EXPECT_EQ(FILE_ERROR_OK, storage_->PutHeader(header)); | |
52 } | |
53 | |
54 // Return |storage_|'s starred_property_initialized. | |
hashimoto
2016/09/29 09:46:06
nit: Returns
harukam
2016/09/29 11:08:22
Acknowledged.
| |
55 bool GetStarredPropertyInitialized() { | |
56 ResourceMetadataHeader header; | |
57 EXPECT_EQ(FILE_ERROR_OK, storage_->GetHeader(&header)); | |
58 return header.starred_property_initialized(); | |
59 } | |
60 | |
46 bool CheckValidity() { | 61 bool CheckValidity() { |
47 return storage_->CheckValidity(); | 62 return storage_->CheckValidity(); |
48 } | 63 } |
49 | 64 |
50 leveldb::DB* resource_map() { return storage_->resource_map_.get(); } | 65 leveldb::DB* resource_map() { return storage_->resource_map_.get(); } |
51 | 66 |
52 // Puts a child entry. | 67 // Puts a child entry. |
53 void PutChild(const std::string& parent_id, | 68 void PutChild(const std::string& parent_id, |
54 const std::string& child_base_name, | 69 const std::string& child_base_name, |
55 const std::string& child_id) { | 70 const std::string& child_id) { |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
627 RemoveChild(key2, name3); | 642 RemoveChild(key2, name3); |
628 EXPECT_FALSE(CheckValidity()); | 643 EXPECT_FALSE(CheckValidity()); |
629 EXPECT_EQ(FILE_ERROR_OK, storage_->RemoveEntry(key3)); | 644 EXPECT_EQ(FILE_ERROR_OK, storage_->RemoveEntry(key3)); |
630 EXPECT_TRUE(CheckValidity()); | 645 EXPECT_TRUE(CheckValidity()); |
631 | 646 |
632 // Remove key1. | 647 // Remove key1. |
633 EXPECT_EQ(FILE_ERROR_OK, storage_->RemoveEntry(key1)); | 648 EXPECT_EQ(FILE_ERROR_OK, storage_->RemoveEntry(key1)); |
634 EXPECT_TRUE(CheckValidity()); | 649 EXPECT_TRUE(CheckValidity()); |
635 } | 650 } |
636 | 651 |
652 TEST_F(ResourceMetadataStorageTest, ChangeStarredPropertyInitialized) { | |
653 // Suppose 'Starred' property has not loaded. | |
654 bool starred_property_initialized = false; | |
655 SetStarredPropertyInitialized(starred_property_initialized); | |
656 | |
657 const int64_t kLargestChangestamp = 1234567890; | |
658 EXPECT_EQ(FILE_ERROR_OK, | |
659 storage_->SetLargestChangestamp(kLargestChangestamp)); | |
660 | |
661 // Close DB and reopen. | |
662 storage_.reset(new ResourceMetadataStorage( | |
663 temp_dir_.GetPath(), base::ThreadTaskRunnerHandle::Get().get())); | |
664 ASSERT_TRUE(storage_->Initialize()); | |
665 | |
666 starred_property_initialized = GetStarredPropertyInitialized(); | |
667 EXPECT_TRUE(starred_property_initialized); | |
668 | |
669 int64_t largest_changestamp = 0; | |
670 EXPECT_EQ(FILE_ERROR_OK, | |
671 storage_->GetLargestChangestamp(&largest_changestamp)); | |
672 EXPECT_EQ(0, largest_changestamp); | |
673 } | |
674 | |
637 } // namespace internal | 675 } // namespace internal |
638 } // namespace drive | 676 } // namespace drive |
OLD | NEW |