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

Side by Side Diff: chrome/browser/extensions/api/file_handlers/mime_util_unittest.cc

Issue 442383002: Move storage-related files from webkit/ to new top-level directory storage/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/extensions/api/file_handlers/mime_util.h" 5 #include "chrome/browser/extensions/api/file_handlers/mime_util.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 20 matching lines...) Expand all
31 *output = mime_type; 31 *output = mime_type;
32 } 32 }
33 33
34 // Saves returned mime types to a vector. 34 // Saves returned mime types to a vector.
35 void OnMimeTypesCollected(std::vector<std::string>* output, 35 void OnMimeTypesCollected(std::vector<std::string>* output,
36 scoped_ptr<std::vector<std::string> > mime_types) { 36 scoped_ptr<std::vector<std::string> > mime_types) {
37 *output = *mime_types; 37 *output = *mime_types;
38 } 38 }
39 39
40 // Creates a native local file system URL for a local path. 40 // Creates a native local file system URL for a local path.
41 fileapi::FileSystemURL CreateNativeLocalFileSystemURL( 41 storage::FileSystemURL CreateNativeLocalFileSystemURL(
42 fileapi::FileSystemContext* context, 42 storage::FileSystemContext* context,
43 const base::FilePath local_path) { 43 const base::FilePath local_path) {
44 return context->CreateCrackedFileSystemURL( 44 return context->CreateCrackedFileSystemURL(
45 GURL(kOrigin), fileapi::kFileSystemTypeNativeLocal, local_path); 45 GURL(kOrigin), storage::kFileSystemTypeNativeLocal, local_path);
46 } 46 }
47 47
48 } // namespace 48 } // namespace
49 49
50 class FileHandlersMimeUtilTest : public testing::Test { 50 class FileHandlersMimeUtilTest : public testing::Test {
51 protected: 51 protected:
52 FileHandlersMimeUtilTest() {} 52 FileHandlersMimeUtilTest() {}
53 virtual ~FileHandlersMimeUtilTest() {} 53 virtual ~FileHandlersMimeUtilTest() {}
54 54
55 virtual void SetUp() OVERRIDE { 55 virtual void SetUp() OVERRIDE {
56 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); 56 ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
57 file_system_context_ = 57 file_system_context_ =
58 content::CreateFileSystemContextForTesting(NULL, data_dir_.path()); 58 content::CreateFileSystemContextForTesting(NULL, data_dir_.path());
59 59
60 EXPECT_TRUE(base::CreateTemporaryFile(&html_mime_file_path_)); 60 EXPECT_TRUE(base::CreateTemporaryFile(&html_mime_file_path_));
61 const std::string kSampleContent = "<html><body></body></html>"; 61 const std::string kSampleContent = "<html><body></body></html>";
62 EXPECT_TRUE(base::WriteFile( 62 EXPECT_TRUE(base::WriteFile(
63 html_mime_file_path_, kSampleContent.c_str(), kSampleContent.size())); 63 html_mime_file_path_, kSampleContent.c_str(), kSampleContent.size()));
64 } 64 }
65 65
66 content::TestBrowserThreadBundle thread_bundle_; 66 content::TestBrowserThreadBundle thread_bundle_;
67 TestingProfile profile_; 67 TestingProfile profile_;
68 scoped_refptr<fileapi::FileSystemContext> file_system_context_; 68 scoped_refptr<storage::FileSystemContext> file_system_context_;
69 base::ScopedTempDir data_dir_; 69 base::ScopedTempDir data_dir_;
70 base::FilePath html_mime_file_path_; 70 base::FilePath html_mime_file_path_;
71 }; 71 };
72 72
73 TEST_F(FileHandlersMimeUtilTest, GetMimeTypeForLocalPath) { 73 TEST_F(FileHandlersMimeUtilTest, GetMimeTypeForLocalPath) {
74 { 74 {
75 std::string result; 75 std::string result;
76 GetMimeTypeForLocalPath( 76 GetMimeTypeForLocalPath(
77 &profile_, 77 &profile_,
78 base::FilePath::FromUTF8Unsafe(kJPEGExtensionFilePath), 78 base::FilePath::FromUTF8Unsafe(kJPEGExtensionFilePath),
(...skipping 18 matching lines...) Expand all
97 html_mime_file_path_, 97 html_mime_file_path_,
98 base::Bind(&OnMimeTypeResult, &result)); 98 base::Bind(&OnMimeTypeResult, &result));
99 content::RunAllBlockingPoolTasksUntilIdle(); 99 content::RunAllBlockingPoolTasksUntilIdle();
100 EXPECT_EQ("text/html", result); 100 EXPECT_EQ("text/html", result);
101 } 101 }
102 } 102 }
103 103
104 TEST_F(FileHandlersMimeUtilTest, MimeTypeCollector_ForURLs) { 104 TEST_F(FileHandlersMimeUtilTest, MimeTypeCollector_ForURLs) {
105 MimeTypeCollector collector(&profile_); 105 MimeTypeCollector collector(&profile_);
106 106
107 std::vector<fileapi::FileSystemURL> urls; 107 std::vector<storage::FileSystemURL> urls;
108 urls.push_back(CreateNativeLocalFileSystemURL( 108 urls.push_back(CreateNativeLocalFileSystemURL(
109 file_system_context_, 109 file_system_context_,
110 base::FilePath::FromUTF8Unsafe(kJPEGExtensionFilePath))); 110 base::FilePath::FromUTF8Unsafe(kJPEGExtensionFilePath)));
111 urls.push_back(CreateNativeLocalFileSystemURL( 111 urls.push_back(CreateNativeLocalFileSystemURL(
112 file_system_context_, 112 file_system_context_,
113 base::FilePath::FromUTF8Unsafe(kJPEGExtensionUpperCaseFilePath))); 113 base::FilePath::FromUTF8Unsafe(kJPEGExtensionUpperCaseFilePath)));
114 urls.push_back(CreateNativeLocalFileSystemURL(file_system_context_, 114 urls.push_back(CreateNativeLocalFileSystemURL(file_system_context_,
115 html_mime_file_path_)); 115 html_mime_file_path_));
116 116
117 std::vector<std::string> result; 117 std::vector<std::string> result;
(...skipping 21 matching lines...) Expand all
139 content::RunAllBlockingPoolTasksUntilIdle(); 139 content::RunAllBlockingPoolTasksUntilIdle();
140 140
141 ASSERT_EQ(3u, result.size()); 141 ASSERT_EQ(3u, result.size());
142 EXPECT_EQ("image/jpeg", result[0]); 142 EXPECT_EQ("image/jpeg", result[0]);
143 EXPECT_EQ("image/jpeg", result[1]); 143 EXPECT_EQ("image/jpeg", result[1]);
144 EXPECT_EQ("text/html", result[2]); 144 EXPECT_EQ("text/html", result[2]);
145 } 145 }
146 146
147 } // namespace app_file_handler_util 147 } // namespace app_file_handler_util
148 } // namespace extensions 148 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/file_handlers/mime_util.cc ('k') | chrome/browser/extensions/api/file_system/file_system_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698