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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/scoped_temp_dir.h" | 12 #include "base/scoped_temp_dir.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/extensions/convert_user_script.h" | 14 #include "chrome/browser/extensions/convert_user_script.h" |
15 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
16 #include "chrome/common/extensions/extension.h" | 16 #include "chrome/common/extensions/extension.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 | 18 |
| 19 namespace extensions { |
| 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 static void AddPattern(URLPatternSet* extent, const std::string& pattern) { | 23 static void AddPattern(URLPatternSet* extent, const std::string& pattern) { |
22 int schemes = URLPattern::SCHEME_ALL; | 24 int schemes = URLPattern::SCHEME_ALL; |
23 extent->AddPattern(URLPattern(schemes, pattern)); | 25 extent->AddPattern(URLPattern(schemes, pattern)); |
24 } | 26 } |
25 | 27 |
26 } | 28 } |
27 | 29 |
28 namespace extensions { | |
29 | |
30 TEST(ExtensionFromUserScript, Basic) { | 30 TEST(ExtensionFromUserScript, Basic) { |
31 ScopedTempDir extensions_dir; | 31 ScopedTempDir extensions_dir; |
32 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir()); | 32 ASSERT_TRUE(extensions_dir.CreateUniqueTempDir()); |
33 | 33 |
34 FilePath test_file; | 34 FilePath test_file; |
35 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_file)); | 35 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_file)); |
36 test_file = test_file.AppendASCII("extensions") | 36 test_file = test_file.AppendASCII("extensions") |
37 .AppendASCII("user_script_basic.user.js"); | 37 .AppendASCII("user_script_basic.user.js"); |
38 | 38 |
39 string16 error; | 39 string16 error; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 EXPECT_EQ("kHnHKec3O/RKKo5/Iu1hKqe4wQERthL0639isNtsfiY=", | 235 EXPECT_EQ("kHnHKec3O/RKKo5/Iu1hKqe4wQERthL0639isNtsfiY=", |
236 extension->public_key()); | 236 extension->public_key()); |
237 | 237 |
238 // Validate run location. | 238 // Validate run location. |
239 ASSERT_EQ(1u, extension->content_scripts().size()); | 239 ASSERT_EQ(1u, extension->content_scripts().size()); |
240 const UserScript& script = extension->content_scripts()[0]; | 240 const UserScript& script = extension->content_scripts()[0]; |
241 EXPECT_EQ(UserScript::DOCUMENT_IDLE, script.run_location()); | 241 EXPECT_EQ(UserScript::DOCUMENT_IDLE, script.run_location()); |
242 } | 242 } |
243 | 243 |
244 } // namespace extensions | 244 } // namespace extensions |
OLD | NEW |