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

Unified Diff: update_attempter_unittest.cc

Issue 6624082: Start action processing asynchronously in UpdateAttempter. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: set to null Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « update_attempter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: update_attempter_unittest.cc
diff --git a/update_attempter_unittest.cc b/update_attempter_unittest.cc
index 76068fd1ecd3b7f705410e9165d81fe7716671bf..73addb5a644801777c1064a9eb4ea121445c2387 100644
--- a/update_attempter_unittest.cc
+++ b/update_attempter_unittest.cc
@@ -39,7 +39,7 @@ class UpdateAttempterUnderTest : public UpdateAttempter {
class UpdateAttempterTest : public ::testing::Test {
protected:
- UpdateAttempterTest() : attempter_(&dbus_) {}
+ UpdateAttempterTest() : attempter_(&dbus_), loop_(NULL) {}
virtual void SetUp() {
EXPECT_EQ(NULL, attempter_.dbus_service_);
EXPECT_EQ(NULL, attempter_.prefs_);
@@ -60,10 +60,16 @@ class UpdateAttempterTest : public ::testing::Test {
attempter_.prefs_ = &prefs_;
}
+ void UpdateTestStart();
+ void UpdateTestVerify();
+ static gboolean StaticUpdateTestStart(gpointer data);
+ static gboolean StaticUpdateTestVerify(gpointer data);
+
MockDbusGlib dbus_;
UpdateAttempterUnderTest attempter_;
ActionProcessorMock* processor_;
NiceMock<PrefsMock> prefs_;
+ GMainLoop* loop_;
};
TEST_F(UpdateAttempterTest, ActionCompletedDownloadTest) {
@@ -227,22 +233,35 @@ TEST_F(UpdateAttempterTest, UpdateStatusToStringTest) {
UpdateStatusToString(static_cast<UpdateStatus>(-1)));
}
-TEST_F(UpdateAttempterTest, UpdateTest) {
+gboolean UpdateAttempterTest::StaticUpdateTestStart(gpointer data) {
+ reinterpret_cast<UpdateAttempterTest*>(data)->UpdateTestStart();
+ return FALSE;
+}
+
+gboolean UpdateAttempterTest::StaticUpdateTestVerify(gpointer data) {
+ reinterpret_cast<UpdateAttempterTest*>(data)->UpdateTestVerify();
+ return FALSE;
+}
+
+namespace {
+const string kActionTypes[] = {
+ OmahaRequestAction::StaticType(),
+ OmahaResponseHandlerAction::StaticType(),
+ FilesystemCopierAction::StaticType(),
+ FilesystemCopierAction::StaticType(),
+ OmahaRequestAction::StaticType(),
+ DownloadAction::StaticType(),
+ OmahaRequestAction::StaticType(),
+ FilesystemCopierAction::StaticType(),
+ FilesystemCopierAction::StaticType(),
+ PostinstallRunnerAction::StaticType(),
+ OmahaRequestAction::StaticType()
+};
+} // namespace {}
+
+void UpdateAttempterTest::UpdateTestStart() {
attempter_.set_http_response_code(200);
InSequence s;
- const string kActionTypes[] = {
- OmahaRequestAction::StaticType(),
- OmahaResponseHandlerAction::StaticType(),
- FilesystemCopierAction::StaticType(),
- FilesystemCopierAction::StaticType(),
- OmahaRequestAction::StaticType(),
- DownloadAction::StaticType(),
- OmahaRequestAction::StaticType(),
- FilesystemCopierAction::StaticType(),
- FilesystemCopierAction::StaticType(),
- PostinstallRunnerAction::StaticType(),
- OmahaRequestAction::StaticType()
- };
for (size_t i = 0; i < arraysize(kActionTypes); ++i) {
EXPECT_CALL(*processor_,
EnqueueAction(Property(&AbstractAction::Type,
@@ -251,7 +270,10 @@ TEST_F(UpdateAttempterTest, UpdateTest) {
EXPECT_CALL(*processor_, StartProcessing()).Times(1);
attempter_.Update("", "", false);
+ g_idle_add(&StaticUpdateTestVerify, this);
+}
+void UpdateAttempterTest::UpdateTestVerify() {
EXPECT_EQ(0, attempter_.http_response_code());
EXPECT_EQ(&attempter_, processor_->delegate());
EXPECT_EQ(arraysize(kActionTypes), attempter_.actions_.size());
@@ -265,6 +287,15 @@ TEST_F(UpdateAttempterTest, UpdateTest) {
ASSERT_TRUE(download_action != NULL);
EXPECT_EQ(&attempter_, download_action->delegate());
EXPECT_EQ(UPDATE_STATUS_CHECKING_FOR_UPDATE, attempter_.status());
+ g_main_loop_quit(loop_);
+}
+
+TEST_F(UpdateAttempterTest, UpdateTest) {
+ loop_ = g_main_loop_new(g_main_context_default(), FALSE);
+ g_idle_add(&StaticUpdateTestStart, this);
+ g_main_loop_run(loop_);
+ g_main_loop_unref(loop_);
+ loop_ = NULL;
}
} // namespace chromeos_update_engine
« no previous file with comments | « update_attempter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698