Chromium Code Reviews| Index: chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util_unittest.cc |
| diff --git a/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util_unittest.cc b/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util_unittest.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c2f9b0e8b4a3bf93d6ce9c755e0ddf59778b0752 |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util_unittest.cc |
| @@ -0,0 +1,93 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "base/files/file_path.h" |
| +#include "chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.h" |
| +#include "storage/browser/fileapi/file_system_url.h" |
| +#include "testing/gtest/include/gtest/gtest.h" |
| +#include "url/gurl.h" |
| + |
| +namespace arc { |
| + |
| +namespace { |
| + |
| +TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrl) { |
| + std::string authority; |
| + std::string root_document_id; |
| + base::FilePath path; |
| + |
| + EXPECT_TRUE(ParseDocumentsProviderUrl( |
| + storage::FileSystemURL::CreateForTest( |
| + GURL(), storage::kFileSystemTypeArcDocumentsProvider, |
| + base::FilePath( |
| + "/special/arc-documents-provider/cats/root/home/calico.jpg")), |
| + &authority, &root_document_id, &path)); |
| + EXPECT_EQ("cats", authority); |
| + EXPECT_EQ("root", root_document_id); |
| + EXPECT_EQ(FILE_PATH_LITERAL("home/calico.jpg"), path.value()); |
| +} |
| + |
| +TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrlEmptyPath) { |
| + std::string authority; |
| + std::string root_document_id; |
| + base::FilePath path; |
| + |
| + EXPECT_TRUE(ParseDocumentsProviderUrl( |
| + storage::FileSystemURL::CreateForTest( |
| + GURL(), storage::kFileSystemTypeArcDocumentsProvider, |
| + base::FilePath("/special/arc-documents-provider/cats/root")), |
| + &authority, &root_document_id, &path)); |
| + EXPECT_EQ("cats", authority); |
| + EXPECT_EQ("root", root_document_id); |
| + EXPECT_EQ(FILE_PATH_LITERAL(""), path.value()); |
| +} |
| + |
| +TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrlInvalidType) { |
| + std::string authority; |
| + std::string root_document_id; |
| + base::FilePath path; |
| + |
| + EXPECT_FALSE(ParseDocumentsProviderUrl( |
| + storage::FileSystemURL::CreateForTest( |
| + GURL(), storage::kFileSystemTypeArcContent, |
| + base::FilePath( |
| + "/special/arc-documents-provider/cats/root/home/calico.jpg")), |
| + &authority, &root_document_id, &path)); |
| +} |
| + |
| +TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrlInvalidPath) { |
| + std::string authority; |
| + std::string root_document_id; |
| + base::FilePath path; |
| + |
| + EXPECT_FALSE(ParseDocumentsProviderUrl( |
| + storage::FileSystemURL::CreateForTest( |
| + GURL(), storage::kFileSystemTypeArcDocumentsProvider, |
| + base::FilePath("/special/arc-documents-provider/root-missing")), |
| + &authority, &root_document_id, &path)); |
| + |
| + EXPECT_FALSE(ParseDocumentsProviderUrl( |
| + storage::FileSystemURL::CreateForTest( |
| + GURL(), storage::kFileSystemTypeArcDocumentsProvider, |
| + base::FilePath( |
| + "special/arc-documents-provider/cats/root/home/calico.jpg")), |
| + &authority, &root_document_id, &path)); |
| + |
| + EXPECT_FALSE(ParseDocumentsProviderUrl( |
| + storage::FileSystemURL::CreateForTest( |
| + GURL(), storage::kFileSystemTypeArcDocumentsProvider, |
| + base::FilePath( |
| + "/invalid/arc-documents-provider/cats/root/home/calico.jpg")), |
| + &authority, &root_document_id, &path)); |
| + |
| + EXPECT_FALSE(ParseDocumentsProviderUrl( |
| + storage::FileSystemURL::CreateForTest( |
| + GURL(), storage::kFileSystemTypeArcDocumentsProvider, |
| + 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.
|
| + &authority, &root_document_id, &path)); |
| +} |
| + |
| +} // namespace |
| + |
| +} // namespace arc |