Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: extensions/browser/sandboxed_unpacker_unittest.cc

Issue 2163883005: WIP: Obtain Bootstrap from utility process Service (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/browser/extensions_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/base64.h" 5 #include "base/base64.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "components/crx_file/id_util.h" 15 #include "components/crx_file/id_util.h"
16 #include "content/public/browser/service_manager_context.h"
16 #include "content/public/test/test_browser_thread_bundle.h" 17 #include "content/public/test/test_browser_thread_bundle.h"
17 #include "content/public/test/test_utils.h" 18 #include "content/public/test/test_utils.h"
18 #include "extensions/browser/extensions_test.h" 19 #include "extensions/browser/extensions_test.h"
19 #include "extensions/browser/sandboxed_unpacker.h" 20 #include "extensions/browser/sandboxed_unpacker.h"
20 #include "extensions/common/constants.h" 21 #include "extensions/common/constants.h"
21 #include "extensions/common/extension.h" 22 #include "extensions/common/extension.h"
22 #include "extensions/common/extension_paths.h" 23 #include "extensions/common/extension_paths.h"
23 #include "extensions/common/switches.h" 24 #include "extensions/common/switches.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 #include "third_party/skia/include/core/SkBitmap.h" 26 #include "third_party/skia/include/core/SkBitmap.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 base::FilePath temp_dir_; 62 base::FilePath temp_dir_;
62 }; 63 };
63 64
64 class SandboxedUnpackerTest : public ExtensionsTest { 65 class SandboxedUnpackerTest : public ExtensionsTest {
65 public: 66 public:
66 void SetUp() override { 67 void SetUp() override {
67 ExtensionsTest::SetUp(); 68 ExtensionsTest::SetUp();
68 ASSERT_TRUE(extensions_dir_.CreateUniqueTempDir()); 69 ASSERT_TRUE(extensions_dir_.CreateUniqueTempDir());
69 browser_threads_.reset(new content::TestBrowserThreadBundle( 70 browser_threads_.reset(new content::TestBrowserThreadBundle(
70 content::TestBrowserThreadBundle::IO_MAINLOOP)); 71 content::TestBrowserThreadBundle::IO_MAINLOOP));
72 service_manager_context_ = content::ServiceManagerContext::Create();
71 in_process_utility_thread_helper_.reset( 73 in_process_utility_thread_helper_.reset(
72 new content::InProcessUtilityThreadHelper); 74 new content::InProcessUtilityThreadHelper);
73 // It will delete itself. 75 // It will delete itself.
74 client_ = new MockSandboxedUnpackerClient; 76 client_ = new MockSandboxedUnpackerClient;
75 77
76 sandboxed_unpacker_ = new SandboxedUnpacker( 78 sandboxed_unpacker_ = new SandboxedUnpacker(
77 Manifest::INTERNAL, Extension::NO_FLAGS, extensions_dir_.path(), 79 Manifest::INTERNAL, Extension::NO_FLAGS, extensions_dir_.path(),
78 base::ThreadTaskRunnerHandle::Get(), client_); 80 base::ThreadTaskRunnerHandle::Get(), client_);
79 } 81 }
80 82
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return client_->temp_dir().AppendASCII(kTempExtensionName); 127 return client_->temp_dir().AppendASCII(kTempExtensionName);
126 } 128 }
127 129
128 base::string16 GetInstallError() { return client_->unpack_err(); } 130 base::string16 GetInstallError() { return client_->unpack_err(); }
129 131
130 protected: 132 protected:
131 base::ScopedTempDir extensions_dir_; 133 base::ScopedTempDir extensions_dir_;
132 MockSandboxedUnpackerClient* client_; 134 MockSandboxedUnpackerClient* client_;
133 scoped_refptr<SandboxedUnpacker> sandboxed_unpacker_; 135 scoped_refptr<SandboxedUnpacker> sandboxed_unpacker_;
134 std::unique_ptr<content::TestBrowserThreadBundle> browser_threads_; 136 std::unique_ptr<content::TestBrowserThreadBundle> browser_threads_;
137 std::unique_ptr<content::ServiceManagerContext> service_manager_context_;
135 std::unique_ptr<content::InProcessUtilityThreadHelper> 138 std::unique_ptr<content::InProcessUtilityThreadHelper>
136 in_process_utility_thread_helper_; 139 in_process_utility_thread_helper_;
137 }; 140 };
138 141
139 TEST_F(SandboxedUnpackerTest, NoCatalogsSuccess) { 142 TEST_F(SandboxedUnpackerTest, NoCatalogsSuccess) {
140 SetupUnpacker("no_l10n.crx", ""); 143 SetupUnpacker("no_l10n.crx", "");
141 // Check that there is no _locales folder. 144 // Check that there is no _locales folder.
142 base::FilePath install_path = GetInstallPath().Append(kLocaleFolder); 145 base::FilePath install_path = GetInstallPath().Append(kLocaleFolder);
143 EXPECT_FALSE(base::PathExists(install_path)); 146 EXPECT_FALSE(base::PathExists(install_path));
144 } 147 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 EXPECT_EQ(base::string16(), GetInstallError()); 185 EXPECT_EQ(base::string16(), GetInstallError());
183 } 186 }
184 187
185 TEST_F(SandboxedUnpackerTest, SkipHashCheck) { 188 TEST_F(SandboxedUnpackerTest, SkipHashCheck) {
186 SetupUnpacker("good_l10n.crx", "badhash"); 189 SetupUnpacker("good_l10n.crx", "badhash");
187 // Check that there is no error message. 190 // Check that there is no error message.
188 EXPECT_EQ(base::string16(), GetInstallError()); 191 EXPECT_EQ(base::string16(), GetInstallError());
189 } 192 }
190 193
191 } // namespace extensions 194 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/extensions_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698