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 "extensions/browser/sandboxed_unpacker.h" | 5 #include "extensions/browser/sandboxed_unpacker.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 TEST_F(SandboxedUnpackerTest, FromDirWithCatalogsSuccess) { | 161 TEST_F(SandboxedUnpackerTest, FromDirWithCatalogsSuccess) { |
162 SetupUnpackerWithDirectory("good_l10n.crx"); | 162 SetupUnpackerWithDirectory("good_l10n.crx"); |
163 // Check that there is _locales folder. | 163 // Check that there is _locales folder. |
164 base::FilePath install_path = GetInstallPath().Append(kLocaleFolder); | 164 base::FilePath install_path = GetInstallPath().Append(kLocaleFolder); |
165 EXPECT_TRUE(base::PathExists(install_path)); | 165 EXPECT_TRUE(base::PathExists(install_path)); |
166 } | 166 } |
167 | 167 |
168 TEST_F(SandboxedUnpackerTest, FailHashCheck) { | 168 TEST_F(SandboxedUnpackerTest, FailHashCheck) { |
169 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 169 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
170 extensions::switches::kEnableCrxHashCheck); | 170 extensions::switches::kEnableCrxHashCheck); |
171 SetupUnpacker("good_l10n.crx", "badhash"); | 171 SetupUnpacker("good_l10n.crx", std::string(64, '0')); |
172 // Check that there is an error message. | 172 // Check that there is an error message. |
173 EXPECT_NE(base::string16(), GetInstallError()); | 173 EXPECT_NE(base::string16(), GetInstallError()); |
174 } | 174 } |
175 | 175 |
176 TEST_F(SandboxedUnpackerTest, PassHashCheck) { | 176 TEST_F(SandboxedUnpackerTest, PassHashCheck) { |
177 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 177 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
178 extensions::switches::kEnableCrxHashCheck); | 178 extensions::switches::kEnableCrxHashCheck); |
179 SetupUnpacker( | 179 SetupUnpacker( |
180 "good_l10n.crx", | 180 "good_l10n.crx", |
181 "6fa171c726373785aa4fcd2df448c3db0420a95d5044fbee831f089b979c4068"); | 181 "6fa171c726373785aa4fcd2df448c3db0420a95d5044fbee831f089b979c4068"); |
182 // Check that there is no error message. | 182 // Check that there is no error message. |
183 EXPECT_EQ(base::string16(), GetInstallError()); | 183 EXPECT_EQ(base::string16(), GetInstallError()); |
184 } | 184 } |
185 | 185 |
186 TEST_F(SandboxedUnpackerTest, SkipHashCheck) { | 186 TEST_F(SandboxedUnpackerTest, SkipHashCheck) { |
187 SetupUnpacker("good_l10n.crx", "badhash"); | 187 SetupUnpacker("good_l10n.crx", "badhash"); |
188 // Check that there is no error message. | 188 // Check that there is no error message. |
189 EXPECT_EQ(base::string16(), GetInstallError()); | 189 EXPECT_EQ(base::string16(), GetInstallError()); |
190 } | 190 } |
191 | 191 |
192 } // namespace extensions | 192 } // namespace extensions |
OLD | NEW |