Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc

Issue 11369179: Move url_request_test_util into net namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_action .h" 5 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_action .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/web_request/web_request_api_helpers.h" 10 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // foo\bar -> foobar 116 // foo\bar -> foobar
117 EXPECT_EQ("foobar", CallPerlToRe2Style("foo\\bar")); 117 EXPECT_EQ("foobar", CallPerlToRe2Style("foo\\bar"));
118 // foo$bar -> foo$bar 118 // foo$bar -> foo$bar
119 EXPECT_EQ("foo$bar", CallPerlToRe2Style("foo$bar")); 119 EXPECT_EQ("foo$bar", CallPerlToRe2Style("foo$bar"));
120 #undef CallPerlToRe2Style 120 #undef CallPerlToRe2Style
121 } 121 }
122 122
123 TEST(WebRequestActionTest, TestPermissions) { 123 TEST(WebRequestActionTest, TestPermissions) {
124 // Necessary for TestURLRequest. 124 // Necessary for TestURLRequest.
125 MessageLoop message_loop(MessageLoop::TYPE_IO); 125 MessageLoop message_loop(MessageLoop::TYPE_IO);
126 TestURLRequestContext context; 126 net::TestURLRequestContext context;
127 127
128 std::string error; 128 std::string error;
129 bool bad_message = false; 129 bool bad_message = false;
130 scoped_ptr<WebRequestActionSet> action_set; 130 scoped_ptr<WebRequestActionSet> action_set;
131 131
132 // Setup redirect to http://www.foobar.com. 132 // Setup redirect to http://www.foobar.com.
133 base::DictionaryValue redirect; 133 base::DictionaryValue redirect;
134 redirect.SetString(keys::kInstanceTypeKey, keys::kRedirectRequestType); 134 redirect.SetString(keys::kInstanceTypeKey, keys::kRedirectRequestType);
135 redirect.SetString(keys::kRedirectUrlKey, "http://www.foobar.com"); 135 redirect.SetString(keys::kRedirectUrlKey, "http://www.foobar.com");
136 136
137 linked_ptr<json_schema_compiler::any::Any> action = make_linked_ptr( 137 linked_ptr<json_schema_compiler::any::Any> action = make_linked_ptr(
138 new json_schema_compiler::any::Any); 138 new json_schema_compiler::any::Any);
139 action->Init(redirect); 139 action->Init(redirect);
140 WebRequestActionSet::AnyVector actions; 140 WebRequestActionSet::AnyVector actions;
141 actions.push_back(action); 141 actions.push_back(action);
142 142
143 action_set = WebRequestActionSet::Create(actions, &error, &bad_message); 143 action_set = WebRequestActionSet::Create(actions, &error, &bad_message);
144 EXPECT_EQ("", error); 144 EXPECT_EQ("", error);
145 EXPECT_FALSE(bad_message); 145 EXPECT_FALSE(bad_message);
146 ASSERT_TRUE(action.get()); 146 ASSERT_TRUE(action.get());
147 147
148 // Check that redirect works on regular URLs but not on protected URLs. 148 // Check that redirect works on regular URLs but not on protected URLs.
149 TestURLRequest regular_request(GURL("http://test.com"), NULL, &context); 149 net::TestURLRequest regular_request(GURL("http://test.com"), NULL, &context);
150 std::list<LinkedPtrEventResponseDelta> deltas = 150 std::list<LinkedPtrEventResponseDelta> deltas =
151 action_set->CreateDeltas( 151 action_set->CreateDeltas(
152 NULL, "ext1", 152 NULL, "ext1",
153 WebRequestRule::RequestData(&regular_request, ON_BEFORE_REQUEST), 153 WebRequestRule::RequestData(&regular_request, ON_BEFORE_REQUEST),
154 false, base::Time()); 154 false, base::Time());
155 EXPECT_EQ(1u, deltas.size()); 155 EXPECT_EQ(1u, deltas.size());
156 156
157 TestURLRequest protected_request(GURL("http://clients1.google.com"), 157 net::TestURLRequest protected_request(GURL("http://clients1.google.com"),
158 NULL, &context); 158 NULL, &context);
159 deltas = action_set->CreateDeltas( 159 deltas = action_set->CreateDeltas(
160 NULL, "ext1", 160 NULL, "ext1",
161 WebRequestRule::RequestData(&protected_request, ON_BEFORE_REQUEST), 161 WebRequestRule::RequestData(&protected_request, ON_BEFORE_REQUEST),
162 false, base::Time()); 162 false, base::Time());
163 EXPECT_EQ(0u, deltas.size()); 163 EXPECT_EQ(0u, deltas.size());
164 } 164 }
165 165
166 } // namespace extensions 166 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698