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

Side by Side Diff: webkit/fileapi/file_system_util_unittest.cc

Issue 6833007: More filesystem cleanup: convert URL-encoded-as-FilePath to actual URL, where (Closed) Base URL: svn://chrome-svn/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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/fileapi/file_system_util.cc ('k') | webkit/fileapi/webfilewriter_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/fileapi/file_system_util.h" 5 #include "webkit/fileapi/file_system_util.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "webkit/fileapi/file_system_types.h" 10 #include "webkit/fileapi/file_system_types.h"
(...skipping 11 matching lines...) Expand all
22 GURL origin_url_; 22 GURL origin_url_;
23 FileSystemType type_; 23 FileSystemType type_;
24 FilePath file_path_; 24 FilePath file_path_;
25 }; 25 };
26 26
27 TEST_F(FileSystemUtilTest, ParsePersistent) { 27 TEST_F(FileSystemUtilTest, ParsePersistent) {
28 ASSERT_TRUE(CrackFileSystemURL( 28 ASSERT_TRUE(CrackFileSystemURL(
29 "filesystem:http://chromium.org/persistent/directory/file")); 29 "filesystem:http://chromium.org/persistent/directory/file"));
30 EXPECT_EQ("http://chromium.org/", origin_url_.spec()); 30 EXPECT_EQ("http://chromium.org/", origin_url_.spec());
31 EXPECT_EQ(kFileSystemTypePersistent, type_); 31 EXPECT_EQ(kFileSystemTypePersistent, type_);
32 EXPECT_EQ(FILE_PATH_LITERAL("directory/file"), file_path_.value()); 32 EXPECT_EQ(FILE_PATH_LITERAL("file"), file_path_.BaseName().value());
33 EXPECT_EQ(FILE_PATH_LITERAL("directory"), file_path_.DirName().value());
33 } 34 }
34 35
35 TEST_F(FileSystemUtilTest, ParseTemporary) { 36 TEST_F(FileSystemUtilTest, ParseTemporary) {
36 ASSERT_TRUE(CrackFileSystemURL( 37 ASSERT_TRUE(CrackFileSystemURL(
37 "filesystem:http://chromium.org/temporary/directory/file")); 38 "filesystem:http://chromium.org/temporary/directory/file"));
38 EXPECT_EQ("http://chromium.org/", origin_url_.spec()); 39 EXPECT_EQ("http://chromium.org/", origin_url_.spec());
39 EXPECT_EQ(kFileSystemTypeTemporary, type_); 40 EXPECT_EQ(kFileSystemTypeTemporary, type_);
40 EXPECT_EQ(FILE_PATH_LITERAL("directory/file"), file_path_.value()); 41 EXPECT_EQ(FILE_PATH_LITERAL("file"), file_path_.BaseName().value());
42 EXPECT_EQ(FILE_PATH_LITERAL("directory"), file_path_.DirName().value());
41 } 43 }
42 44
43 TEST_F(FileSystemUtilTest, EnsureFilePathIsRelative) { 45 TEST_F(FileSystemUtilTest, EnsureFilePathIsRelative) {
44 ASSERT_TRUE(CrackFileSystemURL( 46 ASSERT_TRUE(CrackFileSystemURL(
45 "filesystem:http://chromium.org/temporary/////directory/file")); 47 "filesystem:http://chromium.org/temporary/////directory/file"));
46 EXPECT_EQ("http://chromium.org/", origin_url_.spec()); 48 EXPECT_EQ("http://chromium.org/", origin_url_.spec());
47 EXPECT_EQ(kFileSystemTypeTemporary, type_); 49 EXPECT_EQ(kFileSystemTypeTemporary, type_);
48 EXPECT_EQ(FILE_PATH_LITERAL("directory/file"), file_path_.value()); 50 EXPECT_EQ(FILE_PATH_LITERAL("file"), file_path_.BaseName().value());
51 EXPECT_EQ(FILE_PATH_LITERAL("directory"), file_path_.DirName().value());
49 EXPECT_FALSE(file_path_.IsAbsolute()); 52 EXPECT_FALSE(file_path_.IsAbsolute());
50 } 53 }
51 54
52 TEST_F(FileSystemUtilTest, RejectBadSchemes) { 55 TEST_F(FileSystemUtilTest, RejectBadSchemes) {
53 EXPECT_FALSE(CrackFileSystemURL("http://chromium.org/")); 56 EXPECT_FALSE(CrackFileSystemURL("http://chromium.org/"));
54 EXPECT_FALSE(CrackFileSystemURL("https://chromium.org/")); 57 EXPECT_FALSE(CrackFileSystemURL("https://chromium.org/"));
55 EXPECT_FALSE(CrackFileSystemURL("file:///foo/bar")); 58 EXPECT_FALSE(CrackFileSystemURL("file:///foo/bar"));
56 EXPECT_FALSE(CrackFileSystemURL("foobar:///foo/bar")); 59 EXPECT_FALSE(CrackFileSystemURL("foobar:///foo/bar"));
57 } 60 }
58 61
59 TEST_F(FileSystemUtilTest, UnescapePath) { 62 TEST_F(FileSystemUtilTest, UnescapePath) {
60 ASSERT_TRUE(CrackFileSystemURL( 63 ASSERT_TRUE(CrackFileSystemURL(
61 "filesystem:http://chromium.org/persistent/%7Echromium/space%20bar")); 64 "filesystem:http://chromium.org/persistent/%7Echromium/space%20bar"));
62 EXPECT_EQ(FILE_PATH_LITERAL("~chromium/space bar"), file_path_.value()); 65 EXPECT_EQ(FILE_PATH_LITERAL("space bar"), file_path_.BaseName().value());
66 EXPECT_EQ(FILE_PATH_LITERAL("~chromium"), file_path_.DirName().value());
63 } 67 }
64 68
65 TEST_F(FileSystemUtilTest, RejectBadType) { 69 TEST_F(FileSystemUtilTest, RejectBadType) {
66 EXPECT_FALSE(CrackFileSystemURL("filesystem:http://c.org/foobar/file")); 70 EXPECT_FALSE(CrackFileSystemURL("filesystem:http://c.org/foobar/file"));
67 } 71 }
68 72
69 TEST_F(FileSystemUtilTest, RejectMalformedURL) { 73 TEST_F(FileSystemUtilTest, RejectMalformedURL) {
70 EXPECT_FALSE(CrackFileSystemURL("filesystem:///foobar/file")); 74 EXPECT_FALSE(CrackFileSystemURL("filesystem:///foobar/file"));
71 EXPECT_FALSE(CrackFileSystemURL("filesystem:foobar/file")); 75 EXPECT_FALSE(CrackFileSystemURL("filesystem:foobar/file"));
72 } 76 }
73 77
74 TEST_F(FileSystemUtilTest, GetTempFileSystemRootURI) { 78 TEST_F(FileSystemUtilTest, GetTempFileSystemRootURI) {
75 GURL origin_url("http://chromium.org"); 79 GURL origin_url("http://chromium.org");
76 fileapi::FileSystemType type = fileapi::kFileSystemTypeTemporary; 80 fileapi::FileSystemType type = fileapi::kFileSystemTypeTemporary;
77 GURL uri = GURL("filesystem:http://chromium.org/temporary/"); 81 GURL uri = GURL("filesystem:http://chromium.org/temporary/");
78 EXPECT_EQ(uri, GetFileSystemRootURI(origin_url, type)); 82 EXPECT_EQ(uri, GetFileSystemRootURI(origin_url, type));
79 } 83 }
80 84
81 TEST_F(FileSystemUtilTest, GetPersistentFileSystemRootURI) { 85 TEST_F(FileSystemUtilTest, GetPersistentFileSystemRootURI) {
82 GURL origin_url("http://chromium.org"); 86 GURL origin_url("http://chromium.org");
83 fileapi::FileSystemType type = fileapi::kFileSystemTypePersistent; 87 fileapi::FileSystemType type = fileapi::kFileSystemTypePersistent;
84 GURL uri = GURL("filesystem:http://chromium.org/persistent/"); 88 GURL uri = GURL("filesystem:http://chromium.org/persistent/");
85 EXPECT_EQ(uri, GetFileSystemRootURI(origin_url, type)); 89 EXPECT_EQ(uri, GetFileSystemRootURI(origin_url, type));
86 } 90 }
87 91
88 } // namespace (anonymous) 92 } // namespace (anonymous)
89 } // namespace fileapi 93 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_util.cc ('k') | webkit/fileapi/webfilewriter_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698