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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/files/file.h" | 7 #include "base/files/file.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 bool VerifyNumberOfLines(int expected_lines) { | 28 bool VerifyNumberOfLines(int expected_lines) { |
29 std::vector<std::string> lines = GetLinesFromListFile(); | 29 std::vector<std::string> lines = GetLinesFromListFile(); |
30 EXPECT_EQ(expected_lines, static_cast<int>(lines.size())); | 30 EXPECT_EQ(expected_lines, static_cast<int>(lines.size())); |
31 return expected_lines == static_cast<int>(lines.size()); | 31 return expected_lines == static_cast<int>(lines.size()); |
32 } | 32 } |
33 | 33 |
34 bool VerifyLastLineHasAllInfo() { | 34 bool VerifyLastLineHasAllInfo() { |
35 std::string last_line = GetLastLineFromListFile(); | 35 std::string last_line = GetLastLineFromListFile(); |
36 if (last_line.empty()) | 36 if (last_line.empty()) |
37 return false; | 37 return false; |
38 std::vector<std::string> line_parts; | 38 std::vector<std::string> line_parts = base::SplitString( |
39 base::SplitString(last_line, ',', &line_parts); | 39 last_line, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
40 EXPECT_EQ(3u, line_parts.size()); | 40 EXPECT_EQ(3u, line_parts.size()); |
41 if (3u != line_parts.size()) | 41 if (3u != line_parts.size()) |
42 return false; | 42 return false; |
43 // The time (line_parts[0]) is the time when the info was written to the | 43 // The time (line_parts[0]) is the time when the info was written to the |
44 // file which we don't know, so just verify that it's not empty. | 44 // file which we don't know, so just verify that it's not empty. |
45 EXPECT_FALSE(line_parts[0].empty()); | 45 EXPECT_FALSE(line_parts[0].empty()); |
46 EXPECT_STREQ(kTestReportId, line_parts[1].c_str()); | 46 EXPECT_STREQ(kTestReportId, line_parts[1].c_str()); |
47 EXPECT_STREQ(kTestLocalId, line_parts[2].c_str()); | 47 EXPECT_STREQ(kTestLocalId, line_parts[2].c_str()); |
48 return true; | 48 return true; |
49 } | 49 } |
50 | 50 |
51 bool VerifyLastLineHasLocalIdOnly() { | 51 bool VerifyLastLineHasLocalIdOnly() { |
52 std::string last_line = GetLastLineFromListFile(); | 52 std::string last_line = GetLastLineFromListFile(); |
53 if (last_line.empty()) | 53 if (last_line.empty()) |
54 return false; | 54 return false; |
55 std::vector<std::string> line_parts; | 55 std::vector<std::string> line_parts = base::SplitString( |
56 base::SplitString(last_line, ',', &line_parts); | 56 last_line, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
57 EXPECT_EQ(3u, line_parts.size()); | 57 EXPECT_EQ(3u, line_parts.size()); |
58 if (3u != line_parts.size()) | 58 if (3u != line_parts.size()) |
59 return false; | 59 return false; |
60 EXPECT_TRUE(line_parts[0].empty()); | 60 EXPECT_TRUE(line_parts[0].empty()); |
61 EXPECT_TRUE(line_parts[1].empty()); | 61 EXPECT_TRUE(line_parts[1].empty()); |
62 EXPECT_STREQ(kTestLocalId, line_parts[2].c_str()); | 62 EXPECT_STREQ(kTestLocalId, line_parts[2].c_str()); |
63 return true; | 63 return true; |
64 } | 64 } |
65 | 65 |
66 bool VerifyLastLineHasUploadTimeAndIdOnly() { | 66 bool VerifyLastLineHasUploadTimeAndIdOnly() { |
67 std::string last_line = GetLastLineFromListFile(); | 67 std::string last_line = GetLastLineFromListFile(); |
68 if (last_line.empty()) | 68 if (last_line.empty()) |
69 return false; | 69 return false; |
70 std::vector<std::string> line_parts; | 70 std::vector<std::string> line_parts = base::SplitString( |
71 base::SplitString(last_line, ',', &line_parts); | 71 last_line, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
72 EXPECT_EQ(3u, line_parts.size()); | 72 EXPECT_EQ(3u, line_parts.size()); |
73 if (3u != line_parts.size()) | 73 if (3u != line_parts.size()) |
74 return false; | 74 return false; |
75 EXPECT_FALSE(line_parts[0].empty()); | 75 EXPECT_FALSE(line_parts[0].empty()); |
76 EXPECT_STREQ(kTestReportId, line_parts[1].c_str()); | 76 EXPECT_STREQ(kTestReportId, line_parts[1].c_str()); |
77 EXPECT_TRUE(line_parts[2].empty()); | 77 EXPECT_TRUE(line_parts[2].empty()); |
78 return true; | 78 return true; |
79 } | 79 } |
80 | 80 |
81 bool AddLinesToTestFile(int number_of_lines) { | 81 bool AddLinesToTestFile(int number_of_lines) { |
(...skipping 22 matching lines...) Expand all Loading... |
104 | 104 |
105 std::vector<std::string> GetLinesFromListFile() { | 105 std::vector<std::string> GetLinesFromListFile() { |
106 std::string contents; | 106 std::string contents; |
107 int read = base::ReadFileToString(test_list_path_, &contents); | 107 int read = base::ReadFileToString(test_list_path_, &contents); |
108 EXPECT_GT(read, 0); | 108 EXPECT_GT(read, 0); |
109 if (read == 0) | 109 if (read == 0) |
110 return std::vector<std::string>(); | 110 return std::vector<std::string>(); |
111 // Since every line should end with '\n', the last line should be empty. So | 111 // Since every line should end with '\n', the last line should be empty. So |
112 // we expect at least two lines including the final empty. Remove the empty | 112 // we expect at least two lines including the final empty. Remove the empty |
113 // line before returning. | 113 // line before returning. |
114 std::vector<std::string> lines; | 114 std::vector<std::string> lines = base::SplitString( |
115 base::SplitString(contents, '\n', &lines); | 115 contents, "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
116 EXPECT_GT(lines.size(), 1u); | 116 EXPECT_GT(lines.size(), 1u); |
117 if (lines.size() < 2) | 117 if (lines.size() < 2) |
118 return std::vector<std::string>(); | 118 return std::vector<std::string>(); |
119 EXPECT_TRUE(lines[lines.size() - 1].empty()); | 119 EXPECT_TRUE(lines[lines.size() - 1].empty()); |
120 if (!lines[lines.size() - 1].empty()) | 120 if (!lines[lines.size() - 1].empty()) |
121 return std::vector<std::string>(); | 121 return std::vector<std::string>(); |
122 lines.pop_back(); | 122 lines.pop_back(); |
123 return lines; | 123 return lines; |
124 } | 124 } |
125 | 125 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 scoped_ptr<WebRtcLogBuffer> log(new WebRtcLogBuffer()); | 261 scoped_ptr<WebRtcLogBuffer> log(new WebRtcLogBuffer()); |
262 log->SetComplete(); | 262 log->SetComplete(); |
263 webrtc_log_uploader->LoggingStoppedDoUpload( | 263 webrtc_log_uploader->LoggingStoppedDoUpload( |
264 log.Pass(), make_scoped_ptr(new MetaDataMap()), upload_done_data); | 264 log.Pass(), make_scoped_ptr(new MetaDataMap()), upload_done_data); |
265 | 265 |
266 VerifyRtpDumpInMultipart(post_data, "rtpdump_recv", incoming_dump_content); | 266 VerifyRtpDumpInMultipart(post_data, "rtpdump_recv", incoming_dump_content); |
267 VerifyRtpDumpInMultipart(post_data, "rtpdump_send", outgoing_dump_content); | 267 VerifyRtpDumpInMultipart(post_data, "rtpdump_send", outgoing_dump_content); |
268 | 268 |
269 webrtc_log_uploader->StartShutdown(); | 269 webrtc_log_uploader->StartShutdown(); |
270 } | 270 } |
OLD | NEW |