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

Unified Diff: webkit/chromeos/fileapi/cros_mount_point_provider_unittest.cc

Issue 14096022: Make MountPointProvider pluggable from outside webkit/fileapi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months 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: webkit/chromeos/fileapi/cros_mount_point_provider_unittest.cc
diff --git a/webkit/chromeos/fileapi/cros_mount_point_provider_unittest.cc b/webkit/chromeos/fileapi/cros_mount_point_provider_unittest.cc
index 22f74df023c44b7eb7120ba68d3b23dc2b6e8e7b..3971e221b06e7b30276173f74d67bffc264b26cd 100644
--- a/webkit/chromeos/fileapi/cros_mount_point_provider_unittest.cc
+++ b/webkit/chromeos/fileapi/cros_mount_point_provider_unittest.cc
@@ -7,19 +7,33 @@
#include <set>
#include "base/files/file_path.h"
+#include "base/memory/scoped_vector.h"
+#include "base/message_loop.h"
+#include "base/stringprintf.h"
#include "chromeos/dbus/cros_disks_client.h"
#include "googleurl/src/url_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/fileapi/external_mount_points.h"
#include "webkit/fileapi/file_permission_policy.h"
+#include "webkit/fileapi/file_system_context.h"
+#include "webkit/fileapi/file_system_mount_point_provider.h"
+#include "webkit/fileapi/file_system_task_runners.h"
#include "webkit/fileapi/file_system_url.h"
#include "webkit/fileapi/isolated_context.h"
+#include "webkit/fileapi/mock_file_system_options.h"
#include "webkit/quota/mock_special_storage_policy.h"
#define FPL(x) FILE_PATH_LITERAL(x)
+#if defined(FILE_PATH_USES_DRIVE_LETTERS)
+#define DRIVE FPL("C:")
+#else
+#define DRIVE
+#endif
+
using fileapi::ExternalMountPoints;
using fileapi::FileSystemURL;
+using fileapi::FileSystemContext;
namespace {
@@ -32,6 +46,51 @@ FileSystemURL CreateFileSystemURL(const std::string& extension,
base::FilePath::FromUTF8Unsafe(path));
}
+GURL CreateRawFileSystemURL(const std::string& type_str,
+ const std::string& fs_id) {
+ std::string url_str = base::StringPrintf(
+ "filesystem:http://chromium.org/%s/%s/root/file",
+ type_str.c_str(),
+ fs_id.c_str());
+ return GURL(url_str);
+}
+
+fileapi::FileSystemContext* CreateFileSystemContextForTest(
+ ExternalMountPoints* external_mount_points) {
+ ScopedVector<fileapi::FileSystemMountPointProvider> additional_providers;
+ additional_providers.push_back(
+ new chromeos::CrosMountPointProvider(
+ make_scoped_refptr(new quota::MockSpecialStoragePolicy()),
+ external_mount_points,
+ ExternalMountPoints::GetSystemInstance()));
+ std::vector<fileapi::MountPoints*> additional_mount_points;
+ additional_mount_points.push_back(external_mount_points);
+ return new fileapi::FileSystemContext(
+ fileapi::FileSystemTaskRunners::CreateMockTaskRunners(),
+ NULL,
+ additional_providers.Pass(),
+ additional_mount_points,
+ base::FilePath(FILE_PATH_LITERAL("dummy")),
+ fileapi::CreateAllowFileAccessOptions());
+}
+
+void ExpectFileSystemURLMatches(const fileapi::FileSystemURL& url,
+ const GURL& expect_origin,
+ fileapi::FileSystemType expect_mount_type,
+ fileapi::FileSystemType expect_type,
+ const base::FilePath& expect_path,
+ const base::FilePath& expect_virtual_path,
+ const std::string& expect_filesystem_id) {
+ EXPECT_TRUE(url.is_valid());
+
+ EXPECT_EQ(expect_origin, url.origin());
+ EXPECT_EQ(expect_mount_type, url.mount_type());
+ EXPECT_EQ(expect_type, url.type());
+ EXPECT_EQ(expect_path, url.path());
+ EXPECT_EQ(expect_virtual_path, url.virtual_path());
+ EXPECT_EQ(expect_filesystem_id, url.filesystem_id());
+}
+
TEST(CrosMountPointProviderTest, DefaultMountPoints) {
scoped_refptr<quota::SpecialStoragePolicy> storage_policy =
new quota::MockSpecialStoragePolicy();
@@ -299,4 +358,44 @@ TEST(CrosMountPointProvider, GetVirtualPathConflictWithSystemPoints) {
}
}
+TEST(CrosMountPointProvider, CrosMountPonitProviderKeepsMountPointsAlive) {
tzik 2013/04/17 12:06:04 s/Ponit/Point/
kinuko 2013/04/17 14:27:29 Removed these CrOS changes from this patch.
+ scoped_refptr<ExternalMountPoints> mount_points =
+ ExternalMountPoints::CreateRefCounted();
+
+ // Register system external mount point.
+ ASSERT_TRUE(mount_points->RegisterFileSystem(
+ "system",
+ fileapi::kFileSystemTypeNativeLocal,
+ base::FilePath(DRIVE FPL("/test/sys/"))));
+
+ base::MessageLoop message_loop;
+ scoped_refptr<fileapi::FileSystemContext> file_system_context(
+ CreateFileSystemContextForTest(mount_points.get()));
+
+ // Release a MountPoints reference created in the test.
+ mount_points = NULL;
+
+ // CrosMountPointProvider should keep a reference to the |mount_points|, so it
+ // should be able to resolve the URL.
+ FileSystemURL cracked_external = file_system_context->CrackURL(
+ CreateRawFileSystemURL("external", "system"));
+
+ const char kTestOrigin[] = "http://chromium.org/";
+ ExpectFileSystemURLMatches(
+ cracked_external,
+ GURL(kTestOrigin),
+ fileapi::kFileSystemTypeExternal,
+ fileapi::kFileSystemTypeNativeLocal,
+ base::FilePath(
+ DRIVE FPL("/test/sys/root/file")).NormalizePathSeparators(),
+ base::FilePath(FPL("system/root/file")).NormalizePathSeparators(),
+ "system");
+
+ file_system_context = NULL;
+ message_loop.RunUntilIdle();
+
+ // No need to revoke the registered filesystem since |mount_points| lifetime
+ // is bound to this test.
+}
+
} // namespace

Powered by Google App Engine
This is Rietveld 408576698