| 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 "chrome/browser/chromeos/drive/resource_metadata_storage.h" | 5 #include "chrome/browser/chromeos/drive/resource_metadata_storage.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/strings/string_split.h" |
| 11 #include "chrome/browser/chromeos/drive/drive.pb.h" | 12 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 12 #include "chrome/browser/chromeos/drive/test_util.h" | 13 #include "chrome/browser/chromeos/drive/test_util.h" |
| 13 #include "content/public/test/test_browser_thread_bundle.h" | 14 #include "content/public/test/test_browser_thread_bundle.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 16 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
| 16 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" | 17 #include "third_party/leveldatabase/src/include/leveldb/write_batch.h" |
| 17 | 18 |
| 18 namespace drive { | 19 namespace drive { |
| 19 namespace internal { | 20 namespace internal { |
| 20 | 21 |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 | 192 |
| 192 // Resource ID to local ID mapping is removed. | 193 // Resource ID to local ID mapping is removed. |
| 193 EXPECT_EQ(FILE_ERROR_OK, storage_->RemoveEntry(local_id)); | 194 EXPECT_EQ(FILE_ERROR_OK, storage_->RemoveEntry(local_id)); |
| 194 EXPECT_EQ(FILE_ERROR_NOT_FOUND, | 195 EXPECT_EQ(FILE_ERROR_NOT_FOUND, |
| 195 storage_->GetIdByResourceId(resource_id, &id)); | 196 storage_->GetIdByResourceId(resource_id, &id)); |
| 196 } | 197 } |
| 197 | 198 |
| 198 TEST_F(ResourceMetadataStorageTest, GetChildren) { | 199 TEST_F(ResourceMetadataStorageTest, GetChildren) { |
| 199 const std::string parents_id[] = { "mercury", "venus", "mars", "jupiter", | 200 const std::string parents_id[] = { "mercury", "venus", "mars", "jupiter", |
| 200 "saturn" }; | 201 "saturn" }; |
| 201 std::vector<std::vector<std::pair<std::string, std::string> > > | 202 std::vector<base::StringPairs> children_name_id(arraysize(parents_id)); |
| 202 children_name_id(arraysize(parents_id)); | |
| 203 // Skip children_name_id[0/1] here because Mercury and Venus have no moon. | 203 // Skip children_name_id[0/1] here because Mercury and Venus have no moon. |
| 204 children_name_id[2].push_back(std::make_pair("phobos", "mars_i")); | 204 children_name_id[2].push_back(std::make_pair("phobos", "mars_i")); |
| 205 children_name_id[2].push_back(std::make_pair("deimos", "mars_ii")); | 205 children_name_id[2].push_back(std::make_pair("deimos", "mars_ii")); |
| 206 children_name_id[3].push_back(std::make_pair("io", "jupiter_i")); | 206 children_name_id[3].push_back(std::make_pair("io", "jupiter_i")); |
| 207 children_name_id[3].push_back(std::make_pair("europa", "jupiter_ii")); | 207 children_name_id[3].push_back(std::make_pair("europa", "jupiter_ii")); |
| 208 children_name_id[3].push_back(std::make_pair("ganymede", "jupiter_iii")); | 208 children_name_id[3].push_back(std::make_pair("ganymede", "jupiter_iii")); |
| 209 children_name_id[3].push_back(std::make_pair("calisto", "jupiter_iv")); | 209 children_name_id[3].push_back(std::make_pair("calisto", "jupiter_iv")); |
| 210 children_name_id[4].push_back(std::make_pair("mimas", "saturn_i")); | 210 children_name_id[4].push_back(std::make_pair("mimas", "saturn_i")); |
| 211 children_name_id[4].push_back(std::make_pair("enceladus", "saturn_ii")); | 211 children_name_id[4].push_back(std::make_pair("enceladus", "saturn_ii")); |
| 212 children_name_id[4].push_back(std::make_pair("tethys", "saturn_iii")); | 212 children_name_id[4].push_back(std::make_pair("tethys", "saturn_iii")); |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 EXPECT_EQ(FILE_ERROR_OK, storage_->RemoveEntry(key3)); | 622 EXPECT_EQ(FILE_ERROR_OK, storage_->RemoveEntry(key3)); |
| 623 EXPECT_TRUE(CheckValidity()); | 623 EXPECT_TRUE(CheckValidity()); |
| 624 | 624 |
| 625 // Remove key1. | 625 // Remove key1. |
| 626 EXPECT_EQ(FILE_ERROR_OK, storage_->RemoveEntry(key1)); | 626 EXPECT_EQ(FILE_ERROR_OK, storage_->RemoveEntry(key1)); |
| 627 EXPECT_TRUE(CheckValidity()); | 627 EXPECT_TRUE(CheckValidity()); |
| 628 } | 628 } |
| 629 | 629 |
| 630 } // namespace internal | 630 } // namespace internal |
| 631 } // namespace drive | 631 } // namespace drive |
| OLD | NEW |