OLD | NEW |
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/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 const char kValidImage[] = "RIFF0\0\0\0WEBPVP8 $\0\0\0\xB2\x02\0\x9D\x01\x2A" | 32 const char kValidImage[] = "RIFF0\0\0\0WEBPVP8 $\0\0\0\xB2\x02\0\x9D\x01\x2A" |
33 "\x01\0\x01\0\x2F\x9D\xCE\xE7s\xA8((((\x01\x9CK(\0" | 33 "\x01\0\x01\0\x2F\x9D\xCE\xE7s\xA8((((\x01\x9CK(\0" |
34 "\x05\xCE\xB3l\0\0\xFE\xD8\x80\0\0"; | 34 "\x05\xCE\xB3l\0\0\xFE\xD8\x80\0\0"; |
35 | 35 |
36 const char kInvalidMediaFile[] = "Not a media file"; | 36 const char kInvalidMediaFile[] = "Not a media file"; |
37 | 37 |
38 const int64 kNoFileSize = -1; | 38 const int64 kNoFileSize = -1; |
39 | 39 |
40 void HandleCheckFileResult(int64 expected_size, | 40 void HandleCheckFileResult(int64 expected_size, |
41 const base::Callback<void(bool success)>& callback, | 41 const base::Callback<void(bool success)>& callback, |
42 base::PlatformFileError result, | 42 base::File::Error result, |
43 const base::PlatformFileInfo& file_info) { | 43 const base::File::Info& file_info) { |
44 if (result == base::PLATFORM_FILE_OK) { | 44 if (result == base::File::FILE_OK) { |
45 if (!file_info.is_directory && expected_size != kNoFileSize && | 45 if (!file_info.is_directory && expected_size != kNoFileSize && |
46 file_info.size == expected_size) { | 46 file_info.size == expected_size) { |
47 callback.Run(true); | 47 callback.Run(true); |
48 return; | 48 return; |
49 } | 49 } |
50 } else { | 50 } else { |
51 if (expected_size == kNoFileSize) { | 51 if (expected_size == kNoFileSize) { |
52 callback.Run(true); | 52 callback.Run(true); |
53 return; | 53 return; |
54 } | 54 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 void OnTestFilesReady(bool expected_result, bool test_files_ready) { | 196 void OnTestFilesReady(bool expected_result, bool test_files_ready) { |
197 ASSERT_TRUE(test_files_ready); | 197 ASSERT_TRUE(test_files_ready); |
198 operation_runner()->Move( | 198 operation_runner()->Move( |
199 move_src_, move_dest_, fileapi::FileSystemOperation::OPTION_NONE, | 199 move_src_, move_dest_, fileapi::FileSystemOperation::OPTION_NONE, |
200 base::Bind(&MediaFileValidatorTest::OnMoveResult, | 200 base::Bind(&MediaFileValidatorTest::OnMoveResult, |
201 base::Unretained(this), expected_result)); | 201 base::Unretained(this), expected_result)); |
202 } | 202 } |
203 | 203 |
204 // Check that the move succeeded/failed based on expectation and then | 204 // Check that the move succeeded/failed based on expectation and then |
205 // check that the right file exists. | 205 // check that the right file exists. |
206 void OnMoveResult(bool expected_result, base::PlatformFileError result) { | 206 void OnMoveResult(bool expected_result, base::File::Error result) { |
207 if (expected_result) | 207 if (expected_result) |
208 EXPECT_EQ(base::PLATFORM_FILE_OK, result); | 208 EXPECT_EQ(base::File::FILE_OK, result); |
209 else | 209 else |
210 EXPECT_EQ(base::PLATFORM_FILE_ERROR_SECURITY, result); | 210 EXPECT_EQ(base::File::FILE_ERROR_SECURITY, result); |
211 CheckFiles(!expected_result, | 211 CheckFiles(!expected_result, |
212 base::Bind(&MediaFileValidatorTest::OnTestFilesCheckResult, | 212 base::Bind(&MediaFileValidatorTest::OnTestFilesCheckResult, |
213 base::Unretained(this))); | 213 base::Unretained(this))); |
214 } | 214 } |
215 | 215 |
216 // Check that the correct test file exists and then post the result back | 216 // Check that the correct test file exists and then post the result back |
217 // to the UI thread. | 217 // to the UI thread. |
218 void OnTestFilesCheckResult(bool result) { | 218 void OnTestFilesCheckResult(bool result) { |
219 EXPECT_TRUE(result); | 219 EXPECT_TRUE(result); |
220 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 220 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 test_file = test_file.AppendASCII("no_streams.webm"); | 270 test_file = test_file.AppendASCII("no_streams.webm"); |
271 MoveTestFromFile("no_streams.webm", test_file, false); | 271 MoveTestFromFile("no_streams.webm", test_file, false); |
272 } | 272 } |
273 | 273 |
274 IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, ValidVideo) { | 274 IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, ValidVideo) { |
275 base::FilePath test_file = GetMediaTestDir(); | 275 base::FilePath test_file = GetMediaTestDir(); |
276 ASSERT_FALSE(test_file.empty()); | 276 ASSERT_FALSE(test_file.empty()); |
277 test_file = test_file.AppendASCII("bear-320x240-multitrack.webm"); | 277 test_file = test_file.AppendASCII("bear-320x240-multitrack.webm"); |
278 MoveTestFromFile("multitrack.webm", test_file, true); | 278 MoveTestFromFile("multitrack.webm", test_file, true); |
279 } | 279 } |
OLD | NEW |