| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 // ExtensionServiceTestBase: | 101 // ExtensionServiceTestBase: |
| 102 void SetUp() override; | 102 void SetUp() override; |
| 103 void TearDown() override; | 103 void TearDown() override; |
| 104 | 104 |
| 105 // The browser (and accompanying window). | 105 // The browser (and accompanying window). |
| 106 std::unique_ptr<TestBrowserWindow> browser_window_; | 106 std::unique_ptr<TestBrowserWindow> browser_window_; |
| 107 std::unique_ptr<Browser> browser_; | 107 std::unique_ptr<Browser> browser_; |
| 108 | 108 |
| 109 ScopedVector<TestExtensionDir> test_extension_dirs_; | 109 std::vector<std::unique_ptr<TestExtensionDir>> test_extension_dirs_; |
| 110 | 110 |
| 111 DISALLOW_COPY_AND_ASSIGN(DeveloperPrivateApiUnitTest); | 111 DISALLOW_COPY_AND_ASSIGN(DeveloperPrivateApiUnitTest); |
| 112 }; | 112 }; |
| 113 | 113 |
| 114 bool DeveloperPrivateApiUnitTest::RunFunction( | 114 bool DeveloperPrivateApiUnitTest::RunFunction( |
| 115 const scoped_refptr<UIThreadExtensionFunction>& function, | 115 const scoped_refptr<UIThreadExtensionFunction>& function, |
| 116 const base::ListValue& args) { | 116 const base::ListValue& args) { |
| 117 return extension_function_test_utils::RunFunction( | 117 return extension_function_test_utils::RunFunction( |
| 118 function.get(), base::WrapUnique(args.DeepCopy()), browser(), | 118 function.get(), base::WrapUnique(args.DeepCopy()), browser(), |
| 119 extension_function_test_utils::NONE); | 119 extension_function_test_utils::NONE); |
| 120 } | 120 } |
| 121 | 121 |
| 122 const Extension* DeveloperPrivateApiUnitTest::LoadUnpackedExtension() { | 122 const Extension* DeveloperPrivateApiUnitTest::LoadUnpackedExtension() { |
| 123 const char kManifest[] = | 123 const char kManifest[] = |
| 124 "{" | 124 "{" |
| 125 " \"name\": \"foo\"," | 125 " \"name\": \"foo\"," |
| 126 " \"version\": \"1.0\"," | 126 " \"version\": \"1.0\"," |
| 127 " \"manifest_version\": 2," | 127 " \"manifest_version\": 2," |
| 128 " \"permissions\": [\"*://*/*\"]" | 128 " \"permissions\": [\"*://*/*\"]" |
| 129 "}"; | 129 "}"; |
| 130 | 130 |
| 131 test_extension_dirs_.push_back(new TestExtensionDir); | 131 test_extension_dirs_.push_back(base::MakeUnique<TestExtensionDir>()); |
| 132 TestExtensionDir* dir = test_extension_dirs_.back(); | 132 TestExtensionDir* dir = test_extension_dirs_.back().get(); |
| 133 dir->WriteManifest(kManifest); | 133 dir->WriteManifest(kManifest); |
| 134 | 134 |
| 135 // TODO(devlin): We should extract out methods to load an unpacked extension | 135 // TODO(devlin): We should extract out methods to load an unpacked extension |
| 136 // synchronously. We do it in ExtensionBrowserTest, but that's not helpful | 136 // synchronously. We do it in ExtensionBrowserTest, but that's not helpful |
| 137 // for unittests. | 137 // for unittests. |
| 138 TestExtensionRegistryObserver registry_observer(registry()); | 138 TestExtensionRegistryObserver registry_observer(registry()); |
| 139 scoped_refptr<UnpackedInstaller> installer( | 139 scoped_refptr<UnpackedInstaller> installer( |
| 140 UnpackedInstaller::Create(service())); | 140 UnpackedInstaller::Create(service())); |
| 141 installer->Load(dir->unpacked_path()); | 141 installer->Load(dir->unpacked_path()); |
| 142 base::FilePath extension_path = | 142 base::FilePath extension_path = |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 .Append( | 559 .Append( |
| 560 DictionaryBuilder().Set("extensionId", extension->id()).Build()) | 560 DictionaryBuilder().Set("extensionId", extension->id()).Build()) |
| 561 .Build(); | 561 .Build(); |
| 562 function = new api::DeveloperPrivateDeleteExtensionErrorsFunction(); | 562 function = new api::DeveloperPrivateDeleteExtensionErrorsFunction(); |
| 563 EXPECT_TRUE(RunFunction(function, *args)) << function->GetError(); | 563 EXPECT_TRUE(RunFunction(function, *args)) << function->GetError(); |
| 564 // No more errors! | 564 // No more errors! |
| 565 EXPECT_TRUE(error_console->GetErrorsForExtension(extension->id()).empty()); | 565 EXPECT_TRUE(error_console->GetErrorsForExtension(extension->id()).empty()); |
| 566 } | 566 } |
| 567 | 567 |
| 568 } // namespace extensions | 568 } // namespace extensions |
| OLD | NEW |