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

Unified Diff: postinstall_runner_action_unittest.cc

Issue 4690006: AU: Execute postinst asynchronously so that the D-Bus service is not blocked. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: address review comments Created 10 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « postinstall_runner_action.cc ('k') | subprocess.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: postinstall_runner_action_unittest.cc
diff --git a/postinstall_runner_action_unittest.cc b/postinstall_runner_action_unittest.cc
index 55fe79f8a729c5fb09cc8a6506f8f63f328c295b..7f4e65c16e33e60e7d310548d29afa61a137830a 100644
--- a/postinstall_runner_action_unittest.cc
+++ b/postinstall_runner_action_unittest.cc
@@ -17,6 +17,14 @@ using std::vector;
namespace chromeos_update_engine {
+namespace {
+gboolean StartProcessorInRunLoop(gpointer data) {
+ ActionProcessor *processor = reinterpret_cast<ActionProcessor*>(data);
+ processor->StartProcessing();
+ return FALSE;
+}
+} // namespace
+
class PostinstallRunnerActionTest : public ::testing::Test {
public:
void DoTest(bool do_losetup, bool do_err_script);
@@ -25,8 +33,14 @@ class PostinstallRunnerActionTest : public ::testing::Test {
class PostinstActionProcessorDelegate : public ActionProcessorDelegate {
public:
PostinstActionProcessorDelegate()
- : code_(kActionCodeError),
+ : loop_(NULL),
+ code_(kActionCodeError),
code_set_(false) {}
+ void ProcessingDone(const ActionProcessor* processor,
+ ActionExitCode code) {
+ ASSERT_TRUE(loop_);
+ g_main_loop_quit(loop_);
+ }
void ActionCompleted(ActionProcessor* processor,
AbstractAction* action,
ActionExitCode code) {
@@ -35,6 +49,7 @@ class PostinstActionProcessorDelegate : public ActionProcessorDelegate {
code_set_ = true;
}
}
+ GMainLoop* loop_;
ActionExitCode code_;
bool code_set_;
};
@@ -125,9 +140,13 @@ void PostinstallRunnerActionTest::DoTest(bool do_losetup, bool do_err_script) {
processor.EnqueueAction(&runner_action);
processor.EnqueueAction(&collector_action);
processor.set_delegate(&delegate);
- processor.StartProcessing();
- ASSERT_FALSE(processor.IsRunning())
- << "Update test to handle non-asynch actions";
+
+ GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE);
+ delegate.loop_ = loop;
+ g_timeout_add(0, &StartProcessorInRunLoop, &processor);
+ g_main_loop_run(loop);
+ g_main_loop_unref(loop);
+ ASSERT_FALSE(processor.IsRunning());
EXPECT_TRUE(delegate.code_set_);
EXPECT_EQ(do_losetup && !do_err_script, delegate.code_ == kActionCodeSuccess);
« no previous file with comments | « postinstall_runner_action.cc ('k') | subprocess.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698