Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util_unittest.cc

Issue 2572683004: mediaview: Introduce ArcDocumentsProviderRoot. (Closed)
Patch Set: Constructors are called on the UI thread. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..fceba1ac5e89989a737ef616e37d3ab128d013f6
--- /dev/null
+++ b/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util_unittest.cc
@@ -0,0 +1,139 @@
+// 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(kDocumentsProviderMountPointPath)
+ .Append(FILE_PATH_LITERAL("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;
+ // Assign a non-empty arbitrary path to make sure an empty path is
+ // set in ParseDocumentsProviderUrl().
+ base::FilePath path(FILE_PATH_LITERAL("foobar"));
+
+ // Should accept a path pointing to a root directory.
+ EXPECT_TRUE(ParseDocumentsProviderUrl(
+ storage::FileSystemURL::CreateForTest(
+ GURL(), storage::kFileSystemTypeArcDocumentsProvider,
+ base::FilePath(kDocumentsProviderMountPointPath)
+ .Append(FILE_PATH_LITERAL("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, ParseDocumentsProviderUrlEmptyPathSlash) {
+ std::string authority;
+ std::string root_document_id;
+ // Assign a non-empty arbitrary path to make sure an empty path is
+ // set in ParseDocumentsProviderUrl().
+ base::FilePath path(FILE_PATH_LITERAL("foobar"));
+
+ // Should accept a path pointing to a root directory.
+ EXPECT_TRUE(ParseDocumentsProviderUrl(
+ storage::FileSystemURL::CreateForTest(
+ GURL(), storage::kFileSystemTypeArcDocumentsProvider,
+ base::FilePath(kDocumentsProviderMountPointPath)
+ .Append(FILE_PATH_LITERAL("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;
+
+ // Not storage::kFileSystemTypeArcDocumentsProvider.
+ EXPECT_FALSE(ParseDocumentsProviderUrl(
+ storage::FileSystemURL::CreateForTest(
+ GURL(), storage::kFileSystemTypeArcContent,
+ base::FilePath(kDocumentsProviderMountPointPath)
+ .Append(FILE_PATH_LITERAL("cats/root/home/calico.jpg"))),
+ &authority, &root_document_id, &path));
+}
+
+TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrlInvalidPath) {
+ std::string authority;
+ std::string root_document_id;
+ base::FilePath path;
+
+ // root_document_id part is missing.
+ EXPECT_FALSE(ParseDocumentsProviderUrl(
+ storage::FileSystemURL::CreateForTest(
+ GURL(), storage::kFileSystemTypeArcDocumentsProvider,
+ base::FilePath(kDocumentsProviderMountPointPath)
+ .Append(FILE_PATH_LITERAL("root-missing"))),
+ &authority, &root_document_id, &path));
+
+ // Leading / is missing.
+ EXPECT_FALSE(ParseDocumentsProviderUrl(
+ storage::FileSystemURL::CreateForTest(
+ GURL(), storage::kFileSystemTypeArcDocumentsProvider,
+ base::FilePath(FILE_PATH_LITERAL(
+ "special/arc-documents-provider/cats/root/home/calico.jpg"))),
+ &authority, &root_document_id, &path));
+
+ // Not under /special.
+ EXPECT_FALSE(ParseDocumentsProviderUrl(
+ storage::FileSystemURL::CreateForTest(
+ GURL(), storage::kFileSystemTypeArcDocumentsProvider,
+ base::FilePath(FILE_PATH_LITERAL(
+ "/invalid/arc-documents-provider/cats/root/home/calico.jpg"))),
+ &authority, &root_document_id, &path));
+
+ // Not under /special/arc-documents-provider.
+ EXPECT_FALSE(ParseDocumentsProviderUrl(
+ storage::FileSystemURL::CreateForTest(
+ GURL(), storage::kFileSystemTypeArcDocumentsProvider,
+ base::FilePath(FILE_PATH_LITERAL(
+ "/special/something-else/cats/root/home/calico.jpg"))),
+ &authority, &root_document_id, &path));
+}
+
+TEST(ArcDocumentsProviderUtilTest, ParseDocumentsProviderUrlUtf8) {
+ 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/みけねこ.jpg")),
+ &authority, &root_document_id, &path));
+ EXPECT_EQ("cats", authority);
+ EXPECT_EQ("root", root_document_id);
+ EXPECT_EQ(FILE_PATH_LITERAL("home/みけねこ.jpg"), path.value());
+}
+
+} // namespace
+
+} // namespace arc
« no previous file with comments | « chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698