| 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 "chrome/common/chrome_paths.h" |
| 17 #include "content/public/test/browser_test_utils.h" | 17 #include "content/public/test/browser_test_utils.h" |
| 18 | 18 |
| 19 namespace test { | 19 namespace test { |
| 20 | 20 |
| 21 // Relative to the chrome/test/data directory. | 21 // Relative to the chrome/test/data directory. |
| 22 const base::FilePath::CharType kReferenceFilesDirName[] = | 22 const base::FilePath::CharType kReferenceFilesDirName[] = |
| 23 FILE_PATH_LITERAL("webrtc/resources"); | 23 FILE_PATH_LITERAL("webrtc/resources"); |
| 24 const base::FilePath::CharType kReferenceFileName360p[] = | 24 const base::FilePath::CharType kReferenceFileName360p[] = |
| 25 FILE_PATH_LITERAL("reference_video_640x360_30fps"); | 25 FILE_PATH_LITERAL("reference_video_640x360_30fps"); |
| 26 const base::FilePath::CharType kReferenceFileName720p[] = |
| 27 FILE_PATH_LITERAL("reference_video_1280x720_30fps"); |
| 26 const base::FilePath::CharType kYuvFileExtension[] = FILE_PATH_LITERAL("yuv"); | 28 const base::FilePath::CharType kYuvFileExtension[] = FILE_PATH_LITERAL("yuv"); |
| 27 const base::FilePath::CharType kY4mFileExtension[] = FILE_PATH_LITERAL("y4m"); | 29 const base::FilePath::CharType kY4mFileExtension[] = FILE_PATH_LITERAL("y4m"); |
| 28 | 30 |
| 29 // This message describes how to modify your .gclient to get the reference | 31 // This message describes how to modify your .gclient to get the reference |
| 30 // video files downloaded for you. | 32 // video files downloaded for you. |
| 31 static const char kAdviseOnGclientSolution[] = | 33 static const char kAdviseOnGclientSolution[] = |
| 32 "You need to add this solution to your .gclient to run this test:\n" | 34 "You need to add this solution to your .gclient to run this test:\n" |
| 33 "{\n" | 35 "{\n" |
| 34 " \"name\" : \"webrtc.DEPS\",\n" | 36 " \"name\" : \"webrtc.DEPS\",\n" |
| 35 " \"url\" : \"svn://svn.chromium.org/chrome/trunk/deps/" | 37 " \"url\" : \"svn://svn.chromium.org/chrome/trunk/deps/" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 46 } | 48 } |
| 47 | 49 |
| 48 bool HasReferenceFilesInCheckout() { | 50 bool HasReferenceFilesInCheckout() { |
| 49 if (!base::PathExists(GetReferenceFilesDir())) { | 51 if (!base::PathExists(GetReferenceFilesDir())) { |
| 50 LOG(ERROR) | 52 LOG(ERROR) |
| 51 << "Cannot find the working directory for the reference video " | 53 << "Cannot find the working directory for the reference video " |
| 52 << "files, expected at " << GetReferenceFilesDir().value() << ". " << | 54 << "files, expected at " << GetReferenceFilesDir().value() << ". " << |
| 53 kAdviseOnGclientSolution; | 55 kAdviseOnGclientSolution; |
| 54 return false; | 56 return false; |
| 55 } | 57 } |
| 58 return HasYuvAndY4mFile(test::kReferenceFileName360p) && |
| 59 HasYuvAndY4mFile(test::kReferenceFileName720p); |
| 60 } |
| 61 |
| 62 bool HasYuvAndY4mFile(const base::FilePath::CharType* reference_file) { |
| 56 base::FilePath webrtc_reference_video_yuv = GetReferenceFilesDir() | 63 base::FilePath webrtc_reference_video_yuv = GetReferenceFilesDir() |
| 57 .Append(kReferenceFileName360p).AddExtension(kYuvFileExtension); | 64 .Append(reference_file).AddExtension(kYuvFileExtension); |
| 58 if (!base::PathExists(webrtc_reference_video_yuv)) { | 65 if (!base::PathExists(webrtc_reference_video_yuv)) { |
| 59 LOG(ERROR) | 66 LOG(ERROR) |
| 60 << "Missing YUV reference video to be used for quality" | 67 << "Missing YUV reference video to be used for quality" |
| 61 << " comparison, expected at " << webrtc_reference_video_yuv.value() | 68 << " comparison, expected at " << webrtc_reference_video_yuv.value() |
| 62 << ". " << kAdviseOnGclientSolution; | 69 << ". " << kAdviseOnGclientSolution; |
| 63 return false; | 70 return false; |
| 64 } | 71 } |
| 65 | 72 |
| 66 base::FilePath webrtc_reference_video_y4m = GetReferenceFilesDir() | 73 base::FilePath webrtc_reference_video_y4m = GetReferenceFilesDir() |
| 67 .Append(kReferenceFileName360p).AddExtension(kY4mFileExtension); | 74 .Append(reference_file).AddExtension(kY4mFileExtension); |
| 68 if (!base::PathExists(webrtc_reference_video_y4m)) { | 75 if (!base::PathExists(webrtc_reference_video_y4m)) { |
| 69 LOG(ERROR) | 76 LOG(ERROR) |
| 70 << "Missing Y4M reference video to be used for quality" | 77 << "Missing Y4M reference video to be used for quality" |
| 71 << " comparison, expected at "<< webrtc_reference_video_y4m.value() | 78 << " comparison, expected at "<< webrtc_reference_video_y4m.value() |
| 72 << ". " << kAdviseOnGclientSolution; | 79 << ". " << kAdviseOnGclientSolution; |
| 73 return false; | 80 return false; |
| 74 } | 81 } |
| 75 return true; | 82 return true; |
| 76 } | 83 } |
| 77 | 84 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 void PeerConnectionServerRunner::KillAllPeerConnectionServers() { | 173 void PeerConnectionServerRunner::KillAllPeerConnectionServers() { |
| 167 if (!base::KillProcesses(kServerExecutable, -1, NULL)) { | 174 if (!base::KillProcesses(kServerExecutable, -1, NULL)) { |
| 168 LOG(ERROR) << "Failed to kill instances of " << kServerExecutable << "."; | 175 LOG(ERROR) << "Failed to kill instances of " << kServerExecutable << "."; |
| 169 return; | 176 return; |
| 170 } | 177 } |
| 171 base::WaitForProcessesToExit(kServerExecutable, | 178 base::WaitForProcessesToExit(kServerExecutable, |
| 172 base::TimeDelta::FromSeconds(5), NULL); | 179 base::TimeDelta::FromSeconds(5), NULL); |
| 173 } | 180 } |
| 174 | 181 |
| 175 } // namespace test | 182 } // namespace test |
| OLD | NEW |