[Cleanup] Use EXPECT_FALSE and EXPECT_TRUE in place of EXPECT_EQ where appropriate.
[chromium-blink-merge.git] / chromeos / dbus / fake_debug_daemon_client.cc
blob0dde3abeb60a0a3c2e61239beecbf91d43e4c88a
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chromeos/dbus/fake_debug_daemon_client.h"
7 #include <map>
8 #include <string>
9 #include <vector>
11 #include "base/bind.h"
12 #include "base/callback.h"
13 #include "base/command_line.h"
14 #include "base/location.h"
15 #include "base/message_loop/message_loop.h"
16 #include "chromeos/chromeos_switches.h"
18 namespace chromeos {
20 FakeDebugDaemonClient::FakeDebugDaemonClient()
21 : featues_mask_(DebugDaemonClient::DEV_FEATURE_NONE),
22 service_is_available_(true) {
25 FakeDebugDaemonClient::~FakeDebugDaemonClient() {}
27 void FakeDebugDaemonClient::Init(dbus::Bus* bus) {}
29 void FakeDebugDaemonClient::DumpDebugLogs(
30 bool is_compressed,
31 base::File file,
32 scoped_refptr<base::TaskRunner> task_runner,
33 const GetDebugLogsCallback& callback) {
34 callback.Run(true);
37 void FakeDebugDaemonClient::SetDebugMode(const std::string& subsystem,
38 const SetDebugModeCallback& callback) {
39 callback.Run(false);
41 void FakeDebugDaemonClient::StartSystemTracing() {}
43 bool FakeDebugDaemonClient::RequestStopSystemTracing(
44 scoped_refptr<base::TaskRunner> task_runner,
45 const StopSystemTracingCallback& callback) {
46 std::string no_data;
47 callback.Run(base::RefCountedString::TakeString(&no_data));
48 return true;
51 void FakeDebugDaemonClient::GetRoutes(bool numeric,
52 bool ipv6,
53 const GetRoutesCallback& callback) {
54 std::vector<std::string> empty;
55 base::MessageLoop::current()->PostTask(FROM_HERE,
56 base::Bind(callback, false, empty));
59 void FakeDebugDaemonClient::GetNetworkStatus(
60 const GetNetworkStatusCallback& callback) {
61 base::MessageLoop::current()->PostTask(FROM_HERE,
62 base::Bind(callback, false, ""));
65 void FakeDebugDaemonClient::GetModemStatus(
66 const GetModemStatusCallback& callback) {
67 base::MessageLoop::current()->PostTask(FROM_HERE,
68 base::Bind(callback, false, ""));
71 void FakeDebugDaemonClient::GetWiMaxStatus(
72 const GetWiMaxStatusCallback& callback) {
73 base::MessageLoop::current()->PostTask(FROM_HERE,
74 base::Bind(callback, false, ""));
77 void FakeDebugDaemonClient::GetNetworkInterfaces(
78 const GetNetworkInterfacesCallback& callback) {
79 base::MessageLoop::current()->PostTask(FROM_HERE,
80 base::Bind(callback, false, ""));
83 void FakeDebugDaemonClient::GetPerfData(uint32_t duration,
84 const GetPerfDataCallback& callback) {
85 std::vector<uint8> data;
86 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, data));
89 void FakeDebugDaemonClient::GetScrubbedLogs(const GetLogsCallback& callback) {
90 std::map<std::string, std::string> sample;
91 sample["Sample Scrubbed Log"] = "Your email address is xxxxxxxx";
92 base::MessageLoop::current()->PostTask(FROM_HERE,
93 base::Bind(callback, false, sample));
96 void FakeDebugDaemonClient::GetAllLogs(const GetLogsCallback& callback) {
97 std::map<std::string, std::string> sample;
98 sample["Sample Log"] = "Your email address is abc@abc.com";
99 base::MessageLoop::current()->PostTask(FROM_HERE,
100 base::Bind(callback, false, sample));
103 void FakeDebugDaemonClient::GetUserLogFiles(const GetLogsCallback& callback) {
104 std::map<std::string, std::string> user_logs;
105 user_logs["preferences"] = "Preferences";
106 user_logs["invalid_file"] = "Invalid File";
107 base::MessageLoop::current()->PostTask(FROM_HERE,
108 base::Bind(callback, true, user_logs));
111 void FakeDebugDaemonClient::TestICMP(const std::string& ip_address,
112 const TestICMPCallback& callback) {
113 base::MessageLoop::current()->PostTask(FROM_HERE,
114 base::Bind(callback, false, ""));
117 void FakeDebugDaemonClient::TestICMPWithOptions(
118 const std::string& ip_address,
119 const std::map<std::string, std::string>& options,
120 const TestICMPCallback& callback) {
121 base::MessageLoop::current()->PostTask(FROM_HERE,
122 base::Bind(callback, false, ""));
125 void FakeDebugDaemonClient::UploadCrashes() {
128 void FakeDebugDaemonClient::EnableDebuggingFeatures(
129 const std::string& password,
130 const DebugDaemonClient::EnableDebuggingCallback& callback) {
131 base::MessageLoop::current()->PostTask(FROM_HERE,
132 base::Bind(callback, true));
135 void FakeDebugDaemonClient::QueryDebuggingFeatures(
136 const DebugDaemonClient::QueryDevFeaturesCallback& callback) {
137 bool supported = base::CommandLine::ForCurrentProcess()->HasSwitch(
138 chromeos::switches::kSystemDevMode);
139 base::MessageLoop::current()->PostTask(
140 FROM_HERE,
141 base::Bind(
142 callback, true,
143 static_cast<int>(
144 supported ? featues_mask_
145 : debugd::DevFeatureFlag::DEV_FEATURES_DISABLED)));
148 void FakeDebugDaemonClient::RemoveRootfsVerification(
149 const DebugDaemonClient::EnableDebuggingCallback& callback) {
150 base::MessageLoop::current()->PostTask(FROM_HERE,
151 base::Bind(callback, true));
154 void FakeDebugDaemonClient::WaitForServiceToBeAvailable(
155 const WaitForServiceToBeAvailableCallback& callback) {
156 if (service_is_available_) {
157 base::MessageLoop::current()->PostTask(FROM_HERE,
158 base::Bind(callback, true));
159 } else {
160 pending_wait_for_service_to_be_available_callbacks_.push_back(callback);
164 void FakeDebugDaemonClient::SetDebuggingFeaturesStatus(int featues_mask) {
165 featues_mask_ = featues_mask;
168 void FakeDebugDaemonClient::SetServiceIsAvailable(bool is_available) {
169 service_is_available_ = is_available;
170 if (!is_available)
171 return;
173 std::vector<WaitForServiceToBeAvailableCallback> callbacks;
174 callbacks.swap(pending_wait_for_service_to_be_available_callbacks_);
175 for (size_t i = 0; i < callbacks.size(); ++i)
176 callbacks[i].Run(is_available);
179 } // namespace chromeos