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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <queue> | 10 #include <queue> |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 namespace { | 490 namespace { |
491 | 491 |
492 // Create the numerical representation of |values|, strings passed as | 492 // Create the numerical representation of |values|, strings passed as |
493 // extraInfoSpec by the event handler. Returns true on success, otherwise false. | 493 // extraInfoSpec by the event handler. Returns true on success, otherwise false. |
494 bool GenerateInfoSpec(const std::string& values, int* result) { | 494 bool GenerateInfoSpec(const std::string& values, int* result) { |
495 // Create a base::ListValue of strings. | 495 // Create a base::ListValue of strings. |
496 base::ListValue list_value; | 496 base::ListValue list_value; |
497 for (const std::string& cur : | 497 for (const std::string& cur : |
498 base::SplitString(values, ",", base::KEEP_WHITESPACE, | 498 base::SplitString(values, ",", base::KEEP_WHITESPACE, |
499 base::SPLIT_WANT_NONEMPTY)) | 499 base::SPLIT_WANT_NONEMPTY)) |
500 list_value.Append(new base::StringValue(cur)); | 500 list_value.AppendString(cur); |
501 return ExtraInfoSpec::InitFromValue(list_value, result); | 501 return ExtraInfoSpec::InitFromValue(list_value, result); |
502 } | 502 } |
503 | 503 |
504 } // namespace | 504 } // namespace |
505 | 505 |
506 void ExtensionWebRequestTest::FireURLRequestWithData( | 506 void ExtensionWebRequestTest::FireURLRequestWithData( |
507 const std::string& method, | 507 const std::string& method, |
508 const char* content_type, | 508 const char* content_type, |
509 const std::vector<char>& bytes_1, | 509 const std::vector<char>& bytes_1, |
510 const std::vector<char>& bytes_2) { | 510 const std::vector<char>& bytes_2) { |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 new EventResponseDelta("ext_1", base::Time::FromInternalValue(0))); | 1255 new EventResponseDelta("ext_1", base::Time::FromInternalValue(0))); |
1256 linked_ptr<EventResponseDelta> b( | 1256 linked_ptr<EventResponseDelta> b( |
1257 new EventResponseDelta("ext_2", base::Time::FromInternalValue(1000))); | 1257 new EventResponseDelta("ext_2", base::Time::FromInternalValue(1000))); |
1258 EXPECT_FALSE(InDecreasingExtensionInstallationTimeOrder(a, a)); | 1258 EXPECT_FALSE(InDecreasingExtensionInstallationTimeOrder(a, a)); |
1259 EXPECT_FALSE(InDecreasingExtensionInstallationTimeOrder(a, b)); | 1259 EXPECT_FALSE(InDecreasingExtensionInstallationTimeOrder(a, b)); |
1260 EXPECT_TRUE(InDecreasingExtensionInstallationTimeOrder(b, a)); | 1260 EXPECT_TRUE(InDecreasingExtensionInstallationTimeOrder(b, a)); |
1261 } | 1261 } |
1262 | 1262 |
1263 TEST(ExtensionWebRequestHelpersTest, TestStringToCharList) { | 1263 TEST(ExtensionWebRequestHelpersTest, TestStringToCharList) { |
1264 base::ListValue list_value; | 1264 base::ListValue list_value; |
1265 list_value.Append(new base::FundamentalValue('1')); | 1265 list_value.AppendInteger('1'); |
1266 list_value.Append(new base::FundamentalValue('2')); | 1266 list_value.AppendInteger('2'); |
1267 list_value.Append(new base::FundamentalValue('3')); | 1267 list_value.AppendInteger('3'); |
1268 list_value.Append(new base::FundamentalValue(0xFE)); | 1268 list_value.AppendInteger(0xFE); |
1269 list_value.Append(new base::FundamentalValue(0xD1)); | 1269 list_value.AppendInteger(0xD1); |
1270 | 1270 |
1271 unsigned char char_value[] = {'1', '2', '3', 0xFE, 0xD1}; | 1271 unsigned char char_value[] = {'1', '2', '3', 0xFE, 0xD1}; |
1272 std::string string_value(reinterpret_cast<char *>(char_value), 5); | 1272 std::string string_value(reinterpret_cast<char *>(char_value), 5); |
1273 | 1273 |
1274 std::unique_ptr<base::ListValue> converted_list( | 1274 std::unique_ptr<base::ListValue> converted_list( |
1275 StringToCharList(string_value)); | 1275 StringToCharList(string_value)); |
1276 EXPECT_TRUE(list_value.Equals(converted_list.get())); | 1276 EXPECT_TRUE(list_value.Equals(converted_list.get())); |
1277 | 1277 |
1278 std::string converted_string; | 1278 std::string converted_string; |
1279 EXPECT_TRUE(CharListToString(&list_value, &converted_string)); | 1279 EXPECT_TRUE(CharListToString(&list_value, &converted_string)); |
(...skipping 1034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2314 EXPECT_TRUE(credentials_set); | 2314 EXPECT_TRUE(credentials_set); |
2315 EXPECT_FALSE(auth3.Empty()); | 2315 EXPECT_FALSE(auth3.Empty()); |
2316 EXPECT_EQ(username, auth1.username()); | 2316 EXPECT_EQ(username, auth1.username()); |
2317 EXPECT_EQ(password, auth1.password()); | 2317 EXPECT_EQ(password, auth1.password()); |
2318 EXPECT_EQ(1u, warning_set.size()); | 2318 EXPECT_EQ(1u, warning_set.size()); |
2319 EXPECT_TRUE(HasWarning(warning_set, "extid2")); | 2319 EXPECT_TRUE(HasWarning(warning_set, "extid2")); |
2320 EXPECT_EQ(3u, capturing_net_log.GetSize()); | 2320 EXPECT_EQ(3u, capturing_net_log.GetSize()); |
2321 } | 2321 } |
2322 | 2322 |
2323 } // namespace extensions | 2323 } // namespace extensions |
OLD | NEW |