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_action
.h" | 5 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_action
.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_consta
nts.h" | 8 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_consta
nts.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 linked_ptr<json_schema_compiler::any::Any> action2 = make_linked_ptr( | 93 linked_ptr<json_schema_compiler::any::Any> action2 = make_linked_ptr( |
94 new json_schema_compiler::any::Any); | 94 new json_schema_compiler::any::Any); |
95 action2->Init(incorrect_action); | 95 action2->Init(incorrect_action); |
96 input.push_back(action2); | 96 input.push_back(action2); |
97 error.clear(); | 97 error.clear(); |
98 result = WebRequestActionSet::Create(input, &error, &bad_message); | 98 result = WebRequestActionSet::Create(input, &error, &bad_message); |
99 EXPECT_NE("", error); | 99 EXPECT_NE("", error); |
100 EXPECT_FALSE(result.get()); | 100 EXPECT_FALSE(result.get()); |
101 } | 101 } |
102 | 102 |
| 103 // Test capture group syntax conversions of WebRequestRedirectByRegExAction |
| 104 TEST(WebRequestActionTest, PerlToRe2Style) { |
| 105 #define CallPerlToRe2Style WebRequestRedirectByRegExAction::PerlToRe2Style |
| 106 // foo$1bar -> foo\1bar |
| 107 EXPECT_EQ("foo\\1bar", CallPerlToRe2Style("foo$1bar")); |
| 108 // foo\$1bar -> foo$1bar |
| 109 EXPECT_EQ("foo$1bar", CallPerlToRe2Style("foo\\$1bar")); |
| 110 // foo\\$1bar -> foo\\\1bar |
| 111 EXPECT_EQ("foo\\\\\\1bar", CallPerlToRe2Style("foo\\\\$1bar")); |
| 112 // foo\bar -> foobar |
| 113 EXPECT_EQ("foobar", CallPerlToRe2Style("foo\\bar")); |
| 114 // foo$bar -> foo$bar |
| 115 EXPECT_EQ("foo$bar", CallPerlToRe2Style("foo$bar")); |
| 116 #undef CallPerlToRe2Style |
| 117 } |
| 118 |
103 } // namespace extensions | 119 } // namespace extensions |
OLD | NEW |