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

Unified Diff: chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc

Issue 11827026: Overhaul JSON Schema Compiler to support a number of features required to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc
diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc
index db4f6ea3ad5430b167ce0c9edbac17d3ecb5f415..e6a26ea5abe2ee80a3b8db5ff04ae63977f073af 100644
--- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc
+++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc
@@ -57,6 +57,48 @@ TEST(WebRequestActionTest, CreateAction) {
EXPECT_EQ(WebRequestAction::ACTION_CANCEL_REQUEST, result->GetType());
}
+TEST(WebRequestActionTest, CreateActionSet) {
+ std::string error;
+ bool bad_message = false;
+ scoped_ptr<WebRequestActionSet> result;
+
+ WebRequestActionSet::AnyVector input;
+
+ // Test empty input.
+ error.clear();
+ result = WebRequestActionSet::Create(input, &error, &bad_message);
+ EXPECT_TRUE(error.empty()) << error;
+ EXPECT_FALSE(bad_message);
+ ASSERT_TRUE(result.get());
+ EXPECT_TRUE(result->actions().empty());
+ EXPECT_EQ(std::numeric_limits<int>::min(), result->GetMinimumPriority());
+
+ DictionaryValue correct_action;
+ correct_action.SetString(keys::kInstanceTypeKey, keys::kIgnoreRulesType);
+ correct_action.SetInteger(keys::kLowerPriorityThanKey, 10);
+ DictionaryValue incorrect_action;
+ incorrect_action.SetString(keys::kInstanceTypeKey, kUnknownActionType);
+
+ // Test success.
+ input.push_back(linked_ptr<base::Value>(correct_action.DeepCopy()));
+ error.clear();
+ result = WebRequestActionSet::Create(input, &error, &bad_message);
+ EXPECT_TRUE(error.empty()) << error;
+ EXPECT_FALSE(bad_message);
+ ASSERT_TRUE(result.get());
+ ASSERT_EQ(1u, result->actions().size());
+ EXPECT_EQ(WebRequestAction::ACTION_IGNORE_RULES,
+ result->actions()[0]->GetType());
+ EXPECT_EQ(10, result->GetMinimumPriority());
+
+ // Test failure.
+ input.push_back(linked_ptr<base::Value>(incorrect_action.DeepCopy()));
+ error.clear();
+ result = WebRequestActionSet::Create(input, &error, &bad_message);
+ EXPECT_NE("", error);
+ EXPECT_FALSE(result.get());
+}
+
// Test capture group syntax conversions of WebRequestRedirectByRegExAction
TEST(WebRequestActionTest, PerlToRe2Style) {
#define CallPerlToRe2Style WebRequestRedirectByRegExAction::PerlToRe2Style
@@ -87,16 +129,12 @@ TEST(WebRequestActionTest, TestPermissions) {
redirect.SetString(keys::kInstanceTypeKey, keys::kRedirectRequestType);
redirect.SetString(keys::kRedirectUrlKey, "http://www.foobar.com");
- linked_ptr<json_schema_compiler::any::Any> action = make_linked_ptr(
- new json_schema_compiler::any::Any);
- action->Init(redirect);
WebRequestActionSet::AnyVector actions;
- actions.push_back(action);
+ actions.push_back(linked_ptr<base::Value>(redirect.DeepCopy()));
action_set = WebRequestActionSet::Create(actions, &error, &bad_message);
EXPECT_EQ("", error);
EXPECT_FALSE(bad_message);
- ASSERT_TRUE(action.get());
// Check that redirect works on regular URLs but not on protected URLs.
net::TestURLRequest regular_request(GURL("http://test.com"), NULL, &context);

Powered by Google App Engine
This is Rietveld 408576698