summaryrefslogtreecommitdiff
path: root/update_manager/evaluation_context_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'update_manager/evaluation_context_unittest.cc')
-rw-r--r--update_manager/evaluation_context_unittest.cc75
1 files changed, 14 insertions, 61 deletions
diff --git a/update_manager/evaluation_context_unittest.cc b/update_manager/evaluation_context_unittest.cc
index eb42eb74..cd0b2e6c 100644
--- a/update_manager/evaluation_context_unittest.cc
+++ b/update_manager/evaluation_context_unittest.cc
@@ -39,6 +39,7 @@ using brillo::MessageLoop;
using brillo::MessageLoopRunMaxIterations;
using brillo::MessageLoopRunUntil;
using chromeos_update_engine::FakeClock;
+using std::shared_ptr;
using std::string;
using std::unique_ptr;
using testing::_;
@@ -59,14 +60,14 @@ bool GetBoolean(bool* value) {
}
template <typename T>
-void ReadVar(scoped_refptr<EvaluationContext> ec, Variable<T>* var) {
+void ReadVar(shared_ptr<EvaluationContext> ec, Variable<T>* var) {
ec->GetValue(var);
}
// Runs |evaluation|; if the value pointed by |count_p| is greater than zero,
// decrement it and schedule a reevaluation; otherwise, writes true to |done_p|.
void EvaluateRepeatedly(Closure evaluation,
- scoped_refptr<EvaluationContext> ec,
+ shared_ptr<EvaluationContext> ec,
int* count_p,
bool* done_p) {
evaluation.Run();
@@ -92,11 +93,11 @@ class UmEvaluationContextTest : public ::testing::Test {
fake_clock_.SetMonotonicTime(Time::FromTimeT(1240428300));
// Mar 2, 2006 1:23:45 UTC.
fake_clock_.SetWallclockTime(Time::FromTimeT(1141262625));
- eval_ctx_ = new EvaluationContext(
+ eval_ctx_.reset(new EvaluationContext(
&fake_clock_,
default_timeout_,
default_timeout_,
- unique_ptr<base::Callback<void(EvaluationContext*)>>(nullptr));
+ unique_ptr<base::Callback<void(EvaluationContext*)>>(nullptr)));
}
void TearDown() override {
@@ -126,7 +127,7 @@ class UmEvaluationContextTest : public ::testing::Test {
brillo::FakeMessageLoop loop_{nullptr};
FakeClock fake_clock_;
- scoped_refptr<EvaluationContext> eval_ctx_;
+ shared_ptr<EvaluationContext> eval_ctx_;
// FakeVariables used for testing the EvaluationContext. These are required
// here to prevent them from going away *before* the EvaluationContext under
@@ -210,13 +211,7 @@ TEST_F(UmEvaluationContextTest, RunOnValueChangeOrTimeoutWithoutVariables) {
fake_const_var_.reset(new string("Hello world!"));
EXPECT_EQ(*eval_ctx_->GetValue(&fake_const_var_), "Hello world!");
- EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(
-#if BASE_VER < 576279
- Bind(&base::DoNothing)
-#else
- base::DoNothing()
-#endif
- ));
+ EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(base::DoNothing()));
}
// Test that reevaluation occurs when an async variable it depends on changes.
@@ -286,23 +281,11 @@ TEST_F(UmEvaluationContextTest, RunOnValueChangeOrTimeoutExpires) {
EXPECT_TRUE(value);
// Ensure that we cannot reschedule an evaluation.
- EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(
-#if BASE_VER < 576279
- Bind(&base::DoNothing)
-#else
- base::DoNothing()
-#endif
- ));
+ EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(base::DoNothing()));
// Ensure that we can reschedule an evaluation after resetting expiration.
eval_ctx_->ResetExpiration();
- EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(
-#if BASE_VER < 576279
- Bind(&base::DoNothing)
-#else
- base::DoNothing()
-#endif
- ));
+ EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(base::DoNothing()));
}
// Test that we clear the events when destroying the EvaluationContext.
@@ -348,13 +331,7 @@ TEST_F(UmEvaluationContextTest, ObjectDeletedWithPendingEventsTest) {
fake_poll_var_.reset(new string("Polled value"));
eval_ctx_->GetValue(&fake_async_var_);
eval_ctx_->GetValue(&fake_poll_var_);
- EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(
-#if BASE_VER < 576279
- Bind(&base::DoNothing)
-#else
- base::DoNothing()
-#endif
- ));
+ EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(base::DoNothing()));
// TearDown() checks for leaked observers on this async_variable, which means
// that our object is still alive after removing its reference.
}
@@ -446,13 +423,7 @@ TEST_F(UmEvaluationContextTest,
// The "false" from IsWallclockTimeGreaterThan means that's not that timestamp
// yet, so this should schedule a callback for when that happens.
- EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(
-#if BASE_VER < 576279
- Bind(&base::DoNothing)
-#else
- base::DoNothing()
-#endif
- ));
+ EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(base::DoNothing()));
}
TEST_F(UmEvaluationContextTest,
@@ -462,13 +433,7 @@ TEST_F(UmEvaluationContextTest,
// The "false" from IsMonotonicTimeGreaterThan means that's not that timestamp
// yet, so this should schedule a callback for when that happens.
- EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(
-#if BASE_VER < 576279
- Bind(&base::DoNothing)
-#else
- base::DoNothing()
-#endif
- ));
+ EXPECT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(base::DoNothing()));
}
TEST_F(UmEvaluationContextTest,
@@ -481,13 +446,7 @@ TEST_F(UmEvaluationContextTest,
fake_clock_.GetWallclockTime() - TimeDelta::FromSeconds(1)));
// Callback should not be scheduled.
- EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(
-#if BASE_VER < 576279
- Bind(&base::DoNothing)
-#else
- base::DoNothing()
-#endif
- ));
+ EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(base::DoNothing()));
}
TEST_F(UmEvaluationContextTest,
@@ -500,13 +459,7 @@ TEST_F(UmEvaluationContextTest,
fake_clock_.GetMonotonicTime() - TimeDelta::FromSeconds(1)));
// Callback should not be scheduled.
- EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(
-#if BASE_VER < 576279
- Bind(&base::DoNothing)
-#else
- base::DoNothing()
-#endif
- ));
+ EXPECT_FALSE(eval_ctx_->RunOnValueChangeOrTimeout(base::DoNothing()));
}
TEST_F(UmEvaluationContextTest, DumpContext) {