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

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

Issue 2572683004: mediaview: Introduce ArcDocumentsProviderRoot. (Closed)
Patch Set: Addressed lhchavez's comments. 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
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..ce8b807bc101cd43aff99a7fbdb0770ea4005e9e
--- /dev/null
+++ b/chrome/browser/chromeos/arc/fileapi/arc_documents_provider_util_unittest.cc
@@ -0,0 +1,109 @@
+// 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")),
hashimoto 2016/12/15 03:53:22 1. Why don't you use kDocumentsProviderMountPointP
Shuhei Takahashi 2016/12/15 05:21:53 Done.
+ &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")),
hashimoto 2016/12/15 03:53:22 Please add comments to make it clear what makes ea
Shuhei Takahashi 2016/12/15 05:21:53 Done.
+ &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")),
+ &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

Powered by Google App Engine
This is Rietveld 408576698