| 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 #include <glib.h> | 7 #include <glib.h> |
| 8 #include <gtest/gtest.h> | 8 #include <gtest/gtest.h> |
| 9 #include "update_engine/action_pipe.h" | 9 #include "update_engine/action_pipe.h" |
| 10 #include "update_engine/download_action.h" | 10 #include "update_engine/download_action.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 class DownloadActionTest : public ::testing::Test { }; | 21 class DownloadActionTest : public ::testing::Test { }; |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 class DownloadActionTestProcessorDelegate : public ActionProcessorDelegate { | 24 class DownloadActionTestProcessorDelegate : public ActionProcessorDelegate { |
| 25 public: | 25 public: |
| 26 DownloadActionTestProcessorDelegate() | 26 DownloadActionTestProcessorDelegate() |
| 27 : loop_(NULL), processing_done_called_(false) {} | 27 : loop_(NULL), processing_done_called_(false) {} |
| 28 virtual ~DownloadActionTestProcessorDelegate() { | 28 virtual ~DownloadActionTestProcessorDelegate() { |
| 29 EXPECT_TRUE(processing_done_called_); | 29 EXPECT_TRUE(processing_done_called_); |
| 30 } | 30 } |
| 31 virtual void ProcessingDone(const ActionProcessor* processor) { | 31 virtual void ProcessingDone(const ActionProcessor* processor, bool success) { |
| 32 ASSERT_TRUE(loop_); | 32 ASSERT_TRUE(loop_); |
| 33 g_main_loop_quit(loop_); | 33 g_main_loop_quit(loop_); |
| 34 vector<char> found_data; | 34 vector<char> found_data; |
| 35 ASSERT_TRUE(utils::ReadFile(path_, &found_data)); | 35 ASSERT_TRUE(utils::ReadFile(path_, &found_data)); |
| 36 ASSERT_EQ(expected_data_.size(), found_data.size()); | 36 ASSERT_EQ(expected_data_.size(), found_data.size()); |
| 37 for (unsigned i = 0; i < expected_data_.size(); i++) { | 37 for (unsigned i = 0; i < expected_data_.size(); i++) { |
| 38 EXPECT_EQ(expected_data_[i], found_data[i]); | 38 EXPECT_EQ(expected_data_[i], found_data[i]); |
| 39 } | 39 } |
| 40 processing_done_called_ = true; | 40 processing_done_called_ = true; |
| 41 } | 41 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 InstallPlan expected_input_object_; | 207 InstallPlan expected_input_object_; |
| 208 bool did_run_; | 208 bool did_run_; |
| 209 }; | 209 }; |
| 210 | 210 |
| 211 namespace { | 211 namespace { |
| 212 // This class is an ActionProcessorDelegate that simply terminates the | 212 // This class is an ActionProcessorDelegate that simply terminates the |
| 213 // run loop when the ActionProcessor has completed processing. It's used | 213 // run loop when the ActionProcessor has completed processing. It's used |
| 214 // only by the test PassObjectOutTest. | 214 // only by the test PassObjectOutTest. |
| 215 class PassObjectOutTestProcessorDelegate : public ActionProcessorDelegate { | 215 class PassObjectOutTestProcessorDelegate : public ActionProcessorDelegate { |
| 216 public: | 216 public: |
| 217 void ProcessingDone(const ActionProcessor* processor) { | 217 void ProcessingDone(const ActionProcessor* processor, bool success) { |
| 218 ASSERT_TRUE(loop_); | 218 ASSERT_TRUE(loop_); |
| 219 g_main_loop_quit(loop_); | 219 g_main_loop_quit(loop_); |
| 220 } | 220 } |
| 221 GMainLoop *loop_; | 221 GMainLoop *loop_; |
| 222 }; | 222 }; |
| 223 | 223 |
| 224 gboolean PassObjectOutTestStarter(gpointer data) { | 224 gboolean PassObjectOutTestStarter(gpointer data) { |
| 225 ActionProcessor *processor = reinterpret_cast<ActionProcessor*>(data); | 225 ActionProcessor *processor = reinterpret_cast<ActionProcessor*>(data); |
| 226 processor->StartProcessing(); | 226 processor->StartProcessing(); |
| 227 return FALSE; | 227 return FALSE; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 ActionProcessor processor; | 276 ActionProcessor processor; |
| 277 processor.EnqueueAction(&feeder_action); | 277 processor.EnqueueAction(&feeder_action); |
| 278 processor.EnqueueAction(&download_action); | 278 processor.EnqueueAction(&download_action); |
| 279 processor.StartProcessing(); | 279 processor.StartProcessing(); |
| 280 ASSERT_FALSE(processor.IsRunning()); | 280 ASSERT_FALSE(processor.IsRunning()); |
| 281 | 281 |
| 282 g_main_loop_unref(loop); | 282 g_main_loop_unref(loop); |
| 283 } | 283 } |
| 284 | 284 |
| 285 } // namespace chromeos_update_engine | 285 } // namespace chromeos_update_engine |
| OLD | NEW |