| 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/drive/drive_api_util.h" | 5 #include "chrome/browser/drive/drive_api_util.h" |
| 6 | 6 |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/md5.h" | 8 #include "base/md5.h" |
| 9 #include "google_apis/drive/drive_api_parser.h" | 9 #include "google_apis/drive/drive_api_parser.h" |
| 10 #include "google_apis/drive/gdata_wapi_parser.h" | 10 #include "google_apis/drive/gdata_wapi_parser.h" |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 { | 146 { |
| 147 scoped_ptr<google_apis::ResourceEntry> resource_entry( | 147 scoped_ptr<google_apis::ResourceEntry> resource_entry( |
| 148 ConvertFileResourceToResourceEntry(file_resource_no_fields)); | 148 ConvertFileResourceToResourceEntry(file_resource_no_fields)); |
| 149 | 149 |
| 150 EXPECT_EQ(-1, resource_entry->image_width()); | 150 EXPECT_EQ(-1, resource_entry->image_width()); |
| 151 EXPECT_EQ(-1, resource_entry->image_height()); | 151 EXPECT_EQ(-1, resource_entry->image_height()); |
| 152 EXPECT_EQ(-1, resource_entry->image_rotation()); | 152 EXPECT_EQ(-1, resource_entry->image_rotation()); |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 | 155 |
| 156 TEST(FileSystemUtilTest, ConvertResourceEntryToFileResourceImageMediaMetadata) { | |
| 157 google_apis::ResourceEntry resource_entry_all_fields; | |
| 158 google_apis::ResourceEntry resource_entry_zero_fields; | |
| 159 google_apis::ResourceEntry resource_entry_no_fields; | |
| 160 // Set up FileResource instances; | |
| 161 { | |
| 162 resource_entry_all_fields.set_image_width(640); | |
| 163 resource_entry_all_fields.set_image_height(480); | |
| 164 resource_entry_all_fields.set_image_rotation(90); | |
| 165 | |
| 166 resource_entry_zero_fields.set_image_width(0); | |
| 167 resource_entry_zero_fields.set_image_height(0); | |
| 168 resource_entry_zero_fields.set_image_rotation(0); | |
| 169 } | |
| 170 | |
| 171 // Verify the converted values. | |
| 172 { | |
| 173 scoped_ptr<google_apis::FileResource> file_resource( | |
| 174 ConvertResourceEntryToFileResource(resource_entry_all_fields)); | |
| 175 const google_apis::ImageMediaMetadata& image_media_metadata = | |
| 176 file_resource->image_media_metadata(); | |
| 177 EXPECT_EQ(640, image_media_metadata.width()); | |
| 178 EXPECT_EQ(480, image_media_metadata.height()); | |
| 179 EXPECT_EQ(90, image_media_metadata.rotation()); | |
| 180 } | |
| 181 { | |
| 182 scoped_ptr<google_apis::FileResource> file_resource( | |
| 183 ConvertResourceEntryToFileResource(resource_entry_zero_fields)); | |
| 184 const google_apis::ImageMediaMetadata& image_media_metadata = | |
| 185 file_resource->image_media_metadata(); | |
| 186 EXPECT_EQ(0, image_media_metadata.width()); | |
| 187 EXPECT_EQ(0, image_media_metadata.height()); | |
| 188 EXPECT_EQ(0, image_media_metadata.rotation()); | |
| 189 } | |
| 190 { | |
| 191 scoped_ptr<google_apis::FileResource> file_resource( | |
| 192 ConvertResourceEntryToFileResource(resource_entry_no_fields)); | |
| 193 const google_apis::ImageMediaMetadata& image_media_metadata = | |
| 194 file_resource->image_media_metadata(); | |
| 195 EXPECT_EQ(-1, image_media_metadata.width()); | |
| 196 EXPECT_EQ(-1, image_media_metadata.height()); | |
| 197 EXPECT_EQ(-1, image_media_metadata.rotation()); | |
| 198 } | |
| 199 } | |
| 200 | |
| 201 TEST(DriveAPIUtilTest, GetMd5Digest) { | 156 TEST(DriveAPIUtilTest, GetMd5Digest) { |
| 202 base::ScopedTempDir temp_dir; | 157 base::ScopedTempDir temp_dir; |
| 203 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 158 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 204 | 159 |
| 205 base::FilePath path = temp_dir.path().AppendASCII("test.txt"); | 160 base::FilePath path = temp_dir.path().AppendASCII("test.txt"); |
| 206 const char kTestData[] = "abcdefghijklmnopqrstuvwxyz0123456789"; | 161 const char kTestData[] = "abcdefghijklmnopqrstuvwxyz0123456789"; |
| 207 ASSERT_TRUE(google_apis::test_util::WriteStringToFile(path, kTestData)); | 162 ASSERT_TRUE(google_apis::test_util::WriteStringToFile(path, kTestData)); |
| 208 | 163 |
| 209 EXPECT_EQ(base::MD5String(kTestData), GetMd5Digest(path)); | 164 EXPECT_EQ(base::MD5String(kTestData), GetMd5Digest(path)); |
| 210 } | 165 } |
| 211 | 166 |
| 212 } // namespace util | 167 } // namespace util |
| 213 } // namespace drive | 168 } // namespace drive |
| OLD | NEW |