| 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 "extensions/browser/api/declarative_webrequest/webrequest_condition_att
ribute.h" | 5 #include "extensions/browser/api/declarative_webrequest/webrequest_condition_att
ribute.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 EXPECT_EQ("", error); | 95 EXPECT_EQ("", error); |
| 96 ASSERT_TRUE(attribute.get()); | 96 ASSERT_TRUE(attribute.get()); |
| 97 EXPECT_EQ(std::string(keys::kResourceTypeKey), attribute->GetName()); | 97 EXPECT_EQ(std::string(keys::kResourceTypeKey), attribute->GetName()); |
| 98 | 98 |
| 99 net::TestURLRequestContext context; | 99 net::TestURLRequestContext context; |
| 100 scoped_ptr<net::URLRequest> url_request_ok(context.CreateRequest( | 100 scoped_ptr<net::URLRequest> url_request_ok(context.CreateRequest( |
| 101 GURL("http://www.example.com"), net::DEFAULT_PRIORITY, NULL, NULL)); | 101 GURL("http://www.example.com"), net::DEFAULT_PRIORITY, NULL, NULL)); |
| 102 content::ResourceRequestInfo::AllocateForTesting( | 102 content::ResourceRequestInfo::AllocateForTesting( |
| 103 url_request_ok.get(), | 103 url_request_ok.get(), |
| 104 content::RESOURCE_TYPE_SUB_FRAME, | 104 content::RESOURCE_TYPE_SUB_FRAME, |
| 105 NULL, | 105 NULL, // context |
| 106 -1, | 106 -1, // render_process_id |
| 107 -1, | 107 -1, // render_view_id |
| 108 -1, | 108 -1, // render_frame_id |
| 109 false); | 109 false, // is_main_frame |
| 110 false, // parent_is_main_frame |
| 111 false); // is_async |
| 110 EXPECT_TRUE(attribute->IsFulfilled(WebRequestData(url_request_ok.get(), | 112 EXPECT_TRUE(attribute->IsFulfilled(WebRequestData(url_request_ok.get(), |
| 111 ON_BEFORE_REQUEST))); | 113 ON_BEFORE_REQUEST))); |
| 112 | 114 |
| 113 scoped_ptr<net::URLRequest> url_request_fail(context.CreateRequest( | 115 scoped_ptr<net::URLRequest> url_request_fail(context.CreateRequest( |
| 114 GURL("http://www.example.com"), net::DEFAULT_PRIORITY, NULL, NULL)); | 116 GURL("http://www.example.com"), net::DEFAULT_PRIORITY, NULL, NULL)); |
| 115 content::ResourceRequestInfo::AllocateForTesting( | 117 content::ResourceRequestInfo::AllocateForTesting( |
| 116 url_request_fail.get(), | 118 url_request_fail.get(), |
| 117 content::RESOURCE_TYPE_MAIN_FRAME, | 119 content::RESOURCE_TYPE_MAIN_FRAME, |
| 118 NULL, | 120 NULL, // context |
| 119 -1, | 121 -1, // render_process_id |
| 120 -1, | 122 -1, // render_view_id |
| 121 -1, | 123 -1, // render_frame_id |
| 122 false); | 124 true, // is_main_frame |
| 125 false, // parent_is_main_frame |
| 126 false); // is_async |
| 123 EXPECT_FALSE(attribute->IsFulfilled(WebRequestData(url_request_fail.get(), | 127 EXPECT_FALSE(attribute->IsFulfilled(WebRequestData(url_request_fail.get(), |
| 124 ON_BEFORE_REQUEST))); | 128 ON_BEFORE_REQUEST))); |
| 125 } | 129 } |
| 126 | 130 |
| 127 TEST(WebRequestConditionAttributeTest, ContentType) { | 131 TEST(WebRequestConditionAttributeTest, ContentType) { |
| 128 // Necessary for TestURLRequest. | 132 // Necessary for TestURLRequest. |
| 129 base::MessageLoopForIO message_loop; | 133 base::MessageLoopForIO message_loop; |
| 130 | 134 |
| 131 std::string error; | 135 std::string error; |
| 132 scoped_refptr<const WebRequestConditionAttribute> result; | 136 scoped_refptr<const WebRequestConditionAttribute> result; |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 }; | 714 }; |
| 711 const size_t kExistingSize[] = { arraysize(kExisting) }; | 715 const size_t kExistingSize[] = { arraysize(kExisting) }; |
| 712 GetArrayAsVector(kExisting, kExistingSize, 1u, &tests); | 716 GetArrayAsVector(kExisting, kExistingSize, 1u, &tests); |
| 713 MatchAndCheck(tests, keys::kExcludeResponseHeadersKey, stage, | 717 MatchAndCheck(tests, keys::kExcludeResponseHeadersKey, stage, |
| 714 url_request.get(), &result); | 718 url_request.get(), &result); |
| 715 EXPECT_FALSE(result); | 719 EXPECT_FALSE(result); |
| 716 } | 720 } |
| 717 | 721 |
| 718 } // namespace | 722 } // namespace |
| 719 } // namespace extensions | 723 } // namespace extensions |
| OLD | NEW |