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

Unified Diff: chromeos/components/tether/keep_alive_operation_unittest.cc

Issue 2741253002: [CrOS Tether] Create KeepAliveScheduler, a class which schedules keep-alive tickles to be sent to a… (Closed)
Patch Set: Added tests for other modified files. Created 3 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
Index: chromeos/components/tether/keep_alive_operation_unittest.cc
diff --git a/chromeos/components/tether/keep_alive_operation_unittest.cc b/chromeos/components/tether/keep_alive_operation_unittest.cc
index f0b196d4ae3e7fabc8dddc09e85965a54d92adc2..57e6e467fe4b452e961367977765d7b2b238a3fa 100644
--- a/chromeos/components/tether/keep_alive_operation_unittest.cc
+++ b/chromeos/components/tether/keep_alive_operation_unittest.cc
@@ -19,6 +19,20 @@ namespace tether {
namespace {
+class TestObserver : public KeepAliveOperation::Observer {
+ public:
+ TestObserver() : has_run_callback_(false) {}
+
+ virtual ~TestObserver() {}
+
+ bool has_run_callback() { return has_run_callback_; }
+
+ void OnOperationFinished() override { has_run_callback_ = true; }
+
+ private:
+ bool has_run_callback_;
+};
+
std::string CreateKeepAliveTickleString() {
KeepAliveTickle tickle;
return MessageWrapper(tickle).ToRawMessage();
@@ -37,6 +51,10 @@ class KeepAliveOperationTest : public testing::Test {
operation_ = base::WrapUnique(new KeepAliveOperation(
test_device_, fake_ble_connection_manager_.get()));
+
+ test_observer_ = base::WrapUnique(new TestObserver());
+ operation_->AddObserver(test_observer_.get());
+
operation_->Initialize();
}
@@ -55,6 +73,8 @@ class KeepAliveOperationTest : public testing::Test {
const cryptauth::RemoteDevice test_device_;
std::unique_ptr<FakeBleConnectionManager> fake_ble_connection_manager_;
+ std::unique_ptr<TestObserver> test_observer_;
+
std::unique_ptr<KeepAliveOperation> operation_;
private:
@@ -62,7 +82,9 @@ class KeepAliveOperationTest : public testing::Test {
};
TEST_F(KeepAliveOperationTest, TestSendsKeepAliveTickle) {
+ EXPECT_FALSE(test_observer_->has_run_callback());
SimulateDeviceAuthenticationAndVerifyMessageSent();
+ EXPECT_TRUE(test_observer_->has_run_callback());
}
} // namespace tether

Powered by Google App Engine
This is Rietveld 408576698