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

Side by Side Diff: chrome/browser/component_updater/test/component_patcher_unittest_win.cc

Issue 18332014: Move Copy* into the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: windows Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/compiler_specific.h" 5 #include "base/compiler_specific.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/component_updater/component_patcher.h" 11 #include "chrome/browser/component_updater/component_patcher.h"
12 #include "chrome/browser/component_updater/component_patcher_operation.h" 12 #include "chrome/browser/component_updater/component_patcher_operation.h"
13 #include "chrome/browser/component_updater/component_updater_service.h" 13 #include "chrome/browser/component_updater/component_updater_service.h"
14 #include "chrome/browser/component_updater/test/component_patcher_mock.h" 14 #include "chrome/browser/component_updater/test/component_patcher_mock.h"
15 #include "chrome/browser/component_updater/test/component_patcher_unittest.h" 15 #include "chrome/browser/component_updater/test/component_patcher_unittest.h"
16 #include "chrome/browser/component_updater/test/test_installer.h" 16 #include "chrome/browser/component_updater/test/test_installer.h"
17 #include "chrome/common/chrome_paths.h" 17 #include "chrome/common/chrome_paths.h"
18 #include "courgette/courgette.h" 18 #include "courgette/courgette.h"
19 #include "courgette/third_party/bsdiff.h" 19 #include "courgette/third_party/bsdiff.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 21
22 // Verify that a 'courgette' delta update operation works correctly. 22 // Verify that a 'courgette' delta update operation works correctly.
23 TEST_F(ComponentPatcherOperationTest, CheckCourgetteOperation) { 23 TEST_F(ComponentPatcherOperationTest, CheckCourgetteOperation) {
24 EXPECT_TRUE(file_util::CopyFile( 24 EXPECT_TRUE(base::CopyFile(
25 test_file("binary_input.bin"), 25 test_file("binary_input.bin"),
26 installed_dir_.path().Append(FILE_PATH_LITERAL("binary_input.bin")))); 26 installed_dir_.path().Append(FILE_PATH_LITERAL("binary_input.bin"))));
27 EXPECT_TRUE(file_util::CopyFile( 27 EXPECT_TRUE(base::CopyFile(
28 test_file("binary_courgette_patch.bin"), 28 test_file("binary_courgette_patch.bin"),
29 input_dir_.path().Append( 29 input_dir_.path().Append(
30 FILE_PATH_LITERAL("binary_courgette_patch.bin")))); 30 FILE_PATH_LITERAL("binary_courgette_patch.bin"))));
31 31
32 scoped_ptr<base::DictionaryValue> command_args(new base::DictionaryValue()); 32 scoped_ptr<base::DictionaryValue> command_args(new base::DictionaryValue());
33 command_args->SetString("output", "output.bin"); 33 command_args->SetString("output", "output.bin");
34 command_args->SetString("sha256", binary_output_hash); 34 command_args->SetString("sha256", binary_output_hash);
35 command_args->SetString("op", "courgette"); 35 command_args->SetString("op", "courgette");
36 command_args->SetString("input", "binary_input.bin"); 36 command_args->SetString("input", "binary_input.bin");
37 command_args->SetString("patch", "binary_courgette_patch.bin"); 37 command_args->SetString("patch", "binary_courgette_patch.bin");
38 38
39 int error = 0; 39 int error = 0;
40 scoped_ptr<DeltaUpdateOp> op(new DeltaUpdateOpPatchCourgette()); 40 scoped_ptr<DeltaUpdateOp> op(new DeltaUpdateOpPatchCourgette());
41 ComponentUnpacker::Error result = op->Run(command_args.get(), 41 ComponentUnpacker::Error result = op->Run(command_args.get(),
42 input_dir_.path(), 42 input_dir_.path(),
43 unpack_dir_.path(), 43 unpack_dir_.path(),
44 patcher_.get(), 44 patcher_.get(),
45 installer_.get(), 45 installer_.get(),
46 &error); 46 &error);
47 EXPECT_EQ(ComponentUnpacker::kNone, result); 47 EXPECT_EQ(ComponentUnpacker::kNone, result);
48 EXPECT_EQ(0, error); 48 EXPECT_EQ(0, error);
49 EXPECT_TRUE(file_util::ContentsEqual( 49 EXPECT_TRUE(file_util::ContentsEqual(
50 unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")), 50 unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")),
51 test_file("binary_output.bin"))); 51 test_file("binary_output.bin")));
52 } 52 }
53 53
54 // Verify that a 'bsdiff' delta update operation works correctly. 54 // Verify that a 'bsdiff' delta update operation works correctly.
55 TEST_F(ComponentPatcherOperationTest, CheckBsdiffOperation) { 55 TEST_F(ComponentPatcherOperationTest, CheckBsdiffOperation) {
56 EXPECT_TRUE(file_util::CopyFile( 56 EXPECT_TRUE(base::CopyFile(
57 test_file("binary_input.bin"), 57 test_file("binary_input.bin"),
58 installed_dir_.path().Append(FILE_PATH_LITERAL("binary_input.bin")))); 58 installed_dir_.path().Append(FILE_PATH_LITERAL("binary_input.bin"))));
59 EXPECT_TRUE(file_util::CopyFile( 59 EXPECT_TRUE(base::CopyFile(
60 test_file("binary_bsdiff_patch.bin"), 60 test_file("binary_bsdiff_patch.bin"),
61 input_dir_.path().Append(FILE_PATH_LITERAL("binary_bsdiff_patch.bin")))); 61 input_dir_.path().Append(FILE_PATH_LITERAL("binary_bsdiff_patch.bin"))));
62 62
63 scoped_ptr<base::DictionaryValue> command_args(new base::DictionaryValue()); 63 scoped_ptr<base::DictionaryValue> command_args(new base::DictionaryValue());
64 command_args->SetString("output", "output.bin"); 64 command_args->SetString("output", "output.bin");
65 command_args->SetString("sha256", binary_output_hash); 65 command_args->SetString("sha256", binary_output_hash);
66 command_args->SetString("op", "courgette"); 66 command_args->SetString("op", "courgette");
67 command_args->SetString("input", "binary_input.bin"); 67 command_args->SetString("input", "binary_input.bin");
68 command_args->SetString("patch", "binary_bsdiff_patch.bin"); 68 command_args->SetString("patch", "binary_bsdiff_patch.bin");
69 69
70 int error = 0; 70 int error = 0;
71 scoped_ptr<DeltaUpdateOp> op(new DeltaUpdateOpPatchBsdiff()); 71 scoped_ptr<DeltaUpdateOp> op(new DeltaUpdateOpPatchBsdiff());
72 ComponentUnpacker::Error result = op->Run(command_args.get(), 72 ComponentUnpacker::Error result = op->Run(command_args.get(),
73 input_dir_.path(), 73 input_dir_.path(),
74 unpack_dir_.path(), 74 unpack_dir_.path(),
75 patcher_.get(), 75 patcher_.get(),
76 installer_.get(), 76 installer_.get(),
77 &error); 77 &error);
78 EXPECT_EQ(ComponentUnpacker::kNone, result); 78 EXPECT_EQ(ComponentUnpacker::kNone, result);
79 EXPECT_EQ(0, error); 79 EXPECT_EQ(0, error);
80 EXPECT_TRUE(file_util::ContentsEqual( 80 EXPECT_TRUE(file_util::ContentsEqual(
81 unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")), 81 unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")),
82 test_file("binary_output.bin"))); 82 test_file("binary_output.bin")));
83 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698