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

Side by Side Diff: webrtc/test/testsupport/test_output.cc

Issue 2998123002: Revert of Add Jpeg frame writer for test support.
Patch Set: Created 3 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/test/testsupport/test_output.h" 11 #include "webrtc/test/testsupport/test_output.h"
12 12
13 #include <string.h> 13 #include <string.h>
14 14
15 #include "webrtc/rtc_base/flags.h" 15 #include "gflags/gflags.h"
16 #include "webrtc/rtc_base/file.h" 16 #include "webrtc/rtc_base/file.h"
17 #include "webrtc/rtc_base/logging.h" 17 #include "webrtc/rtc_base/logging.h"
18 #include "webrtc/rtc_base/pathutils.h" 18 #include "webrtc/rtc_base/pathutils.h"
19 #include "webrtc/test/testsupport/fileutils.h" 19 #include "webrtc/test/testsupport/fileutils.h"
20 20
21 namespace {
22 const std::string kDefaultOutputPath = webrtc::test::OutputPath();
23 }
24
25 DEFINE_string(test_output_dir, 21 DEFINE_string(test_output_dir,
26 kDefaultOutputPath.c_str(), 22 webrtc::test::OutputPath(),
27 "The output folder where test output should be saved."); 23 "The output folder where test output should be saved.");
28 24
29 namespace webrtc { 25 namespace webrtc {
30 namespace test { 26 namespace test {
31 27
32 bool GetTestOutputDir(std::string* out_dir) { 28 bool GetTestOutputDir(std::string* out_dir) {
33 if (strlen(FLAG_test_output_dir) == 0) { 29 if (FLAGS_test_output_dir.empty()) {
34 LOG(LS_WARNING) << "No test_out_dir defined."; 30 LOG(LS_WARNING) << "No test_out_dir defined.";
35 return false; 31 return false;
36 } 32 }
37 *out_dir = FLAG_test_output_dir; 33 *out_dir = FLAGS_test_output_dir;
38 return true; 34 return true;
39 } 35 }
40 36
41 bool WriteToTestOutput(const char* filename, 37 bool WriteToTestOutput(const char* filename,
42 const uint8_t* buffer, 38 const uint8_t* buffer,
43 size_t length) { 39 size_t length) {
44 if (strlen(FLAG_test_output_dir) == 0) { 40 if (FLAGS_test_output_dir.empty()) {
45 LOG(LS_WARNING) << "No test_out_dir defined."; 41 LOG(LS_WARNING) << "No test_out_dir defined.";
46 return false; 42 return false;
47 } 43 }
48 44
49 if (filename == nullptr || strlen(filename) == 0) { 45 if (filename == nullptr || strlen(filename) == 0) {
50 LOG(LS_WARNING) << "filename must be provided."; 46 LOG(LS_WARNING) << "filename must be provided.";
51 return false; 47 return false;
52 } 48 }
53 49
54 rtc::File output = 50 rtc::File output =
55 rtc::File::Create(rtc::Pathname(FLAG_test_output_dir, filename)); 51 rtc::File::Create(rtc::Pathname(FLAGS_test_output_dir, filename));
56 52
57 return output.IsOpen() && output.Write(buffer, length) == length; 53 return output.IsOpen() && output.Write(buffer, length) == length;
58 } 54 }
59 55
60 bool WriteToTestOutput(const char* filename, const std::string& content) { 56 bool WriteToTestOutput(const char* filename, const std::string& content) {
61 return WriteToTestOutput(filename, 57 return WriteToTestOutput(filename,
62 reinterpret_cast<const uint8_t*>(content.c_str()), 58 reinterpret_cast<const uint8_t*>(content.c_str()),
63 content.length()); 59 content.length());
64 } 60 }
65 61
66 } // namespace test 62 } // namespace test
67 } // namespace webrtc 63 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/testsupport/jpeg_frame_writer.cc ('k') | webrtc/test/testsupport/test_output_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698