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

Side by Side Diff: webkit/browser/fileapi/copy_or_move_file_validator_unittest.cc

Issue 16155009: Update webkit/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 TestMountPointProvider* provider = static_cast<TestMountPointProvider*>( 91 TestMountPointProvider* provider = static_cast<TestMountPointProvider*>(
92 file_system_context_->GetMountPointProvider(kWithValidatorType)); 92 file_system_context_->GetMountPointProvider(kWithValidatorType));
93 provider->InitializeCopyOrMoveFileValidatorFactory(factory.Pass()); 93 provider->InitializeCopyOrMoveFileValidatorFactory(factory.Pass());
94 } 94 }
95 95
96 void CopyTest(base::PlatformFileError expected) { 96 void CopyTest(base::PlatformFileError expected) {
97 ASSERT_TRUE(FileExists(copy_src_, 10)); 97 ASSERT_TRUE(FileExists(copy_src_, 10));
98 ASSERT_FALSE(FileExists(copy_dest_, 10)); 98 ASSERT_FALSE(FileExists(copy_dest_, 10));
99 99
100 EXPECT_EQ(expected, 100 EXPECT_EQ(expected,
101 AsyncFileTestHelper::Copy(file_system_context_, copy_src_, 101 AsyncFileTestHelper::Copy(
102 copy_dest_)); 102 file_system_context_.get(), copy_src_, copy_dest_));
103 103
104 EXPECT_TRUE(FileExists(copy_src_, 10)); 104 EXPECT_TRUE(FileExists(copy_src_, 10));
105 if (expected == base::PLATFORM_FILE_OK) 105 if (expected == base::PLATFORM_FILE_OK)
106 EXPECT_TRUE(FileExists(copy_dest_, 10)); 106 EXPECT_TRUE(FileExists(copy_dest_, 10));
107 else 107 else
108 EXPECT_FALSE(FileExists(copy_dest_, 10)); 108 EXPECT_FALSE(FileExists(copy_dest_, 10));
109 }; 109 };
110 110
111 void MoveTest(base::PlatformFileError expected) { 111 void MoveTest(base::PlatformFileError expected) {
112 ASSERT_TRUE(FileExists(move_src_, 10)); 112 ASSERT_TRUE(FileExists(move_src_, 10));
113 ASSERT_FALSE(FileExists(move_dest_, 10)); 113 ASSERT_FALSE(FileExists(move_dest_, 10));
114 114
115 EXPECT_EQ(expected, 115 EXPECT_EQ(expected,
116 AsyncFileTestHelper::Move(file_system_context_, move_src_, 116 AsyncFileTestHelper::Move(
117 move_dest_)); 117 file_system_context_.get(), move_src_, move_dest_));
118 118
119 if (expected == base::PLATFORM_FILE_OK) { 119 if (expected == base::PLATFORM_FILE_OK) {
120 EXPECT_FALSE(FileExists(move_src_, 10)); 120 EXPECT_FALSE(FileExists(move_src_, 10));
121 EXPECT_TRUE(FileExists(move_dest_, 10)); 121 EXPECT_TRUE(FileExists(move_dest_, 10));
122 } else { 122 } else {
123 EXPECT_TRUE(FileExists(move_src_, 10)); 123 EXPECT_TRUE(FileExists(move_src_, 10));
124 EXPECT_FALSE(FileExists(move_dest_, 10)); 124 EXPECT_FALSE(FileExists(move_dest_, 10));
125 } 125 }
126 }; 126 };
127 127
128 private: 128 private:
129 FileSystemURL SourceURL(const std::string& path) { 129 FileSystemURL SourceURL(const std::string& path) {
130 return file_system_context_->CreateCrackedFileSystemURL( 130 return file_system_context_->CreateCrackedFileSystemURL(
131 origin_, src_type_, 131 origin_, src_type_,
132 base::FilePath().AppendASCII("src").AppendASCII(path)); 132 base::FilePath().AppendASCII("src").AppendASCII(path));
133 } 133 }
134 134
135 FileSystemURL DestURL(const std::string& path) { 135 FileSystemURL DestURL(const std::string& path) {
136 return file_system_context_->CreateCrackedFileSystemURL( 136 return file_system_context_->CreateCrackedFileSystemURL(
137 origin_, dest_type_, 137 origin_, dest_type_,
138 base::FilePath().AppendASCII("dest").AppendASCII(path)); 138 base::FilePath().AppendASCII("dest").AppendASCII(path));
139 } 139 }
140 140
141 base::PlatformFileError CreateFile(const FileSystemURL& url, size_t size) { 141 base::PlatformFileError CreateFile(const FileSystemURL& url, size_t size) {
142 base::PlatformFileError result = 142 base::PlatformFileError result =
143 AsyncFileTestHelper::CreateFile(file_system_context_, url); 143 AsyncFileTestHelper::CreateFile(file_system_context_.get(), url);
144 if (result != base::PLATFORM_FILE_OK) 144 if (result != base::PLATFORM_FILE_OK)
145 return result; 145 return result;
146 return AsyncFileTestHelper::TruncateFile(file_system_context_, url, size); 146 return AsyncFileTestHelper::TruncateFile(
147 file_system_context_.get(), url, size);
147 } 148 }
148 149
149 base::PlatformFileError CreateDirectory(const FileSystemURL& url) { 150 base::PlatformFileError CreateDirectory(const FileSystemURL& url) {
150 return AsyncFileTestHelper::CreateDirectory(file_system_context_, url); 151 return AsyncFileTestHelper::CreateDirectory(file_system_context_.get(),
152 url);
151 } 153 }
152 154
153 bool FileExists(const FileSystemURL& url, int64 expected_size) { 155 bool FileExists(const FileSystemURL& url, int64 expected_size) {
154 return AsyncFileTestHelper::FileExists( 156 return AsyncFileTestHelper::FileExists(
155 file_system_context_, url, expected_size); 157 file_system_context_.get(), url, expected_size);
156 } 158 }
157 159
158 base::ScopedTempDir base_; 160 base::ScopedTempDir base_;
159 161
160 const GURL origin_; 162 const GURL origin_;
161 163
162 const FileSystemType src_type_; 164 const FileSystemType src_type_;
163 const FileSystemType dest_type_; 165 const FileSystemType dest_type_;
164 std::string src_fsid_; 166 std::string src_fsid_;
165 std::string dest_fsid_; 167 std::string dest_fsid_;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 280
279 scoped_ptr<CopyOrMoveFileValidatorFactory> accept_factory( 281 scoped_ptr<CopyOrMoveFileValidatorFactory> accept_factory(
280 new TestCopyOrMoveFileValidatorFactory(true /*accept_all*/)); 282 new TestCopyOrMoveFileValidatorFactory(true /*accept_all*/));
281 helper.SetMediaCopyOrMoveFileValidatorFactory(accept_factory.Pass()); 283 helper.SetMediaCopyOrMoveFileValidatorFactory(accept_factory.Pass());
282 284
283 helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY); 285 helper.CopyTest(base::PLATFORM_FILE_ERROR_SECURITY);
284 helper.MoveTest(base::PLATFORM_FILE_ERROR_SECURITY); 286 helper.MoveTest(base::PLATFORM_FILE_ERROR_SECURITY);
285 } 287 }
286 288
287 } // namespace fileapi 289 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/database/database_tracker_unittest.cc ('k') | webkit/browser/fileapi/file_system_context_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698