Commit 06fe2c0f authored by Kartik Hegde's avatar Kartik Hegde Committed by Commit Bot

cros_healthd: Add SignalStrength routine

Add the SignalStrength routine to the ServiceConnection.

BUG=chromium:956783
TEST=1) chromeos_unittests --gtest_filter=CrosHealthdServiceConnectionTest.*
2) Applied SignalStrength changes and successfully ran the
SignalStrength routine on a DUT (verified using cros-health-tool diag
--action=run_routine --routine=signal_strength).

Change-Id: Iffa5fe58ee8c03e0fed30cfc984f7bf2d02a4f00
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2343667Reviewed-by: default avatarPaul Moy <pmoy@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarOleh Lamzin <lamzin@google.com>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Kartik Hegde <khegde@chromium.org>
Cr-Commit-Position: refs/heads/master@{#810899}
parent a52ab56b
......@@ -503,6 +503,15 @@ void DeviceCommandRunRoutineJob::RunImpl(CallbackWithResult succeeded_callback,
std::move(failed_callback)));
break;
}
case chromeos::cros_healthd::mojom::DiagnosticRoutineEnum::
kSignalStrength: {
chromeos::cros_healthd::ServiceConnection::GetInstance()
->RunSignalStrengthRoutine(base::BindOnce(
&DeviceCommandRunRoutineJob::OnCrosHealthdResponseReceived,
weak_ptr_factory_.GetWeakPtr(), std::move(succeeded_callback),
std::move(failed_callback)));
break;
}
}
}
......
......@@ -1312,4 +1312,23 @@ TEST_F(DeviceCommandRunRoutineJobTest, RunLanConnectivityRoutineSuccess) {
})));
}
// Note that the signal strength routine has no parameters, so we only need to
// test that it can be run successfully.
TEST_F(DeviceCommandRunRoutineJobTest, RunSignalStrengthRoutineSuccess) {
auto run_routine_response =
chromeos::cros_healthd::mojom::RunRoutineResponse::New(kId, kStatus);
chromeos::cros_healthd::FakeCrosHealthdClient::Get()
->SetRunRoutineResponseForTesting(run_routine_response);
base::Value params_dict(base::Value::Type::DICTIONARY);
EXPECT_TRUE(RunJob(
chromeos::cros_healthd::mojom::DiagnosticRoutineEnum::kSignalStrength,
std::move(params_dict),
base::BindLambdaForTesting([](RemoteCommandJob* job) {
EXPECT_EQ(job->status(), RemoteCommandJob::SUCCEEDED);
std::unique_ptr<std::string> payload = job->GetResultPayload();
EXPECT_TRUE(payload);
EXPECT_EQ(CreateSuccessPayload(kId, kStatus), *payload);
})));
}
} // namespace policy
......@@ -212,6 +212,11 @@ void FakeCrosHealthdService::RunLanConnectivityRoutine(
std::move(callback).Run(run_routine_response_.Clone());
}
void FakeCrosHealthdService::RunSignalStrengthRoutine(
RunSignalStrengthRoutineCallback callback) {
std::move(callback).Run(run_routine_response_.Clone());
}
void FakeCrosHealthdService::AddBluetoothObserver(
mojom::CrosHealthdBluetoothObserverPtr observer) {
bluetooth_observers_.Add(observer.PassInterface());
......
......@@ -100,6 +100,8 @@ class FakeCrosHealthdService final
void RunMemoryRoutine(RunMemoryRoutineCallback callback) override;
void RunLanConnectivityRoutine(
RunLanConnectivityRoutineCallback callback) override;
void RunSignalStrengthRoutine(
RunSignalStrengthRoutineCallback callback) override;
// CrosHealthdEventService overrides:
void AddBluetoothObserver(
......
......@@ -107,6 +107,9 @@ class ServiceConnectionImpl : public ServiceConnection {
void RunLanConnectivityRoutine(
mojom::CrosHealthdDiagnosticsService::RunLanConnectivityRoutineCallback
callback) override;
void RunSignalStrengthRoutine(
mojom::CrosHealthdDiagnosticsService::RunSignalStrengthRoutineCallback
callback) override;
void AddBluetoothObserver(
mojo::PendingRemote<mojom::CrosHealthdBluetoothObserver> pending_observer)
override;
......@@ -365,6 +368,15 @@ void ServiceConnectionImpl::RunLanConnectivityRoutine(
std::move(callback));
}
void ServiceConnectionImpl::RunSignalStrengthRoutine(
mojom::CrosHealthdDiagnosticsService::RunSignalStrengthRoutineCallback
callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
BindCrosHealthdDiagnosticsServiceIfNeeded();
cros_healthd_diagnostics_service_->RunSignalStrengthRoutine(
std::move(callback));
}
void ServiceConnectionImpl::AddBluetoothObserver(
mojo::PendingRemote<mojom::CrosHealthdBluetoothObserver> pending_observer) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......
......@@ -186,6 +186,13 @@ class ServiceConnection {
mojom::CrosHealthdDiagnosticsService::RunLanConnectivityRoutineCallback
callback) = 0;
// Requests that cros_healthd runs the lan connectivity routine. See
// src/chromeos/service/cros_healthd/public/mojom/cros_healthd.mojom for
// details.
virtual void RunSignalStrengthRoutine(
mojom::CrosHealthdDiagnosticsService::RunSignalStrengthRoutineCallback
callback) = 0;
// Subscribes to cros_healthd's Bluetooth-related events. See
// src/chromeos/services/cros_healthd/public/mojom/cros_healthd.mojom for
// details.
......
......@@ -528,6 +528,19 @@ TEST_F(CrosHealthdServiceConnectionTest, RunLanConnectivityRoutine) {
run_loop.Run();
}
TEST_F(CrosHealthdServiceConnectionTest, RunSignalStrengthRoutine) {
// Test that we can run the signal strength routine.
auto response = MakeRunRoutineResponse();
FakeCrosHealthdClient::Get()->SetRunRoutineResponseForTesting(response);
base::RunLoop run_loop;
ServiceConnection::GetInstance()->RunSignalStrengthRoutine(
base::BindLambdaForTesting([&](mojom::RunRoutineResponsePtr response) {
EXPECT_EQ(response, MakeRunRoutineResponse());
run_loop.Quit();
}));
run_loop.Run();
}
// Test that we can add a Bluetooth observer.
TEST_F(CrosHealthdServiceConnectionTest, AddBluetoothObserver) {
MockCrosHealthdBluetoothObserver observer;
......
......@@ -316,6 +316,16 @@ interface CrosHealthdDiagnosticsService {
// * |response| - contains a unique identifier and status for the created
// routine.
RunLanConnectivityRoutine() => (RunRoutineResponse response);
// Requests that the SignalStrength routine is created and started on the
// platform. This routine checks whether there is an acceptable signal
// strength on wireless networks. This routine is only available if
// GetAvailableRoutines returned kSignalStrength.
//
// The response:
// * |response| - contains a unique identifier and status for the created
// routine.
RunSignalStrengthRoutine() => (RunRoutineResponse response);
};
// Event interface exposed by the cros_healthd daemon.
......
......@@ -32,6 +32,7 @@ enum DiagnosticRoutineEnum {
kBatteryCharge = 13,
kMemory = 14,
kLanConnectivity = 15,
kSignalStrength = 16,
};
// Enumeration of the possible DiskRead routine's command type
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment