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(
fake_service_.RunLanConnectivityRoutineForTesting(std::move(callback));
}
base::Optional<FakeCrosHealthdService::RoutineUpdateParams>
FakeCrosHealthdClient::GetRoutineUpdateParams() {
return fake_service_.GetRoutineUpdateParams();
}
} // namespace cros_healthd
} // namespace chromeos
......@@ -8,6 +8,7 @@
#include "base/callback_forward.h"
#include "base/files/scoped_file.h"
#include "base/macros.h"
#include "base/optional.h"
#include "base/time/time.h"
#include "chromeos/dbus/cros_healthd/cros_healthd_client.h"
#include "chromeos/dbus/cros_healthd/fake_cros_healthd_service.h"
......@@ -115,6 +116,11 @@ class COMPONENT_EXPORT(CROS_HEALTHD) FakeCrosHealthdClient
chromeos::network_diagnostics::mojom::NetworkDiagnosticsRoutines::
LanConnectivityCallback);
// Returns the parameters passed for the most recent call to
// `GetRoutineUpdate`.
base::Optional<FakeCrosHealthdService::RoutineUpdateParams>
GetRoutineUpdateParams();
private:
FakeCrosHealthdService fake_service_;
mojo::Receiver<mojom::CrosHealthdServiceFactory> receiver_{&fake_service_};
......
......@@ -12,6 +12,12 @@
namespace chromeos {
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;
......@@ -55,6 +61,8 @@ void FakeCrosHealthdService::GetRoutineUpdate(
mojom::DiagnosticRoutineCommandEnum command,
bool include_output,
GetRoutineUpdateCallback callback) {
routine_update_params_ =
FakeCrosHealthdService::RoutineUpdateParams(id, command, include_output);
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::BindOnce(
......@@ -385,5 +393,10 @@ void FakeCrosHealthdService::RunLanConnectivityRoutineForTesting(
network_diagnostics_routines_->LanConnectivity(std::move(callback));
}
base::Optional<FakeCrosHealthdService::RoutineUpdateParams>
FakeCrosHealthdService::GetRoutineUpdateParams() const {
return routine_update_params_;
}
} // namespace cros_healthd
} // namespace chromeos
......@@ -5,9 +5,11 @@
#ifndef CHROMEOS_DBUS_CROS_HEALTHD_FAKE_CROS_HEALTHD_SERVICE_H_
#define CHROMEOS_DBUS_CROS_HEALTHD_FAKE_CROS_HEALTHD_SERVICE_H_
#include <cstdint>
#include <vector>
#include "base/macros.h"
#include "base/optional.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_diagnostics.mojom.h"
......@@ -33,6 +35,16 @@ class FakeCrosHealthdService final
public mojom::CrosHealthdEventService,
public mojom::CrosHealthdProbeService {
public:
struct RoutineUpdateParams {
RoutineUpdateParams(int32_t id,
mojom::DiagnosticRoutineCommandEnum command,
bool include_output);
int32_t id;
mojom::DiagnosticRoutineCommandEnum command;
bool include_output;
};
FakeCrosHealthdService();
~FakeCrosHealthdService() override;
......@@ -203,6 +215,10 @@ class FakeCrosHealthdService final
chromeos::network_diagnostics::mojom::NetworkDiagnosticsRoutines::
LanConnectivityCallback callback);
// Returns the parameters passed for the most recent call to
// `GetRoutineUpdate`.
base::Optional<RoutineUpdateParams> GetRoutineUpdateParams() const;
private:
// Used as the response to any GetAvailableRoutines IPCs received.
std::vector<mojom::DiagnosticRoutineEnum> available_routines_;
......@@ -235,6 +251,10 @@ class FakeCrosHealthdService final
// Collection of registered 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
// interface.
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