OLD | NEW |
---|---|
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 "chrome/browser/media/webrtc_browsertest_common.h" | 5 #include "chrome/browser/media/webrtc_browsertest_common.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/process/launch.h" | 10 #include "base/process/launch.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/test/test_timeouts.h" | 12 #include "base/test/test_timeouts.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ui/browser_tabstrip.h" | 15 #include "chrome/browser/ui/browser_tabstrip.h" |
16 #include "chrome/common/chrome_paths.h" | |
16 #include "content/public/test/browser_test_utils.h" | 17 #include "content/public/test/browser_test_utils.h" |
17 | 18 |
18 namespace test { | 19 namespace test { |
19 | 20 |
20 const base::FilePath::CharType kReferenceVideosDirName[] = | 21 // Relative to the chrome/test/data directory. |
21 FILE_PATH_LITERAL("webrtc.DEPS/webrtc_videos"); | 22 const base::FilePath::CharType kReferenceFilesDirName[] = |
23 FILE_PATH_LITERAL("webrtc/resources"); | |
22 const base::FilePath::CharType kReferenceFileName360p[] = | 24 const base::FilePath::CharType kReferenceFileName360p[] = |
23 FILE_PATH_LITERAL("reference_video_640x360_30fps"); | 25 FILE_PATH_LITERAL("reference_video_640x360_30fps"); |
24 const base::FilePath::CharType kYuvFileExtension[] = FILE_PATH_LITERAL("yuv"); | 26 const base::FilePath::CharType kYuvFileExtension[] = FILE_PATH_LITERAL("yuv"); |
25 const base::FilePath::CharType kY4mFileExtension[] = FILE_PATH_LITERAL("y4m"); | 27 const base::FilePath::CharType kY4mFileExtension[] = FILE_PATH_LITERAL("y4m"); |
26 | 28 |
27 // This message describes how to modify your .gclient to get the reference | 29 // This message describes how to modify your .gclient to get the reference |
28 // video files downloaded for you. | 30 // video files downloaded for you. |
29 static const char kAdviseOnGclientSolution[] = | 31 static const char kAdviseOnGclientSolution[] = |
30 "You need to add this solution to your .gclient to run this test:\n" | 32 "You need to add this solution to your .gclient to run this test:\n" |
31 "{\n" | 33 "{\n" |
32 " \"name\" : \"webrtc.DEPS\",\n" | 34 " \"name\" : \"webrtc.DEPS\",\n" |
33 " \"url\" : \"svn://svn.chromium.org/chrome/trunk/deps/" | 35 " \"url\" : \"svn://svn.chromium.org/chrome/trunk/deps/" |
34 "third_party/webrtc/webrtc.DEPS\",\n" | 36 "third_party/webrtc/webrtc.DEPS\",\n" |
35 "}"; | 37 "}"; |
36 | 38 |
37 const int kDefaultPollIntervalMsec = 250; | 39 const int kDefaultPollIntervalMsec = 250; |
38 | 40 |
39 base::FilePath GetReferenceVideosDir() { | 41 base::FilePath GetReferenceFilesDir() { |
40 // FilePath does not tolerate relative paths, and we want to hang the | 42 base::FilePath test_data_dir; |
41 // kReferenceVideosDirName at the same level as Chromium codebase, so we | 43 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); |
42 // need to subtract the trailing .../src manually from the path. | |
43 const size_t src_token_length = 3u; | |
44 const base::FilePath::StringType src_token(FILE_PATH_LITERAL("src")); | |
45 | 44 |
46 base::FilePath source_dir; | 45 return test_data_dir.Append(kReferenceFilesDirName); |
47 PathService::Get(base::DIR_SOURCE_ROOT, &source_dir); | |
48 | |
49 base::FilePath::StringType path = source_dir.value(); | |
50 DCHECK_GT(path.size(), src_token_length); | |
51 std::size_t found = path.rfind(src_token); | |
52 if (found != std::string::npos) | |
53 path.erase(found, src_token_length); | |
kjellander_chromium
2014/04/07 14:59:58
Very nice to get rid of this hacky code!
| |
54 return base::FilePath(path).Append(kReferenceVideosDirName); | |
55 } | 46 } |
56 | 47 |
57 bool HasReferenceFilesInCheckout() { | 48 bool HasReferenceFilesInCheckout() { |
58 if (!base::PathExists(GetReferenceVideosDir())) { | 49 if (!base::PathExists(GetReferenceFilesDir())) { |
59 LOG(ERROR) | 50 LOG(ERROR) |
60 << "Cannot find the working directory for the reference video " | 51 << "Cannot find the working directory for the reference video " |
61 << "files, expected at " << GetReferenceVideosDir().value() << ". " << | 52 << "files, expected at " << GetReferenceFilesDir().value() << ". " << |
62 kAdviseOnGclientSolution; | 53 kAdviseOnGclientSolution; |
63 return false; | 54 return false; |
64 } | 55 } |
65 base::FilePath webrtc_reference_video_yuv = GetReferenceVideosDir() | 56 base::FilePath webrtc_reference_video_yuv = GetReferenceFilesDir() |
66 .Append(kReferenceFileName360p).AddExtension(kYuvFileExtension); | 57 .Append(kReferenceFileName360p).AddExtension(kYuvFileExtension); |
67 if (!base::PathExists(webrtc_reference_video_yuv)) { | 58 if (!base::PathExists(webrtc_reference_video_yuv)) { |
68 LOG(ERROR) | 59 LOG(ERROR) |
69 << "Missing YUV reference video to be used for quality" | 60 << "Missing YUV reference video to be used for quality" |
70 << " comparison, expected at " << webrtc_reference_video_yuv.value() | 61 << " comparison, expected at " << webrtc_reference_video_yuv.value() |
71 << ". " << kAdviseOnGclientSolution; | 62 << ". " << kAdviseOnGclientSolution; |
72 return false; | 63 return false; |
73 } | 64 } |
74 | 65 |
75 base::FilePath webrtc_reference_video_y4m = GetReferenceVideosDir() | 66 base::FilePath webrtc_reference_video_y4m = GetReferenceFilesDir() |
76 .Append(kReferenceFileName360p).AddExtension(kY4mFileExtension); | 67 .Append(kReferenceFileName360p).AddExtension(kY4mFileExtension); |
77 if (!base::PathExists(webrtc_reference_video_y4m)) { | 68 if (!base::PathExists(webrtc_reference_video_y4m)) { |
78 LOG(ERROR) | 69 LOG(ERROR) |
79 << "Missing Y4M reference video to be used for quality" | 70 << "Missing Y4M reference video to be used for quality" |
80 << " comparison, expected at "<< webrtc_reference_video_y4m.value() | 71 << " comparison, expected at "<< webrtc_reference_video_y4m.value() |
81 << ". " << kAdviseOnGclientSolution; | 72 << ". " << kAdviseOnGclientSolution; |
82 return false; | 73 return false; |
83 } | 74 } |
84 return true; | 75 return true; |
85 } | 76 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 void PeerConnectionServerRunner::KillAllPeerConnectionServers() { | 166 void PeerConnectionServerRunner::KillAllPeerConnectionServers() { |
176 if (!base::KillProcesses(kServerExecutable, -1, NULL)) { | 167 if (!base::KillProcesses(kServerExecutable, -1, NULL)) { |
177 LOG(ERROR) << "Failed to kill instances of " << kServerExecutable << "."; | 168 LOG(ERROR) << "Failed to kill instances of " << kServerExecutable << "."; |
178 return; | 169 return; |
179 } | 170 } |
180 base::WaitForProcessesToExit(kServerExecutable, | 171 base::WaitForProcessesToExit(kServerExecutable, |
181 base::TimeDelta::FromSeconds(5), NULL); | 172 base::TimeDelta::FromSeconds(5), NULL); |
182 } | 173 } |
183 | 174 |
184 } // namespace test | 175 } // namespace test |
OLD | NEW |