OLD | NEW |
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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/compiler_specific.h" | 6 #include "base/compiler_specific.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 command_args->SetString("sha256", binary_output_hash); | 85 command_args->SetString("sha256", binary_output_hash); |
86 command_args->SetString("op", "create"); | 86 command_args->SetString("op", "create"); |
87 command_args->SetString("patch", "binary_output.bin"); | 87 command_args->SetString("patch", "binary_output.bin"); |
88 | 88 |
89 TestCallback callback; | 89 TestCallback callback; |
90 scoped_refptr<DeltaUpdateOp> op = new DeltaUpdateOpCreate(); | 90 scoped_refptr<DeltaUpdateOp> op = new DeltaUpdateOpCreate(); |
91 op->Run(command_args.get(), | 91 op->Run(command_args.get(), |
92 input_dir_.path(), | 92 input_dir_.path(), |
93 unpack_dir_.path(), | 93 unpack_dir_.path(), |
94 NULL, | 94 NULL, |
95 true, | |
96 base::Bind(&TestCallback::Set, base::Unretained(&callback)), | 95 base::Bind(&TestCallback::Set, base::Unretained(&callback)), |
97 task_runner_); | 96 task_runner_); |
98 base::RunLoop().RunUntilIdle(); | 97 base::RunLoop().RunUntilIdle(); |
99 | 98 |
100 EXPECT_EQ(true, callback.called_); | 99 EXPECT_EQ(true, callback.called_); |
101 EXPECT_EQ(ComponentUnpacker::kNone, callback.error_); | 100 EXPECT_EQ(ComponentUnpacker::kNone, callback.error_); |
102 EXPECT_EQ(0, callback.extra_code_); | 101 EXPECT_EQ(0, callback.extra_code_); |
103 EXPECT_TRUE(base::ContentsEqual( | 102 EXPECT_TRUE(base::ContentsEqual( |
104 unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")), | 103 unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")), |
105 test_file("binary_output.bin"))); | 104 test_file("binary_output.bin"))); |
(...skipping 10 matching lines...) Expand all Loading... |
116 command_args->SetString("sha256", binary_output_hash); | 115 command_args->SetString("sha256", binary_output_hash); |
117 command_args->SetString("op", "copy"); | 116 command_args->SetString("op", "copy"); |
118 command_args->SetString("input", "binary_output.bin"); | 117 command_args->SetString("input", "binary_output.bin"); |
119 | 118 |
120 TestCallback callback; | 119 TestCallback callback; |
121 scoped_refptr<DeltaUpdateOp> op = new DeltaUpdateOpCopy(); | 120 scoped_refptr<DeltaUpdateOp> op = new DeltaUpdateOpCopy(); |
122 op->Run(command_args.get(), | 121 op->Run(command_args.get(), |
123 input_dir_.path(), | 122 input_dir_.path(), |
124 unpack_dir_.path(), | 123 unpack_dir_.path(), |
125 installer_.get(), | 124 installer_.get(), |
126 true, | |
127 base::Bind(&TestCallback::Set, base::Unretained(&callback)), | 125 base::Bind(&TestCallback::Set, base::Unretained(&callback)), |
128 task_runner_); | 126 task_runner_); |
129 base::RunLoop().RunUntilIdle(); | 127 base::RunLoop().RunUntilIdle(); |
130 | 128 |
131 EXPECT_EQ(true, callback.called_); | 129 EXPECT_EQ(true, callback.called_); |
132 EXPECT_EQ(ComponentUnpacker::kNone, callback.error_); | 130 EXPECT_EQ(ComponentUnpacker::kNone, callback.error_); |
133 EXPECT_EQ(0, callback.extra_code_); | 131 EXPECT_EQ(0, callback.extra_code_); |
134 EXPECT_TRUE(base::ContentsEqual( | 132 EXPECT_TRUE(base::ContentsEqual( |
135 unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")), | 133 unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")), |
136 test_file("binary_output.bin"))); | 134 test_file("binary_output.bin"))); |
137 } | 135 } |
138 | 136 |
139 // Verify that a 'courgette' delta update operation works correctly. | 137 // Verify that a 'courgette' delta update operation works correctly. |
140 TEST_F(ComponentPatcherOperationTest, CheckCourgetteOperation) { | 138 TEST_F(ComponentPatcherOperationTest, CheckCourgetteOperation) { |
141 EXPECT_TRUE(base::CopyFile( | 139 EXPECT_TRUE(base::CopyFile( |
142 test_file("binary_input.bin"), | 140 test_file("binary_input.bin"), |
143 installed_dir_.path().Append(FILE_PATH_LITERAL("binary_input.bin")))); | 141 installed_dir_.path().Append(FILE_PATH_LITERAL("binary_input.bin")))); |
144 EXPECT_TRUE(base::CopyFile(test_file("binary_courgette_patch.bin"), | 142 EXPECT_TRUE(base::CopyFile(test_file("binary_courgette_patch.bin"), |
145 input_dir_.path().Append(FILE_PATH_LITERAL( | 143 input_dir_.path().Append(FILE_PATH_LITERAL( |
146 "binary_courgette_patch.bin")))); | 144 "binary_courgette_patch.bin")))); |
147 | 145 |
148 scoped_ptr<base::DictionaryValue> command_args(new base::DictionaryValue()); | 146 scoped_ptr<base::DictionaryValue> command_args(new base::DictionaryValue()); |
149 command_args->SetString("output", "output.bin"); | 147 command_args->SetString("output", "output.bin"); |
150 command_args->SetString("sha256", binary_output_hash); | 148 command_args->SetString("sha256", binary_output_hash); |
151 command_args->SetString("op", "courgette"); | 149 command_args->SetString("op", "courgette"); |
152 command_args->SetString("input", "binary_input.bin"); | 150 command_args->SetString("input", "binary_input.bin"); |
153 command_args->SetString("patch", "binary_courgette_patch.bin"); | 151 command_args->SetString("patch", "binary_courgette_patch.bin"); |
154 | 152 |
155 TestCallback callback; | 153 TestCallback callback; |
156 scoped_refptr<DeltaUpdateOp> op = CreateDeltaUpdateOp("courgette"); | 154 scoped_refptr<DeltaUpdateOp> op = |
| 155 CreateDeltaUpdateOp("courgette", NULL /* out_of_process_patcher */); |
157 op->Run(command_args.get(), | 156 op->Run(command_args.get(), |
158 input_dir_.path(), | 157 input_dir_.path(), |
159 unpack_dir_.path(), | 158 unpack_dir_.path(), |
160 installer_.get(), | 159 installer_.get(), |
161 true, | |
162 base::Bind(&TestCallback::Set, base::Unretained(&callback)), | 160 base::Bind(&TestCallback::Set, base::Unretained(&callback)), |
163 task_runner_); | 161 task_runner_); |
164 base::RunLoop().RunUntilIdle(); | 162 base::RunLoop().RunUntilIdle(); |
165 | 163 |
166 EXPECT_EQ(true, callback.called_); | 164 EXPECT_EQ(true, callback.called_); |
167 EXPECT_EQ(ComponentUnpacker::kNone, callback.error_); | 165 EXPECT_EQ(ComponentUnpacker::kNone, callback.error_); |
168 EXPECT_EQ(0, callback.extra_code_); | 166 EXPECT_EQ(0, callback.extra_code_); |
169 EXPECT_TRUE(base::ContentsEqual( | 167 EXPECT_TRUE(base::ContentsEqual( |
170 unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")), | 168 unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")), |
171 test_file("binary_output.bin"))); | 169 test_file("binary_output.bin"))); |
172 } | 170 } |
173 | 171 |
174 // Verify that a 'bsdiff' delta update operation works correctly. | 172 // Verify that a 'bsdiff' delta update operation works correctly. |
175 TEST_F(ComponentPatcherOperationTest, CheckBsdiffOperation) { | 173 TEST_F(ComponentPatcherOperationTest, CheckBsdiffOperation) { |
176 EXPECT_TRUE(base::CopyFile( | 174 EXPECT_TRUE(base::CopyFile( |
177 test_file("binary_input.bin"), | 175 test_file("binary_input.bin"), |
178 installed_dir_.path().Append(FILE_PATH_LITERAL("binary_input.bin")))); | 176 installed_dir_.path().Append(FILE_PATH_LITERAL("binary_input.bin")))); |
179 EXPECT_TRUE(base::CopyFile( | 177 EXPECT_TRUE(base::CopyFile( |
180 test_file("binary_bsdiff_patch.bin"), | 178 test_file("binary_bsdiff_patch.bin"), |
181 input_dir_.path().Append(FILE_PATH_LITERAL("binary_bsdiff_patch.bin")))); | 179 input_dir_.path().Append(FILE_PATH_LITERAL("binary_bsdiff_patch.bin")))); |
182 | 180 |
183 scoped_ptr<base::DictionaryValue> command_args(new base::DictionaryValue()); | 181 scoped_ptr<base::DictionaryValue> command_args(new base::DictionaryValue()); |
184 command_args->SetString("output", "output.bin"); | 182 command_args->SetString("output", "output.bin"); |
185 command_args->SetString("sha256", binary_output_hash); | 183 command_args->SetString("sha256", binary_output_hash); |
186 command_args->SetString("op", "courgette"); | 184 command_args->SetString("op", "courgette"); |
187 command_args->SetString("input", "binary_input.bin"); | 185 command_args->SetString("input", "binary_input.bin"); |
188 command_args->SetString("patch", "binary_bsdiff_patch.bin"); | 186 command_args->SetString("patch", "binary_bsdiff_patch.bin"); |
189 | 187 |
190 TestCallback callback; | 188 TestCallback callback; |
191 scoped_refptr<DeltaUpdateOp> op = CreateDeltaUpdateOp("bsdiff"); | 189 scoped_refptr<DeltaUpdateOp> op = |
| 190 CreateDeltaUpdateOp("bsdiff", NULL /* out_of_process_patcher */); |
192 op->Run(command_args.get(), | 191 op->Run(command_args.get(), |
193 input_dir_.path(), | 192 input_dir_.path(), |
194 unpack_dir_.path(), | 193 unpack_dir_.path(), |
195 installer_.get(), | 194 installer_.get(), |
196 true, | |
197 base::Bind(&TestCallback::Set, base::Unretained(&callback)), | 195 base::Bind(&TestCallback::Set, base::Unretained(&callback)), |
198 task_runner_); | 196 task_runner_); |
199 base::RunLoop().RunUntilIdle(); | 197 base::RunLoop().RunUntilIdle(); |
200 | 198 |
201 EXPECT_EQ(true, callback.called_); | 199 EXPECT_EQ(true, callback.called_); |
202 EXPECT_EQ(ComponentUnpacker::kNone, callback.error_); | 200 EXPECT_EQ(ComponentUnpacker::kNone, callback.error_); |
203 EXPECT_EQ(0, callback.extra_code_); | 201 EXPECT_EQ(0, callback.extra_code_); |
204 EXPECT_TRUE(base::ContentsEqual( | 202 EXPECT_TRUE(base::ContentsEqual( |
205 unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")), | 203 unpack_dir_.path().Append(FILE_PATH_LITERAL("output.bin")), |
206 test_file("binary_output.bin"))); | 204 test_file("binary_output.bin"))); |
207 } | 205 } |
208 | 206 |
209 } // namespace component_updater | 207 } // namespace component_updater |
OLD | NEW |