Rename MockTaskRunner into FakeTaskRunner

BUG: 24267885
Change-Id: Iaf72821cd9f6eee77a199dba7939dbbcb1e35402
Reviewed-on: https://weave-review.googlesource.com/1173
Reviewed-by: Vitaly Buka <vitalybuka@google.com>
diff --git a/libweave/src/commands/cloud_command_proxy_unittest.cc b/libweave/src/commands/cloud_command_proxy_unittest.cc
index 3a3ce38..d96508d 100644
--- a/libweave/src/commands/cloud_command_proxy_unittest.cc
+++ b/libweave/src/commands/cloud_command_proxy_unittest.cc
@@ -9,7 +9,7 @@
 
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
-#include <weave/provider/test/mock_task_runner.h>
+#include <weave/provider/test/fake_task_runner.h>
 
 #include "libweave/src/commands/command_dictionary.h"
 #include "libweave/src/commands/command_instance.h"
@@ -136,7 +136,7 @@
   base::CallbackList<void(StateChangeQueueInterface::UpdateID)> callbacks_;
   testing::StrictMock<MockCloudCommandUpdateInterface> cloud_updater_;
   testing::StrictMock<MockStateChangeQueueInterface> state_change_queue_;
-  testing::StrictMock<provider::test::MockTaskRunner> task_runner_;
+  testing::StrictMock<provider::test::FakeTaskRunner> task_runner_;
   std::queue<base::Closure> task_queue_;
   CommandDictionary command_dictionary_;
   std::unique_ptr<CommandInstance> command_instance_;
@@ -214,7 +214,6 @@
   // We should retry with both state and progress fields updated this time,
   // after the initial backoff (which should be 1s in our case).
   base::TimeDelta expected_delay = base::TimeDelta::FromSeconds(1);
-  EXPECT_CALL(task_runner_, PostDelayedTask(_, _, expected_delay));
   on_error.Run();
 
   // Execute the delayed request. But pretend that it failed too.
@@ -228,7 +227,6 @@
 
   // Now backoff should be 2 seconds.
   expected_delay = base::TimeDelta::FromSeconds(2);
-  EXPECT_CALL(task_runner_, PostDelayedTask(_, _, expected_delay));
   on_error.Run();
 
   // Retry the task.
diff --git a/libweave/src/notification/xmpp_channel_unittest.cc b/libweave/src/notification/xmpp_channel_unittest.cc
index beecd1d..e783727 100644
--- a/libweave/src/notification/xmpp_channel_unittest.cc
+++ b/libweave/src/notification/xmpp_channel_unittest.cc
@@ -8,8 +8,8 @@
 #include <queue>
 
 #include <gtest/gtest.h>
+#include <weave/provider/test/fake_task_runner.h>
 #include <weave/provider/test/mock_network.h>
-#include <weave/provider/test/mock_task_runner.h>
 #include <weave/test/fake_stream.h>
 
 #include "libweave/src/bind_lambda.h"
@@ -144,7 +144,7 @@
     EXPECT_EQ(st, xmpp_client_.state());
   }
 
-  StrictMock<provider::test::MockTaskRunner> task_runner_;
+  StrictMock<provider::test::FakeTaskRunner> task_runner_;
   StrictMock<MockNetwork> network_;
   FakeXmppChannel xmpp_client_{&task_runner_, &network_};
 };
diff --git a/libweave/src/notification/xmpp_iq_stanza_handler_unittest.cc b/libweave/src/notification/xmpp_iq_stanza_handler_unittest.cc
index 27392b3..2fa7d97 100644
--- a/libweave/src/notification/xmpp_iq_stanza_handler_unittest.cc
+++ b/libweave/src/notification/xmpp_iq_stanza_handler_unittest.cc
@@ -9,7 +9,7 @@
 
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
-#include <weave/provider/test/mock_task_runner.h>
+#include <weave/provider/test/fake_task_runner.h>
 
 #include "libweave/src/bind_lambda.h"
 #include "libweave/src/notification/xml_node.h"
@@ -76,7 +76,7 @@
 class IqStanzaHandlerTest : public testing::Test {
  public:
   testing::StrictMock<MockXmppChannelInterface> mock_xmpp_channel_;
-  provider::test::MockTaskRunner task_runner_;
+  provider::test::FakeTaskRunner task_runner_;
   IqStanzaHandler iq_stanza_handler_{&mock_xmpp_channel_, &task_runner_};
   MockResponseReceiver receiver_;
 };
@@ -122,16 +122,12 @@
 }
 
 TEST_F(IqStanzaHandlerTest, SequentialResponses) {
-  EXPECT_CALL(task_runner_, PostDelayedTask(_, _, _)).Times(2);
-
   EXPECT_CALL(mock_xmpp_channel_, SendMessage(_)).Times(2);
   iq_stanza_handler_.SendRequest("set", "", "", "<body/>",
                                  receiver_.callback(1), {});
   iq_stanza_handler_.SendRequest("get", "", "", "<body/>",
                                  receiver_.callback(2), {});
 
-  EXPECT_CALL(task_runner_, PostDelayedTask(_, _, _)).Times(2);
-
   EXPECT_CALL(receiver_, OnResponse(1, "foo"));
   auto request = XmlParser{}.Parse("<iq id='1' type='result'><foo/></iq>");
   EXPECT_TRUE(iq_stanza_handler_.HandleIqStanza(std::move(request)));
@@ -144,16 +140,12 @@
 }
 
 TEST_F(IqStanzaHandlerTest, OutOfOrderResponses) {
-  EXPECT_CALL(task_runner_, PostDelayedTask(_, _, _)).Times(2);
-
   EXPECT_CALL(mock_xmpp_channel_, SendMessage(_)).Times(2);
   iq_stanza_handler_.SendRequest("set", "", "", "<body/>",
                                  receiver_.callback(1), {});
   iq_stanza_handler_.SendRequest("get", "", "", "<body/>",
                                  receiver_.callback(2), {});
 
-  EXPECT_CALL(task_runner_, PostDelayedTask(_, _, _)).Times(2);
-
   EXPECT_CALL(receiver_, OnResponse(2, "bar"));
   auto request = XmlParser{}.Parse("<iq id='2' type='result'><bar/></iq>");
   EXPECT_TRUE(iq_stanza_handler_.HandleIqStanza(std::move(request)));
@@ -166,8 +158,6 @@
 }
 
 TEST_F(IqStanzaHandlerTest, RequestTimeout) {
-  EXPECT_CALL(task_runner_, PostDelayedTask(_, _, _)).Times(1);
-
   bool called = false;
   auto on_timeout = [&called]() { called = true; };
 
diff --git a/libweave/src/privet/security_manager_unittest.cc b/libweave/src/privet/security_manager_unittest.cc
index 5c9fc2d..c85bd5f 100644
--- a/libweave/src/privet/security_manager_unittest.cc
+++ b/libweave/src/privet/security_manager_unittest.cc
@@ -19,7 +19,7 @@
 #include <base/strings/string_util.h>
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
-#include <weave/provider/test/mock_task_runner.h>
+#include <weave/provider/test/fake_task_runner.h>
 
 #include "libweave/external/crypto/p224_spake.h"
 #include "libweave/src/data_encoding.h"
@@ -100,7 +100,7 @@
   }
 
   const base::Time time_ = base::Time::FromTimeT(1410000000);
-  provider::test::MockTaskRunner task_runner_;
+  provider::test::FakeTaskRunner task_runner_;
   SecurityManager security_{{PairingType::kEmbeddedCode},
                             "1234",
                             false,
diff --git a/libweave/src/test/fake_task_runner.cc b/libweave/src/test/fake_task_runner.cc
new file mode 100644
index 0000000..8ba3b4c
--- /dev/null
+++ b/libweave/src/test/fake_task_runner.cc
@@ -0,0 +1,57 @@
+// Copyright 2015 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <weave/provider/test/fake_task_runner.h>
+
+namespace weave {
+namespace provider {
+namespace test {
+
+class FakeTaskRunner::TestClock : public base::Clock {
+ public:
+  base::Time Now() override { return now_; }
+
+  void SetNow(base::Time now) { now_ = now; }
+
+ private:
+  base::Time now_{base::Time::Now()};
+};
+
+FakeTaskRunner::FakeTaskRunner() : test_clock_{new TestClock} {}
+
+FakeTaskRunner::~FakeTaskRunner() {}
+
+bool FakeTaskRunner::RunOnce() {
+  if (queue_.empty())
+    return false;
+  auto top = queue_.top();
+  queue_.pop();
+  test_clock_->SetNow(std::max(test_clock_->Now(), top.first.first));
+  top.second.Run();
+  return true;
+}
+
+void FakeTaskRunner::Run() {
+  break_ = false;
+  while (!break_ && RunOnce()) {
+  }
+}
+
+void FakeTaskRunner::Break() {
+  break_ = true;
+}
+
+base::Clock* FakeTaskRunner::GetClock() {
+  return test_clock_.get();
+}
+
+void FakeTaskRunner::PostDelayedTask(const tracked_objects::Location& from_here,
+                                     const base::Closure& task,
+                                     base::TimeDelta delay) {
+  queue_.emplace(std::make_pair(test_clock_->Now() + delay, ++counter_), task);
+}
+
+}  // namespace test
+}  // namespace provider
+}  // namespace weave
diff --git a/libweave/src/test/mock_task_runner.cc b/libweave/src/test/mock_task_runner.cc
deleted file mode 100644
index 78af5ad..0000000
--- a/libweave/src/test/mock_task_runner.cc
+++ /dev/null
@@ -1,65 +0,0 @@
-// Copyright 2015 The Chromium OS Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <weave/provider/test/mock_task_runner.h>
-
-using testing::_;
-using testing::Invoke;
-using testing::AnyNumber;
-
-namespace weave {
-namespace provider {
-namespace test {
-
-class MockTaskRunner::TestClock : public base::Clock {
- public:
-  base::Time Now() override { return now_; }
-
-  void SetNow(base::Time now) { now_ = now; }
-
- private:
-  base::Time now_{base::Time::Now()};
-};
-
-MockTaskRunner::MockTaskRunner() : test_clock_{new TestClock} {
-  ON_CALL(*this, PostDelayedTask(_, _, _))
-      .WillByDefault(Invoke(this, &MockTaskRunner::SaveTask));
-  EXPECT_CALL(*this, PostDelayedTask(_, _, _)).Times(AnyNumber());
-}
-
-MockTaskRunner::~MockTaskRunner() {}
-
-bool MockTaskRunner::RunOnce() {
-  if (queue_.empty())
-    return false;
-  auto top = queue_.top();
-  queue_.pop();
-  test_clock_->SetNow(std::max(test_clock_->Now(), top.first.first));
-  top.second.Run();
-  return true;
-}
-
-void MockTaskRunner::Run() {
-  break_ = false;
-  while (!break_ && RunOnce()) {
-  }
-}
-
-void MockTaskRunner::Break() {
-  break_ = true;
-}
-
-base::Clock* MockTaskRunner::GetClock() {
-  return test_clock_.get();
-}
-
-void MockTaskRunner::SaveTask(const tracked_objects::Location& from_here,
-                              const base::Closure& task,
-                              base::TimeDelta delay) {
-  queue_.emplace(std::make_pair(test_clock_->Now() + delay, ++counter_), task);
-}
-
-}  // namespace test
-}  // namespace provider
-}  // namespace weave
diff --git a/libweave/src/weave_unittest.cc b/libweave/src/weave_unittest.cc
index e92c266..15891d6 100644
--- a/libweave/src/weave_unittest.cc
+++ b/libweave/src/weave_unittest.cc
@@ -6,13 +6,13 @@
 
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
+#include <weave/provider/test/fake_task_runner.h>
 #include <weave/provider/test/mock_bluetooth.h>
 #include <weave/provider/test/mock_config_store.h>
 #include <weave/provider/test/mock_dns_service_discovery.h>
 #include <weave/provider/test/mock_http_client.h>
 #include <weave/provider/test/mock_http_server.h>
 #include <weave/provider/test/mock_network.h>
-#include <weave/provider/test/mock_task_runner.h>
 #include <weave/provider/test/mock_wifi.h>
 #include <weave/test/unittest_utils.h>
 
@@ -323,7 +323,7 @@
   std::vector<provider::HttpServer::OnRequestCallback> http_server_request_cb_;
 
   StrictMock<provider::test::MockConfigStore> config_store_;
-  StrictMock<provider::test::MockTaskRunner> task_runner_;
+  StrictMock<provider::test::FakeTaskRunner> task_runner_;
   StrictMock<provider::test::MockHttpClient> http_client_;
   StrictMock<provider::test::MockNetwork> network_;
   StrictMock<provider::test::MockDnsServiceDiscovery> dns_sd_;