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

Side by Side Diff: media/base/test_data_util.cc

Issue 357413002: Have media content and chrome browser tests load data from media/test/data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: few merge fixes Created 6 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/base/test_data_util.h" 5 #include "media/base/test_data_util.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/numerics/safe_conversions.h" 9 #include "base/numerics/safe_conversions.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "media/base/decoder_buffer.h" 11 #include "media/base/decoder_buffer.h"
12 12
13 namespace media { 13 namespace media {
14 14
15 base::FilePath GetTestDataFilePath(const std::string& name) { 15 base::FilePath GetTestDataFilePath(const std::string& name) {
16 base::FilePath file_path; 16 base::FilePath file_path;
17 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file_path)); 17 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file_path));
18 return file_path.Append(GetTestDataPath()).AppendASCII(name);
19 }
18 20
19 return file_path.AppendASCII("media") 21 base::FilePath GetTestDataPath() {
20 .AppendASCII("test") 22 return base::FilePath(FILE_PATH_LITERAL("media/test/data"));
21 .AppendASCII("data")
22 .AppendASCII(name);
23 } 23 }
24 24
25 scoped_refptr<DecoderBuffer> ReadTestDataFile(const std::string& name) { 25 scoped_refptr<DecoderBuffer> ReadTestDataFile(const std::string& name) {
26 base::FilePath file_path = GetTestDataFilePath(name); 26 base::FilePath file_path = GetTestDataFilePath(name);
27 27
28 int64 tmp = 0; 28 int64 tmp = 0;
29 CHECK(base::GetFileSize(file_path, &tmp)) 29 CHECK(base::GetFileSize(file_path, &tmp))
30 << "Failed to get file size for '" << name << "'"; 30 << "Failed to get file size for '" << name << "'";
31 31
32 int file_size = base::checked_cast<int>(tmp); 32 int file_size = base::checked_cast<int>(tmp);
33 33
34 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(file_size)); 34 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(file_size));
35 CHECK_EQ(file_size, 35 CHECK_EQ(file_size,
36 base::ReadFile( 36 base::ReadFile(
37 file_path, reinterpret_cast<char*>(buffer->writable_data()), 37 file_path, reinterpret_cast<char*>(buffer->writable_data()),
38 file_size)) << "Failed to read '" << name << "'"; 38 file_size)) << "Failed to read '" << name << "'";
39 39
40 return buffer; 40 return buffer;
41 } 41 }
42 42
43 } // namespace media 43 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698