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

Side by Side Diff: components/device_event_log/device_event_log_impl_unittest.cc

Issue 1234973004: Update SplitString calls in components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/device_event_log/device_event_log_impl.h" 5 #include "components/device_event_log/device_event_log_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 void SetUp() override { 47 void SetUp() override {
48 impl_.reset(new DeviceEventLogImpl(task_runner_, kDefaultMaxEvents)); 48 impl_.reset(new DeviceEventLogImpl(task_runner_, kDefaultMaxEvents));
49 } 49 }
50 50
51 void TearDown() override { impl_.reset(); } 51 void TearDown() override { impl_.reset(); }
52 52
53 protected: 53 protected:
54 std::string SkipTime(const std::string& input) { 54 std::string SkipTime(const std::string& input) {
55 std::string output; 55 std::string output;
56 std::vector<std::string> lines; 56 for (const std::string& line : base::SplitString(
57 base::SplitString(input, '\n', &lines); 57 input, "\n", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL)) {
yzshen1 2015/07/22 22:50:34 TRIM_WHITESPACE
58 for (size_t i = 0; i < lines.size(); ++i) { 58 size_t n = line.find(']');
59 size_t n = lines[i].find(']');
60 if (n != std::string::npos) 59 if (n != std::string::npos)
61 output += "[time] " + lines[i].substr(n + 2) + '\n'; 60 output += "[time] " + line.substr(n + 2) + '\n';
62 else 61 else
63 output += lines[i]; 62 output += line;
64 } 63 }
65 return output; 64 return output;
66 } 65 }
67 66
68 size_t CountLines(const std::string& input) { 67 size_t CountLines(const std::string& input) {
69 return std::count(input.begin(), input.end(), '\n'); 68 return std::count(input.begin(), input.end(), '\n');
70 } 69 }
71 70
72 std::string GetAsString(StringOrder order, 71 std::string GetAsString(StringOrder order,
73 const std::string& format, 72 const std::string& format,
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 "Power: event2\n" 286 "Power: event2\n"
288 "Network: event3\n" 287 "Network: event3\n"
289 "Power: event4\n" 288 "Power: event4\n"
290 "Network: event5\n" 289 "Network: event5\n"
291 "Network: event6\n"); 290 "Network: event6\n");
292 EXPECT_EQ(all_events, GetLogStringForType("network,power")); 291 EXPECT_EQ(all_events, GetLogStringForType("network,power"));
293 EXPECT_EQ(all_events, GetLogStringForType("")); 292 EXPECT_EQ(all_events, GetLogStringForType(""));
294 } 293 }
295 294
296 } // namespace device_event_log 295 } // namespace device_event_log
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698