OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/compiler_specific.h" |
| 6 #include "base/file_util.h" |
| 7 #include "base/files/file_path.h" |
| 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/path_service.h" |
| 10 #include "base/values.h" |
| 11 #include "chrome/browser/component_updater/component_patcher.h" |
| 12 #include "chrome/browser/component_updater/component_patcher_operation.h" |
| 13 #include "chrome/browser/component_updater/component_updater_service.h" |
| 14 #include "chrome/browser/component_updater/test/component_patcher_mock.h" |
| 15 #include "chrome/browser/component_updater/test/component_patcher_unittest.h" |
| 16 #include "chrome/browser/component_updater/test/test_installer.h" |
| 17 #include "chrome/common/chrome_paths.h" |
| 18 #include "courgette/courgette.h" |
| 19 #include "courgette/third_party/bsdiff.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 |
| 22 // Verify that a 'courgette' delta update operation works correctly. |
| 23 TEST_F(ComponentPatcherOperationTest, CheckCourgetteOperation) { |
| 24 EXPECT_TRUE(file_util::CopyFile( |
| 25 test_file("binary_input.bin"), |
| 26 installed_dir_.path().Append(FILE_PATH_LITERAL("binary_input.bin")))); |
| 27 EXPECT_TRUE(file_util::CopyFile( |
| 28 test_file("binary_courgette_patch.bin"), |
| 29 input_dir_.path().Append( |
| 30 FILE_PATH_LITERAL("binary_courgette_patch.bin")))); |
| 31 |
| 32 scoped_ptr<base::DictionaryValue> command_args(new base::DictionaryValue()); |
| 33 command_args->SetString("output", "output.bin"); |
| 34 command_args->SetString("sha256", binary_output_hash); |
| 35 command_args->SetString("op", "courgette"); |
| 36 command_args->SetString("input", "binary_input.bin"); |
| 37 command_args->SetString("patch", "binary_courgette_patch.bin"); |
| 38 |
| 39 int error = 0; |
| 40 scoped_ptr<DeltaUpdateOp> op(new DeltaUpdateOpPatchCourgette()); |
| 41 ComponentUnpacker::Error result = op->Run(command_args.get(), |
| 42 input_dir_.path(), |
| 43 unpack_dir_.path(), |
| 44 patcher_.get(), |
| 45 installer_.get(), |
| 46 &error); |
| 47 EXPECT_EQ(ComponentUnpacker::kNone, result); |
| 48 EXPECT_EQ(0, error); |
| 49 EXPECT_TRUE(file_util::ContentsEqual( |
| 50 unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")), |
| 51 test_file("binary_output.bin"))); |
| 52 } |
| 53 |
| 54 // Verify that a 'bsdiff' delta update operation works correctly. |
| 55 TEST_F(ComponentPatcherOperationTest, CheckBsdiffOperation) { |
| 56 EXPECT_TRUE(file_util::CopyFile( |
| 57 test_file("binary_input.bin"), |
| 58 installed_dir_.path().Append(FILE_PATH_LITERAL("binary_input.bin")))); |
| 59 EXPECT_TRUE(file_util::CopyFile( |
| 60 test_file("binary_bsdiff_patch.bin"), |
| 61 input_dir_.path().Append(FILE_PATH_LITERAL("binary_bsdiff_patch.bin")))); |
| 62 |
| 63 scoped_ptr<base::DictionaryValue> command_args(new base::DictionaryValue()); |
| 64 command_args->SetString("output", "output.bin"); |
| 65 command_args->SetString("sha256", binary_output_hash); |
| 66 command_args->SetString("op", "courgette"); |
| 67 command_args->SetString("input", "binary_input.bin"); |
| 68 command_args->SetString("patch", "binary_bsdiff_patch.bin"); |
| 69 |
| 70 int error = 0; |
| 71 scoped_ptr<DeltaUpdateOp> op(new DeltaUpdateOpPatchBsdiff()); |
| 72 ComponentUnpacker::Error result = op->Run(command_args.get(), |
| 73 input_dir_.path(), |
| 74 unpack_dir_.path(), |
| 75 patcher_.get(), |
| 76 installer_.get(), |
| 77 &error); |
| 78 EXPECT_EQ(ComponentUnpacker::kNone, result); |
| 79 EXPECT_EQ(0, error); |
| 80 EXPECT_TRUE(file_util::ContentsEqual( |
| 81 unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")), |
| 82 test_file("binary_output.bin"))); |
| 83 } |
OLD | NEW |