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

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

Issue 2827853003: Rewrite base::Bind to base::BindOnce with base_bind_rewriters in //chrome/browser/media_galleries (Closed)
Patch Set: Created 3 years, 8 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // reasons). 86 // reasons).
87 file_system_context_ = nullptr; 87 file_system_context_ = nullptr;
88 InProcessBrowserTest::TearDownOnMainThread(); 88 InProcessBrowserTest::TearDownOnMainThread();
89 } 89 }
90 90
91 // Write |content| into |filename| in a test file system and try to move 91 // Write |content| into |filename| in a test file system and try to move
92 // it into a media file system. The result is compared to |expected_result|. 92 // it into a media file system. The result is compared to |expected_result|.
93 void MoveTest(const std::string& filename, const std::string& content, 93 void MoveTest(const std::string& filename, const std::string& content,
94 bool expected_result) { 94 bool expected_result) {
95 content::BrowserThread::PostTask( 95 content::BrowserThread::PostTask(
96 content::BrowserThread::FILE, 96 content::BrowserThread::FILE, FROM_HERE,
97 FROM_HERE, 97 base::BindOnce(&MediaFileValidatorTest::SetupOnFileThread,
98 base::Bind(&MediaFileValidatorTest::SetupOnFileThread, 98 base::Unretained(this), filename, content,
99 base::Unretained(this), filename, content, expected_result)); 99 expected_result));
100 loop_runner_ = new content::MessageLoopRunner; 100 loop_runner_ = new content::MessageLoopRunner;
101 loop_runner_->Run(); 101 loop_runner_->Run();
102 } 102 }
103 103
104 // Write |source| into |filename| in a test file system and try to move it 104 // Write |source| into |filename| in a test file system and try to move it
105 // into a media file system. The result is compared to |expected_result|. 105 // into a media file system. The result is compared to |expected_result|.
106 void MoveTestFromFile(const std::string& filename, 106 void MoveTestFromFile(const std::string& filename,
107 const base::FilePath& source, bool expected_result) { 107 const base::FilePath& source, bool expected_result) {
108 content::BrowserThread::PostTask( 108 content::BrowserThread::PostTask(
109 content::BrowserThread::FILE, 109 content::BrowserThread::FILE, FROM_HERE,
110 FROM_HERE, 110 base::BindOnce(&MediaFileValidatorTest::SetupFromFileOnFileThread,
111 base::Bind(&MediaFileValidatorTest::SetupFromFileOnFileThread, 111 base::Unretained(this), filename, source,
112 base::Unretained(this), filename, source, expected_result)); 112 expected_result));
113 loop_runner_ = new content::MessageLoopRunner; 113 loop_runner_ = new content::MessageLoopRunner;
114 loop_runner_->Run(); 114 loop_runner_->Run();
115 } 115 }
116 116
117 private: 117 private:
118 // Create the test files, filesystem objects, etc. 118 // Create the test files, filesystem objects, etc.
119 void SetupOnFileThread(const std::string& filename, 119 void SetupOnFileThread(const std::string& filename,
120 const std::string& content, 120 const std::string& content,
121 bool expected_result) { 121 bool expected_result) {
122 ASSERT_TRUE(base_dir_.CreateUniqueTempDir()); 122 ASSERT_TRUE(base_dir_.CreateUniqueTempDir());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 156
157 size_t extension_index = filename.find_last_of("."); 157 size_t extension_index = filename.find_last_of(".");
158 ASSERT_NE(std::string::npos, extension_index); 158 ASSERT_NE(std::string::npos, extension_index);
159 std::string extension = filename.substr(extension_index); 159 std::string extension = filename.substr(extension_index);
160 std::string dest_root_fs_url = storage::GetIsolatedFileSystemRootURIString( 160 std::string dest_root_fs_url = storage::GetIsolatedFileSystemRootURIString(
161 GURL(kOrigin), dest_fsid, "dest_fs/"); 161 GURL(kOrigin), dest_fsid, "dest_fs/");
162 move_dest_ = file_system_context_->CrackURL(GURL( 162 move_dest_ = file_system_context_->CrackURL(GURL(
163 dest_root_fs_url + "move_dest" + extension)); 163 dest_root_fs_url + "move_dest" + extension));
164 164
165 content::BrowserThread::PostTask( 165 content::BrowserThread::PostTask(
166 content::BrowserThread::IO, 166 content::BrowserThread::IO, FROM_HERE,
167 FROM_HERE, 167 base::BindOnce(&MediaFileValidatorTest::CheckFiles,
168 base::Bind(&MediaFileValidatorTest::CheckFiles, 168 base::Unretained(this), true,
169 base::Unretained(this), true, 169 base::Bind(&MediaFileValidatorTest::OnTestFilesReady,
170 base::Bind(&MediaFileValidatorTest::OnTestFilesReady, 170 base::Unretained(this), expected_result)));
171 base::Unretained(this), expected_result)));
172 } 171 }
173 172
174 void SetupFromFileOnFileThread(const std::string& filename, 173 void SetupFromFileOnFileThread(const std::string& filename,
175 const base::FilePath& source, 174 const base::FilePath& source,
176 bool expected_result) { 175 bool expected_result) {
177 std::string content; 176 std::string content;
178 ASSERT_TRUE(base::ReadFileToString(source, &content)); 177 ASSERT_TRUE(base::ReadFileToString(source, &content));
179 SetupOnFileThread(filename, content, expected_result); 178 SetupOnFileThread(filename, content, expected_result);
180 } 179 }
181 180
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 test_file = test_file.AppendASCII("no_streams.webm"); 300 test_file = test_file.AppendASCII("no_streams.webm");
302 MoveTestFromFile("no_streams.webm", test_file, false); 301 MoveTestFromFile("no_streams.webm", test_file, false);
303 } 302 }
304 303
305 IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, ValidVideo) { 304 IN_PROC_BROWSER_TEST_F(MediaFileValidatorTest, ValidVideo) {
306 base::FilePath test_file = GetMediaTestDir(); 305 base::FilePath test_file = GetMediaTestDir();
307 ASSERT_FALSE(test_file.empty()); 306 ASSERT_FALSE(test_file.empty());
308 test_file = test_file.AppendASCII("bear-320x240-multitrack.webm"); 307 test_file = test_file.AppendASCII("bear-320x240-multitrack.webm");
309 MoveTestFromFile("multitrack.webm", test_file, true); 308 MoveTestFromFile("multitrack.webm", test_file, true);
310 } 309 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698