OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/pickle.h" | 6 #include "base/pickle.h" |
7 #include "chrome/common/extensions/user_script.h" | 7 #include "chrome/common/extensions/user_script.h" |
8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 } | 71 } |
72 | 72 |
73 TEST(UserScriptTest, Pickle) { | 73 TEST(UserScriptTest, Pickle) { |
74 URLPattern pattern1; | 74 URLPattern pattern1; |
75 URLPattern pattern2; | 75 URLPattern pattern2; |
76 ASSERT_TRUE(pattern1.Parse("http://*/foo*")); | 76 ASSERT_TRUE(pattern1.Parse("http://*/foo*")); |
77 ASSERT_TRUE(pattern2.Parse("http://bar/baz*")); | 77 ASSERT_TRUE(pattern2.Parse("http://bar/baz*")); |
78 | 78 |
79 UserScript script1; | 79 UserScript script1; |
80 script1.js_scripts().push_back(UserScript::File( | 80 script1.js_scripts().push_back(UserScript::File( |
81 ExtensionResource(FilePath(FILE_PATH_LITERAL("c:\\foo\\")), | 81 FilePath(FILE_PATH_LITERAL("c:\\foo\\")), |
82 FilePath(FILE_PATH_LITERAL("foo.user.js"))), | 82 FilePath(FILE_PATH_LITERAL("foo.user.js")), |
83 GURL("chrome-user-script:/foo.user.js"))); | 83 GURL("chrome-user-script:/foo.user.js"))); |
84 script1.css_scripts().push_back(UserScript::File( | 84 script1.css_scripts().push_back(UserScript::File( |
85 ExtensionResource(FilePath(FILE_PATH_LITERAL("c:\\foo\\")), | 85 FilePath(FILE_PATH_LITERAL("c:\\foo\\")), |
86 FilePath(FILE_PATH_LITERAL("foo.user.css"))), | 86 FilePath(FILE_PATH_LITERAL("foo.user.css")), |
87 GURL("chrome-user-script:/foo.user.css"))); | 87 GURL("chrome-user-script:/foo.user.css"))); |
88 script1.css_scripts().push_back(UserScript::File( | 88 script1.css_scripts().push_back(UserScript::File( |
89 ExtensionResource(FilePath(FILE_PATH_LITERAL("c:\\foo\\")), | 89 FilePath(FILE_PATH_LITERAL("c:\\foo\\")), |
90 FilePath(FILE_PATH_LITERAL("foo2.user.css"))), | 90 FilePath(FILE_PATH_LITERAL("foo2.user.css")), |
91 GURL("chrome-user-script:/foo2.user.css"))); | 91 GURL("chrome-user-script:/foo2.user.css"))); |
92 script1.set_run_location(UserScript::DOCUMENT_START); | 92 script1.set_run_location(UserScript::DOCUMENT_START); |
93 | 93 |
94 script1.add_url_pattern(pattern1); | 94 script1.add_url_pattern(pattern1); |
95 script1.add_url_pattern(pattern2); | 95 script1.add_url_pattern(pattern2); |
96 | 96 |
97 Pickle pickle; | 97 Pickle pickle; |
98 script1.Pickle(&pickle); | 98 script1.Pickle(&pickle); |
99 | 99 |
100 void* iter = NULL; | 100 void* iter = NULL; |
(...skipping 16 matching lines...) Expand all Loading... |
117 for (size_t i = 0; i < script1.url_patterns().size(); ++i) { | 117 for (size_t i = 0; i < script1.url_patterns().size(); ++i) { |
118 EXPECT_EQ(script1.url_patterns()[i].GetAsString(), | 118 EXPECT_EQ(script1.url_patterns()[i].GetAsString(), |
119 script2.url_patterns()[i].GetAsString()); | 119 script2.url_patterns()[i].GetAsString()); |
120 } | 120 } |
121 } | 121 } |
122 | 122 |
123 TEST(UserScriptTest, Defaults) { | 123 TEST(UserScriptTest, Defaults) { |
124 UserScript script; | 124 UserScript script; |
125 ASSERT_EQ(UserScript::DOCUMENT_END, script.run_location()); | 125 ASSERT_EQ(UserScript::DOCUMENT_END, script.run_location()); |
126 } | 126 } |
OLD | NEW |