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/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 TEST(WebRequestConditionAttributeTest, ContentType) { | 103 TEST(WebRequestConditionAttributeTest, ContentType) { |
104 // Necessary for TestURLRequest. | 104 // Necessary for TestURLRequest. |
105 MessageLoop message_loop(MessageLoop::TYPE_IO); | 105 MessageLoop message_loop(MessageLoop::TYPE_IO); |
106 | 106 |
107 std::string error; | 107 std::string error; |
108 scoped_ptr<WebRequestConditionAttribute> result; | 108 scoped_ptr<WebRequestConditionAttribute> result; |
109 | 109 |
110 net::TestServer test_server( | 110 net::TestServer test_server( |
111 net::TestServer::TYPE_HTTP, | 111 net::TestServer::TYPE_HTTP, |
112 net::TestServer::kLocalhost, | 112 net::TestServer::kLocalhost, |
113 base::FilePath(FILE_PATH_LITERAL( | 113 net::TestServer::GetSourceRelativePath(base::FilePath(FILE_PATH_LITERAL( |
114 "chrome/test/data/extensions/api_test/webrequest/declarative"))); | 114 "chrome/test/data/extensions/api_test/webrequest/declarative")))); |
115 ASSERT_TRUE(test_server.Start()); | 115 ASSERT_TRUE(test_server.Start()); |
116 | 116 |
117 net::TestURLRequestContext context; | 117 net::TestURLRequestContext context; |
118 net::TestDelegate delegate; | 118 net::TestDelegate delegate; |
119 net::TestURLRequest url_request(test_server.GetURL("files/headers.html"), | 119 net::TestURLRequest url_request(test_server.GetURL("files/headers.html"), |
120 &delegate, &context); | 120 &delegate, &context); |
121 url_request.Start(); | 121 url_request.Start(); |
122 MessageLoop::current()->Run(); | 122 MessageLoop::current()->Run(); |
123 | 123 |
124 ListValue content_types; | 124 ListValue content_types; |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 // 1. Correct implementation of prefix/suffix/contains/equals matching. | 473 // 1. Correct implementation of prefix/suffix/contains/equals matching. |
474 // 2. Performing logical disjunction (||) between multiple specifications. | 474 // 2. Performing logical disjunction (||) between multiple specifications. |
475 // 3. Negating the match in case of 'doesNotContainHeaders'. | 475 // 3. Negating the match in case of 'doesNotContainHeaders'. |
476 TEST(WebRequestConditionAttributeTest, ResponseHeaders) { | 476 TEST(WebRequestConditionAttributeTest, ResponseHeaders) { |
477 // Necessary for TestURLRequest. | 477 // Necessary for TestURLRequest. |
478 MessageLoop message_loop(MessageLoop::TYPE_IO); | 478 MessageLoop message_loop(MessageLoop::TYPE_IO); |
479 | 479 |
480 net::TestServer test_server( | 480 net::TestServer test_server( |
481 net::TestServer::TYPE_HTTP, | 481 net::TestServer::TYPE_HTTP, |
482 net::TestServer::kLocalhost, | 482 net::TestServer::kLocalhost, |
483 base::FilePath(FILE_PATH_LITERAL( | 483 net::TestServer::GetSourceRelativePath(base::FilePath(FILE_PATH_LITERAL( |
484 "chrome/test/data/extensions/api_test/webrequest/declarative"))); | 484 "chrome/test/data/extensions/api_test/webrequest/declarative")))); |
485 ASSERT_TRUE(test_server.Start()); | 485 ASSERT_TRUE(test_server.Start()); |
486 | 486 |
487 net::TestURLRequestContext context; | 487 net::TestURLRequestContext context; |
488 net::TestDelegate delegate; | 488 net::TestDelegate delegate; |
489 net::TestURLRequest url_request(test_server.GetURL("files/headers.html"), | 489 net::TestURLRequest url_request(test_server.GetURL("files/headers.html"), |
490 &delegate, &context); | 490 &delegate, &context); |
491 url_request.Start(); | 491 url_request.Start(); |
492 MessageLoop::current()->Run(); | 492 MessageLoop::current()->Run(); |
493 | 493 |
494 // In all the tests below we assume that the server includes the headers | 494 // In all the tests below we assume that the server includes the headers |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 keys::kValueEqualsKey, "valueB" | 649 keys::kValueEqualsKey, "valueB" |
650 }; | 650 }; |
651 const size_t kExistingSize[] = { arraysize(kExisting) }; | 651 const size_t kExistingSize[] = { arraysize(kExisting) }; |
652 GetArrayAsVector(kExisting, kExistingSize, 1u, &tests); | 652 GetArrayAsVector(kExisting, kExistingSize, 1u, &tests); |
653 MatchAndCheck( | 653 MatchAndCheck( |
654 tests, keys::kExcludeResponseHeadersKey, stage, &url_request, &result); | 654 tests, keys::kExcludeResponseHeadersKey, stage, &url_request, &result); |
655 EXPECT_FALSE(result); | 655 EXPECT_FALSE(result); |
656 } | 656 } |
657 | 657 |
658 } // namespace extensions | 658 } // namespace extensions |
OLD | NEW |