| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/developer_private/developer_private_api.
h" | 5 #include "chrome/browser/extensions/api/developer_private/developer_private_api.
h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 registry_observer.WaitForExtensionLoaded(); | 296 registry_observer.WaitForExtensionLoaded(); |
| 297 EXPECT_EQ(extension_id, reloaded_extension->id()); | 297 EXPECT_EQ(extension_id, reloaded_extension->id()); |
| 298 } | 298 } |
| 299 | 299 |
| 300 // Test developerPrivate.packDirectory. | 300 // Test developerPrivate.packDirectory. |
| 301 TEST_F(DeveloperPrivateApiUnitTest, DeveloperPrivatePackFunction) { | 301 TEST_F(DeveloperPrivateApiUnitTest, DeveloperPrivatePackFunction) { |
| 302 // Use a temp dir isolating the extension dir and its generated files. | 302 // Use a temp dir isolating the extension dir and its generated files. |
| 303 base::ScopedTempDir temp_dir; | 303 base::ScopedTempDir temp_dir; |
| 304 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 304 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
| 305 base::FilePath root_path = data_dir().AppendASCII("good_unpacked"); | 305 base::FilePath root_path = data_dir().AppendASCII("good_unpacked"); |
| 306 ASSERT_TRUE(base::CopyDirectory(root_path, temp_dir.path(), true)); | 306 ASSERT_TRUE(base::CopyDirectory(root_path, temp_dir.GetPath(), true)); |
| 307 | 307 |
| 308 base::FilePath temp_root_path = temp_dir.path().Append(root_path.BaseName()); | 308 base::FilePath temp_root_path = |
| 309 base::FilePath crx_path = temp_dir.path().AppendASCII("good_unpacked.crx"); | 309 temp_dir.GetPath().Append(root_path.BaseName()); |
| 310 base::FilePath pem_path = temp_dir.path().AppendASCII("good_unpacked.pem"); | 310 base::FilePath crx_path = temp_dir.GetPath().AppendASCII("good_unpacked.crx"); |
| 311 base::FilePath pem_path = temp_dir.GetPath().AppendASCII("good_unpacked.pem"); |
| 311 | 312 |
| 312 EXPECT_FALSE(base::PathExists(crx_path)) | 313 EXPECT_FALSE(base::PathExists(crx_path)) |
| 313 << "crx should not exist before the test is run!"; | 314 << "crx should not exist before the test is run!"; |
| 314 EXPECT_FALSE(base::PathExists(pem_path)) | 315 EXPECT_FALSE(base::PathExists(pem_path)) |
| 315 << "pem should not exist before the test is run!"; | 316 << "pem should not exist before the test is run!"; |
| 316 | 317 |
| 317 // First, test a directory that should pack properly. | 318 // First, test a directory that should pack properly. |
| 318 base::ListValue pack_args; | 319 base::ListValue pack_args; |
| 319 pack_args.AppendString(temp_root_path.AsUTF8Unsafe()); | 320 pack_args.AppendString(temp_root_path.AsUTF8Unsafe()); |
| 320 EXPECT_TRUE(TestPackExtensionFunction( | 321 EXPECT_TRUE(TestPackExtensionFunction( |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 .Append( | 560 .Append( |
| 560 DictionaryBuilder().Set("extensionId", extension->id()).Build()) | 561 DictionaryBuilder().Set("extensionId", extension->id()).Build()) |
| 561 .Build(); | 562 .Build(); |
| 562 function = new api::DeveloperPrivateDeleteExtensionErrorsFunction(); | 563 function = new api::DeveloperPrivateDeleteExtensionErrorsFunction(); |
| 563 EXPECT_TRUE(RunFunction(function, *args)) << function->GetError(); | 564 EXPECT_TRUE(RunFunction(function, *args)) << function->GetError(); |
| 564 // No more errors! | 565 // No more errors! |
| 565 EXPECT_TRUE(error_console->GetErrorsForExtension(extension->id()).empty()); | 566 EXPECT_TRUE(error_console->GetErrorsForExtension(extension->id()).empty()); |
| 566 } | 567 } |
| 567 | 568 |
| 568 } // namespace extensions | 569 } // namespace extensions |
| OLD | NEW |