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

Unified Diff: chromeos/dbus/fake_modem_messaging_client.cc

Issue 91373004: Move DBusClient stub implementations into separate files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years 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 | « chromeos/dbus/fake_modem_messaging_client.h ('k') | chromeos/dbus/fake_permission_broker_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/fake_modem_messaging_client.cc
diff --git a/chromeos/dbus/fake_modem_messaging_client.cc b/chromeos/dbus/fake_modem_messaging_client.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5704c22cbf5340d32bb27782d00cf72e7c0f390d
--- /dev/null
+++ b/chromeos/dbus/fake_modem_messaging_client.cc
@@ -0,0 +1,64 @@
+// Copyright 2013 The Chromium 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 "chromeos/dbus/fake_modem_messaging_client.h"
+
+#include <string>
+#include <vector>
+
+#include "base/callback.h"
+#include "base/logging.h"
+#include "dbus/object_path.h"
+
+namespace chromeos {
+
+FakeModemMessagingClient::FakeModemMessagingClient() {}
+FakeModemMessagingClient::~FakeModemMessagingClient() {}
+
+void FakeModemMessagingClient::Init(dbus::Bus* bus) {}
+
+void FakeModemMessagingClient::SetSmsReceivedHandler(
+ const std::string& service_name,
+ const dbus::ObjectPath& object_path,
+ const SmsReceivedHandler& handler) {
+ DCHECK(sms_received_handler_.is_null());
+ sms_received_handler_ = handler;
+}
+
+void FakeModemMessagingClient::ResetSmsReceivedHandler(
+ const std::string& service_name,
+ const dbus::ObjectPath& object_path) {
+ sms_received_handler_.Reset();
+}
+
+void FakeModemMessagingClient::Delete(const std::string& service_name,
+ const dbus::ObjectPath& object_path,
+ const dbus::ObjectPath& sms_path,
+ const DeleteCallback& callback) {
+ std::vector<dbus::ObjectPath>::iterator it(
+ find(message_paths_.begin(), message_paths_.end(), sms_path));
+ if (it != message_paths_.end())
+ message_paths_.erase(it);
+ callback.Run();
+}
+
+void FakeModemMessagingClient::List(const std::string& service_name,
+ const dbus::ObjectPath& object_path,
+ const ListCallback& callback) {
+ // This entire FakeModemMessagingClient is for testing.
+ // Calling List with |service_name| equal to "AddSMS" allows unit
+ // tests to confirm that the sms_received_handler is functioning.
+ if (service_name == "AddSMS") {
+ std::vector<dbus::ObjectPath> no_paths;
+ const dbus::ObjectPath kSmsPath("/SMS/0");
+ message_paths_.push_back(kSmsPath);
+ if (!sms_received_handler_.is_null())
+ sms_received_handler_.Run(kSmsPath, true);
+ callback.Run(no_paths);
+ } else {
+ callback.Run(message_paths_);
+ }
+}
+
+} // namespace chromeos
« no previous file with comments | « chromeos/dbus/fake_modem_messaging_client.h ('k') | chromeos/dbus/fake_permission_broker_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698