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

Side by Side Diff: download_action_unittest.cc

Issue 3521016: AU: Start checkpointing update progress. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: address review comments Created 10 years, 2 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
« no previous file with comments | « download_action.cc ('k') | generate_delta_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium OS 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7
7 #include <glib.h> 8 #include <glib.h>
8 #include <gmock/gmock.h> 9 #include <gmock/gmock.h>
9 #include <gtest/gtest.h> 10 #include <gtest/gtest.h>
11
10 #include "update_engine/action_pipe.h" 12 #include "update_engine/action_pipe.h"
11 #include "update_engine/download_action.h" 13 #include "update_engine/download_action.h"
12 #include "update_engine/mock_http_fetcher.h" 14 #include "update_engine/mock_http_fetcher.h"
13 #include "update_engine/omaha_hash_calculator.h" 15 #include "update_engine/omaha_hash_calculator.h"
16 #include "update_engine/prefs_mock.h"
14 #include "update_engine/test_utils.h" 17 #include "update_engine/test_utils.h"
15 #include "update_engine/utils.h" 18 #include "update_engine/utils.h"
16 19
17 namespace chromeos_update_engine { 20 namespace chromeos_update_engine {
18 21
19 using std::string; 22 using std::string;
20 using std::vector; 23 using std::vector;
21 using testing::_; 24 using testing::_;
22 using testing::AtLeast; 25 using testing::AtLeast;
23 using testing::InSequence; 26 using testing::InSequence;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 OmahaHashCalculator::OmahaHashOfData(data); 102 OmahaHashCalculator::OmahaHashOfData(data);
100 uint64_t size = data.size() + (size_test ? 1 : 0); 103 uint64_t size = data.size() + (size_test ? 1 : 0);
101 InstallPlan install_plan(true, 104 InstallPlan install_plan(true,
102 "", 105 "",
103 size, 106 size,
104 hash, 107 hash,
105 output_temp_file.GetPath(), 108 output_temp_file.GetPath(),
106 ""); 109 "");
107 ObjectFeederAction<InstallPlan> feeder_action; 110 ObjectFeederAction<InstallPlan> feeder_action;
108 feeder_action.set_obj(install_plan); 111 feeder_action.set_obj(install_plan);
109 DownloadAction download_action(new MockHttpFetcher(&data[0], 112 PrefsMock prefs;
110 data.size())); 113 DownloadAction download_action(&prefs, new MockHttpFetcher(&data[0],
114 data.size()));
111 download_action.SetTestFileWriter(&writer); 115 download_action.SetTestFileWriter(&writer);
112 BondActions(&feeder_action, &download_action); 116 BondActions(&feeder_action, &download_action);
113 DownloadActionDelegateMock download_delegate; 117 DownloadActionDelegateMock download_delegate;
114 if (use_download_delegate) { 118 if (use_download_delegate) {
115 InSequence s; 119 InSequence s;
116 download_action.set_delegate(&download_delegate); 120 download_action.set_delegate(&download_delegate);
117 EXPECT_CALL(download_delegate, SetDownloadStatus(true)).Times(1); 121 EXPECT_CALL(download_delegate, SetDownloadStatus(true)).Times(1);
118 EXPECT_CALL(download_delegate, BytesReceived(_, _)).Times(AtLeast(1)); 122 EXPECT_CALL(download_delegate, BytesReceived(_, _)).Times(AtLeast(1));
119 EXPECT_CALL(download_delegate, SetDownloadStatus(false)).Times(1); 123 EXPECT_CALL(download_delegate, SetDownloadStatus(false)).Times(1);
120 } 124 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 memset(&data[0], 0, data.size()); 222 memset(&data[0], 0, data.size());
219 223
220 ScopedTempFile temp_file; 224 ScopedTempFile temp_file;
221 { 225 {
222 DirectFileWriter writer; 226 DirectFileWriter writer;
223 227
224 // takes ownership of passed in HttpFetcher 228 // takes ownership of passed in HttpFetcher
225 ObjectFeederAction<InstallPlan> feeder_action; 229 ObjectFeederAction<InstallPlan> feeder_action;
226 InstallPlan install_plan(true, "", 0, "", temp_file.GetPath(), ""); 230 InstallPlan install_plan(true, "", 0, "", temp_file.GetPath(), "");
227 feeder_action.set_obj(install_plan); 231 feeder_action.set_obj(install_plan);
228 DownloadAction download_action(new MockHttpFetcher(&data[0], data.size())); 232 PrefsMock prefs;
233 DownloadAction download_action(&prefs,
234 new MockHttpFetcher(&data[0], data.size()));
229 download_action.SetTestFileWriter(&writer); 235 download_action.SetTestFileWriter(&writer);
230 DownloadActionDelegateMock download_delegate; 236 DownloadActionDelegateMock download_delegate;
231 if (use_download_delegate) { 237 if (use_download_delegate) {
232 InSequence s; 238 InSequence s;
233 download_action.set_delegate(&download_delegate); 239 download_action.set_delegate(&download_delegate);
234 EXPECT_CALL(download_delegate, SetDownloadStatus(true)).Times(1); 240 EXPECT_CALL(download_delegate, SetDownloadStatus(true)).Times(1);
235 EXPECT_CALL(download_delegate, SetDownloadStatus(false)).Times(1); 241 EXPECT_CALL(download_delegate, SetDownloadStatus(false)).Times(1);
236 } 242 }
237 TerminateEarlyTestProcessorDelegate delegate; 243 TerminateEarlyTestProcessorDelegate delegate;
238 delegate.loop_ = loop; 244 delegate.loop_ = loop;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 326
321 // takes ownership of passed in HttpFetcher 327 // takes ownership of passed in HttpFetcher
322 InstallPlan install_plan(true, 328 InstallPlan install_plan(true,
323 "", 329 "",
324 1, 330 1,
325 OmahaHashCalculator::OmahaHashOfString("x"), 331 OmahaHashCalculator::OmahaHashOfString("x"),
326 "/dev/null", 332 "/dev/null",
327 "/dev/null"); 333 "/dev/null");
328 ObjectFeederAction<InstallPlan> feeder_action; 334 ObjectFeederAction<InstallPlan> feeder_action;
329 feeder_action.set_obj(install_plan); 335 feeder_action.set_obj(install_plan);
330 DownloadAction download_action(new MockHttpFetcher("x", 1)); 336 PrefsMock prefs;
337 DownloadAction download_action(&prefs, new MockHttpFetcher("x", 1));
331 download_action.SetTestFileWriter(&writer); 338 download_action.SetTestFileWriter(&writer);
332 339
333 DownloadActionTestAction test_action; 340 DownloadActionTestAction test_action;
334 test_action.expected_input_object_ = install_plan; 341 test_action.expected_input_object_ = install_plan;
335 BondActions(&feeder_action, &download_action); 342 BondActions(&feeder_action, &download_action);
336 BondActions(&download_action, &test_action); 343 BondActions(&download_action, &test_action);
337 344
338 ActionProcessor processor; 345 ActionProcessor processor;
339 PassObjectOutTestProcessorDelegate delegate; 346 PassObjectOutTestProcessorDelegate delegate;
340 delegate.loop_ = loop; 347 delegate.loop_ = loop;
(...skipping 12 matching lines...) Expand all
353 TEST(DownloadActionTest, BadOutFileTest) { 360 TEST(DownloadActionTest, BadOutFileTest) {
354 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE); 361 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE);
355 362
356 const string path("/fake/path/that/cant/be/created/because/of/missing/dirs"); 363 const string path("/fake/path/that/cant/be/created/because/of/missing/dirs");
357 DirectFileWriter writer; 364 DirectFileWriter writer;
358 365
359 // takes ownership of passed in HttpFetcher 366 // takes ownership of passed in HttpFetcher
360 InstallPlan install_plan(true, "", 0, "", path, ""); 367 InstallPlan install_plan(true, "", 0, "", path, "");
361 ObjectFeederAction<InstallPlan> feeder_action; 368 ObjectFeederAction<InstallPlan> feeder_action;
362 feeder_action.set_obj(install_plan); 369 feeder_action.set_obj(install_plan);
363 DownloadAction download_action(new MockHttpFetcher("x", 1)); 370 PrefsMock prefs;
371 DownloadAction download_action(&prefs, new MockHttpFetcher("x", 1));
364 download_action.SetTestFileWriter(&writer); 372 download_action.SetTestFileWriter(&writer);
365 373
366 BondActions(&feeder_action, &download_action); 374 BondActions(&feeder_action, &download_action);
367 375
368 ActionProcessor processor; 376 ActionProcessor processor;
369 processor.EnqueueAction(&feeder_action); 377 processor.EnqueueAction(&feeder_action);
370 processor.EnqueueAction(&download_action); 378 processor.EnqueueAction(&download_action);
371 processor.StartProcessing(); 379 processor.StartProcessing();
372 ASSERT_FALSE(processor.IsRunning()); 380 ASSERT_FALSE(processor.IsRunning());
373 381
374 g_main_loop_unref(loop); 382 g_main_loop_unref(loop);
375 } 383 }
376 384
377 } // namespace chromeos_update_engine 385 } // namespace chromeos_update_engine
OLDNEW
« no previous file with comments | « download_action.cc ('k') | generate_delta_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698