Change ErrorCode into an enum class.
This change is needed in order for us to be able to import ErrorCode
symbols from chromeos_update_engine into chromeos_update_manager.
Unfortunately, shifting from plain 'enum' into an 'enum class' means
that the compiler treats the new class as a distinct type from int,
which in turn means that plenty of seamless arithmetic/bitwise
operations we used for manipulating error code values throughout the
code needed to be retrofitted with static_cast operators.
In the future, we should consider imposing a proper abstraction on
update engine error codes that'll prevent mingling with value encoding
directly and prevent such nastiness. It'll also make things more
coherent (types, semantics) and safer.
BUG=chromium:358329
TEST=Unit tests.
Change-Id: Ie55fa566b764cdab6c4785d995fb6daee4cb32d3
Reviewed-on: https://chromium-review.googlesource.com/203209
Tested-by: Gilad Arnold <[email protected]>
Reviewed-by: Alex Deymo <[email protected]>
Commit-Queue: Gilad Arnold <[email protected]>
diff --git a/postinstall_runner_action_unittest.cc b/postinstall_runner_action_unittest.cc
index be77e08..acceb2b 100644
--- a/postinstall_runner_action_unittest.cc
+++ b/postinstall_runner_action_unittest.cc
@@ -47,7 +47,7 @@
public:
PostinstActionProcessorDelegate()
: loop_(NULL),
- code_(kErrorCodeError),
+ code_(ErrorCode::kError),
code_set_(false) {}
void ProcessingDone(const ActionProcessor* processor,
ErrorCode code) {
@@ -192,7 +192,7 @@
ASSERT_FALSE(processor.IsRunning());
EXPECT_TRUE(delegate.code_set_);
- EXPECT_EQ(should_succeed, delegate.code_ == kErrorCodeSuccess);
+ EXPECT_EQ(should_succeed, delegate.code_ == ErrorCode::kSuccess);
EXPECT_EQ(should_succeed, !collector_action.object().install_path.empty());
if (should_succeed)
EXPECT_TRUE(install_plan == collector_action.object());
@@ -208,7 +208,7 @@
}
if (err_code == 2)
- EXPECT_EQ(kErrorCodePostinstallBootedFromFirmwareB, delegate.code_);
+ EXPECT_EQ(ErrorCode::kPostinstallBootedFromFirmwareB, delegate.code_);
struct stat stbuf;
int rc = lstat((string(cwd) + "/postinst_called").c_str(), &stbuf);