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

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: fix net dependency for media_perftests 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"));
xhwang 2014/07/07 17:39:55 nit: put "media/test/data" in a file level const c
shadi 2014/07/07 22:58:44 Can't make it a const char, it has to be a CharTyp
21 .AppendASCII("data") 23 }
22 .AppendASCII(name); 24
25 std::string GetURLQueryString(std::vector<StringPair>* query_params) {
26 std::string query = "";
27 if (query_params != NULL && !query_params->empty()) {
28 std::vector<StringPair>::const_iterator itr = query_params->begin();
29 query = itr->first + "=" + itr->second;
30 ++itr;
31 for (; itr != query_params->end(); ++itr) {
32 query.append("&" + itr->first + "=" + itr->second);
33 }
34 }
35 return query;
36 }
xhwang 2014/07/07 17:39:55 How about letting this function return the query s
shadi 2014/07/07 22:58:44 Having query start with "?" would not work with co
37
38 scoped_ptr<net::SpawnedTestServer> StartMediaHttpTestServer() {
39 scoped_ptr<net::SpawnedTestServer> http_test_server;
40 http_test_server.reset(new net::SpawnedTestServer(
41 net::SpawnedTestServer::TYPE_HTTP,
42 net::SpawnedTestServer::kLocalhost,
43 GetTestDataPath()));
44 CHECK(http_test_server->Start());
45 return http_test_server.Pass();
23 } 46 }
24 47
25 scoped_refptr<DecoderBuffer> ReadTestDataFile(const std::string& name) { 48 scoped_refptr<DecoderBuffer> ReadTestDataFile(const std::string& name) {
26 base::FilePath file_path = GetTestDataFilePath(name); 49 base::FilePath file_path = GetTestDataFilePath(name);
27 50
28 int64 tmp = 0; 51 int64 tmp = 0;
29 CHECK(base::GetFileSize(file_path, &tmp)) 52 CHECK(base::GetFileSize(file_path, &tmp))
30 << "Failed to get file size for '" << name << "'"; 53 << "Failed to get file size for '" << name << "'";
31 54
32 int file_size = base::checked_cast<int>(tmp); 55 int file_size = base::checked_cast<int>(tmp);
33 56
34 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(file_size)); 57 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(file_size));
35 CHECK_EQ(file_size, 58 CHECK_EQ(file_size,
36 base::ReadFile( 59 base::ReadFile(
37 file_path, reinterpret_cast<char*>(buffer->writable_data()), 60 file_path, reinterpret_cast<char*>(buffer->writable_data()),
38 file_size)) << "Failed to read '" << name << "'"; 61 file_size)) << "Failed to read '" << name << "'";
39 62
40 return buffer; 63 return buffer;
41 } 64 }
42 65
43 } // namespace media 66 } // namespace media
OLDNEW
« media/base/test_data_util.h ('K') | « media/base/test_data_util.h ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698