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

Unified Diff: filesystem_copier_action_unittest.cc

Issue 3022008: For actions, switch bool success into an exit code. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: switch to all positive error codes. Created 10 years, 5 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 | « filesystem_copier_action.cc ('k') | integration_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: filesystem_copier_action_unittest.cc
diff --git a/filesystem_copier_action_unittest.cc b/filesystem_copier_action_unittest.cc
index e2bd42be5f46208d4deca3fce5a34ffade775848..03aa86aa16996ddf307c5cc839b01c794803060c 100644
--- a/filesystem_copier_action_unittest.cc
+++ b/filesystem_copier_action_unittest.cc
@@ -33,14 +33,14 @@ class FilesystemCopierActionTest : public ::testing::Test {
class FilesystemCopierActionTestDelegate : public ActionProcessorDelegate {
public:
- FilesystemCopierActionTestDelegate() : ran_(false), success_(false) {}
+ FilesystemCopierActionTestDelegate() : ran_(false), code_(kActionCodeError) {}
void ExitMainLoop() {
while (g_main_context_pending(NULL)) {
g_main_context_iteration(NULL, false);
}
g_main_loop_quit(loop_);
}
- void ProcessingDone(const ActionProcessor* processor, bool success) {
+ void ProcessingDone(const ActionProcessor* processor, ActionExitCode code) {
ExitMainLoop();
}
void ProcessingStopped(const ActionProcessor* processor) {
@@ -48,21 +48,21 @@ class FilesystemCopierActionTestDelegate : public ActionProcessorDelegate {
}
void ActionCompleted(ActionProcessor* processor,
AbstractAction* action,
- bool success) {
+ ActionExitCode code) {
if (action->Type() == FilesystemCopierAction::StaticType()) {
ran_ = true;
- success_ = success;
+ code_ = code;
}
}
void set_loop(GMainLoop* loop) {
loop_ = loop;
}
bool ran() { return ran_; }
- bool success() { return success_; }
+ ActionExitCode code() { return code_; }
private:
GMainLoop* loop_;
bool ran_;
- bool success_;
+ ActionExitCode code_;
};
struct StartProcessorCallbackArgs {
@@ -96,7 +96,7 @@ void FilesystemCopierActionTest::DoTest(bool run_out_of_space,
string a_loop_file;
string b_loop_file;
-
+
EXPECT_TRUE(utils::MakeTempFile("/tmp/a_loop_file.XXXXXX",
&a_loop_file,
NULL));
@@ -105,7 +105,7 @@ void FilesystemCopierActionTest::DoTest(bool run_out_of_space,
&b_loop_file,
NULL));
ScopedPathUnlinker b_loop_file_unlinker(b_loop_file);
-
+
// Make random data for a, zero filled data for b.
const size_t kLoopFileSize = 10 * 1024 * 1024 + 512;
vector<char> a_loop_data(kLoopFileSize);
@@ -173,10 +173,10 @@ void FilesystemCopierActionTest::DoTest(bool run_out_of_space,
if (!terminate_early)
EXPECT_TRUE(delegate.ran());
if (run_out_of_space || terminate_early) {
- EXPECT_FALSE(delegate.success());
+ EXPECT_EQ(kActionCodeError, delegate.code());
return;
}
- EXPECT_TRUE(delegate.success());
+ EXPECT_EQ(kActionCodeSuccess, delegate.code());
// Make sure everything in the out_image is there
vector<char> a_out;
@@ -193,15 +193,15 @@ class FilesystemCopierActionTest2Delegate : public ActionProcessorDelegate {
public:
void ActionCompleted(ActionProcessor* processor,
AbstractAction* action,
- bool success) {
+ ActionExitCode code) {
if (action->Type() == FilesystemCopierAction::StaticType()) {
ran_ = true;
- success_ = success;
+ code_ = code;
}
}
GMainLoop *loop_;
bool ran_;
- bool success_;
+ ActionExitCode code_;
};
TEST_F(FilesystemCopierActionTest, MissingInputObjectTest) {
@@ -220,7 +220,7 @@ TEST_F(FilesystemCopierActionTest, MissingInputObjectTest) {
processor.StartProcessing();
EXPECT_FALSE(processor.IsRunning());
EXPECT_TRUE(delegate.ran_);
- EXPECT_FALSE(delegate.success_);
+ EXPECT_EQ(kActionCodeError, delegate.code_);
}
TEST_F(FilesystemCopierActionTest, FullUpdateTest) {
@@ -245,7 +245,7 @@ TEST_F(FilesystemCopierActionTest, FullUpdateTest) {
processor.StartProcessing();
EXPECT_FALSE(processor.IsRunning());
EXPECT_TRUE(delegate.ran_);
- EXPECT_TRUE(delegate.success_);
+ EXPECT_EQ(kActionCodeSuccess, delegate.code_);
EXPECT_EQ(kUrl, collector_action.object().download_url);
}
@@ -269,7 +269,7 @@ TEST_F(FilesystemCopierActionTest, NonExistentDriveTest) {
processor.StartProcessing();
EXPECT_FALSE(processor.IsRunning());
EXPECT_TRUE(delegate.ran_);
- EXPECT_FALSE(delegate.success_);
+ EXPECT_EQ(kActionCodeError, delegate.code_);
}
TEST_F(FilesystemCopierActionTest, RunAsRootNoSpaceTest) {
« no previous file with comments | « filesystem_copier_action.cc ('k') | integration_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698