| OLD | NEW |
| 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 |
| 8 #include <glib.h> | 8 #include <glib.h> |
| 9 #include <gmock/gmock.h> | 9 #include <gmock/gmock.h> |
| 10 #include <gtest/gtest.h> | 10 #include <gtest/gtest.h> |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 InstallPlan install_plan(true, | 136 InstallPlan install_plan(true, |
| 137 false, | 137 false, |
| 138 "", | 138 "", |
| 139 size, | 139 size, |
| 140 hash, | 140 hash, |
| 141 output_temp_file.GetPath(), | 141 output_temp_file.GetPath(), |
| 142 ""); | 142 ""); |
| 143 ObjectFeederAction<InstallPlan> feeder_action; | 143 ObjectFeederAction<InstallPlan> feeder_action; |
| 144 feeder_action.set_obj(install_plan); | 144 feeder_action.set_obj(install_plan); |
| 145 PrefsMock prefs; | 145 PrefsMock prefs; |
| 146 MockHttpFetcher* http_fetcher = new MockHttpFetcher(&data[0], data.size()); | 146 MockHttpFetcher* http_fetcher = new MockHttpFetcher(&data[0], |
| 147 data.size(), |
| 148 NULL); |
| 147 // takes ownership of passed in HttpFetcher | 149 // takes ownership of passed in HttpFetcher |
| 148 DownloadAction download_action(&prefs, http_fetcher); | 150 DownloadAction download_action(&prefs, http_fetcher); |
| 149 download_action.SetTestFileWriter(&writer); | 151 download_action.SetTestFileWriter(&writer); |
| 150 BondActions(&feeder_action, &download_action); | 152 BondActions(&feeder_action, &download_action); |
| 151 DownloadActionDelegateMock download_delegate; | 153 DownloadActionDelegateMock download_delegate; |
| 152 if (use_download_delegate) { | 154 if (use_download_delegate) { |
| 153 InSequence s; | 155 InSequence s; |
| 154 download_action.set_delegate(&download_delegate); | 156 download_action.set_delegate(&download_delegate); |
| 155 EXPECT_CALL(download_delegate, SetDownloadStatus(true)).Times(1); | 157 EXPECT_CALL(download_delegate, SetDownloadStatus(true)).Times(1); |
| 156 if (data.size() > kMockHttpFetcherChunkSize) | 158 if (data.size() > kMockHttpFetcherChunkSize) |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 ScopedTempFile temp_file; | 284 ScopedTempFile temp_file; |
| 283 { | 285 { |
| 284 DirectFileWriter writer; | 286 DirectFileWriter writer; |
| 285 | 287 |
| 286 // takes ownership of passed in HttpFetcher | 288 // takes ownership of passed in HttpFetcher |
| 287 ObjectFeederAction<InstallPlan> feeder_action; | 289 ObjectFeederAction<InstallPlan> feeder_action; |
| 288 InstallPlan install_plan(true, false, "", 0, "", temp_file.GetPath(), ""); | 290 InstallPlan install_plan(true, false, "", 0, "", temp_file.GetPath(), ""); |
| 289 feeder_action.set_obj(install_plan); | 291 feeder_action.set_obj(install_plan); |
| 290 PrefsMock prefs; | 292 PrefsMock prefs; |
| 291 DownloadAction download_action(&prefs, | 293 DownloadAction download_action(&prefs, |
| 292 new MockHttpFetcher(&data[0], data.size())); | 294 new MockHttpFetcher(&data[0], |
| 295 data.size(), |
| 296 NULL)); |
| 293 download_action.SetTestFileWriter(&writer); | 297 download_action.SetTestFileWriter(&writer); |
| 294 DownloadActionDelegateMock download_delegate; | 298 DownloadActionDelegateMock download_delegate; |
| 295 if (use_download_delegate) { | 299 if (use_download_delegate) { |
| 296 InSequence s; | 300 InSequence s; |
| 297 download_action.set_delegate(&download_delegate); | 301 download_action.set_delegate(&download_delegate); |
| 298 EXPECT_CALL(download_delegate, SetDownloadStatus(true)).Times(1); | 302 EXPECT_CALL(download_delegate, SetDownloadStatus(true)).Times(1); |
| 299 EXPECT_CALL(download_delegate, SetDownloadStatus(false)).Times(1); | 303 EXPECT_CALL(download_delegate, SetDownloadStatus(false)).Times(1); |
| 300 } | 304 } |
| 301 TerminateEarlyTestProcessorDelegate delegate; | 305 TerminateEarlyTestProcessorDelegate delegate; |
| 302 delegate.loop_ = loop; | 306 delegate.loop_ = loop; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 InstallPlan install_plan(true, | 390 InstallPlan install_plan(true, |
| 387 false, | 391 false, |
| 388 "", | 392 "", |
| 389 1, | 393 1, |
| 390 OmahaHashCalculator::OmahaHashOfString("x"), | 394 OmahaHashCalculator::OmahaHashOfString("x"), |
| 391 "/dev/null", | 395 "/dev/null", |
| 392 "/dev/null"); | 396 "/dev/null"); |
| 393 ObjectFeederAction<InstallPlan> feeder_action; | 397 ObjectFeederAction<InstallPlan> feeder_action; |
| 394 feeder_action.set_obj(install_plan); | 398 feeder_action.set_obj(install_plan); |
| 395 PrefsMock prefs; | 399 PrefsMock prefs; |
| 396 DownloadAction download_action(&prefs, new MockHttpFetcher("x", 1)); | 400 DownloadAction download_action(&prefs, new MockHttpFetcher("x", 1, NULL)); |
| 397 download_action.SetTestFileWriter(&writer); | 401 download_action.SetTestFileWriter(&writer); |
| 398 | 402 |
| 399 DownloadActionTestAction test_action; | 403 DownloadActionTestAction test_action; |
| 400 test_action.expected_input_object_ = install_plan; | 404 test_action.expected_input_object_ = install_plan; |
| 401 BondActions(&feeder_action, &download_action); | 405 BondActions(&feeder_action, &download_action); |
| 402 BondActions(&download_action, &test_action); | 406 BondActions(&download_action, &test_action); |
| 403 | 407 |
| 404 ActionProcessor processor; | 408 ActionProcessor processor; |
| 405 PassObjectOutTestProcessorDelegate delegate; | 409 PassObjectOutTestProcessorDelegate delegate; |
| 406 delegate.loop_ = loop; | 410 delegate.loop_ = loop; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 420 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE); | 424 GMainLoop *loop = g_main_loop_new(g_main_context_default(), FALSE); |
| 421 | 425 |
| 422 const string path("/fake/path/that/cant/be/created/because/of/missing/dirs"); | 426 const string path("/fake/path/that/cant/be/created/because/of/missing/dirs"); |
| 423 DirectFileWriter writer; | 427 DirectFileWriter writer; |
| 424 | 428 |
| 425 // takes ownership of passed in HttpFetcher | 429 // takes ownership of passed in HttpFetcher |
| 426 InstallPlan install_plan(true, false, "", 0, "", path, ""); | 430 InstallPlan install_plan(true, false, "", 0, "", path, ""); |
| 427 ObjectFeederAction<InstallPlan> feeder_action; | 431 ObjectFeederAction<InstallPlan> feeder_action; |
| 428 feeder_action.set_obj(install_plan); | 432 feeder_action.set_obj(install_plan); |
| 429 PrefsMock prefs; | 433 PrefsMock prefs; |
| 430 DownloadAction download_action(&prefs, new MockHttpFetcher("x", 1)); | 434 DownloadAction download_action(&prefs, new MockHttpFetcher("x", 1, NULL)); |
| 431 download_action.SetTestFileWriter(&writer); | 435 download_action.SetTestFileWriter(&writer); |
| 432 | 436 |
| 433 BondActions(&feeder_action, &download_action); | 437 BondActions(&feeder_action, &download_action); |
| 434 | 438 |
| 435 ActionProcessor processor; | 439 ActionProcessor processor; |
| 436 processor.EnqueueAction(&feeder_action); | 440 processor.EnqueueAction(&feeder_action); |
| 437 processor.EnqueueAction(&download_action); | 441 processor.EnqueueAction(&download_action); |
| 438 processor.StartProcessing(); | 442 processor.StartProcessing(); |
| 439 ASSERT_FALSE(processor.IsRunning()); | 443 ASSERT_FALSE(processor.IsRunning()); |
| 440 | 444 |
| 441 g_main_loop_unref(loop); | 445 g_main_loop_unref(loop); |
| 442 } | 446 } |
| 443 | 447 |
| 444 } // namespace chromeos_update_engine | 448 } // namespace chromeos_update_engine |
| OLD | NEW |