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

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

Issue 383063009: Revert 282795 "Have media content and chrome browser tests load ..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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
« no previous file with comments | « trunk/src/media/base/test_data_util.h ('k') | trunk/src/media/media.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 const base::FilePath::CharType kTestDataPath[] =
16 FILE_PATH_LITERAL("media/test/data");
17
18 base::FilePath GetTestDataFilePath(const std::string& name) { 15 base::FilePath GetTestDataFilePath(const std::string& name) {
19 base::FilePath file_path; 16 base::FilePath file_path;
20 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file_path)); 17 CHECK(PathService::Get(base::DIR_SOURCE_ROOT, &file_path));
21 return file_path.Append(GetTestDataPath()).AppendASCII(name);
22 }
23 18
24 base::FilePath GetTestDataPath() { 19 return file_path.AppendASCII("media")
25 return base::FilePath(kTestDataPath); 20 .AppendASCII("test")
26 } 21 .AppendASCII("data")
27 22 .AppendASCII(name);
28 std::string GetURLQueryString(const QueryParams& query_params) {
29 std::string query = "";
30 QueryParams::const_iterator itr = query_params.begin();
31 for (; itr != query_params.end(); ++itr) {
32 if (itr != query_params.begin())
33 query.append("&");
34 query.append(itr->first + "=" + itr->second);
35 }
36 return query;
37 }
38
39 scoped_ptr<net::SpawnedTestServer> StartMediaHttpTestServer() {
40 scoped_ptr<net::SpawnedTestServer> http_test_server;
41 http_test_server.reset(new net::SpawnedTestServer(
42 net::SpawnedTestServer::TYPE_HTTP,
43 net::SpawnedTestServer::kLocalhost,
44 GetTestDataPath()));
45 CHECK(http_test_server->Start());
46 return http_test_server.Pass();
47 } 23 }
48 24
49 scoped_refptr<DecoderBuffer> ReadTestDataFile(const std::string& name) { 25 scoped_refptr<DecoderBuffer> ReadTestDataFile(const std::string& name) {
50 base::FilePath file_path = GetTestDataFilePath(name); 26 base::FilePath file_path = GetTestDataFilePath(name);
51 27
52 int64 tmp = 0; 28 int64 tmp = 0;
53 CHECK(base::GetFileSize(file_path, &tmp)) 29 CHECK(base::GetFileSize(file_path, &tmp))
54 << "Failed to get file size for '" << name << "'"; 30 << "Failed to get file size for '" << name << "'";
55 31
56 int file_size = base::checked_cast<int>(tmp); 32 int file_size = base::checked_cast<int>(tmp);
57 33
58 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(file_size)); 34 scoped_refptr<DecoderBuffer> buffer(new DecoderBuffer(file_size));
59 CHECK_EQ(file_size, 35 CHECK_EQ(file_size,
60 base::ReadFile( 36 base::ReadFile(
61 file_path, reinterpret_cast<char*>(buffer->writable_data()), 37 file_path, reinterpret_cast<char*>(buffer->writable_data()),
62 file_size)) << "Failed to read '" << name << "'"; 38 file_size)) << "Failed to read '" << name << "'";
63 39
64 return buffer; 40 return buffer;
65 } 41 }
66 42
67 } // namespace media 43 } // namespace media
OLDNEW
« no previous file with comments | « trunk/src/media/base/test_data_util.h ('k') | trunk/src/media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698