OLD | NEW |
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008 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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "chrome/renderer/greasemonkey_slave.h" | 6 #include "chrome/renderer/greasemonkey_slave.h" |
7 #include "googleurl/src/gurl.h" | 7 #include "googleurl/src/gurl.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 class GreasemonkeySlaveTest : public testing::Test { | |
11 }; | |
12 | |
13 TEST(GreasemonkeySlaveTest, EscapeGlob) { | 10 TEST(GreasemonkeySlaveTest, EscapeGlob) { |
14 EXPECT_EQ("", GreasemonkeyScript::EscapeGlob("")); | 11 EXPECT_EQ("", GreasemonkeyScript::EscapeGlob("")); |
15 EXPECT_EQ("*", GreasemonkeyScript::EscapeGlob("*")); | 12 EXPECT_EQ("*", GreasemonkeyScript::EscapeGlob("*")); |
16 EXPECT_EQ("www.google.com", GreasemonkeyScript::EscapeGlob("www.google.com")); | 13 EXPECT_EQ("www.google.com", GreasemonkeyScript::EscapeGlob("www.google.com")); |
17 EXPECT_EQ("*google.com*", GreasemonkeyScript::EscapeGlob("*google.com*")); | 14 EXPECT_EQ("*google.com*", GreasemonkeyScript::EscapeGlob("*google.com*")); |
18 EXPECT_EQ("foo\\\\bar\\?hot=dog", | 15 EXPECT_EQ("foo\\\\bar\\?hot=dog", |
19 GreasemonkeyScript::EscapeGlob("foo\\bar?hot=dog")); | 16 GreasemonkeyScript::EscapeGlob("foo\\bar?hot=dog")); |
20 } | 17 } |
21 | 18 |
22 TEST(GreasemonkeySlaveTest, Parse1) { | 19 TEST(GreasemonkeySlaveTest, Parse1) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 "// @include *foo*\n" | 62 "// @include *foo*\n" |
66 "// ==/UserScript=="); // no trailing newline | 63 "// ==/UserScript=="); // no trailing newline |
67 | 64 |
68 GreasemonkeyScript script("foo"); | 65 GreasemonkeyScript script("foo"); |
69 script.Parse(text); | 66 script.Parse(text); |
70 EXPECT_EQ(1, script.include_patterns_.size()); | 67 EXPECT_EQ(1, script.include_patterns_.size()); |
71 EXPECT_EQ(text, script.GetBody()); | 68 EXPECT_EQ(text, script.GetBody()); |
72 EXPECT_TRUE(script.MatchesUrl(GURL("http://foo.com/bar"))); | 69 EXPECT_TRUE(script.MatchesUrl(GURL("http://foo.com/bar"))); |
73 EXPECT_FALSE(script.MatchesUrl(GURL("http://baz.org"))); | 70 EXPECT_FALSE(script.MatchesUrl(GURL("http://baz.org"))); |
74 } | 71 } |
OLD | NEW |