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 // Get |storage_|'s starred_property_initialized. | |
55 void GetStarredPropertyInitialized(bool* value) { | |
hashimoto
2016/09/29 08:43:43
How about returning the value?
bool GetStarredPr
harukam
2016/09/29 09:39:46
I chose passe-by-pointer like as GetLargestChanges
| |
56 ResourceMetadataHeader header; | |
57 EXPECT_EQ(FILE_ERROR_OK, storage_->GetHeader(&header)); | |
58 *value = 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 // Close DB and reopen. | |
658 storage_.reset(new ResourceMetadataStorage( | |
659 temp_dir_.GetPath(), base::ThreadTaskRunnerHandle::Get().get())); | |
660 ASSERT_TRUE(storage_->Initialize()); | |
661 | |
662 GetStarredPropertyInitialized(&starred_property_initialized); | |
663 EXPECT_TRUE(starred_property_initialized); | |
hashimoto
2016/09/29 08:43:43
Please check that the largest changestamp becomes
harukam
2016/09/29 09:39:46
Done.
| |
664 } | |
665 | |
637 } // namespace internal | 666 } // namespace internal |
638 } // namespace drive | 667 } // namespace drive |
OLD | NEW |