OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "net/dns/dns_config_service.h" | 5 #include "net/dns/dns_config_service.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/cancelable_callback.h" | 9 #include "base/cancelable_callback.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 NameServerClassifier::NAME_SERVERS_TYPE_PRIVATE; | 30 NameServerClassifier::NAME_SERVERS_TYPE_PRIVATE; |
31 const NameServerClassifier::NameServersType kPublic = | 31 const NameServerClassifier::NameServersType kPublic = |
32 NameServerClassifier::NAME_SERVERS_TYPE_PUBLIC; | 32 NameServerClassifier::NAME_SERVERS_TYPE_PUBLIC; |
33 const NameServerClassifier::NameServersType kMixed = | 33 const NameServerClassifier::NameServersType kMixed = |
34 NameServerClassifier::NAME_SERVERS_TYPE_MIXED; | 34 NameServerClassifier::NAME_SERVERS_TYPE_MIXED; |
35 | 35 |
36 class NameServerClassifierTest : public testing::Test { | 36 class NameServerClassifierTest : public testing::Test { |
37 protected: | 37 protected: |
38 NameServerClassifier::NameServersType Classify( | 38 NameServerClassifier::NameServersType Classify( |
39 const std::string& servers_string) { | 39 const std::string& servers_string) { |
40 std::vector<std::string> server_strings; | |
41 base::SplitString(servers_string, ' ', &server_strings); | |
42 | |
43 std::vector<IPEndPoint> servers; | 40 std::vector<IPEndPoint> servers; |
44 for (std::vector<std::string>::const_iterator it = server_strings.begin(); | 41 for (const base::StringPiece& server_str : |
45 it != server_strings.end(); | 42 base::SplitStringPiece(servers_string, " ", base::TRIM_WHITESPACE, |
46 ++it) { | 43 base::SPLIT_WANT_ALL)) { |
47 if (it->empty()) | 44 if (server_str.empty()) |
48 continue; | 45 continue; |
49 | 46 |
50 IPAddressNumber address; | 47 IPAddressNumber address; |
51 bool parsed = ParseIPLiteralToNumber(*it, &address); | 48 bool parsed = ParseIPLiteralToNumber(server_str, &address); |
52 EXPECT_TRUE(parsed); | 49 EXPECT_TRUE(parsed); |
53 servers.push_back(IPEndPoint(address, dns_protocol::kDefaultPort)); | 50 servers.push_back(IPEndPoint(address, dns_protocol::kDefaultPort)); |
54 } | 51 } |
55 | 52 |
56 return classifier_.GetNameServersType(servers); | 53 return classifier_.GetNameServersType(servers); |
57 } | 54 } |
58 | 55 |
59 private: | 56 private: |
60 NameServerClassifier classifier_; | 57 NameServerClassifier classifier_; |
61 }; | 58 }; |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 | 327 |
331 last_config_ = bad_config; | 328 last_config_ = bad_config; |
332 // No change, so no update. | 329 // No change, so no update. |
333 service_->InvalidateConfig(); | 330 service_->InvalidateConfig(); |
334 service_->OnConfigRead(config2); | 331 service_->OnConfigRead(config2); |
335 EXPECT_TRUE(last_config_.Equals(bad_config)); | 332 EXPECT_TRUE(last_config_.Equals(bad_config)); |
336 } | 333 } |
337 | 334 |
338 } // namespace net | 335 } // namespace net |
339 | 336 |
OLD | NEW |