| 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( |
| 172 "good_l10n.crx", |
| 173 "0000000000000000000000000000000000000000000000000000000000000000"); |
| 172 // Check that there is an error message. | 174 // Check that there is an error message. |
| 173 EXPECT_NE(base::string16(), GetInstallError()); | 175 EXPECT_NE(base::string16(), GetInstallError()); |
| 174 } | 176 } |
| 175 | 177 |
| 176 TEST_F(SandboxedUnpackerTest, PassHashCheck) { | 178 TEST_F(SandboxedUnpackerTest, PassHashCheck) { |
| 177 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 179 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 178 extensions::switches::kEnableCrxHashCheck); | 180 extensions::switches::kEnableCrxHashCheck); |
| 179 SetupUnpacker( | 181 SetupUnpacker( |
| 180 "good_l10n.crx", | 182 "good_l10n.crx", |
| 181 "6fa171c726373785aa4fcd2df448c3db0420a95d5044fbee831f089b979c4068"); | 183 "6fa171c726373785aa4fcd2df448c3db0420a95d5044fbee831f089b979c4068"); |
| 182 // Check that there is no error message. | 184 // Check that there is no error message. |
| 183 EXPECT_EQ(base::string16(), GetInstallError()); | 185 EXPECT_EQ(base::string16(), GetInstallError()); |
| 184 } | 186 } |
| 185 | 187 |
| 186 TEST_F(SandboxedUnpackerTest, SkipHashCheck) { | 188 TEST_F(SandboxedUnpackerTest, SkipHashCheck) { |
| 187 SetupUnpacker("good_l10n.crx", "badhash"); | 189 SetupUnpacker("good_l10n.crx", "badhash"); |
| 188 // Check that there is no error message. | 190 // Check that there is no error message. |
| 189 EXPECT_EQ(base::string16(), GetInstallError()); | 191 EXPECT_EQ(base::string16(), GetInstallError()); |
| 190 } | 192 } |
| 191 | 193 |
| 192 } // namespace extensions | 194 } // namespace extensions |
| OLD | NEW |