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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/fileapi/file_stream_writer_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chromeos/file_system_provider/fileapi/file_stream_write r.h" 5 #include "chrome/browser/chromeos/file_system_provider/fileapi/file_stream_write r.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/files/file.h" 10 #include "base/files/file.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/files/scoped_temp_dir.h" 12 #include "base/files/scoped_temp_dir.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "chrome/browser/chromeos/file_system_provider/fake_provided_file_system .h" 16 #include "chrome/browser/chromeos/file_system_provider/fake_provided_file_system .h"
17 #include "chrome/browser/chromeos/file_system_provider/service.h" 17 #include "chrome/browser/chromeos/file_system_provider/service.h"
18 #include "chrome/browser/chromeos/file_system_provider/service_factory.h" 18 #include "chrome/browser/chromeos/file_system_provider/service_factory.h"
19 #include "chrome/test/base/testing_browser_process.h" 19 #include "chrome/test/base/testing_browser_process.h"
20 #include "chrome/test/base/testing_profile.h" 20 #include "chrome/test/base/testing_profile.h"
21 #include "chrome/test/base/testing_profile_manager.h" 21 #include "chrome/test/base/testing_profile_manager.h"
22 #include "content/public/test/test_browser_thread_bundle.h" 22 #include "content/public/test/test_browser_thread_bundle.h"
23 #include "content/public/test/test_file_system_context.h" 23 #include "content/public/test/test_file_system_context.h"
24 #include "extensions/browser/extension_registry.h" 24 #include "extensions/browser/extension_registry.h"
25 #include "net/base/io_buffer.h" 25 #include "net/base/io_buffer.h"
26 #include "net/base/net_errors.h" 26 #include "net/base/net_errors.h"
27 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
28 #include "webkit/browser/fileapi/async_file_util.h" 28 #include "storage/browser/fileapi/async_file_util.h"
29 #include "webkit/browser/fileapi/external_mount_points.h" 29 #include "storage/browser/fileapi/external_mount_points.h"
30 #include "webkit/browser/fileapi/file_system_url.h" 30 #include "storage/browser/fileapi/file_system_url.h"
31 31
32 namespace chromeos { 32 namespace chromeos {
33 namespace file_system_provider { 33 namespace file_system_provider {
34 namespace { 34 namespace {
35 35
36 const char kExtensionId[] = "mbflcebpggnecokmikipoihdbecnjfoj"; 36 const char kExtensionId[] = "mbflcebpggnecokmikipoihdbecnjfoj";
37 const char kFileSystemId[] = "testing-file-system"; 37 const char kFileSystemId[] = "testing-file-system";
38 const char kTextToWrite[] = "This is a test of FileStreamWriter."; 38 const char kTextToWrite[] = "This is a test of FileStreamWriter.";
39 39
40 // Pushes a value to the passed log vector. 40 // Pushes a value to the passed log vector.
41 void LogValue(std::vector<int>* log, int value) { 41 void LogValue(std::vector<int>* log, int value) {
42 log->push_back(value); 42 log->push_back(value);
43 } 43 }
44 44
45 // Creates a cracked FileSystemURL for tests. 45 // Creates a cracked FileSystemURL for tests.
46 fileapi::FileSystemURL CreateFileSystemURL(const std::string& mount_point_name, 46 storage::FileSystemURL CreateFileSystemURL(const std::string& mount_point_name,
47 const base::FilePath& file_path) { 47 const base::FilePath& file_path) {
48 const std::string origin = std::string("chrome-extension://") + kExtensionId; 48 const std::string origin = std::string("chrome-extension://") + kExtensionId;
49 const fileapi::ExternalMountPoints* const mount_points = 49 const storage::ExternalMountPoints* const mount_points =
50 fileapi::ExternalMountPoints::GetSystemInstance(); 50 storage::ExternalMountPoints::GetSystemInstance();
51 return mount_points->CreateCrackedFileSystemURL( 51 return mount_points->CreateCrackedFileSystemURL(
52 GURL(origin), 52 GURL(origin),
53 fileapi::kFileSystemTypeExternal, 53 storage::kFileSystemTypeExternal,
54 base::FilePath::FromUTF8Unsafe(mount_point_name).Append(file_path)); 54 base::FilePath::FromUTF8Unsafe(mount_point_name).Append(file_path));
55 } 55 }
56 56
57 // Creates a Service instance. Used to be able to destroy the service in 57 // Creates a Service instance. Used to be able to destroy the service in
58 // TearDown(). 58 // TearDown().
59 KeyedService* CreateService(content::BrowserContext* context) { 59 KeyedService* CreateService(content::BrowserContext* context) {
60 return new Service(Profile::FromBrowserContext(context), 60 return new Service(Profile::FromBrowserContext(context),
61 extensions::ExtensionRegistry::Get(context)); 61 extensions::ExtensionRegistry::Get(context));
62 } 62 }
63 63
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // Setting the testing factory to NULL will destroy the created service 105 // Setting the testing factory to NULL will destroy the created service
106 // associated with the testing profile. 106 // associated with the testing profile.
107 ServiceFactory::GetInstance()->SetTestingFactory(profile_, NULL); 107 ServiceFactory::GetInstance()->SetTestingFactory(profile_, NULL);
108 } 108 }
109 109
110 content::TestBrowserThreadBundle thread_bundle_; 110 content::TestBrowserThreadBundle thread_bundle_;
111 base::ScopedTempDir data_dir_; 111 base::ScopedTempDir data_dir_;
112 scoped_ptr<TestingProfileManager> profile_manager_; 112 scoped_ptr<TestingProfileManager> profile_manager_;
113 TestingProfile* profile_; // Owned by TestingProfileManager. 113 TestingProfile* profile_; // Owned by TestingProfileManager.
114 FakeProvidedFileSystem* provided_file_system_; // Owned by Service. 114 FakeProvidedFileSystem* provided_file_system_; // Owned by Service.
115 fileapi::FileSystemURL file_url_; 115 storage::FileSystemURL file_url_;
116 fileapi::FileSystemURL wrong_file_url_; 116 storage::FileSystemURL wrong_file_url_;
117 }; 117 };
118 118
119 TEST_F(FileSystemProviderFileStreamWriter, Write) { 119 TEST_F(FileSystemProviderFileStreamWriter, Write) {
120 std::vector<int> write_log; 120 std::vector<int> write_log;
121 121
122 const int64 initial_offset = 0; 122 const int64 initial_offset = 0;
123 FileStreamWriter writer(file_url_, initial_offset); 123 FileStreamWriter writer(file_url_, initial_offset);
124 scoped_refptr<net::IOBuffer> io_buffer(new net::StringIOBuffer(kTextToWrite)); 124 scoped_refptr<net::IOBuffer> io_buffer(new net::StringIOBuffer(kTextToWrite));
125 125
126 { 126 {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 FakeEntry entry_after; 207 FakeEntry entry_after;
208 ASSERT_TRUE(provided_file_system_->GetEntry( 208 ASSERT_TRUE(provided_file_system_->GetEntry(
209 base::FilePath::FromUTF8Unsafe(kFakeFilePath), &entry_after)); 209 base::FilePath::FromUTF8Unsafe(kFakeFilePath), &entry_after));
210 const std::string expected_contents = entry_before.contents + kTextToWrite; 210 const std::string expected_contents = entry_before.contents + kTextToWrite;
211 EXPECT_EQ(expected_contents, entry_after.contents); 211 EXPECT_EQ(expected_contents, entry_after.contents);
212 } 212 }
213 213
214 } // namespace file_system_provider 214 } // namespace file_system_provider
215 } // namespace chromeos 215 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698