Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/files/file_path.h" | |
| 6 #include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h" | |
| 7 #include "storage/browser/fileapi/file_system_url.h" | |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
| 9 #include "url/gurl.h" | |
| 10 | |
| 11 namespace arc { | |
| 12 | |
| 13 namespace { | |
| 14 | |
| 15 TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrl) { | |
| 16 std::string authority; | |
| 17 std::string root_document_id; | |
| 18 base::FilePath path; | |
| 19 | |
| 20 EXPECT_TRUE(ParseDocumentsProviderUrl( | |
| 21 storage::FileSystemURL::CreateForTest( | |
| 22 GURL(), storage::kFileSystemTypeArcDocumentsProvider, | |
| 23 base::FilePath( | |
| 24 "/special/arc-documents-provider/cats/root/home/calico.jpg")), | |
| 25 &authority, &root_document_id, &path)); | |
| 26 EXPECT_EQ("cats", authority); | |
| 27 EXPECT_EQ("root", root_document_id); | |
| 28 EXPECT_EQ(FILE_PATH_LITERAL("home/calico.jpg"), path.value()); | |
| 29 } | |
| 30 | |
| 31 TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrlEmptyPath) { | |
| 32 std::string authority; | |
| 33 std::string root_document_id; | |
| 34 base::FilePath path; | |
| 35 | |
| 36 EXPECT_TRUE(ParseDocumentsProviderUrl( | |
| 37 storage::FileSystemURL::CreateForTest( | |
| 38 GURL(), storage::kFileSystemTypeArcDocumentsProvider, | |
| 39 base::FilePath("/special/arc-documents-provider/cats/root")), | |
| 40 &authority, &root_document_id, &path)); | |
| 41 EXPECT_EQ("cats", authority); | |
| 42 EXPECT_EQ("root", root_document_id); | |
| 43 EXPECT_EQ(FILE_PATH_LITERAL(""), path.value()); | |
| 44 } | |
| 45 | |
| 46 TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrlInvalidType) { | |
| 47 std::string authority; | |
| 48 std::string root_document_id; | |
| 49 base::FilePath path; | |
| 50 | |
| 51 EXPECT_FALSE(ParseDocumentsProviderUrl( | |
| 52 storage::FileSystemURL::CreateForTest( | |
| 53 GURL(), storage::kFileSystemTypeArcContent, | |
| 54 base::FilePath( | |
| 55 "/special/arc-documents-provider/cats/root/home/calico.jpg")), | |
| 56 &authority, &root_document_id, &path)); | |
| 57 } | |
| 58 | |
| 59 TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrlInvalidPath) { | |
| 60 std::string authority; | |
| 61 std::string root_document_id; | |
| 62 base::FilePath path; | |
| 63 | |
| 64 EXPECT_FALSE(ParseDocumentsProviderUrl( | |
| 65 storage::FileSystemURL::CreateForTest( | |
| 66 GURL(), storage::kFileSystemTypeArcDocumentsProvider, | |
| 67 base::FilePath("/special/arc-documents-provider/root-missing")), | |
| 68 &authority, &root_document_id, &path)); | |
| 69 | |
| 70 EXPECT_FALSE(ParseDocumentsProviderUrl( | |
| 71 storage::FileSystemURL::CreateForTest( | |
| 72 GURL(), storage::kFileSystemTypeArcDocumentsProvider, | |
| 73 base::FilePath( | |
| 74 "special/arc-documents-provider/cats/root/home/calico.jpg")), | |
| 75 &authority, &root_document_id, &path)); | |
| 76 | |
| 77 EXPECT_FALSE(ParseDocumentsProviderUrl( | |
| 78 storage::FileSystemURL::CreateForTest( | |
| 79 GURL(), storage::kFileSystemTypeArcDocumentsProvider, | |
| 80 base::FilePath( | |
| 81 "/invalid/arc-documents-provider/cats/root/home/calico.jpg")), | |
| 82 &authority, &root_document_id, &path)); | |
| 83 | |
| 84 EXPECT_FALSE(ParseDocumentsProviderUrl( | |
| 85 storage::FileSystemURL::CreateForTest( | |
| 86 GURL(), storage::kFileSystemTypeArcDocumentsProvider, | |
| 87 base::FilePath("/special/something-else/cats/root/home/calico.jpg")), | |
|
Luis Héctor Chávez
2016/12/14 20:53:51
Can you add some paths with Japanese to exercise t
Shuhei Takahashi
2016/12/15 02:37:55
Sure, done.
| |
| 88 &authority, &root_document_id, &path)); | |
| 89 } | |
| 90 | |
| 91 } // namespace | |
| 92 | |
| 93 } // namespace arc | |
| OLD | NEW |