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

Side by Side Diff: chrome/browser/media_galleries/fileapi/media_file_validator_browsertest.cc

Issue 1550593002: Switch to standard integer types in chrome/browser/, part 2 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
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 <stddef.h>
6 #include <stdint.h>
7
6 #include "base/bind.h" 8 #include "base/bind.h"
7 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
8 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 11 #include "base/files/scoped_temp_dir.h"
10 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/macros.h"
11 #include "base/path_service.h" 14 #include "base/path_service.h"
12 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
13 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
14 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" 17 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h"
15 #include "chrome/test/base/in_process_browser_test.h" 18 #include "chrome/test/base/in_process_browser_test.h"
16 #include "content/public/test/browser_test.h" 19 #include "content/public/test/browser_test.h"
17 #include "content/public/test/test_file_system_backend.h" 20 #include "content/public/test/test_file_system_backend.h"
18 #include "content/public/test/test_file_system_context.h" 21 #include "content/public/test/test_file_system_context.h"
19 #include "content/public/test/test_utils.h" 22 #include "content/public/test/test_utils.h"
20 #include "storage/browser/fileapi/copy_or_move_file_validator.h" 23 #include "storage/browser/fileapi/copy_or_move_file_validator.h"
21 #include "storage/browser/fileapi/file_system_backend.h" 24 #include "storage/browser/fileapi/file_system_backend.h"
22 #include "storage/browser/fileapi/file_system_context.h" 25 #include "storage/browser/fileapi/file_system_context.h"
23 #include "storage/browser/fileapi/file_system_operation_runner.h" 26 #include "storage/browser/fileapi/file_system_operation_runner.h"
24 #include "storage/browser/fileapi/file_system_url.h" 27 #include "storage/browser/fileapi/file_system_url.h"
25 #include "storage/browser/fileapi/isolated_context.h" 28 #include "storage/browser/fileapi/isolated_context.h"
26 #include "storage/common/fileapi/file_system_types.h" 29 #include "storage/common/fileapi/file_system_types.h"
27 #include "testing/gtest/include/gtest/gtest.h" 30 #include "testing/gtest/include/gtest/gtest.h"
28 31
29 namespace { 32 namespace {
30 33
31 const char kOrigin[] = "http://foo"; 34 const char kOrigin[] = "http://foo";
32 35
33 const char kValidImage[] = "RIFF0\0\0\0WEBPVP8 $\0\0\0\xB2\x02\0\x9D\x01\x2A" 36 const char kValidImage[] = "RIFF0\0\0\0WEBPVP8 $\0\0\0\xB2\x02\0\x9D\x01\x2A"
34 "\x01\0\x01\0\x2F\x9D\xCE\xE7s\xA8((((\x01\x9CK(\0" 37 "\x01\0\x01\0\x2F\x9D\xCE\xE7s\xA8((((\x01\x9CK(\0"
35 "\x05\xCE\xB3l\0\0\xFE\xD8\x80\0\0"; 38 "\x05\xCE\xB3l\0\0\xFE\xD8\x80\0\0";
36 39
37 const char kInvalidMediaFile[] = "Not a media file"; 40 const char kInvalidMediaFile[] = "Not a media file";
38 41
39 const int64 kNoFileSize = -1; 42 const int64_t kNoFileSize = -1;
40 43
41 void HandleCheckFileResult(int64 expected_size, 44 void HandleCheckFileResult(int64_t expected_size,
42 const base::Callback<void(bool success)>& callback, 45 const base::Callback<void(bool success)>& callback,
43 base::File::Error result, 46 base::File::Error result,
44 const base::File::Info& file_info) { 47 const base::File::Info& file_info) {
45 if (result == base::File::FILE_OK) { 48 if (result == base::File::FILE_OK) {
46 if (!file_info.is_directory && expected_size != kNoFileSize && 49 if (!file_info.is_directory && expected_size != kNoFileSize &&
47 file_info.size == expected_size) { 50 file_info.size == expected_size) {
48 callback.Run(true); 51 callback.Run(true);
49 return; 52 return;
50 } 53 }
51 } else { 54 } else {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 const base::Callback<void(bool success)>& callback) { 171 const base::Callback<void(bool success)>& callback) {
169 CheckFile(move_src_, src_expected ? test_file_size_ : kNoFileSize, 172 CheckFile(move_src_, src_expected ? test_file_size_ : kNoFileSize,
170 base::Bind(&MediaFileValidatorTest::OnCheckFilesFirstResult, 173 base::Bind(&MediaFileValidatorTest::OnCheckFilesFirstResult,
171 base::Unretained(this), !src_expected, callback)); 174 base::Unretained(this), !src_expected, callback));
172 } 175 }
173 176
174 // Helper that checks a file has the |expected_size|, which may be 177 // Helper that checks a file has the |expected_size|, which may be
175 // |kNoFileSize| if the file should not exist. |callback| is called 178 // |kNoFileSize| if the file should not exist. |callback| is called
176 // with success/failure. 179 // with success/failure.
177 void CheckFile(storage::FileSystemURL url, 180 void CheckFile(storage::FileSystemURL url,
178 int64 expected_size, 181 int64_t expected_size,
179 const base::Callback<void(bool success)>& callback) { 182 const base::Callback<void(bool success)>& callback) {
180 operation_runner()->GetMetadata( 183 operation_runner()->GetMetadata(
181 url, storage::FileSystemOperation::GET_METADATA_FIELD_SIZE, 184 url, storage::FileSystemOperation::GET_METADATA_FIELD_SIZE,
182 base::Bind(&HandleCheckFileResult, expected_size, callback)); 185 base::Bind(&HandleCheckFileResult, expected_size, callback));
183 } 186 }
184 187
185 // Helper that checks the result of |move_src_| lookup and then checks 188 // Helper that checks the result of |move_src_| lookup and then checks
186 // |move_dest_| if all is as expected. 189 // |move_dest_| if all is as expected.
187 void OnCheckFilesFirstResult(bool dest_expected, 190 void OnCheckFilesFirstResult(bool dest_expected,
188 const base::Callback<void(bool)>& callback, 191 const base::Callback<void(bool)>& callback,
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 test_file = test_file.AppendASCII("no_streams.webm"); 280 test_file = test_file.AppendASCII("no_streams.webm");
278 MoveTestFromFile("no_streams.webm", test_file, false); 281 MoveTestFromFile("no_streams.webm", test_file, false);
279 } 282 }
280 283
281 IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, ValidVideo) { 284 IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, ValidVideo) {
282 base::FilePath test_file = GetMediaTestDir(); 285 base::FilePath test_file = GetMediaTestDir();
283 ASSERT_FALSE(test_file.empty()); 286 ASSERT_FALSE(test_file.empty());
284 test_file = test_file.AppendASCII("bear-320x240-multitrack.webm"); 287 test_file = test_file.AppendASCII("bear-320x240-multitrack.webm");
285 MoveTestFromFile("multitrack.webm", test_file, true); 288 MoveTestFromFile("multitrack.webm", test_file, true);
286 } 289 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698