| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 EXPECT_TRUE(PathService::Get(extensions::DIR_TEST_DATA, &base_path)); | 141 EXPECT_TRUE(PathService::Get(extensions::DIR_TEST_DATA, &base_path)); |
| 142 base_path = base_path.AppendASCII("content_hash_fetcher"); | 142 base_path = base_path.AppendASCII("content_hash_fetcher"); |
| 143 return base_path.Append(relative_path); | 143 return base_path.Append(relative_path); |
| 144 } | 144 } |
| 145 | 145 |
| 146 // Unzips the extension source from |extension_zip| into a temporary | 146 // Unzips the extension source from |extension_zip| into a temporary |
| 147 // directory and loads it, returning the resuling Extension object. | 147 // directory and loads it, returning the resuling Extension object. |
| 148 scoped_refptr<Extension> UnzipToTempDirAndLoad( | 148 scoped_refptr<Extension> UnzipToTempDirAndLoad( |
| 149 const base::FilePath& extension_zip) { | 149 const base::FilePath& extension_zip) { |
| 150 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); | 150 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 151 base::FilePath destination = temp_dir_.path(); | 151 base::FilePath destination = temp_dir_.GetPath(); |
| 152 EXPECT_TRUE(zip::Unzip(extension_zip, destination)); | 152 EXPECT_TRUE(zip::Unzip(extension_zip, destination)); |
| 153 | 153 |
| 154 std::string error; | 154 std::string error; |
| 155 scoped_refptr<Extension> extension = file_util::LoadExtension( | 155 scoped_refptr<Extension> extension = file_util::LoadExtension( |
| 156 destination, Manifest::INTERNAL, 0 /* flags */, &error); | 156 destination, Manifest::INTERNAL, 0 /* flags */, &error); |
| 157 EXPECT_NE(nullptr, extension.get()) << " error:'" << error << "'"; | 157 EXPECT_NE(nullptr, extension.get()) << " error:'" << error << "'"; |
| 158 return extension; | 158 return extension; |
| 159 } | 159 } |
| 160 | 160 |
| 161 // Registers interception of requests for |url| to respond with the contents | 161 // Registers interception of requests for |url| to respond with the contents |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 EXPECT_TRUE( | 251 EXPECT_TRUE( |
| 252 base::ContainsKey(result->mismatch_paths, script_path.BaseName())); | 252 base::ContainsKey(result->mismatch_paths, script_path.BaseName())); |
| 253 | 253 |
| 254 // Make sure the verified_contents.json file was written into the extension's | 254 // Make sure the verified_contents.json file was written into the extension's |
| 255 // install dir. | 255 // install dir. |
| 256 EXPECT_TRUE( | 256 EXPECT_TRUE( |
| 257 base::PathExists(file_util::GetVerifiedContentsPath(extension->path()))); | 257 base::PathExists(file_util::GetVerifiedContentsPath(extension->path()))); |
| 258 } | 258 } |
| 259 | 259 |
| 260 } // namespace extensions | 260 } // namespace extensions |
| OLD | NEW |