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

Side by Side Diff: components/domain_reliability/context_unittest.cc

Issue 2278723003: Use StringPiece more in base::Value interfaces. (Closed)
Patch Set: CrOS build fixes Created 4 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
« no previous file with comments | « components/arc/net/arc_net_host_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/domain_reliability/context.h" 5 #include "components/domain_reliability/context.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/bind.h" 14 #include "base/bind.h"
15 #include "base/json/json_reader.h" 15 #include "base/json/json_reader.h"
16 #include "base/strings/string_piece.h"
16 #include "components/domain_reliability/beacon.h" 17 #include "components/domain_reliability/beacon.h"
17 #include "components/domain_reliability/dispatcher.h" 18 #include "components/domain_reliability/dispatcher.h"
18 #include "components/domain_reliability/scheduler.h" 19 #include "components/domain_reliability/scheduler.h"
19 #include "components/domain_reliability/test_util.h" 20 #include "components/domain_reliability/test_util.h"
20 #include "components/domain_reliability/uploader.h" 21 #include "components/domain_reliability/uploader.h"
21 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
22 #include "net/url_request/url_request_test_util.h" 23 #include "net/url_request/url_request_test_util.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 25
25 namespace domain_reliability { 26 namespace domain_reliability {
(...skipping 27 matching lines...) Expand all
53 beacon->upload_depth = 0; 54 beacon->upload_depth = 0;
54 beacon->sample_rate = 1.0; 55 beacon->sample_rate = 1.0;
55 return beacon; 56 return beacon;
56 } 57 }
57 58
58 std::unique_ptr<DomainReliabilityBeacon> MakeBeacon(MockableTime* time) { 59 std::unique_ptr<DomainReliabilityBeacon> MakeBeacon(MockableTime* time) {
59 return MakeCustomizedBeacon(time, "tcp.connection_reset", "", false); 60 return MakeCustomizedBeacon(time, "tcp.connection_reset", "", false);
60 } 61 }
61 62
62 template <typename ValueType, 63 template <typename ValueType,
63 bool (DictionaryValue::* GetValueType)(const std::string&, 64 bool (DictionaryValue::*GetValueType)(base::StringPiece, ValueType*)
64 ValueType*) const> 65 const>
65 struct HasValue { 66 struct HasValue {
66 bool operator()(const DictionaryValue& dict, 67 bool operator()(const DictionaryValue& dict,
67 const std::string& key, 68 const std::string& key,
68 ValueType expected_value) { 69 ValueType expected_value) {
69 ValueType actual_value; 70 ValueType actual_value;
70 bool got_value = (dict.*GetValueType)(key, &actual_value); 71 bool got_value = (dict.*GetValueType)(key, &actual_value);
71 if (got_value) 72 if (got_value)
72 EXPECT_EQ(expected_value, actual_value); 73 EXPECT_EQ(expected_value, actual_value);
73 return got_value && (expected_value == actual_value); 74 return got_value && (expected_value == actual_value);
74 } 75 }
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 beacon->chrome_error = net::OK; 535 beacon->chrome_error = net::OK;
535 context_->OnBeacon(std::move(beacon)); 536 context_->OnBeacon(std::move(beacon));
536 context_->GetQueuedBeaconsForTesting(&beacons); 537 context_->GetQueuedBeaconsForTesting(&beacons);
537 EXPECT_EQ(0u, beacons.size()); 538 EXPECT_EQ(0u, beacons.size());
538 } 539 }
539 540
540 // TODO(juliatuttle): Add beacon_unittest.cc to test serialization. 541 // TODO(juliatuttle): Add beacon_unittest.cc to test serialization.
541 542
542 } // namespace 543 } // namespace
543 } // namespace domain_reliability 544 } // namespace domain_reliability
OLDNEW
« no previous file with comments | « components/arc/net/arc_net_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698