| 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 "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit
ion_attribute.h" | 5 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit
ion_attribute.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 // 1.g. -- This should pass, empty values are values as well. | 369 // 1.g. -- This should pass, empty values are values as well. |
| 370 const std::string kEmpty[] = { | 370 const std::string kEmpty[] = { |
| 371 keys::kNameEqualsKey, "custom-header-d", | 371 keys::kNameEqualsKey, "custom-header-d", |
| 372 keys::kValueEqualsKey, "" | 372 keys::kValueEqualsKey, "" |
| 373 }; | 373 }; |
| 374 const size_t kEmptySizes[] = { arraysize(kEmpty) }; | 374 const size_t kEmptySizes[] = { arraysize(kEmpty) }; |
| 375 GetArrayAsVector(kEmpty, kEmptySizes, 1u, &tests); | 375 GetArrayAsVector(kEmpty, kEmptySizes, 1u, &tests); |
| 376 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); | 376 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); |
| 377 EXPECT_TRUE(result); | 377 EXPECT_TRUE(result); |
| 378 | 378 |
| 379 // 1.h. -- Values are case-sensitive, this should fail | 379 // 1.h. -- Values are case-sensitive, this should fail. |
| 380 const std::string kLowercase[] = { | 380 const std::string kLowercase[] = { |
| 381 keys::kNameEqualsKey, "Custom-header-b", | 381 keys::kNameEqualsKey, "Custom-header-b", |
| 382 keys::kValueEqualsKey, "valuea" // valuea != valueA | 382 keys::kValuePrefixKey, "valueb", // valueb != valueB |
| 383 keys::kNameEqualsKey, "Custom-header-b", |
| 384 keys::kValueSuffixKey, "valueb", |
| 385 keys::kNameEqualsKey, "Custom-header-b", |
| 386 keys::kValueContainsKey, "valueb", |
| 387 keys::kNameEqualsKey, "Custom-header-b", |
| 388 keys::kValueEqualsKey, "valueb" |
| 383 }; | 389 }; |
| 384 const size_t kLowercaseSizes[] = { arraysize(kLowercase) }; | 390 const size_t kLowercaseSizes[] = { 4u, 4u, 4u, 4u }; // As disjunction. |
| 385 GetArrayAsVector(kLowercase, kLowercaseSizes, 1u, &tests); | 391 GetArrayAsVector(kLowercase, kLowercaseSizes, 4u, &tests); |
| 386 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); | 392 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); |
| 387 EXPECT_FALSE(result); | 393 EXPECT_FALSE(result); |
| 388 | 394 |
| 395 // 1.i. -- Names are case-insensitive, this should pass. |
| 396 const std::string kUppercase[] = { |
| 397 keys::kNamePrefixKey, "CUSTOM-HEADER-B", |
| 398 keys::kNameSuffixKey, "CUSTOM-HEADER-B", |
| 399 keys::kNameEqualsKey, "CUSTOM-HEADER-B", |
| 400 keys::kNameContainsKey, "CUSTOM-HEADER-B" |
| 401 }; |
| 402 const size_t kUppercaseSizes[] = { arraysize(kUppercase) }; // Conjunction. |
| 403 GetArrayAsVector(kUppercase, kUppercaseSizes, 1u, &tests); |
| 404 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); |
| 405 EXPECT_TRUE(result); |
| 406 |
| 389 // 2.a. -- This should pass as disjunction, because one of the tests passes. | 407 // 2.a. -- This should pass as disjunction, because one of the tests passes. |
| 390 const std::string kDisjunction[] = { | 408 const std::string kDisjunction[] = { |
| 391 keys::kNamePrefixKey, "Non-existing", // This one fails. | 409 keys::kNamePrefixKey, "Non-existing", // This one fails. |
| 392 keys::kNameSuffixKey, "Non-existing", // This one fails. | 410 keys::kNameSuffixKey, "Non-existing", // This one fails. |
| 393 keys::kValueEqualsKey, "void", // This one fails. | 411 keys::kValueEqualsKey, "void", // This one fails. |
| 394 keys::kValueContainsKey, "alu" // This passes. | 412 keys::kValueContainsKey, "alu" // This passes. |
| 395 }; | 413 }; |
| 396 const size_t kDisjunctionSizes[] = { 2u, 2u, 2u, 2u }; | 414 const size_t kDisjunctionSizes[] = { 2u, 2u, 2u, 2u }; |
| 397 GetArrayAsVector(kDisjunction, kDisjunctionSizes, 4u, &tests); | 415 GetArrayAsVector(kDisjunction, kDisjunctionSizes, 4u, &tests); |
| 398 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); | 416 MatchAndCheck(tests, keys::kResponseHeadersKey, &url_request, &result); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 413 keys::kNameEqualsKey, "custom-header-b", | 431 keys::kNameEqualsKey, "custom-header-b", |
| 414 keys::kValueEqualsKey, "valueB" | 432 keys::kValueEqualsKey, "valueB" |
| 415 }; | 433 }; |
| 416 const size_t kExistingSize[] = { arraysize(kExisting) }; | 434 const size_t kExistingSize[] = { arraysize(kExisting) }; |
| 417 GetArrayAsVector(kExisting, kExistingSize, 1u, &tests); | 435 GetArrayAsVector(kExisting, kExistingSize, 1u, &tests); |
| 418 MatchAndCheck(tests, keys::kExcludeResponseHeadersKey, &url_request, &result); | 436 MatchAndCheck(tests, keys::kExcludeResponseHeadersKey, &url_request, &result); |
| 419 EXPECT_FALSE(result); | 437 EXPECT_FALSE(result); |
| 420 } | 438 } |
| 421 | 439 |
| 422 } // namespace extensions | 440 } // namespace extensions |
| OLD | NEW |