OLD | NEW |
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 "chrome/browser/chromeos/drive/resource_entry_conversion.h" | 5 #include "chrome/browser/chromeos/drive/resource_entry_conversion.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/chromeos/drive/drive.pb.h" | 9 #include "chrome/browser/chromeos/drive/drive.pb.h" |
| 10 #include "chrome/browser/chromeos/drive/drive_file_system_util.h" |
10 #include "chrome/browser/chromeos/drive/drive_test_util.h" | 11 #include "chrome/browser/chromeos/drive/drive_test_util.h" |
11 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 12 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
12 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 namespace drive { | 16 namespace drive { |
16 | 17 |
17 TEST(ResourceEntryConversionTest, ConvertResourceEntryToDriveEntryProto_File) { | 18 TEST(ResourceEntryConversionTest, ConvertResourceEntryToDriveEntryProto_File) { |
18 scoped_ptr<base::Value> value = | 19 scoped_ptr<base::Value> value = |
19 google_apis::test_util::LoadJSONFile("chromeos/gdata/file_entry.json"); | 20 google_apis::test_util::LoadJSONFile("chromeos/gdata/file_entry.json"); |
20 ASSERT_TRUE(value.get()); | 21 ASSERT_TRUE(value.get()); |
21 | 22 |
22 scoped_ptr<google_apis::ResourceEntry> resource_entry( | 23 scoped_ptr<google_apis::ResourceEntry> resource_entry( |
23 google_apis::ResourceEntry::ExtractAndParse(*value)); | 24 google_apis::ResourceEntry::ExtractAndParse(*value)); |
24 ASSERT_TRUE(resource_entry.get()); | 25 ASSERT_TRUE(resource_entry.get()); |
25 | 26 |
26 DriveEntryProto entry_proto = | 27 DriveEntryProto entry_proto = |
27 ConvertResourceEntryToDriveEntryProto(*resource_entry); | 28 ConvertResourceEntryToDriveEntryProto(*resource_entry); |
28 | 29 |
29 EXPECT_EQ("File 1.mp3", entry_proto.title()); | 30 EXPECT_EQ("File 1.mp3", entry_proto.title()); |
30 EXPECT_EQ("File 1.mp3", entry_proto.base_name()); | 31 EXPECT_EQ("File 1.mp3", entry_proto.base_name()); |
31 EXPECT_EQ("file:2_file_resource_id", entry_proto.resource_id()); | 32 EXPECT_EQ("file:2_file_resource_id", entry_proto.resource_id()); |
32 EXPECT_EQ("https://file_content_url/", entry_proto.download_url()); | 33 EXPECT_EQ("https://file_content_url/", entry_proto.download_url()); |
33 EXPECT_EQ("https://file1_link_self/file:2_file_resource_id", | 34 EXPECT_EQ("https://file1_link_self/file:2_file_resource_id", |
34 entry_proto.edit_url()); | 35 entry_proto.edit_url()); |
35 EXPECT_EQ("", entry_proto.parent_resource_id()); | 36 EXPECT_EQ(util::kDriveOtherDirSpecialResourceId, |
| 37 entry_proto.parent_resource_id()); |
36 | 38 |
37 EXPECT_FALSE(entry_proto.deleted()); | 39 EXPECT_FALSE(entry_proto.deleted()); |
38 EXPECT_FALSE(entry_proto.shared_with_me()); | 40 EXPECT_FALSE(entry_proto.shared_with_me()); |
39 | 41 |
40 base::Time expected_creation_time; | 42 base::Time expected_creation_time; |
41 base::Time expected_modified_time; | 43 base::Time expected_modified_time; |
42 | 44 |
43 { | 45 { |
44 // 2011-12-14T00:40:47.330Z | 46 // 2011-12-14T00:40:47.330Z |
45 base::Time::Exploded exploded; | 47 base::Time::Exploded exploded; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 DriveEntryProto entry_proto = | 108 DriveEntryProto entry_proto = |
107 ConvertResourceEntryToDriveEntryProto(*resource_entry); | 109 ConvertResourceEntryToDriveEntryProto(*resource_entry); |
108 | 110 |
109 EXPECT_EQ("Document 1", entry_proto.title()); | 111 EXPECT_EQ("Document 1", entry_proto.title()); |
110 EXPECT_EQ("Document 1.gdoc", entry_proto.base_name()); // The suffix added. | 112 EXPECT_EQ("Document 1.gdoc", entry_proto.base_name()); // The suffix added. |
111 EXPECT_EQ(".gdoc", entry_proto.file_specific_info().document_extension()); | 113 EXPECT_EQ(".gdoc", entry_proto.file_specific_info().document_extension()); |
112 EXPECT_EQ("document:5_document_resource_id", entry_proto.resource_id()); | 114 EXPECT_EQ("document:5_document_resource_id", entry_proto.resource_id()); |
113 EXPECT_EQ("https://3_document_content/", entry_proto.download_url()); | 115 EXPECT_EQ("https://3_document_content/", entry_proto.download_url()); |
114 EXPECT_EQ("https://3_document_self_link/document:5_document_resource_id", | 116 EXPECT_EQ("https://3_document_self_link/document:5_document_resource_id", |
115 entry_proto.edit_url()); | 117 entry_proto.edit_url()); |
116 EXPECT_EQ("", entry_proto.parent_resource_id()); | 118 EXPECT_EQ(util::kDriveOtherDirSpecialResourceId, |
| 119 entry_proto.parent_resource_id()); |
117 | 120 |
118 EXPECT_FALSE(entry_proto.deleted()); | 121 EXPECT_FALSE(entry_proto.deleted()); |
119 EXPECT_FALSE(entry_proto.shared_with_me()); | 122 EXPECT_FALSE(entry_proto.shared_with_me()); |
120 | 123 |
121 // 2011-12-12T23:28:52.783Z | 124 // 2011-12-12T23:28:52.783Z |
122 base::Time::Exploded exploded; | 125 base::Time::Exploded exploded; |
123 exploded.year = 2011; | 126 exploded.year = 2011; |
124 exploded.month = 12; | 127 exploded.month = 12; |
125 exploded.day_of_month = 12; | 128 exploded.day_of_month = 12; |
126 exploded.day_of_week = 1; // Monday | 129 exploded.day_of_week = 1; // Monday |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 267 |
265 DriveEntryProto entry_proto = | 268 DriveEntryProto entry_proto = |
266 ConvertResourceEntryToDriveEntryProto(*resource_entry); | 269 ConvertResourceEntryToDriveEntryProto(*resource_entry); |
267 | 270 |
268 EXPECT_EQ("Deleted document", entry_proto.title()); | 271 EXPECT_EQ("Deleted document", entry_proto.title()); |
269 EXPECT_EQ("Deleted document.gdoc", entry_proto.base_name()); | 272 EXPECT_EQ("Deleted document.gdoc", entry_proto.base_name()); |
270 EXPECT_EQ("document:deleted_in_root_id", entry_proto.resource_id()); | 273 EXPECT_EQ("document:deleted_in_root_id", entry_proto.resource_id()); |
271 EXPECT_EQ("https://content_url/", entry_proto.download_url()); | 274 EXPECT_EQ("https://content_url/", entry_proto.download_url()); |
272 EXPECT_EQ("https://edit_url/document%3Adeleted_in_root_id", | 275 EXPECT_EQ("https://edit_url/document%3Adeleted_in_root_id", |
273 entry_proto.edit_url()); | 276 entry_proto.edit_url()); |
274 EXPECT_EQ("", entry_proto.parent_resource_id()); | 277 EXPECT_EQ(util::kDriveOtherDirSpecialResourceId, |
| 278 entry_proto.parent_resource_id()); |
275 | 279 |
276 EXPECT_TRUE(entry_proto.deleted()); // The document was deleted. | 280 EXPECT_TRUE(entry_proto.deleted()); // The document was deleted. |
277 EXPECT_FALSE(entry_proto.shared_with_me()); | 281 EXPECT_FALSE(entry_proto.shared_with_me()); |
278 | 282 |
279 // 2012-04-10T22:50:55.797Z | 283 // 2012-04-10T22:50:55.797Z |
280 base::Time::Exploded exploded; | 284 base::Time::Exploded exploded; |
281 exploded.year = 2012; | 285 exploded.year = 2012; |
282 exploded.month = 04; | 286 exploded.month = 04; |
283 exploded.day_of_month = 10; | 287 exploded.day_of_month = 10; |
284 exploded.day_of_week = 2; // Tuesday | 288 exploded.day_of_week = 2; // Tuesday |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 google_apis::ResourceEntry::ExtractAndParse(*value)); | 348 google_apis::ResourceEntry::ExtractAndParse(*value)); |
345 ASSERT_TRUE(resource_entry.get()); | 349 ASSERT_TRUE(resource_entry.get()); |
346 | 350 |
347 DriveEntryProto entry_proto = | 351 DriveEntryProto entry_proto = |
348 ConvertResourceEntryToDriveEntryProto(*resource_entry); | 352 ConvertResourceEntryToDriveEntryProto(*resource_entry); |
349 | 353 |
350 EXPECT_TRUE(entry_proto.shared_with_me()); | 354 EXPECT_TRUE(entry_proto.shared_with_me()); |
351 } | 355 } |
352 | 356 |
353 } // namespace drive | 357 } // namespace drive |
OLD | NEW |