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

Side by Side Diff: chromeos/network/network_util_unittest.cc

Issue 2392693002: Rewrite simple uses of base::ListValue::Append(base::Value*) on CrOS. (Closed)
Patch Set: MakeUnique Created 4 years, 2 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 | « chromeos/network/network_util.cc ('k') | chromeos/network/onc/onc_mapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chromeos/network/network_util.h" 5 #include "chromeos/network/network_util.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility>
10
11 #include "base/memory/ptr_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/cros_system_api/dbus/service_constants.h" 13 #include "third_party/cros_system_api/dbus/service_constants.h"
11 14
12 using chromeos::CellularScanResult; 15 using chromeos::CellularScanResult;
13 using chromeos::network_util::NetmaskToPrefixLength; 16 using chromeos::network_util::NetmaskToPrefixLength;
14 using chromeos::network_util::PrefixLengthToNetmask; 17 using chromeos::network_util::PrefixLengthToNetmask;
15 using chromeos::network_util::ParseCellularScanResults; 18 using chromeos::network_util::ParseCellularScanResults;
16 19
17 typedef testing::Test NetworkUtilTest; 20 typedef testing::Test NetworkUtilTest;
18 21
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 114
112 // Empty list value. 115 // Empty list value.
113 EXPECT_TRUE(ParseCellularScanResults(list, &scan_results)); 116 EXPECT_TRUE(ParseCellularScanResults(list, &scan_results));
114 117
115 // List contains invalid item. 118 // List contains invalid item.
116 list.AppendInteger(0); 119 list.AppendInteger(0);
117 EXPECT_FALSE(ParseCellularScanResults(list, &scan_results)); 120 EXPECT_FALSE(ParseCellularScanResults(list, &scan_results));
118 121
119 // Scan result has no network id. 122 // Scan result has no network id.
120 list.Clear(); 123 list.Clear();
121 base::DictionaryValue* dict_value = new base::DictionaryValue(); 124 auto dict_value = base::MakeUnique<base::DictionaryValue>();
122 dict_value->SetString(shill::kStatusProperty, "available"); 125 dict_value->SetString(shill::kStatusProperty, "available");
123 list.Append(dict_value); 126 list.Append(std::move(dict_value));
124 EXPECT_TRUE(ParseCellularScanResults(list, &scan_results)); 127 EXPECT_TRUE(ParseCellularScanResults(list, &scan_results));
125 EXPECT_TRUE(scan_results.empty()); 128 EXPECT_TRUE(scan_results.empty());
126 129
127 // Mixed parse results. 130 // Mixed parse results.
128 dict_value = new base::DictionaryValue(); 131 dict_value = base::MakeUnique<base::DictionaryValue>();
129 dict_value->SetString(shill::kNetworkIdProperty, "000001"); 132 dict_value->SetString(shill::kNetworkIdProperty, "000001");
130 dict_value->SetString(shill::kStatusProperty, "unknown"); 133 dict_value->SetString(shill::kStatusProperty, "unknown");
131 dict_value->SetString(shill::kTechnologyProperty, "GSM"); 134 dict_value->SetString(shill::kTechnologyProperty, "GSM");
132 list.Append(dict_value); 135 list.Append(std::move(dict_value));
133 136
134 dict_value = new base::DictionaryValue(); 137 dict_value = base::MakeUnique<base::DictionaryValue>();
135 dict_value->SetString(shill::kNetworkIdProperty, "000002"); 138 dict_value->SetString(shill::kNetworkIdProperty, "000002");
136 dict_value->SetString(shill::kStatusProperty, "available"); 139 dict_value->SetString(shill::kStatusProperty, "available");
137 dict_value->SetString(shill::kLongNameProperty, "Long Name"); 140 dict_value->SetString(shill::kLongNameProperty, "Long Name");
138 list.Append(dict_value); 141 list.Append(std::move(dict_value));
139 142
140 EXPECT_TRUE(ParseCellularScanResults(list, &scan_results)); 143 EXPECT_TRUE(ParseCellularScanResults(list, &scan_results));
141 EXPECT_EQ(static_cast<size_t>(2), scan_results.size()); 144 EXPECT_EQ(static_cast<size_t>(2), scan_results.size());
142 EXPECT_EQ("000001", scan_results[0].network_id); 145 EXPECT_EQ("000001", scan_results[0].network_id);
143 EXPECT_EQ("unknown", scan_results[0].status); 146 EXPECT_EQ("unknown", scan_results[0].status);
144 EXPECT_EQ("GSM", scan_results[0].technology); 147 EXPECT_EQ("GSM", scan_results[0].technology);
145 EXPECT_TRUE(scan_results[0].long_name.empty()); 148 EXPECT_TRUE(scan_results[0].long_name.empty());
146 EXPECT_TRUE(scan_results[0].short_name.empty()); 149 EXPECT_TRUE(scan_results[0].short_name.empty());
147 150
148 EXPECT_EQ("000002", scan_results[1].network_id); 151 EXPECT_EQ("000002", scan_results[1].network_id);
149 EXPECT_EQ("available", scan_results[1].status); 152 EXPECT_EQ("available", scan_results[1].status);
150 EXPECT_EQ("Long Name", scan_results[1].long_name); 153 EXPECT_EQ("Long Name", scan_results[1].long_name);
151 EXPECT_TRUE(scan_results[1].short_name.empty()); 154 EXPECT_TRUE(scan_results[1].short_name.empty());
152 EXPECT_TRUE(scan_results[1].technology.empty()); 155 EXPECT_TRUE(scan_results[1].technology.empty());
153 } 156 }
OLDNEW
« no previous file with comments | « chromeos/network/network_util.cc ('k') | chromeos/network/onc/onc_mapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698