| 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.h" | 5 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_condit
ion.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 // Test success (can we support multiple criteria?) | 64 // Test success (can we support multiple criteria?) |
| 65 error.clear(); | 65 error.clear(); |
| 66 result = WebRequestCondition::Create(matcher.condition_factory(), | 66 result = WebRequestCondition::Create(matcher.condition_factory(), |
| 67 valid_condition, &error); | 67 valid_condition, &error); |
| 68 EXPECT_EQ("", error); | 68 EXPECT_EQ("", error); |
| 69 ASSERT_TRUE(result.get()); | 69 ASSERT_TRUE(result.get()); |
| 70 | 70 |
| 71 TestURLRequest match_request(GURL("http://www.example.com"), NULL); | 71 TestURLRequest match_request(GURL("http://www.example.com"), NULL); |
| 72 content::ResourceRequestInfo::AllocateForTesting(&match_request, | 72 content::ResourceRequestInfo::AllocateForTesting(&match_request, |
| 73 ResourceType::MAIN_FRAME, NULL); | 73 ResourceType::MAIN_FRAME, NULL, -1, -1); |
| 74 EXPECT_TRUE(result->IsFulfilled(&match_request, ON_BEFORE_REQUEST)); | 74 EXPECT_TRUE(result->IsFulfilled(&match_request, ON_BEFORE_REQUEST)); |
| 75 | 75 |
| 76 TestURLRequest wrong_resource_type(GURL("https://www.example.com"), NULL); | 76 TestURLRequest wrong_resource_type(GURL("https://www.example.com"), NULL); |
| 77 content::ResourceRequestInfo::AllocateForTesting(&wrong_resource_type, | 77 content::ResourceRequestInfo::AllocateForTesting(&wrong_resource_type, |
| 78 ResourceType::SUB_FRAME, NULL); | 78 ResourceType::SUB_FRAME, NULL, -1, -1); |
| 79 EXPECT_FALSE(result->IsFulfilled(&wrong_resource_type, ON_BEFORE_REQUEST)); | 79 EXPECT_FALSE(result->IsFulfilled(&wrong_resource_type, ON_BEFORE_REQUEST)); |
| 80 } | 80 } |
| 81 | 81 |
| 82 TEST(WebRequestConditionTest, CreateConditionSet) { | 82 TEST(WebRequestConditionTest, CreateConditionSet) { |
| 83 // Necessary for TestURLRequest. | 83 // Necessary for TestURLRequest. |
| 84 MessageLoop message_loop(MessageLoop::TYPE_IO); | 84 MessageLoop message_loop(MessageLoop::TYPE_IO); |
| 85 URLMatcher matcher; | 85 URLMatcher matcher; |
| 86 | 86 |
| 87 ListValue* http_scheme_list = new ListValue(); | 87 ListValue* http_scheme_list = new ListValue(); |
| 88 http_scheme_list->Append(Value::CreateStringValue("http")); | 88 http_scheme_list->Append(Value::CreateStringValue("http")); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 url_match_ids = matcher.MatchURL(http_url_1000); | 227 url_match_ids = matcher.MatchURL(http_url_1000); |
| 228 ASSERT_EQ(1u, url_match_ids.size()); | 228 ASSERT_EQ(1u, url_match_ids.size()); |
| 229 | 229 |
| 230 GURL http_url_2000("http://www.example.com:2000"); | 230 GURL http_url_2000("http://www.example.com:2000"); |
| 231 TestURLRequest http_request_2000(http_url_2000, NULL); | 231 TestURLRequest http_request_2000(http_url_2000, NULL); |
| 232 url_match_ids = matcher.MatchURL(http_url_2000); | 232 url_match_ids = matcher.MatchURL(http_url_2000); |
| 233 ASSERT_EQ(0u, url_match_ids.size()); | 233 ASSERT_EQ(0u, url_match_ids.size()); |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace extensions | 236 } // namespace extensions |
| OLD | NEW |