| 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/drive_api_util.h" | 5 #include "components/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/test_util.h" | 10 #include "google_apis/drive/test_util.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 EXPECT_EQ(resource_id, CanonicalizeResourceId("presentation:" + resource_id)); | 64 EXPECT_EQ(resource_id, CanonicalizeResourceId("presentation:" + resource_id)); |
| 65 EXPECT_EQ(resource_id, CanonicalizeResourceId("drawing:" + resource_id)); | 65 EXPECT_EQ(resource_id, CanonicalizeResourceId("drawing:" + resource_id)); |
| 66 EXPECT_EQ(resource_id, CanonicalizeResourceId("table:" + resource_id)); | 66 EXPECT_EQ(resource_id, CanonicalizeResourceId("table:" + resource_id)); |
| 67 EXPECT_EQ(resource_id, CanonicalizeResourceId("externalapp:" + resource_id)); | 67 EXPECT_EQ(resource_id, CanonicalizeResourceId("externalapp:" + resource_id)); |
| 68 } | 68 } |
| 69 | 69 |
| 70 TEST(DriveAPIUtilTest, GetMd5Digest) { | 70 TEST(DriveAPIUtilTest, GetMd5Digest) { |
| 71 base::ScopedTempDir temp_dir; | 71 base::ScopedTempDir temp_dir; |
| 72 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 72 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 73 | 73 |
| 74 base::FilePath path = temp_dir.path().AppendASCII("test.txt"); | 74 base::FilePath path = temp_dir.GetPath().AppendASCII("test.txt"); |
| 75 const char kTestData[] = "abcdefghijklmnopqrstuvwxyz0123456789"; | 75 const char kTestData[] = "abcdefghijklmnopqrstuvwxyz0123456789"; |
| 76 ASSERT_TRUE(google_apis::test_util::WriteStringToFile(path, kTestData)); | 76 ASSERT_TRUE(google_apis::test_util::WriteStringToFile(path, kTestData)); |
| 77 | 77 |
| 78 EXPECT_EQ(base::MD5String(kTestData), GetMd5Digest(path, nullptr)); | 78 EXPECT_EQ(base::MD5String(kTestData), GetMd5Digest(path, nullptr)); |
| 79 } | 79 } |
| 80 | 80 |
| 81 TEST(DriveAPIUtilTest, HasHostedDocumentExtension) { | 81 TEST(DriveAPIUtilTest, HasHostedDocumentExtension) { |
| 82 EXPECT_TRUE( | 82 EXPECT_TRUE( |
| 83 HasHostedDocumentExtension(base::FilePath::FromUTF8Unsafe("xx.gdoc"))); | 83 HasHostedDocumentExtension(base::FilePath::FromUTF8Unsafe("xx.gdoc"))); |
| 84 EXPECT_TRUE( | 84 EXPECT_TRUE( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 103 EXPECT_FALSE( | 103 EXPECT_FALSE( |
| 104 HasHostedDocumentExtension(base::FilePath::FromUTF8Unsafe("xx.docx"))); | 104 HasHostedDocumentExtension(base::FilePath::FromUTF8Unsafe("xx.docx"))); |
| 105 EXPECT_FALSE( | 105 EXPECT_FALSE( |
| 106 HasHostedDocumentExtension(base::FilePath::FromUTF8Unsafe("xx.jpg"))); | 106 HasHostedDocumentExtension(base::FilePath::FromUTF8Unsafe("xx.jpg"))); |
| 107 EXPECT_FALSE( | 107 EXPECT_FALSE( |
| 108 HasHostedDocumentExtension(base::FilePath::FromUTF8Unsafe("xx.gmap"))); | 108 HasHostedDocumentExtension(base::FilePath::FromUTF8Unsafe("xx.gmap"))); |
| 109 } | 109 } |
| 110 | 110 |
| 111 } // namespace util | 111 } // namespace util |
| 112 } // namespace drive | 112 } // namespace drive |
| OLD | NEW |