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/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_consta
nts.h" | 9 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_consta
nts.h" |
| 10 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rule.h
" |
10 #include "content/public/browser/resource_request_info.h" | 11 #include "content/public/browser/resource_request_info.h" |
11 #include "net/url_request/url_request_test_util.h" | 12 #include "net/url_request/url_request_test_util.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 namespace { | 15 namespace { |
15 const char kUnknownConditionName[] = "unknownType"; | 16 const char kUnknownConditionName[] = "unknownType"; |
16 } // namespace | 17 } // namespace |
17 | 18 |
18 namespace extensions { | 19 namespace extensions { |
19 | 20 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 scoped_ptr<WebRequestConditionAttribute> attribute = | 65 scoped_ptr<WebRequestConditionAttribute> attribute = |
65 WebRequestConditionAttribute::Create( | 66 WebRequestConditionAttribute::Create( |
66 keys::kResourceTypeKey, &resource_types, &error); | 67 keys::kResourceTypeKey, &resource_types, &error); |
67 EXPECT_EQ("", error); | 68 EXPECT_EQ("", error); |
68 ASSERT_TRUE(attribute.get()); | 69 ASSERT_TRUE(attribute.get()); |
69 | 70 |
70 TestURLRequestContext context; | 71 TestURLRequestContext context; |
71 TestURLRequest url_request_ok(GURL("http://www.example.com"), NULL, &context); | 72 TestURLRequest url_request_ok(GURL("http://www.example.com"), NULL, &context); |
72 content::ResourceRequestInfo::AllocateForTesting(&url_request_ok, | 73 content::ResourceRequestInfo::AllocateForTesting(&url_request_ok, |
73 ResourceType::MAIN_FRAME, NULL, -1, -1); | 74 ResourceType::MAIN_FRAME, NULL, -1, -1); |
74 EXPECT_TRUE(attribute->IsFulfilled(&url_request_ok, ON_BEFORE_REQUEST)); | 75 EXPECT_TRUE(attribute->IsFulfilled( |
| 76 WebRequestRule::RequestData(&url_request_ok, ON_BEFORE_REQUEST))); |
75 | 77 |
76 TestURLRequest url_request_fail( | 78 TestURLRequest url_request_fail( |
77 GURL("http://www.example.com"), NULL, &context); | 79 GURL("http://www.example.com"), NULL, &context); |
78 content::ResourceRequestInfo::AllocateForTesting(&url_request_ok, | 80 content::ResourceRequestInfo::AllocateForTesting(&url_request_ok, |
79 ResourceType::SUB_FRAME, NULL, -1, -1); | 81 ResourceType::SUB_FRAME, NULL, -1, -1); |
80 EXPECT_FALSE(attribute->IsFulfilled(&url_request_fail, ON_BEFORE_REQUEST)); | 82 EXPECT_FALSE(attribute->IsFulfilled( |
| 83 WebRequestRule::RequestData(&url_request_fail, ON_BEFORE_REQUEST))); |
81 } | 84 } |
82 | 85 |
83 } // namespace extensions | 86 } // namespace extensions |
OLD | NEW |