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

Unified Diff: webkit/fileapi/file_system_operation_unittest.cc

Issue 6864040: Fixed file/directory url resolution for external mount point provider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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/fileapi/file_system_operation_unittest.cc
===================================================================
--- webkit/fileapi/file_system_operation_unittest.cc (revision 82172)
+++ webkit/fileapi/file_system_operation_unittest.cc (working copy)
@@ -4,14 +4,19 @@
#include "webkit/fileapi/file_system_operation.h"
+#include "base/file_util.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/scoped_temp_dir.h"
#include "base/message_loop.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "webkit/fileapi/file_system_callback_dispatcher.h"
+#include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_file_util.h"
+#include "webkit/fileapi/file_system_mount_point_provider.h"
#include "webkit/fileapi/file_system_operation.h"
+#include "webkit/fileapi/file_system_path_manager.h"
+#include "webkit/fileapi/file_system_util.h"
namespace fileapi {
@@ -39,6 +44,8 @@
FileSystemOperation* operation();
+ void set_local_path(const FilePath& path) { local_path_ = path; }
+ const FilePath& local_path() const { return local_path_; }
void set_status(int status) { status_ = status; }
int status() const { return status_; }
void set_info(const base::PlatformFileInfo& info) { info_ = info; }
@@ -66,10 +73,19 @@
return GURL("file://").Resolve(path.value());
}
+ GURL TestLocalPath(const FilePath& path) const {
+ return GURL(std::string("chrome://test") + path.value());
ericu 2011/04/20 02:23:46 This looks unlikely to work on Windows, where path
zel 2011/04/20 02:49:57 Done.
+ }
+
+ GURL TestURLForPath(const FilePath& path) const {
+ return GURL(std::string("filesystem:") + TestLocalPath(path).spec());
ericu 2011/04/20 02:23:46 Likewise here, can you use one of the above functi
zel 2011/04/20 02:49:57 Yes, I've been already bitten by angry bbots on th
+ }
+
// For post-operation status.
int status_;
base::PlatformFileInfo info_;
FilePath path_;
+ FilePath local_path_;
std::vector<base::FileUtilProxy::Entry> entries_;
DISALLOW_COPY_AND_ASSIGN(FileSystemOperationTest);
@@ -87,6 +103,11 @@
test_->set_status(kFileOperationSucceeded);
}
+ virtual void DidGetLocalPath(const FilePath& local_path) {
+ test_->set_local_path(local_path);
+ test_->set_status(kFileOperationSucceeded);
+ }
+
virtual void DidReadMetadata(
const base::PlatformFileInfo& info,
const FilePath& platform_path) {
@@ -126,6 +147,7 @@
GURL origin_url("fake://fake.foo/");
operation->file_system_operation_context()->set_src_origin_url(origin_url);
operation->file_system_operation_context()->set_dest_origin_url(origin_url);
+
return operation;
}
@@ -610,6 +632,22 @@
EXPECT_EQ(file, path());
}
+TEST_F(FileSystemOperationTest, TestGetLocalFilePathSuccess) {
+ ScopedTempDir dir;
+ ASSERT_TRUE(dir.CreateUniqueTempDir());
+ operation()->GetLocalPath(TestURLForPath(dir.path()));
+ MessageLoop::current()->RunAllPending();
+ EXPECT_EQ(kFileOperationSucceeded, status());
+ EXPECT_EQ(local_path().value(), TestLocalPath(dir.path()).spec());
+
+ FilePath file;
+ file_util::CreateTemporaryFileInDir(dir.path(), &file);
+ operation()->GetLocalPath(TestURLForPath(file));
+ MessageLoop::current()->RunAllPending();
+ EXPECT_EQ(kFileOperationSucceeded, status());
+ EXPECT_EQ(local_path().value(), TestLocalPath(file).spec());
+}
+
TEST_F(FileSystemOperationTest, TestTypeMismatchErrors) {
ScopedTempDir dir;
ASSERT_TRUE(dir.CreateUniqueTempDir());

Powered by Google App Engine
This is Rietveld 408576698