Commit 65e69eea authored by Bailey Berro's avatar Bailey Berro Committed by Commit Bot

Add GetRoutineUpdateParams to FakeCrosHealthdService

This change adds support for a GetRoutineUpdateParams to
FakeCrosHealthdService. This enables te verification of the parameters
passed to GetRoutineUpdate from unittests.

Bug: 1128204
Change-Id: Iba54a416272b59c34ce5356a35736ac26f312681
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2558764
Commit-Queue: Bailey Berro <baileyberro@chromium.org>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#831114}
parent 949b5172
...@@ -173,5 +173,10 @@ void FakeCrosHealthdClient::RunLanConnectivityRoutineForTesting( ...@@ -173,5 +173,10 @@ void FakeCrosHealthdClient::RunLanConnectivityRoutineForTesting(
fake_service_.RunLanConnectivityRoutineForTesting(std::move(callback)); fake_service_.RunLanConnectivityRoutineForTesting(std::move(callback));
} }
base::Optional<FakeCrosHealthdService::RoutineUpdateParams>
FakeCrosHealthdClient::GetRoutineUpdateParams() {
return fake_service_.GetRoutineUpdateParams();
}
} // namespace cros_healthd } // namespace cros_healthd
} // namespace chromeos } // namespace chromeos
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/callback_forward.h" #include "base/callback_forward.h"
#include "base/files/scoped_file.h" #include "base/files/scoped_file.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chromeos/dbus/cros_healthd/cros_healthd_client.h" #include "chromeos/dbus/cros_healthd/cros_healthd_client.h"
#include "chromeos/dbus/cros_healthd/fake_cros_healthd_service.h" #include "chromeos/dbus/cros_healthd/fake_cros_healthd_service.h"
...@@ -115,6 +116,11 @@ class COMPONENT_EXPORT(CROS_HEALTHD) FakeCrosHealthdClient ...@@ -115,6 +116,11 @@ class COMPONENT_EXPORT(CROS_HEALTHD) FakeCrosHealthdClient
chromeos::network_diagnostics::mojom::NetworkDiagnosticsRoutines:: chromeos::network_diagnostics::mojom::NetworkDiagnosticsRoutines::
LanConnectivityCallback); LanConnectivityCallback);
// Returns the parameters passed for the most recent call to
// `GetRoutineUpdate`.
base::Optional<FakeCrosHealthdService::RoutineUpdateParams>
GetRoutineUpdateParams();
private: private:
FakeCrosHealthdService fake_service_; FakeCrosHealthdService fake_service_;
mojo::Receiver<mojom::CrosHealthdServiceFactory> receiver_{&fake_service_}; mojo::Receiver<mojom::CrosHealthdServiceFactory> receiver_{&fake_service_};
......
...@@ -12,6 +12,12 @@ ...@@ -12,6 +12,12 @@
namespace chromeos { namespace chromeos {
namespace cros_healthd { namespace cros_healthd {
FakeCrosHealthdService::RoutineUpdateParams::RoutineUpdateParams(
int32_t id,
mojom::DiagnosticRoutineCommandEnum command,
bool include_output)
: id(id), command(command), include_output(include_output) {}
FakeCrosHealthdService::FakeCrosHealthdService() = default; FakeCrosHealthdService::FakeCrosHealthdService() = default;
FakeCrosHealthdService::~FakeCrosHealthdService() = default; FakeCrosHealthdService::~FakeCrosHealthdService() = default;
...@@ -55,6 +61,8 @@ void FakeCrosHealthdService::GetRoutineUpdate( ...@@ -55,6 +61,8 @@ void FakeCrosHealthdService::GetRoutineUpdate(
mojom::DiagnosticRoutineCommandEnum command, mojom::DiagnosticRoutineCommandEnum command,
bool include_output, bool include_output,
GetRoutineUpdateCallback callback) { GetRoutineUpdateCallback callback) {
routine_update_params_ =
FakeCrosHealthdService::RoutineUpdateParams(id, command, include_output);
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, FROM_HERE,
base::BindOnce( base::BindOnce(
...@@ -385,5 +393,10 @@ void FakeCrosHealthdService::RunLanConnectivityRoutineForTesting( ...@@ -385,5 +393,10 @@ void FakeCrosHealthdService::RunLanConnectivityRoutineForTesting(
network_diagnostics_routines_->LanConnectivity(std::move(callback)); network_diagnostics_routines_->LanConnectivity(std::move(callback));
} }
base::Optional<FakeCrosHealthdService::RoutineUpdateParams>
FakeCrosHealthdService::GetRoutineUpdateParams() const {
return routine_update_params_;
}
} // namespace cros_healthd } // namespace cros_healthd
} // namespace chromeos } // namespace chromeos
...@@ -5,9 +5,11 @@ ...@@ -5,9 +5,11 @@
#ifndef CHROMEOS_DBUS_CROS_HEALTHD_FAKE_CROS_HEALTHD_SERVICE_H_ #ifndef CHROMEOS_DBUS_CROS_HEALTHD_FAKE_CROS_HEALTHD_SERVICE_H_
#define CHROMEOS_DBUS_CROS_HEALTHD_FAKE_CROS_HEALTHD_SERVICE_H_ #define CHROMEOS_DBUS_CROS_HEALTHD_FAKE_CROS_HEALTHD_SERVICE_H_
#include <cstdint>
#include <vector> #include <vector>
#include "base/macros.h" #include "base/macros.h"
#include "base/optional.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chromeos/services/cros_healthd/public/mojom/cros_healthd.mojom.h" #include "chromeos/services/cros_healthd/public/mojom/cros_healthd.mojom.h"
#include "chromeos/services/cros_healthd/public/mojom/cros_healthd_diagnostics.mojom.h" #include "chromeos/services/cros_healthd/public/mojom/cros_healthd_diagnostics.mojom.h"
...@@ -33,6 +35,16 @@ class FakeCrosHealthdService final ...@@ -33,6 +35,16 @@ class FakeCrosHealthdService final
public mojom::CrosHealthdEventService, public mojom::CrosHealthdEventService,
public mojom::CrosHealthdProbeService { public mojom::CrosHealthdProbeService {
public: public:
struct RoutineUpdateParams {
RoutineUpdateParams(int32_t id,
mojom::DiagnosticRoutineCommandEnum command,
bool include_output);
int32_t id;
mojom::DiagnosticRoutineCommandEnum command;
bool include_output;
};
FakeCrosHealthdService(); FakeCrosHealthdService();
~FakeCrosHealthdService() override; ~FakeCrosHealthdService() override;
...@@ -203,6 +215,10 @@ class FakeCrosHealthdService final ...@@ -203,6 +215,10 @@ class FakeCrosHealthdService final
chromeos::network_diagnostics::mojom::NetworkDiagnosticsRoutines:: chromeos::network_diagnostics::mojom::NetworkDiagnosticsRoutines::
LanConnectivityCallback callback); LanConnectivityCallback callback);
// Returns the parameters passed for the most recent call to
// `GetRoutineUpdate`.
base::Optional<RoutineUpdateParams> GetRoutineUpdateParams() const;
private: private:
// Used as the response to any GetAvailableRoutines IPCs received. // Used as the response to any GetAvailableRoutines IPCs received.
std::vector<mojom::DiagnosticRoutineEnum> available_routines_; std::vector<mojom::DiagnosticRoutineEnum> available_routines_;
...@@ -235,6 +251,10 @@ class FakeCrosHealthdService final ...@@ -235,6 +251,10 @@ class FakeCrosHealthdService final
// Collection of registered power observers. // Collection of registered power observers.
mojo::RemoteSet<mojom::CrosHealthdPowerObserver> power_observers_; mojo::RemoteSet<mojom::CrosHealthdPowerObserver> power_observers_;
// Contains the most recent params passed to `GetRoutineUpdate`, if it has
// been called.
base::Optional<RoutineUpdateParams> routine_update_params_;
// Allow |this| to call the methods on the NetworkDiagnosticsRoutines // Allow |this| to call the methods on the NetworkDiagnosticsRoutines
// interface. // interface.
mojo::Remote<chromeos::network_diagnostics::mojom::NetworkDiagnosticsRoutines> mojo::Remote<chromeos::network_diagnostics::mojom::NetworkDiagnosticsRoutines>
......
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