| 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/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
| 10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 input_value.SetString(keys::kVersion, "1.0.0.0"); | 255 input_value.SetString(keys::kVersion, "1.0.0.0"); |
| 256 input_value.SetString(keys::kName, "my extension"); | 256 input_value.SetString(keys::kName, "my extension"); |
| 257 EXPECT_TRUE(extension.InitFromValue(input_value, false, NULL)); | 257 EXPECT_TRUE(extension.InitFromValue(input_value, false, NULL)); |
| 258 | 258 |
| 259 EXPECT_EQ(extension.url().spec() + "bar/baz.js", | 259 EXPECT_EQ(extension.url().spec() + "bar/baz.js", |
| 260 Extension::GetResourceURL(extension.url(), "bar/baz.js").spec()); | 260 Extension::GetResourceURL(extension.url(), "bar/baz.js").spec()); |
| 261 EXPECT_EQ(extension.url().spec() + "baz.js", | 261 EXPECT_EQ(extension.url().spec() + "baz.js", |
| 262 Extension::GetResourceURL(extension.url(), "bar/../baz.js").spec()); | 262 Extension::GetResourceURL(extension.url(), "bar/../baz.js").spec()); |
| 263 EXPECT_EQ(extension.url().spec() + "baz.js", | 263 EXPECT_EQ(extension.url().spec() + "baz.js", |
| 264 Extension::GetResourceURL(extension.url(), "../baz.js").spec()); | 264 Extension::GetResourceURL(extension.url(), "../baz.js").spec()); |
| 265 | |
| 266 EXPECT_EQ(path.Append(FILE_PATH_LITERAL("bar")) | |
| 267 .Append(FILE_PATH_LITERAL("baz.js")).value(), | |
| 268 Extension::GetResourcePath(extension.path(), "bar/baz.js").value()); | |
| 269 EXPECT_EQ(path.Append(FILE_PATH_LITERAL("baz.js")).value(), | |
| 270 Extension::GetResourcePath(extension.path(), "bar/../baz.js") | |
| 271 .value()); | |
| 272 EXPECT_EQ(FilePath().value(), | |
| 273 Extension::GetResourcePath(extension.path(), "../baz.js").value()); | |
| 274 } | 265 } |
| 275 | 266 |
| 276 TEST(ExtensionTest, LoadPageActionHelper) { | 267 TEST(ExtensionTest, LoadPageActionHelper) { |
| 277 #if defined(OS_WIN) | 268 #if defined(OS_WIN) |
| 278 FilePath path(StringPrintf(L"c:\\extension")); | 269 FilePath path(StringPrintf(L"c:\\extension")); |
| 279 #else | 270 #else |
| 280 FilePath path(StringPrintf("/extension")); | 271 FilePath path(StringPrintf("/extension")); |
| 281 #endif | 272 #endif |
| 282 Extension extension(path); | 273 Extension extension(path); |
| 283 std::string error_msg; | 274 std::string error_msg; |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 scoped_ptr<Extension> new_extension( | 651 scoped_ptr<Extension> new_extension( |
| 661 LoadManifest("allow_silent_upgrade", | 652 LoadManifest("allow_silent_upgrade", |
| 662 std::string(kTests[i].base_name) + "_new.json")); | 653 std::string(kTests[i].base_name) + "_new.json")); |
| 663 | 654 |
| 664 EXPECT_EQ(kTests[i].expect_success, | 655 EXPECT_EQ(kTests[i].expect_success, |
| 665 Extension::IsPrivilegeIncrease(old_extension.get(), | 656 Extension::IsPrivilegeIncrease(old_extension.get(), |
| 666 new_extension.get())) | 657 new_extension.get())) |
| 667 << kTests[i].base_name; | 658 << kTests[i].base_name; |
| 668 } | 659 } |
| 669 } | 660 } |
| OLD | NEW |